@@ -96,6 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9696 $ this ->renamePluginFiles ($ io , $ names , $ dryRun );
9797 $ this ->updateFileContents ($ io , $ names , $ dryRun );
9898 $ this ->updateComposerJson ($ io , $ names ['package ' ], $ description , $ names , $ dryRun );
99+ $ this ->createTestApplicationEnv ($ io , $ names , $ dryRun );
99100
100101 if (!$ dryRun ) {
101102 $ this ->runComposerDumpAutoload ($ io );
@@ -231,22 +232,26 @@ private function generateNameVariations(string $company, string $pluginName, boo
231232 ];
232233 }
233234
234- $ syliusPlugin = 'Sylius ' . $ plugin ;
235+ $ hasSyliusPrefix = str_starts_with ($ pluginName , 'Sylius ' );
236+ $ syliusPlugin = $ hasSyliusPrefix ? $ plugin : 'Sylius ' . $ plugin ;
237+ $ syliusPluginName = $ hasSyliusPrefix ? $ pluginName : 'Sylius ' . $ pluginName ;
238+
235239 $ fullClass = $ company . $ syliusPlugin ;
236- $ extensionClass = $ company . ' Sylius ' . $ pluginName . 'Extension ' ;
240+ $ extensionClass = $ company . $ syliusPluginName . 'Extension ' ;
237241
238242 $ companyKebab = $ this ->toKebabCase ($ company );
239243 $ fullPluginKebab = $ this ->toKebabCase ($ syliusPlugin );
240244 $ companySnake = $ this ->toSnakeCase ($ company );
245+ $ pluginSnakeForDb = $ hasSyliusPrefix ? $ pluginSnake : 'sylius_ ' . $ pluginSnake ;
241246
242247 return [
243248 'company ' => $ company ,
244249 'plugin ' => $ syliusPlugin ,
245250 'fullClass ' => $ fullClass ,
246251 'extensionClass ' => $ extensionClass ,
247252 'package ' => $ companyKebab . '/ ' . $ fullPluginKebab ,
248- 'db ' => $ companySnake . '_sylius_ ' . $ pluginSnake . '_plugin ' ,
249- 'configKey ' => $ companySnake . '_sylius_ ' . $ pluginSnake ,
253+ 'db ' => $ companySnake . '_ ' . $ pluginSnakeForDb . '_plugin ' ,
254+ 'configKey ' => $ companySnake . '_ ' . $ pluginSnakeForDb ,
250255 ];
251256 }
252257
@@ -382,6 +387,9 @@ private function updateComposerJson(SymfonyStyle $io, string $packageName, strin
382387 unset($ composer ['autoload-dev ' ]['psr-4 ' ]['Tests \\Acme \\SyliusExamplePlugin \\' ]);
383388 $ composer ['autoload-dev ' ]['psr-4 ' ]["Tests \\{$ names ['company ' ]}\\{$ names ['plugin ' ]}\\" ] = ['tests/ ' , 'tests/TestApplication/src/ ' ];
384389
390+ unset($ composer ['scripts ' ]['post-create-project-cmd ' ]);
391+ unset($ composer ['scripts ' ]['post-root-package-install ' ]);
392+
385393 if ($ dryRun ) {
386394 $ io ->writeln ('[DRY RUN] Would update composer.json with: ' );
387395 $ io ->writeln (' - name: ' . $ packageName );
@@ -396,6 +404,30 @@ private function updateComposerJson(SymfonyStyle $io, string $packageName, strin
396404 }
397405 }
398406
407+ private function createTestApplicationEnv (SymfonyStyle $ io , array $ names , bool $ dryRun ): void
408+ {
409+ $ io ->section ('Creating TestApplication .env ' );
410+
411+ $ envDir = __DIR__ . '/../tests/TestApplication ' ;
412+ $ envFile = $ envDir . '/.env ' ;
413+ $ envContent = "DATABASE_URL=mysql://root@127.0.0.1/ {$ names ['db ' ]}_%kernel.environment% \n" ;
414+
415+ if ($ dryRun ) {
416+ $ io ->writeln ("[DRY RUN] Would create {$ envFile } with DATABASE_URL for {$ names ['db ' ]}" );
417+ return ;
418+ }
419+
420+ if (!is_dir ($ envDir )) {
421+ mkdir ($ envDir , 0755 , true );
422+ }
423+
424+ if (file_put_contents ($ envFile , $ envContent ) === false ) {
425+ throw new \RuntimeException ("Failed to create {$ envFile }" );
426+ }
427+
428+ $ io ->success ('TestApplication .env created ' );
429+ }
430+
399431 private function runComposerDumpAutoload (SymfonyStyle $ io ): void
400432 {
401433 $ io ->section ('Refreshing autoload files ' );
0 commit comments