44
55use Illuminate \Console \Command ;
66use Illuminate \Filesystem \Filesystem ;
7+ use function Laravel \Prompts \confirm ;
78
89class 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}
0 commit comments