Skip to content

Commit 20e47a3

Browse files
authored
Merge pull request #65 from RonasIT/add-install-laravel-ui
feat: add install laravel/ui
2 parents 2de6d18 + b7c6110 commit 20e47a3

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

src/Commands/InitCommand.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class InitCommand extends Command implements Isolatable
6363
protected string $readmeContent = '';
6464

6565
protected array $shellCommands = [
66+
'composer require laravel/ui',
6667
'composer require ronasit/laravel-helpers',
6768
'composer require ronasit/laravel-swagger',
6869
'php artisan vendor:publish --provider="RonasIT\\AutoDoc\\AutoDocServiceProvider"',
@@ -74,6 +75,8 @@ class InitCommand extends Command implements Isolatable
7475
'php artisan lang:publish',
7576
];
7677

78+
protected bool $shouldUninstallPackage = false;
79+
7780
protected string $appName;
7881

7982
protected AppTypeEnum $appType;
@@ -118,8 +121,6 @@ public function handle(): void
118121
'DB_CONNECTION' => 'pgsql',
119122
]);
120123

121-
$this->publishWebLogin();
122-
123124
$this->info('Project initialized successfully!');
124125

125126
$this->appType = AppTypeEnum::from(
@@ -227,7 +228,7 @@ public function handle(): void
227228
}
228229

229230
if ($this->confirm('Do you want to uninstall project-initializator package?', true)) {
230-
$this->shellCommands[] = 'composer remove --dev ronasit/laravel-project-initializator';
231+
$this->shouldUninstallPackage = true;
231232
}
232233

233234
$this->setupComposerHooks();
@@ -238,7 +239,13 @@ public function handle(): void
238239
shell_exec("{$shellCommand} --ansi");
239240
}
240241

242+
$this->publishWebLogin();
243+
241244
Artisan::call('migrate');
245+
246+
if ($this->shouldUninstallPackage) {
247+
shell_exec('composer remove --dev ronasit/laravel-project-initializator --no-script --ansi');
248+
}
242249
}
243250

244251
protected function setupComposerHooks(): void

tests/InitCommandTest.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ public function testRunWithoutAdminAndReadmeCreationConvertAppNameToPascalCaseTe
2929

3030
$this->callFileGetContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
3131

32-
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
3332
$this->callFilePutContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
33+
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
3434

35+
$this->callShellExec('composer require laravel/ui --ansi'),
3536
$this->callShellExec('composer require ronasit/laravel-helpers --ansi'),
3637
$this->callShellExec('composer require ronasit/laravel-swagger --ansi'),
3738
$this->callShellExec('php artisan vendor:publish --provider="RonasIT\AutoDoc\AutoDocServiceProvider" --ansi'),
@@ -77,10 +78,11 @@ public function testRunWithoutAdminAndReadmeCreation()
7778

7879
$this->callFileGetContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
7980

80-
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
8181
$this->callFilePutContent('renovate.json', $this->getFixture('renovate.json')),
8282
$this->callFilePutContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
83+
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
8384

85+
$this->callShellExec('composer require laravel/ui --ansi'),
8486
$this->callShellExec('composer require ronasit/laravel-helpers --ansi'),
8587
$this->callShellExec('composer require ronasit/laravel-swagger --ansi'),
8688
$this->callShellExec('php artisan vendor:publish --provider="RonasIT\AutoDoc\AutoDocServiceProvider" --ansi'),
@@ -128,10 +130,11 @@ public function testRunWithAdminAndWithoutReadmeCreation()
128130

129131
$this->callFileGetContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
130132

131-
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
132133
$this->callFilePutContent('database/migrations/2018_11_11_111111_add_default_user.php', $this->getFixture('migration.php')),
133134
$this->callFilePutContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
135+
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
134136

137+
$this->callShellExec('composer require laravel/ui --ansi'),
135138
$this->callShellExec('composer require ronasit/laravel-helpers --ansi'),
136139
$this->callShellExec('composer require ronasit/laravel-swagger --ansi'),
137140
$this->callShellExec('php artisan vendor:publish --provider="RonasIT\AutoDoc\AutoDocServiceProvider" --ansi'),
@@ -195,16 +198,17 @@ public function testRunWithAdminAndDefaultReadmeCreation()
195198
$this->callFileGetContent($this->generateResourcePath('md/readme/RENOVATE.md'), $this->getReadmeTemplateContent('RENOVATE.md')),
196199
$this->callFileGetContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
197200

198-
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
199201
$this->callFilePutContent('database/migrations/2018_11_11_111111_users_add_clerk_id_field.php', $this->getFixture('users_add_clerk_id_field_migration.php')),
200202
$this->callFilePutContent('app/Support/Clerk/ClerkUserRepository.php', $this->getFixture('clerk_user_repository.php')),
201203
$this->callFilePutContent('database/migrations/2018_11_11_111111_admins_create_table.php', $this->getFixture('admins_table_migration.php')),
202204
$this->callFilePutContent('README.md', $this->getFixture('default_readme.md')),
203205
$this->callFilePutContent('renovate.json', $this->getFixture('renovate.json')),
204206
$this->callFilePutContent('README.md', $this->getFixture('default_readme_after_using_renovate.md')),
205207
$this->callFilePutContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
208+
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
206209

207210
$this->callShellExec('git ls-remote --get-url origin', 'https://github.com/ronasit/laravel-helpers.git'),
211+
$this->callShellExec('composer require laravel/ui --ansi'),
208212
$this->callShellExec('composer require ronasit/laravel-helpers --ansi'),
209213
$this->callShellExec('composer require ronasit/laravel-swagger --ansi'),
210214
$this->callShellExec('php artisan vendor:publish --provider="RonasIT\AutoDoc\AutoDocServiceProvider" --ansi'),
@@ -314,10 +318,11 @@ public function testRunWithAdminAndPartialReadmeCreation()
314318
$this->callFileGetContent($this->generateResourcePath('md/readme/CREDENTIALS_AND_ACCESS.md'), $this->getReadmeTemplateContent('CREDENTIALS_AND_ACCESS.md')),
315319
$this->callFileGetContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
316320

317-
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
318321
$this->callFilePutContent('README.md', $this->getFixture('partial_readme.md')),
319322
$this->callFilePutContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
323+
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
320324

325+
$this->callShellExec('composer require laravel/ui --ansi'),
321326
$this->callShellExec('composer require ronasit/laravel-helpers --ansi'),
322327
$this->callShellExec('composer require ronasit/laravel-swagger --ansi'),
323328
$this->callShellExec('php artisan vendor:publish --provider="RonasIT\AutoDoc\AutoDocServiceProvider" --ansi'),
@@ -418,14 +423,15 @@ public function testRunWithAdminAndFullReadmeCreationAndRemovingInitializatorIns
418423
$this->callFileGetContent($this->generateResourcePath('md/readme/RENOVATE.md'), $this->getReadmeTemplateContent('RENOVATE.md')),
419424
$this->callFileGetContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
420425

421-
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
422426
$this->callFilePutContent('database/migrations/2018_11_11_111111_add_default_user.php', $this->getFixture('migration.php')),
423427
$this->callFilePutContent('README.md', $this->getFixture('full_readme.md')),
424428
$this->callFilePutContent('renovate.json', $this->getFixture('renovate.json')),
425429
$this->callFilePutContent('README.md', $this->getFixture('full_readme_after_using_renovate.md')),
426430
$this->callFilePutContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
431+
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
427432

428433
$this->callShellExec('git ls-remote --get-url origin', 'https://github.com/ronasit/laravel-helpers.git'),
434+
$this->callShellExec('composer require laravel/ui --ansi'),
429435
$this->callShellExec('composer require ronasit/laravel-helpers --ansi'),
430436
$this->callShellExec('composer require ronasit/laravel-swagger --ansi'),
431437
$this->callShellExec('php artisan vendor:publish --provider="RonasIT\AutoDoc\AutoDocServiceProvider" --ansi'),
@@ -438,7 +444,7 @@ public function testRunWithAdminAndFullReadmeCreationAndRemovingInitializatorIns
438444
$this->callShellExec('composer require ronasit/laravel-telescope-extension --ansi'),
439445
$this->callShellExec('php artisan telescope:install --ansi'),
440446
$this->callShellExec('composer require ronasit/laravel-media --ansi'),
441-
$this->callShellExec('composer remove --dev ronasit/laravel-project-initializator --ansi'),
447+
$this->callShellExec('composer remove --dev ronasit/laravel-project-initializator --no-script --ansi'),
442448
);
443449

444450
$this
@@ -532,10 +538,11 @@ public function testRunWithoutAdminAndUsingTelescope()
532538
$this->callFileGetContent($this->generateResourcePath('md/readme/CREDENTIALS_AND_ACCESS.md'), $this->getReadmeTemplateContent('CREDENTIALS_AND_ACCESS.md')),
533539
$this->callFileGetContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
534540

535-
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
536541
$this->callFilePutContent('README.md', $this->getFixture('partial_readme_with_telescope.md')),
537542
$this->callFilePutContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
543+
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
538544

545+
$this->callShellExec('composer require laravel/ui --ansi'),
539546
$this->callShellExec('composer require ronasit/laravel-helpers --ansi'),
540547
$this->callShellExec('composer require ronasit/laravel-swagger --ansi'),
541548
$this->callShellExec('php artisan vendor:publish --provider="RonasIT\AutoDoc\AutoDocServiceProvider" --ansi'),
@@ -643,16 +650,17 @@ public function testRunWithClerkMobileAppWithPintInstalled(): void
643650
$this->callFileGetContent($this->generateResourcePath('md/readme/RENOVATE.md'), $this->getReadmeTemplateContent('RENOVATE.md')),
644651
$this->callFileGetContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
645652

646-
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
647653
$this->callFilePutContent('database/migrations/2018_11_11_111111_users_add_clerk_id_field.php', $this->getFixture('users_add_clerk_id_field_migration.php')),
648654
$this->callFilePutContent('app/Support/Clerk/ClerkUserRepository.php', $this->getFixture('clerk_user_repository.php')),
649655
$this->callFilePutContent('database/migrations/2018_11_11_111111_admins_create_table.php', $this->getFixture('admins_table_migration.php')),
650656
$this->callFilePutContent('README.md', $this->getFixture('default_readme_with_mobile_app.md')),
651657
$this->callFilePutContent('renovate.json', $this->getFixture('renovate.json')),
652658
$this->callFilePutContent('README.md', $this->getFixture('default_readme_with_mobile_app_after_using_renovate.md')),
653659
$this->callFilePutContent(base_path('composer.json'), $this->getFixture('composer_with_pint_settings.json')),
660+
$this->callFilePutContent(base_path('/routes/web.php'), "\nAuth::routes();\n", FILE_APPEND),
654661

655662
$this->callShellExec('git ls-remote --get-url origin', 'https://github.com/ronasit/laravel-helpers.git'),
663+
$this->callShellExec('composer require laravel/ui --ansi'),
656664
$this->callShellExec('composer require ronasit/laravel-helpers --ansi'),
657665
$this->callShellExec('composer require ronasit/laravel-swagger --ansi'),
658666
$this->callShellExec('php artisan vendor:publish --provider="RonasIT\AutoDoc\AutoDocServiceProvider" --ansi'),

0 commit comments

Comments
 (0)