Skip to content

Commit c546957

Browse files
committed
Update install command.
1 parent 8b5b9e9 commit c546957

File tree

3 files changed

+56
-12
lines changed

3 files changed

+56
-12
lines changed

src/Console/InstallCommand.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Console\Command;
66
use Illuminate\Filesystem\Filesystem;
7+
use function Laravel\Prompts\confirm;
78

89
class InstallCommand extends Command
910
{
@@ -17,50 +18,66 @@ public function handle(): void
1718
$this->copyResourcesFiles();
1819
$this->copyResourcesSiteFiles();
1920
$this->copyResourcesComponentsFiles();
21+
$this->copyTranslationFile();
2022

2123
$this->call('storage:link');
2224

25+
$this->call('modular:blog-migrate');
26+
2327
$this->info('Modular Blog installed successfully.');
24-
$this->info('Running the following command to migrate the Blog module:');
2528

26-
if ($this->confirm('Do you wish to run the Blog migrations?')) {
27-
$this->call('modular:blog-migrate');
29+
$seederConfirmed = confirm(
30+
label: 'Do you wish to run the Blog Seeders?',
31+
default: true,
32+
yes: 'Yes',
33+
no: 'No',
34+
hint: 'The seeder process may take a few seconds, it fetches some images'
35+
);
2836

29-
if ($this->confirm('Do you wish to run the Blog seeders?')) {
30-
$this->call('modular:blog-seed');
31-
}
37+
if ($seederConfirmed) {
38+
$this->call('modular:blog-seed');
3239
}
3340
}
3441

3542
private function copyBlogModuleDirectory(): void
3643
{
3744
$this->info('Copying Blog Module directory...');
3845
(new Filesystem)->ensureDirectoryExists(base_path('modules'));
39-
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/modules/Blog', base_path('modules/Blog'));
46+
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/modules/Blog', base_path('modules/Blog'));
4047
$this->info('Blog Module directory copied successfully.');
4148
}
4249

4350
private function copyResourcesComponentsFiles(): void
4451
{
4552
$this->info('Copying Blog Module components...');
4653
(new Filesystem)->ensureDirectoryExists(resource_path('js/Components/Modules/Blog'));
47-
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/resources/js/Components/Modules/Blog', resource_path('js/Components/Modules/Blog'));
54+
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/resources/js/Components/Modules/Blog', resource_path('js/Components/Modules/Blog'));
4855
$this->info('Blog Module components copied successfully.');
4956
}
5057

5158
private function copyResourcesFiles(): void
5259
{
5360
$this->info('Copying Blog Module resources...');
5461
(new Filesystem)->ensureDirectoryExists(resource_path('js/Pages'));
55-
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/resources/js/Pages', resource_path('js/Pages'));
62+
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/resources/js/Pages', resource_path('js/Pages'));
5663
$this->info('Blog Module resources copied successfully.');
5764
}
5865

5966
private function copyResourcesSiteFiles(): void
6067
{
6168
$this->info('Copying Blog Module resources-site...');
6269
(new Filesystem)->ensureDirectoryExists(base_path('resources-site'));
63-
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/resources-site', base_path('resources-site'));
70+
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/resources-site', base_path('resources-site'));
6471
$this->info('Blog Module resources-site copied successfully.');
6572
}
73+
74+
private function copyTranslationFile(): void
75+
{
76+
$paginationEnglish = base_path('lang/en/pagination.php');
77+
78+
if(!file_exists($paginationEnglish)){
79+
(new Filesystem)->ensureDirectoryExists(base_path('lang/en'));
80+
copy(__DIR__.'/../../stubs/lang/en/pagination.php', base_path('lang/en/pagination.php'));
81+
}
82+
}
6683
}

stubs/lang/en/pagination.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Pagination Language Lines
8+
|--------------------------------------------------------------------------
9+
|
10+
| The following language lines are used by the paginator library to build
11+
| the simple pagination links. You are free to change them to anything
12+
| you want to customize your views to better match your application.
13+
|
14+
*/
15+
16+
'previous' => '&laquo; Previous',
17+
'next' => 'Next &raquo;',
18+
19+
'Showing' => 'Showing',
20+
'to' => 'to',
21+
'of' => 'of',
22+
'results' => 'results'
23+
24+
];

tests/Console/InstallCommandTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
(new Filesystem)->deleteDirectory(resource_path('js'));
88
(new Filesystem)->deleteDirectory(base_path('resources-site'));
99
(new Filesystem)->deleteDirectory(base_path('database/seeders'));
10+
(new Filesystem)->deleteDirectory(base_path('lang/en'));
1011
});
1112

1213
it('can run modular-blog:install command', function () {
1314
$this->artisan('modular:blog-install')
14-
->expectsConfirmation('Do you wish to run the Blog migrations?', 'no')
15+
->expectsConfirmation('Do you wish to run the Blog Seeders?', 'no')
1516
->assertSuccessful();
1617
});
1718

1819
it('can copy the Blog directories and files', function () {
1920
$this->artisan('modular:blog-install')
20-
->expectsConfirmation('Do you wish to run the Blog migrations?', 'no')
21+
->expectsConfirmation('Do you wish to run the Blog Seeders?', 'no')
2122
->assertExitCode(0);
2223

2324
// modules/Blog
@@ -38,6 +39,8 @@
3839
$this->assertFileExists(base_path('modules/Blog/Http/Controllers/PostController.php'));
3940
$this->assertFileExists(base_path('modules/Blog/Models/Post.php'));
4041

42+
$this->assertFileExists(base_path('lang/en/pagination.php'));
43+
4144
// resources/js/Pages
4245
$this->assertDirectoryExists(resource_path('js/Pages/BlogAuthor'));
4346
$this->assertFileExists(resource_path('js/Pages/BlogAuthor/AuthorIndex.vue'));

0 commit comments

Comments
 (0)