diff --git a/composer.json b/composer.json index f5493c7..1bbe200 100644 --- a/composer.json +++ b/composer.json @@ -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" diff --git a/october b/october index cbf9c35..f261749 100755 --- a/october +++ b/october @@ -1,6 +1,7 @@ #!/usr/bin/env php add(new \OFFLINE\Bootstrapper\October\Console\InitCommand); $app->add(new \OFFLINE\Bootstrapper\October\Console\InstallCommand); $app->add(new \OFFLINE\Bootstrapper\October\Console\UpdateCommand); diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 2dbfec4..60f7304 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -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); @@ -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'); + } + } }