Skip to content

Commit 2a14fd9

Browse files
Adds default-environment option (#184)
* Adds `default-environment` option * Uses default environment from base command * Update Manifest.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent 6c32c56 commit 2a14fd9

18 files changed

+34
-17
lines changed

src/Commands/BuildCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function configure()
4141
{
4242
$this
4343
->setName('build')
44-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
44+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
4545
->addOption('asset-url', null, InputOption::VALUE_OPTIONAL, 'The asset base URL')
4646
->addOption('build-arg', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Docker build argument')
4747
->setDescription('Build the project archive');

src/Commands/Command.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use DateTime;
66
use Laravel\VaporCli\ConsoleVaporClient;
77
use Laravel\VaporCli\Helpers;
8+
use Laravel\VaporCli\Manifest;
89
use Laravel\VaporCli\Path;
910
use Symfony\Component\Console\Command\Command as SymfonyCommand;
1011
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
@@ -106,7 +107,13 @@ protected function configureOutputStyles(OutputInterface $output)
106107
*/
107108
protected function argument($key)
108109
{
109-
return $this->input->getArgument($key);
110+
$value = $this->input->getArgument($key);
111+
112+
if ($key == 'environment' && is_null($value)) {
113+
$value = Manifest::defaultEnvironment();
114+
}
115+
116+
return $value;
110117
}
111118

112119
/**

src/Commands/CommandCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected function configure()
1919
{
2020
$this
2121
->setName('command')
22-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
22+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2323
->addOption('command', null, InputOption::VALUE_OPTIONAL, 'The command that should be executed')
2424
->setDescription('Execute a CLI command');
2525
}

src/Commands/DeployCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function configure()
2828
{
2929
$this
3030
->setName('deploy')
31-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
31+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
3232
->addOption('commit', null, InputOption::VALUE_OPTIONAL, 'The commit hash that is being deployed')
3333
->addOption('message', null, InputOption::VALUE_OPTIONAL, 'The message for the commit that is being deployed')
3434
->addOption('without-waiting', null, InputOption::VALUE_NONE, 'Deploy without waiting for progress')

src/Commands/DeployListCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected function configure()
1818
{
1919
$this
2020
->setName('deploy:list')
21-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
21+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2222
->setDescription('List the deployments for an environment');
2323
}
2424

src/Commands/DownCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function configure()
2020
{
2121
$this
2222
->setName('down')
23-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
23+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2424
->addOption('secret', null, InputOption::VALUE_REQUIRED, 'The secret phrase that may be used to bypass maintenance mode')
2525
->setDescription('Place an environment in maintenance mode');
2626
}

src/Commands/MetricsCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function configure()
1717
{
1818
$this
1919
->setName('metrics')
20-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
20+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2121
->addArgument('period', InputArgument::OPTIONAL, 'The metric period (1m, 5m, 30m, 1h, 8h, 1d, 3d, 7d, 1M)', '1d')
2222
->setDescription('Get usage and performance metrics for an environment');
2323
}

src/Commands/OpenCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function configure()
1717
{
1818
$this
1919
->setName('open')
20-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
20+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2121
->setDescription('Open an environment in your default browser');
2222
}
2323

src/Commands/RedeployCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected function configure()
1919
{
2020
$this
2121
->setName('redeploy')
22-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
22+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2323
->setDescription("Redeploy an environment's latest deployment");
2424
}
2525

src/Commands/RollbackCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected function configure()
2121
{
2222
$this
2323
->setName('rollback')
24-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
24+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2525
->addOption('select', null, InputOption::VALUE_NONE, 'Present a list of deployments to choose from')
2626
->setDescription('Rollback an environment to a previous deployment');
2727
}

src/Commands/SecretCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected function configure()
1818
{
1919
$this
2020
->setName('secret')
21-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
21+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2222
->addOption('name', null, InputOption::VALUE_OPTIONAL, 'The secret name')
2323
->addOption('value', null, InputOption::VALUE_OPTIONAL, 'The secret value')
2424
->addOption('file', null, InputOption::VALUE_OPTIONAL, 'The file that contains the secret value')

src/Commands/SecretDeleteCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected function configure()
1818
{
1919
$this
2020
->setName('secret:delete')
21-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
21+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2222
->addOption('name', null, InputOption::VALUE_OPTIONAL, 'The secret name')
2323
->addOption('force', null, InputOption::VALUE_NONE, 'Perform the action without confirmation')
2424
->setDescription('Delete a secret from an environment');

src/Commands/SecretListCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function configure()
1717
{
1818
$this
1919
->setName('secret:list')
20-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
20+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2121
->setDescription('List the secrets for a given environment');
2222
}
2323

src/Commands/SecretPassportCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function configure()
1717
{
1818
$this
1919
->setName('secret:passport')
20-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
20+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2121
->setDescription('Store the application\'s Passport keys as secrets');
2222
}
2323

src/Commands/TailCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function configure()
4242
{
4343
$this
4444
->setName('tail')
45-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
45+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
4646
->addOption('filter', null, InputOption::VALUE_OPTIONAL, 'The text that should be used to filter the logs')
4747
->addOption('cli', null, InputOption::VALUE_NONE, 'Tail the log for the CLI / queue function')
4848
->addOption('without-queue', null, InputOption::VALUE_NONE, 'Hide Vapor generated queue processing messages')

src/Commands/TinkerCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function configure()
1717
{
1818
$this
1919
->setName('tinker')
20-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
20+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2121
->addOption('code', null, InputOption::VALUE_OPTIONAL, 'The code to execute with Tinker')
2222
->setDescription('Execute a code with Tinker');
2323
}

src/Commands/UpCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected function configure()
1919
{
2020
$this
2121
->setName('up')
22-
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
22+
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name')
2323
->setDescription('Remove an environment from maintenance mode');
2424
}
2525

src/Manifest.php

+10
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ public static function current()
4040
return Yaml::parse(file_get_contents(Path::manifest()));
4141
}
4242

43+
/**
44+
* Get the default environment of the project.
45+
*
46+
* @return string
47+
*/
48+
public static function defaultEnvironment()
49+
{
50+
return static::current()['default-environment'] ?? 'staging';
51+
}
52+
4353
/**
4454
* Get the build commands for the given environment.
4555
*

0 commit comments

Comments
 (0)