Skip to content

Commit

Permalink
Add importer prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Oct 28, 2024
1 parent 4e59c96 commit c9f78f8
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class NewCommand extends Command
public $withoutDependencies;
public $shouldConfigureDatabase = false;
public $ssg;
public $importer;
public $force;
public $baseInstallSuccessful;
public $shouldUpdateCliToVersion = false;
Expand Down Expand Up @@ -83,7 +84,8 @@ protected function configure()
->addOption('with-config', null, InputOption::VALUE_NONE, 'Optionally copy starter-kit.yaml config for local development')
->addOption('without-dependencies', null, InputOption::VALUE_NONE, 'Optionally install starter kit without dependencies')
->addOption('pro', null, InputOption::VALUE_NONE, 'Enable Statamic Pro for additional features')
->addOption('ssg', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Optionally install the Static Site Generator addon', [])
->addOption('ssg', null, InputOption::VALUE_OPTIONAL, 'Optionally install the Static Site Generator addon', false)
->addOption('importer', null, InputOption::VALUE_OPTIONAL, 'Optionally install the Importer addon', false)
->addOption('git', null, InputOption::VALUE_NONE, 'Initialize a Git repository')
->addOption('branch', null, InputOption::VALUE_REQUIRED, 'The branch that should be created for a new repository')
->addOption('github', null, InputOption::VALUE_OPTIONAL, 'Create a new repository on GitHub', false)
Expand Down Expand Up @@ -135,6 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
->askToInstallEloquentDriver()
->askToEnableStatamicPro()
->askToInstallSsg()
->askToInstallImporter()
->askToMakeSuperUser()
->askToInitializeGitRepository()
->askToPushToGithub()
Expand All @@ -146,6 +149,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
->configureDatabaseConnection()
->installEloquentDriver()
->installSsg()
->installImporter()
->initializeGitRepository()
->pushToGithub()
->notifyIfOldCliVersion()
Expand Down Expand Up @@ -269,8 +273,9 @@ protected function processArguments()
$this->local = $this->input->getOption('local');
$this->withConfig = $this->input->getOption('with-config');
$this->withoutDependencies = $this->input->getOption('without-dependencies');
$this->pro = $this->input->getOption('pro') ?? true;
$this->ssg = $this->input->getOption('ssg');
$this->pro = $this->input->getOption('pro') !== false;
$this->ssg = $this->input->getOption('ssg') !== false;
$this->importer = $this->input->getOption('importer') !== false;
$this->force = $this->input->getOption('force');
$this->initializeGitRepository = $this->input->getOption('git') !== false || $this->input->getOption('github') !== false;
$this->shouldPushToGithub = $this->input->getOption('github') !== false;
Expand Down Expand Up @@ -692,6 +697,33 @@ protected function installSsg()
return $this;
}

protected function askToInstallImporter()
{
if ($this->importer || ! $this->input->isInteractive()) {
return $this;
}

if (confirm('Do you want to install the importer?', default: false)) {
$this->importer = true;
}

return $this;
}

protected function installImporter()
{
if (! $this->importer) {
return $this;
}

$this->output->write(PHP_EOL);
intro('Installing the Importer addon...');

$this->runCommand("{$this->findComposer()} require statamic/importer", workingPath: $this->absolutePath);

return $this;
}

protected function askToMakeSuperUser()
{
if (! $this->input->isInteractive()) {
Expand Down

0 comments on commit c9f78f8

Please sign in to comment.