protected function fire()
{
$path = rtrim($this->argument('path'), DIRECTORY_SEPARATOR) ?: getcwd();
if (!is_dir($path) && !@mkdir($path, 0777, true)) {
$this->error(sprintf('Could not create directory %s.', $path));
return;
}
// check terms and conditions
if (!$this->option('terms') && !$this->confirm('I agree to the terms and conditions (https://buildwithcraft.com/license)')) {
$this->error('You did not agree to the terms and conditions (https://buildwithcraft.com/license)');
return;
}
// check if craft is already installed, and overwrite option
if (file_exists($path . '/craft') && !$this->option('overwrite')) {
$this->error('Craft is already installed here!');
if (!$this->confirm('Do you want to overwrite?')) {
$this->info('Exited without installing.');
return;
}
}
$url = 'https://buildwithcraft.com/latest.tar.gz?accept_license=yes';
$this->comment('Downloading...');
$downloader = new TempDownloader($url, '.tar.gz');
$downloader->setOutput($this->output);
try {
$filePath = $downloader->download();
} catch (Exception $e) {
$this->error($e->getMessage());
return;
}
$this->comment('Extracting...');
$tarExtractor = new TarExtractor($filePath, $path);
$tarExtractor->extract();
// change the name of the public folder
if ($public = $this->option('public')) {
rename($path . '/public', $path . '/' . $public);
}
$this->info('Installation complete!');
}