Skip to content

Commit c9f78f8

Browse files
committed
Add importer prompt
1 parent 4e59c96 commit c9f78f8

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

src/NewCommand.php

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class NewCommand extends Command
5555
public $withoutDependencies;
5656
public $shouldConfigureDatabase = false;
5757
public $ssg;
58+
public $importer;
5859
public $force;
5960
public $baseInstallSuccessful;
6061
public $shouldUpdateCliToVersion = false;
@@ -83,7 +84,8 @@ protected function configure()
8384
->addOption('with-config', null, InputOption::VALUE_NONE, 'Optionally copy starter-kit.yaml config for local development')
8485
->addOption('without-dependencies', null, InputOption::VALUE_NONE, 'Optionally install starter kit without dependencies')
8586
->addOption('pro', null, InputOption::VALUE_NONE, 'Enable Statamic Pro for additional features')
86-
->addOption('ssg', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Optionally install the Static Site Generator addon', [])
87+
->addOption('ssg', null, InputOption::VALUE_OPTIONAL, 'Optionally install the Static Site Generator addon', false)
88+
->addOption('importer', null, InputOption::VALUE_OPTIONAL, 'Optionally install the Importer addon', false)
8789
->addOption('git', null, InputOption::VALUE_NONE, 'Initialize a Git repository')
8890
->addOption('branch', null, InputOption::VALUE_REQUIRED, 'The branch that should be created for a new repository')
8991
->addOption('github', null, InputOption::VALUE_OPTIONAL, 'Create a new repository on GitHub', false)
@@ -135,6 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
135137
->askToInstallEloquentDriver()
136138
->askToEnableStatamicPro()
137139
->askToInstallSsg()
140+
->askToInstallImporter()
138141
->askToMakeSuperUser()
139142
->askToInitializeGitRepository()
140143
->askToPushToGithub()
@@ -146,6 +149,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
146149
->configureDatabaseConnection()
147150
->installEloquentDriver()
148151
->installSsg()
152+
->installImporter()
149153
->initializeGitRepository()
150154
->pushToGithub()
151155
->notifyIfOldCliVersion()
@@ -269,8 +273,9 @@ protected function processArguments()
269273
$this->local = $this->input->getOption('local');
270274
$this->withConfig = $this->input->getOption('with-config');
271275
$this->withoutDependencies = $this->input->getOption('without-dependencies');
272-
$this->pro = $this->input->getOption('pro') ?? true;
273-
$this->ssg = $this->input->getOption('ssg');
276+
$this->pro = $this->input->getOption('pro') !== false;
277+
$this->ssg = $this->input->getOption('ssg') !== false;
278+
$this->importer = $this->input->getOption('importer') !== false;
274279
$this->force = $this->input->getOption('force');
275280
$this->initializeGitRepository = $this->input->getOption('git') !== false || $this->input->getOption('github') !== false;
276281
$this->shouldPushToGithub = $this->input->getOption('github') !== false;
@@ -692,6 +697,33 @@ protected function installSsg()
692697
return $this;
693698
}
694699

700+
protected function askToInstallImporter()
701+
{
702+
if ($this->importer || ! $this->input->isInteractive()) {
703+
return $this;
704+
}
705+
706+
if (confirm('Do you want to install the importer?', default: false)) {
707+
$this->importer = true;
708+
}
709+
710+
return $this;
711+
}
712+
713+
protected function installImporter()
714+
{
715+
if (! $this->importer) {
716+
return $this;
717+
}
718+
719+
$this->output->write(PHP_EOL);
720+
intro('Installing the Importer addon...');
721+
722+
$this->runCommand("{$this->findComposer()} require statamic/importer", workingPath: $this->absolutePath);
723+
724+
return $this;
725+
}
726+
695727
protected function askToMakeSuperUser()
696728
{
697729
if (! $this->input->isInteractive()) {

0 commit comments

Comments
 (0)