Skip to content

Commit 5d3f82b

Browse files
Replace addons prompt with SSG prompt (#83)
Co-authored-by: Jason Varga <jason@pixelfear.com>
1 parent d312f31 commit 5d3f82b

1 file changed

Lines changed: 20 additions & 41 deletions

File tree

src/NewCommand.php

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class NewCommand extends Command
5454
public $local;
5555
public $withConfig;
5656
public $withoutDependencies;
57-
public $addons;
57+
public $ssg;
5858
public $force;
5959
public $baseInstallSuccessful;
6060
public $shouldUpdateCliToVersion = false;
@@ -79,7 +79,7 @@ protected function configure()
7979
->addOption('with-config', null, InputOption::VALUE_NONE, 'Optionally copy starter-kit.yaml config for local development')
8080
->addOption('without-dependencies', null, InputOption::VALUE_NONE, 'Optionally install starter kit without dependencies')
8181
->addOption('pro', null, InputOption::VALUE_NONE, 'Enable Statamic Pro for additional features')
82-
->addOption('addon', 'p', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Install first-party addons?', [])
82+
->addOption('ssg', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Optionally install the Static Site Generator addon', [])
8383
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force install even if the directory already exists');
8484
}
8585

@@ -125,14 +125,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
125125
->askForRepo()
126126
->validateStarterKitLicense()
127127
->askToEnableStatamicPro()
128-
->askToInstallAddons()
128+
->askToInstallSsg()
129129
->askToMakeSuperUser()
130130
->askToSpreadJoy()
131131
->installBaseProject()
132132
->installStarterKit()
133133
->enableStatamicPro()
134134
->makeSuperUser()
135-
->installAddons()
135+
->installSsg()
136136
->notifyIfOldCliVersion()
137137
->showSuccessMessage()
138138
->showPostInstallInstructions();
@@ -255,7 +255,7 @@ protected function processArguments()
255255
$this->withConfig = $this->input->getOption('with-config');
256256
$this->withoutDependencies = $this->input->getOption('without-dependencies');
257257
$this->pro = $this->input->getOption('pro') ?? true;
258-
$this->addons = $this->input->getOption('addon');
258+
$this->ssg = $this->input->getOption('ssg');
259259
$this->force = $this->input->getOption('force');
260260

261261
return $this;
@@ -545,56 +545,35 @@ protected function installStarterKit()
545545
return $this;
546546
}
547547

548-
protected function askToInstallAddons()
548+
protected function askToInstallSsg()
549549
{
550-
if ($this->addons || ! $this->input->isInteractive()) {
550+
if ($this->ssg || ! $this->input->isInteractive()) {
551551
return $this;
552552
}
553553

554-
$choice = select(
555-
label: 'Would you like to install any first-party addons?',
556-
options: [
557-
$withoutAddonsOption = "No, I'm good for now.",
558-
"Yes, let me pick.",
559-
],
560-
);
561-
562-
if ($choice === $withoutAddonsOption) {
563-
return $this;
564-
}
565-
566-
$this->addons = multiselect(
567-
label: 'Which first-party addons do you want to install?',
568-
options: [
569-
'collaboration' => 'Collaboration',
570-
'eloquent-driver' => 'Eloquent Driver',
571-
'ssg' => 'Static Site Generator',
572-
],
573-
hint: 'Use the space bar to select options.'
574-
);
575-
576-
if (count($this->addons) > 0) {
577-
$this->output->write(" Great. We'll get these installed right after we setup your Statamic site.".PHP_EOL.PHP_EOL);
554+
if (confirm('Do you plan to generate a static site?', default: false)) {
555+
$this->ssg = true;
578556
}
579557

580558
return $this;
581559
}
582560

583-
protected function installAddons()
561+
protected function installSsg()
584562
{
585-
if (! $this->addons) {
563+
if (! $this->ssg) {
586564
return $this;
587565
}
588566

589-
collect($this->addons)->each(function (string $addon) {
590-
$statusCode = (new Please($this->output))
591-
->cwd($this->absolutePath)
592-
->run("install:{$addon}");
567+
$this->output->write(PHP_EOL);
568+
intro("Installing the Static Site Generator addon...");
593569

594-
if ($statusCode !== 0) {
595-
throw new RuntimeException("There was a problem installing the [{$addon}] addon!");
596-
}
597-
});
570+
$statusCode = (new Please($this->output))
571+
->cwd($this->absolutePath)
572+
->run("install:ssg");
573+
574+
if ($statusCode !== 0) {
575+
throw new RuntimeException("There was a problem installing the Static Site Generator addon!");
576+
}
598577

599578
return $this;
600579
}

0 commit comments

Comments
 (0)