//this will transform the relative path to the target file into kebab case
$relativePathTransformer = fn(string $relativePath) => array_map('Str::kebab', \AntonioPrimera\FileSystem\OS::pathParts($relativePath));
/**
* For a command argument 'SiteComponents/Sections/HeroSection', the above transformer will return 'site-components/sections'.
* The OS::pathParts method belongs to the 'antonioprimera/filesystem' package, which is a dependency of this package.
*/
//instead of providing all the recipe attributes, you can now chain the setters
$recipe = \AntonioPrimera\Artisan\FileRecipe::create()
->withStub('path/to/stubFile.json.stub')
->withTargetFolder('path/to/target/root')
->withFileNameTransformer(fn(string $fileName) => strtolower($fileName));
//in a generator command, you can define the recipe like this
use AntonioPrimera\Artisan\FileRecipes\MigrationRecipe;
//this will create a migration file recipe, prepending the current timestamp to the file name
protected function recipe(): MigrationRecipe
{
return (new MigrationRecipe('stubs/migration-file.php.stub'))
->withReplace(['GENERATED_ON' => now()->format('d.m.Y H:i:s')]); //add any additional replace items
}