Skip to content

Commit

Permalink
Add deploy --dry-run option
Browse files Browse the repository at this point in the history
  • Loading branch information
t-geindre committed Jun 13, 2018
1 parent 9290b90 commit 54cc27d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
11 changes: 8 additions & 3 deletions bref
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 13 additions & 11 deletions src/Console/Deployer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 54cc27d

Please sign in to comment.