From 54cc27dda2e64b28ea9df7077378d700da27d312 Mon Sep 17 00:00:00 2001 From: Thierry Geindre Date: Wed, 13 Jun 2018 11:13:49 +0200 Subject: [PATCH] Add deploy --dry-run option --- bref | 11 ++++++++--- src/Console/Deployer.php | 24 +++++++++++++----------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/bref b/bref index f13c0493e..77cd7e430 100755 --- a/bref +++ b/bref @@ -66,9 +66,14 @@ $app->command( '--raw' => 'Pass data as a raw string even if it is JSON. If not set, JSON data are parsed and passed as an object.', ]); -$app->command('deploy', function (SymfonyStyle $io) { - (new Deployer)->deploy($io); -}); +$app->command( + 'deploy [--dry-run]', + function (SymfonyStyle $io, bool $dryRun) { + (new Deployer)->deploy($io, $dryRun); + }) + ->descriptions('Deploy serverless application', [ + '--dry-run' => 'Build the serverless package without deploying it', + ]); /** * Run a CLI command in the remote environment. diff --git a/src/Console/Deployer.php b/src/Console/Deployer.php index 7f6b96dc9..f360c3d0a 100644 --- a/src/Console/Deployer.php +++ b/src/Console/Deployer.php @@ -65,23 +65,25 @@ function ($value, $key) { return $process->getOutput(); } - public function deploy(SymfonyStyle $io) : void + public function deploy(SymfonyStyle $io, bool $dryRun) : void { $progress = $this->createProgressBar($io, 8); $this->generateArchive($io, $progress); - $progress->setMessage('Uploading the lambda'); - $progress->display(); - $process = new Process('serverless deploy', '.bref/output'); - $process->setTimeout(null); - $completeDeployOutput = ''; - $process->mustRun(function ($type, $buffer) use ($io, $progress, &$completeDeployOutput) { - $completeDeployOutput .= $buffer; - $progress->clear(); - $io->writeln($buffer); + if (!$dryRun) { + $progress->setMessage('Uploading the lambda'); $progress->display(); - }); + $process = new Process('serverless deploy', '.bref/output'); + $process->setTimeout(null); + $completeDeployOutput = ''; + $process->mustRun(function ($type, $buffer) use ($io, $progress, &$completeDeployOutput) { + $completeDeployOutput .= $buffer; + $progress->clear(); + $io->writeln($buffer); + $progress->display(); + }); + } $progress->setMessage('Deployment success'); $progress->finish();