@@ -56,6 +56,7 @@ protected function configure()
56
56
->addOption ('pest ' , null , InputOption::VALUE_NONE , 'Install the Pest testing framework ' )
57
57
->addOption ('phpunit ' , null , InputOption::VALUE_NONE , 'Install the PHPUnit testing framework ' )
58
58
->addOption ('npm ' , null , InputOption::VALUE_NONE , 'Install and build NPM dependencies ' )
59
+ ->addOption ('using ' , null , InputOption::VALUE_OPTIONAL , 'Install a custom starter kit from a community maintained package ' )
59
60
->addOption ('force ' , 'f ' , InputOption::VALUE_NONE , 'Forces install even if the directory already exists ' );
60
61
}
61
62
@@ -108,7 +109,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
108
109
);
109
110
}
110
111
111
- if (! $ input -> getOption ( ' react ' ) && ! $ input-> getOption ( ' vue ' ) && ! $ input -> getOption ( ' livewire ' )) {
112
+ if (! $ this -> usingStarterKit ( $ input )) {
112
113
match (select (
113
114
label: 'Which starter kit would you like to install? ' ,
114
115
options: [
@@ -125,7 +126,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
125
126
default => null ,
126
127
};
127
128
128
- if ($ this ->usingStarterKit ($ input )) {
129
+ if ($ this ->usingLaravelStarterKit ($ input )) {
129
130
match (select (
130
131
label: 'Which authentication provider do you prefer? ' ,
131
132
options: [
@@ -148,7 +149,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
148
149
}
149
150
}
150
151
151
- if ($ this ->usingStarterKit ($ input )) {
152
+ if ($ this ->usingLaravelStarterKit ($ input )) {
152
153
if (! $ input ->getOption ('phpunit ' ) &&
153
154
! $ input ->getOption ('pest ' )) {
154
155
$ input ->setOption ('pest ' , select (
@@ -226,22 +227,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
226
227
227
228
$ createProjectCommand = $ composer ." create-project laravel/laravel \"$ directory \" $ version --remove-vcs --prefer-dist --no-scripts " ;
228
229
229
- $ stackSlug = match (true ) {
230
- $ input ->getOption ('react ' ) => 'react ' ,
231
- $ input ->getOption ('vue ' ) => 'vue ' ,
232
- $ input ->getOption ('livewire ' ) => 'livewire ' ,
233
- default => null
234
- };
230
+ $ starterKit = $ this ->getStarterKit ($ input );
235
231
236
- if ($ stackSlug ) {
237
- $ createProjectCommand = $ composer ." create-project laravel/ $ stackSlug -starter-kit \"$ directory \" --stability=dev " ;
232
+ if ($ starterKit ) {
233
+ $ createProjectCommand = $ composer ." create-project { $ starterKit } \"{ $ directory} \" --stability=dev " ;
238
234
239
- if ($ input ->getOption ('livewire-class-components ' )) {
240
- $ createProjectCommand = str_replace (" laravel/ { $ stackSlug } -starter-kit " , " laravel/ { $ stackSlug } -starter-kit :dev-components " , $ createProjectCommand );
235
+ if ($ this -> usingLaravelStarterKit ( $ input ) && $ input ->getOption ('livewire-class-components ' )) {
236
+ $ createProjectCommand = str_replace (" { $ starterKit } " , " { $ starterKit } :dev-components " , $ createProjectCommand );
241
237
}
242
238
243
- if ($ input ->getOption ('workos ' )) {
244
- $ createProjectCommand = str_replace (" laravel/ { $ stackSlug } -starter-kit " , " laravel/ { $ stackSlug } -starter-kit :dev-workos " , $ createProjectCommand );
239
+ if ($ this -> usingLaravelStarterKit ( $ input ) && $ input ->getOption ('workos ' )) {
240
+ $ createProjectCommand = str_replace (" { $ starterKit } " , " { $ starterKit } :dev-workos " , $ createProjectCommand );
245
241
}
246
242
}
247
243
@@ -591,7 +587,7 @@ protected function installPest(string $directory, InputInterface $input, OutputI
591
587
$ this ->phpBinary ().' ./vendor/bin/pest --init ' ,
592
588
];
593
589
594
- if ($ input -> getOption ( ' react ' ) || $ input-> getOption ( ' vue ' ) || $ input -> getOption ( ' livewire ' )) {
590
+ if ($ this -> usingStarterKit ( $ input )) {
595
591
$ commands [] = $ composerBinary .' require pestphp/pest-plugin-drift --dev ' ;
596
592
$ commands [] = $ this ->phpBinary ().' ./vendor/bin/pest --drift ' ;
597
593
$ commands [] = $ composerBinary .' remove pestphp/pest-plugin-drift --dev ' ;
@@ -611,15 +607,15 @@ protected function installPest(string $directory, InputInterface $input, OutputI
611
607
$ directory .'/tests/Unit/ExampleTest.php ' ,
612
608
);
613
609
614
- if ($ input -> getOption ( ' react ' ) || $ input-> getOption ( ' vue ' ) || $ input -> getOption ( ' livewire ' )) {
610
+ if ($ this -> usingStarterKit ( $ input )) {
615
611
$ this ->replaceInFile (
616
612
'./vendor/bin/phpunit ' ,
617
613
'./vendor/bin/pest ' ,
618
614
$ directory .'/.github/workflows/tests.yml ' ,
619
615
);
620
616
}
621
617
622
- if (( $ input -> getOption ( ' react ' ) || $ input-> getOption ( ' vue ' ) || $ input -> getOption ( ' livewire ' ) ) && $ input ->getOption ('phpunit ' )) {
618
+ if ($ this -> usingStarterKit ( $ input ) && $ input ->getOption ('phpunit ' )) {
623
619
$ this ->deleteFile ($ directory .'/tests/Pest.php ' );
624
620
}
625
621
@@ -747,6 +743,28 @@ protected function generateAppUrl($name)
747
743
return $ this ->canResolveHostname ($ hostname ) ? 'http:// ' .$ hostname : 'http://localhost ' ;
748
744
}
749
745
746
+ /**
747
+ * Get the starter kit repository, if any.
748
+ */
749
+ protected function getStarterKit (InputInterface $ input ): ?string
750
+ {
751
+ return match (true ) {
752
+ $ input ->getOption ('react ' ) => 'laravel/react-starter-kit ' ,
753
+ $ input ->getOption ('vue ' ) => 'laravel/vue-starter-kit ' ,
754
+ $ input ->getOption ('livewire ' ) => 'laravel/livewire-starter-kit ' ,
755
+ default => $ input ->getOption ('using ' ),
756
+ };
757
+ }
758
+
759
+ /**
760
+ * Determine if a Laravel first-party starter kit has been chosen.
761
+ */
762
+ protected function usingLaravelStarterKit (InputInterface $ input ): bool
763
+ {
764
+ return $ this ->usingStarterKit ($ input ) &&
765
+ str_starts_with ($ this ->getStarterKit ($ input ), 'laravel/ ' );
766
+ }
767
+
750
768
/**
751
769
* Determine if a starter kit is being used.
752
770
*
@@ -755,7 +773,7 @@ protected function generateAppUrl($name)
755
773
*/
756
774
protected function usingStarterKit (InputInterface $ input )
757
775
{
758
- return $ input ->getOption ('react ' ) || $ input ->getOption ('vue ' ) || $ input ->getOption ('livewire ' );
776
+ return $ input ->getOption ('react ' ) || $ input ->getOption ('vue ' ) || $ input ->getOption ('livewire ' ) || $ input -> getOption ( ' using ' ) ;
759
777
}
760
778
761
779
/**
0 commit comments