Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ class NewCommand extends Command
public $relativePath;
public $absolutePath;
public $name;
public $version;
public $starterKit;
public $starterKitVcs;
public $starterKitLicense;
public $local;
public $withConfig;
public $withoutDependencies;
public $force;
public $v2;
public $baseInstallSuccessful;
Expand All @@ -56,6 +58,7 @@ protected function configure()
->addOption('license', null, InputOption::VALUE_OPTIONAL, 'Optionally provide explicit starter kit license')
->addOption('local', null, InputOption::VALUE_NONE, 'Optionally install from local repo configured in composer config.json')
->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('v2', null, InputOption::VALUE_NONE, 'Create a legacy Statamic v2 application (not recommended)')
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force install even if the directory already exists');
}
Expand Down Expand Up @@ -158,10 +161,15 @@ protected function processArguments()

$this->name = pathinfo($this->absolutePath)['basename'];

$this->version = $this->input->getOption('dev')
? 'dev-master'
: '';

$this->starterKit = $this->input->getArgument('starter-kit');
$this->starterKitLicense = $this->input->getOption('license');
$this->local = $this->input->getOption('local');
$this->withConfig = $this->input->getOption('with-config');
$this->withoutDependencies = $this->input->getOption('without-dependencies');

$this->force = $this->input->getOption('force');

Expand Down Expand Up @@ -206,6 +214,10 @@ protected function validateArguments()
throw new RuntimeException('Starter kit is required when using `--with-config` option!');
}

if (! $this->starterKit && $this->withoutDependencies) {
throw new RuntimeException('Starter kit is required when using `--without-dependencies` option!');
}

return $this;
}

Expand Down Expand Up @@ -503,6 +515,10 @@ protected function installStarterKit()
$options[] = $this->starterKitLicense;
}

if ($this->withoutDependencies) {
$options[] = '--without-dependencies';
}

$statusCode = (new Please($this->output))
->cwd($this->absolutePath)
->run('starter-kit:install', $this->starterKit, ...$options);
Expand Down Expand Up @@ -710,11 +726,9 @@ protected function createProjectCommand()

$baseRepo = self::BASE_REPO;

$version = $this->getVersion();

$directory = $this->pathIsCwd() ? '.' : $this->relativePath;

return $composer." create-project {$baseRepo} \"{$directory}\" {$version} --remove-vcs --prefer-dist";
return $composer." create-project {$baseRepo} \"{$directory}\" {$this->version} --remove-vcs --prefer-dist";
}

/**
Expand Down Expand Up @@ -831,13 +845,4 @@ public function __call($method, $args)
}
};
}

protected function getVersion()
{
if ($this->input->getOption('dev')) {
return 'dev-master';
}

return '';
}
}