33namespace Statamic \Cli ;
44
55use GuzzleHttp \Client ;
6- use function Laravel \Prompts \confirm ;
76use Laravel \Prompts \ConfirmPrompt ;
87use Laravel \Prompts \Prompt ;
9- use function Laravel \Prompts \select ;
108use Laravel \Prompts \SelectPrompt ;
11- use function Laravel \Prompts \suggest ;
129use Laravel \Prompts \SuggestPrompt ;
13- use function Laravel \Prompts \text ;
1410use Laravel \Prompts \TextPrompt ;
1511use RuntimeException ;
1612use Statamic \Cli \Theme \ConfirmPromptRenderer ;
2521use Symfony \Component \Console \Question \Question ;
2622use Symfony \Component \Console \Style \SymfonyStyle ;
2723
24+ use function Laravel \Prompts \confirm ;
25+ use function Laravel \Prompts \multiselect ;
26+ use function Laravel \Prompts \select ;
27+ use function Laravel \Prompts \suggest ;
28+ use function Laravel \Prompts \text ;
29+
2830class NewCommand extends Command
2931{
30- use Concerns \RunsCommands , Concerns \ConfiguresPrompts ;
32+ use Concerns \ConfiguresPrompts , Concerns \RunsCommands ;
3133
3234 const BASE_REPO = 'statamic/statamic ' ;
3335 const OUTPOST_ENDPOINT = 'https://outpost.statamic.com/v3/starter-kits/ ' ;
@@ -46,6 +48,7 @@ class NewCommand extends Command
4648 public $ local ;
4749 public $ withConfig ;
4850 public $ withoutDependencies ;
51+ public $ addons ;
4952 public $ force ;
5053 public $ baseInstallSuccessful ;
5154 public $ shouldUpdateCliToVersion = false ;
@@ -69,6 +72,7 @@ protected function configure()
6972 ->addOption ('local ' , null , InputOption::VALUE_NONE , 'Optionally install from local repo configured in composer config.json ' )
7073 ->addOption ('with-config ' , null , InputOption::VALUE_NONE , 'Optionally copy starter-kit.yaml config for local development ' )
7174 ->addOption ('without-dependencies ' , null , InputOption::VALUE_NONE , 'Optionally install starter kit without dependencies ' )
75+ ->addOption ('addon ' , 'p ' , InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY , 'Install first-party addons? ' , [])
7276 ->addOption ('force ' , 'f ' , InputOption::VALUE_NONE , 'Force install even if the directory already exists ' );
7377 }
7478
@@ -112,12 +116,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
112116 ->validateArguments ()
113117 ->askForRepo ()
114118 ->validateStarterKitLicense ()
119+ ->askToInstallAddons ()
115120 ->askToMakeSuperUser ()
116121 ->askToSpreadJoy ()
117122 ->readySetGo ()
118123 ->installBaseProject ()
119124 ->installStarterKit ()
120125 ->makeSuperUser ()
126+ ->installAddons ()
121127 ->notifyIfOldCliVersion ()
122128 ->showSuccessMessage ()
123129 ->showPostInstallInstructions ();
@@ -235,6 +241,7 @@ protected function processArguments()
235241 $ this ->withConfig = $ this ->input ->getOption ('with-config ' );
236242 $ this ->withoutDependencies = $ this ->input ->getOption ('without-dependencies ' );
237243
244+ $ this ->addons = $ this ->input ->getOption ('addon ' );
238245 $ this ->force = $ this ->input ->getOption ('force ' );
239246
240247 return $ this ;
@@ -558,6 +565,44 @@ protected function installStarterKit()
558565 return $ this ;
559566 }
560567
568+ protected function askToInstallAddons ()
569+ {
570+ if ($ this ->addons || ! $ this ->input ->isInteractive ()) {
571+ return $ this ;
572+ }
573+
574+ $ this ->addons = multiselect ('Would you like to install any first-party addons? ' , [
575+ 'collaboration ' => 'Collaboration ' ,
576+ 'eloquent-driver ' => 'Eloquent Driver ' ,
577+ 'ssg ' => 'Static Site Generator ' ,
578+ ]);
579+
580+ if (count ($ this ->addons ) > 0 ) {
581+ $ this ->output ->write (" Great. We'll get these installed right after we setup your Statamic site. " .PHP_EOL .PHP_EOL );
582+ }
583+
584+ return $ this ;
585+ }
586+
587+ protected function installAddons ()
588+ {
589+ if (! $ this ->addons ) {
590+ return $ this ;
591+ }
592+
593+ collect ($ this ->addons )->each (function (string $ addon ) {
594+ $ statusCode = (new Please ($ this ->output ))
595+ ->cwd ($ this ->absolutePath )
596+ ->run ("install: {$ addon }" );
597+
598+ if ($ statusCode !== 0 ) {
599+ throw new RuntimeException ("There was a problem installing the [ {$ addon }] addon! " );
600+ }
601+ });
602+
603+ return $ this ;
604+ }
605+
561606 protected function askToMakeSuperUser ()
562607 {
563608 if (! $ this ->input ->isInteractive ()) {
0 commit comments