Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-kuendig committed Feb 5, 2020
2 parents cedd2ec + 7d4ad8d commit 61546b8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"symfony/console": "~3.0|~4.0",
"symfony/process": "~3.0|~4.0",
"symfony/filesystem": "~3.0|~4.0",
"symfony/yaml": "~3.0|~4.0"
"symfony/yaml": "~3.0|~4.0",
"ext-json": "*"
},
"bin": [
"october"
Expand Down
3 changes: 2 additions & 1 deletion october
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env php
<?php
define('DS', DIRECTORY_SEPARATOR);
define('VERSION', '0.7.0');

if (file_exists(__DIR__.'/../../autoload.php')) {
require __DIR__.'/../../autoload.php';
} else {
require __DIR__.'/vendor/autoload.php';
}

$app = new Symfony\Component\Console\Application('October CMS Bootstrapper', '0.6.0');
$app = new Symfony\Component\Console\Application('October CMS Bootstrapper', VERSION);
$app->add(new \OFFLINE\Bootstrapper\October\Console\InitCommand);
$app->add(new \OFFLINE\Bootstrapper\October\Console\InstallCommand);
$app->add(new \OFFLINE\Bootstrapper\October\Console\UpdateCommand);
Expand Down
36 changes: 35 additions & 1 deletion src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
return false;
}

$this->write('Patching composer.json...');
$this->patchComposerJson();

$this->write('Installing composer dependencies...');
$this->composer->install();
$this->composer->addDependency('offline/oc-bootstrapper');

$this->write('Setting up config files...');
$this->writeConfig($this->force);
Expand Down Expand Up @@ -405,4 +407,36 @@ public function prepareDatabase()
}
}
}

/**
* Add oc-bootstrapper as a local dependency.
*
* @return void
*/
protected function patchComposerJson()
{
if ( ! $this->fileExists('composer.json')) {
$this->write('Failed to locate composer.json in local directory', 'error');

return;
}

$structure = json_decode(file_get_contents($this->path('composer.json')));
if (json_last_error() !== JSON_ERROR_NONE) {
$this->write('Failed to parse composer.json', 'error');

return;
}

if (isset($structure->config)) {
$structure->config->platform->php = '7.2.0'; // Minimum required version by cypresslab/gitelephant
}

$structure->require->{'offline/oc-bootstrapper'} = '^' . VERSION;

$contents = json_encode($structure, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
if (file_put_contents($this->path('composer.json'), $contents) === false) {
$this->write('Failed to write new composer.json', 'error');
}
}
}

0 comments on commit 61546b8

Please sign in to comment.