From 5f0baab2ac20e03f901ee01ea27901bcb7ec0fce Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 19 Aug 2016 15:50:08 +0200 Subject: [PATCH] Created script to update an already existing system --- bin/cli | 9 ++++++++- bin/cli.php | 10 ---------- bin/install | 12 +++++++++++- bin/{install.php => update} | 4 ++-- module/CLI/src/Command/Install/InstallCommand.php | 14 ++++++++++++-- module/CLI/src/Command/Install/UpdateCommand.php | 12 ++++++++++++ 6 files changed, 45 insertions(+), 16 deletions(-) delete mode 100644 bin/cli.php rename bin/{install.php => update} (71%) create mode 100644 module/CLI/src/Command/Install/UpdateCommand.php diff --git a/bin/cli b/bin/cli index 6f752583..66086b23 100755 --- a/bin/cli +++ b/bin/cli @@ -1,4 +1,11 @@ #!/usr/bin/env php get(CliApp::class); +$app->run(); diff --git a/bin/cli.php b/bin/cli.php deleted file mode 100644 index d15f1eef..00000000 --- a/bin/cli.php +++ /dev/null @@ -1,10 +0,0 @@ -get(CliApp::class); -$app->run(); diff --git a/bin/install b/bin/install index fde1f4a7..c47036a9 100755 --- a/bin/install +++ b/bin/install @@ -1,4 +1,14 @@ #!/usr/bin/env php add(new InstallCommand(new PhpArray())); +$app->setDefaultCommand('shlink:install'); +$app->run(); diff --git a/bin/install.php b/bin/update similarity index 71% rename from bin/install.php rename to bin/update index c47036a9..b226a9fa 100755 --- a/bin/install.php +++ b/bin/update @@ -1,6 +1,6 @@ #!/usr/bin/env php add(new InstallCommand(new PhpArray())); +$app->add(new UpdateCommand(new PhpArray())); $app->setDefaultCommand('shlink:install'); $app->run(); diff --git a/module/CLI/src/Command/Install/InstallCommand.php b/module/CLI/src/Command/Install/InstallCommand.php index 75eac1ef..1271e2ea 100644 --- a/module/CLI/src/Command/Install/InstallCommand.php +++ b/module/CLI/src/Command/Install/InstallCommand.php @@ -44,6 +44,11 @@ class InstallCommand extends Command */ private $configWriter; + /** + * InstallCommand constructor. + * @param WriterInterface $configWriter + * @param callable|null $databaseCreationLogic + */ public function __construct(WriterInterface $configWriter) { parent::__construct(null); @@ -94,8 +99,7 @@ class InstallCommand extends Command $output->writeln(['Custom configuration properly generated!', '']); // Generate database - $output->writeln('Initializing database...'); - if (! $this->runCommand('php vendor/bin/doctrine.php orm:schema-tool:create', 'Error generating database.')) { + if (! $this->createDatabase()) { return; } @@ -273,6 +277,12 @@ class InstallCommand extends Command return $config; } + protected function createDatabase() + { + $this->output->writeln('Initializing database...'); + return $this->runCommand('php vendor/bin/doctrine.php orm:schema-tool:create', 'Error generating database.'); + } + /** * @param string $command * @param string $errorMessage diff --git a/module/CLI/src/Command/Install/UpdateCommand.php b/module/CLI/src/Command/Install/UpdateCommand.php new file mode 100644 index 00000000..3aed5512 --- /dev/null +++ b/module/CLI/src/Command/Install/UpdateCommand.php @@ -0,0 +1,12 @@ +