From 26df107874859da74533063f911c1ee7c254d45b Mon Sep 17 00:00:00 2001 From: Musa <40173603+voyula@users.noreply.github.com> Date: Tue, 14 Apr 2020 12:08:01 +0300 Subject: [PATCH 01/11] Create .editorconfig --- .editorconfig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..6537ca46 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 From 51a4cfdb860b77ee6194c926b5c2a747e9c7317f Mon Sep 17 00:00:00 2001 From: Musa <40173603+voyula@users.noreply.github.com> Date: Tue, 14 Apr 2020 12:08:49 +0300 Subject: [PATCH 02/11] Normalize See: https://github.com/laravel/framework/blob/7.x/phpunit.xml.dist#L14 --- phpunit.xml => phpunit.xml.dist | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename phpunit.xml => phpunit.xml.dist (95%) diff --git a/phpunit.xml b/phpunit.xml.dist similarity index 95% rename from phpunit.xml rename to phpunit.xml.dist index 09b9fb0c..2b34d4a7 100644 --- a/phpunit.xml +++ b/phpunit.xml.dist @@ -8,7 +8,8 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false"> + stopOnFailure="false" +> tests From 01836afe46ff3527457d87501a93ad0bbec16a4b Mon Sep 17 00:00:00 2001 From: henrydennis-sonin <58974670+henrydennis-sonin@users.noreply.github.com> Date: Mon, 27 Apr 2020 19:04:21 +0000 Subject: [PATCH 03/11] Passthrough return status of passthru Return the status of the docker cmd so that is can be used further. This allows the result of the test to be used in CI pipelines. --- src/Commands/LocalCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Commands/LocalCommand.php b/src/Commands/LocalCommand.php index 52f26293..e7bc9897 100644 --- a/src/Commands/LocalCommand.php +++ b/src/Commands/LocalCommand.php @@ -53,6 +53,8 @@ protected function configure() public function handle() { $options = array_slice($_SERVER['argv'], $this->option('php') ? 3 : 2); + + $returnStatus = 0; file_put_contents( $dockerComposePath = Path::current().'/vapor-docker-compose.yml', @@ -75,10 +77,13 @@ public function handle() '-v', Path::current().':/app', 'app', - ], $options)) + ], $options)), + $returnStatus ); unlink($dockerComposePath); + + exit($returnStatus); } /** From f4e25b748cf011eacdd5e90c03d50b381c853140 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 27 Apr 2020 15:23:47 -0500 Subject: [PATCH 04/11] Update LocalCommand.php --- src/Commands/LocalCommand.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Commands/LocalCommand.php b/src/Commands/LocalCommand.php index e7bc9897..e63e186a 100644 --- a/src/Commands/LocalCommand.php +++ b/src/Commands/LocalCommand.php @@ -47,14 +47,14 @@ protected function configure() /** * Execute the command. * - * @return void + * @return int * @throws Exception */ public function handle() { $options = array_slice($_SERVER['argv'], $this->option('php') ? 3 : 2); - $returnStatus = 0; + $status = 0; file_put_contents( $dockerComposePath = Path::current().'/vapor-docker-compose.yml', @@ -78,12 +78,12 @@ public function handle() Path::current().':/app', 'app', ], $options)), - $returnStatus + $status ); unlink($dockerComposePath); - exit($returnStatus); + return $status; } /** From 98b1dfc65d0e23a7e33fea804f998b8df541e508 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 27 Apr 2020 15:25:26 -0500 Subject: [PATCH 05/11] update exit code --- src/Commands/Command.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Commands/Command.php b/src/Commands/Command.php index 1656e9b9..5a27a417 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -68,9 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->configureOutputStyles($output); - Helpers::app()->call([$this, 'handle']); - - return 0; + return Helpers::app()->call([$this, 'handle']) ?: 0; } /** From 357c670ed4997f52672af0380345e888d3450fe8 Mon Sep 17 00:00:00 2001 From: Beau Simensen Date: Fri, 1 May 2020 09:08:55 -0500 Subject: [PATCH 06/11] Add project:describe and env:describe commands --- src/Commands/EnvDescribeCommand.php | 102 ++++++++++++++++++++++++ src/Commands/ProjectDescribeCommand.php | 91 +++++++++++++++++++++ src/ConsoleVaporClient.php | 13 +++ vapor | 2 + 4 files changed, 208 insertions(+) create mode 100644 src/Commands/EnvDescribeCommand.php create mode 100644 src/Commands/ProjectDescribeCommand.php diff --git a/src/Commands/EnvDescribeCommand.php b/src/Commands/EnvDescribeCommand.php new file mode 100644 index 00000000..2f36fa88 --- /dev/null +++ b/src/Commands/EnvDescribeCommand.php @@ -0,0 +1,102 @@ +%setting-key%] %setting-value%'; + + /** + * Configure the command options. + * + * @return void + */ + protected function configure() + { + $this + ->setName('env:describe') + ->addArgument('environment', InputArgument::REQUIRED, 'The environment name') + ->addOption('list', 'l', InputOption::VALUE_NONE, 'List settings') + ->addOption('format', 'f', InputOption::VALUE_REQUIRED, 'List format') + ->addArgument('setting-key', null, 'Setting key') + ->setDescription('Describe an environment'); + } + + /** + * Execute the command. + * + * @return void + */ + public function handle() + { + Helpers::ensure_api_token_is_available(); + + $environment = $this->vapor->environmentNamed( + Manifest::id(), + $this->argument('environment') + ); + + $domains = $environment['latest_deployment']['root_domains'] ?: []; + $domain = count($domains) ? $domains[0] : null; + + $description = [ + 'project_id' => $environment['project_id'], + 'uuid' => $environment['uuid'], + 'id' => $environment['id'], + 'name' => $environment['name'], + 'vanity_domain' => $environment['vanity_domain'], + 'latest_deployment_id' => $environment['latest_deployment_id'], + 'latest_deployment_status' => $environment['latest_deployment']['status'], + 'latest_deployment_url' => 'https://vapor.laravel.com/app/projects/' . $environment['project_id'] . '/environments/' . $environment['name'] . '/deployments/' . $environment['latest_deployment_id'], + 'deployment_status' => $environment['deployment_status'], + 'domains' => $domains, + 'domain' => $domain, + 'management_url' => 'https://vapor.laravel.com/app/projects/' . $environment['project_id'] . '/environments/' . $environment['name'], + 'vanity_url' => 'https://' . $environment['vanity_domain'], + 'custom_url' => $domain ? 'https://' . $domain : null, + ]; + + // List the configuration of the file settings + if ($this->option('list')) { + $format = $this->option('format') ?: static::DEFAULT_FORMAT; + + foreach ($description as $settingKey => $settingValue) { + if (is_bool($settingValue)) { + $settingValue = var_export($settingValue, true); + } + + if (is_array($settingValue)) { + $settingValue = implode(',', $settingValue); + } + + Helpers::line(str_replace(['%setting-key%', '%setting-value%'], [$settingKey, $settingValue], $format)); + } + + return; + } + + $settingKey = $this->argument('setting-key'); + + if (!$settingKey || !is_string($settingKey)) { + return; + } + + if (! array_key_exists($settingKey, $description)) { + throw new RuntimeException($settingKey.' is not defined'); + } + + $settingValue = $description[$settingKey]; + + if (is_bool($settingValue)) { + $settingValue = var_export($settingValue, true); + } + + Helpers::line($settingValue); + } +} diff --git a/src/Commands/ProjectDescribeCommand.php b/src/Commands/ProjectDescribeCommand.php new file mode 100644 index 00000000..9125c5f4 --- /dev/null +++ b/src/Commands/ProjectDescribeCommand.php @@ -0,0 +1,91 @@ +%setting-key%] %setting-value%'; + + /** + * Configure the command options. + * + * @return void + */ + protected function configure() + { + $this + ->setName('project:describe') + ->addOption('list', 'l', InputOption::VALUE_NONE, 'List settings') + ->addOption('format', 'f', InputOption::VALUE_REQUIRED, 'List format') + ->addArgument('setting-key', null, 'Setting key') + ->setDescription('Describe the project'); + } + + /** + * Execute the command. + * + * @return void + */ + public function handle() + { + Helpers::ensure_api_token_is_available(); + + $settingKey = $this->argument('setting-key'); + + if ($settingKey && $settingKey === 'id') { + // If we want the ID, we can just get it. + Helpers::line(Manifest::id()); + + return; + } + + $project = $this->vapor->project(Manifest::id()); + + $description = [ + 'id' => $project['id'], + 'name' => $project['name'], + 'team_id' => $project['team_id'], + 'team_name' => $project['team']['name'], + 'region' => $project['region'], + 'github_repository' => $project['github_repository'], + 'management_url' => 'https://vapor.laravel.com/app/projects/' . $project['id'], + ]; + + // List the configuration of the file settings + if ($this->option('list')) { + $format = $this->option('format') ?: static::DEFAULT_FORMAT; + + foreach ($description as $settingKey => $settingValue) { + if (is_bool($settingValue)) { + $settingValue = var_export($settingValue, true); + } + + Helpers::line(str_replace(['%setting-key%', '%setting-value%'], [$settingKey, $settingValue], $format)); + } + + return; + } + + if (!$settingKey || !is_string($settingKey)) { + return; + } + + if (! array_key_exists($settingKey, $description)) { + throw new RuntimeException($settingKey.' is not defined'); + } + + $settingValue = $description[$settingKey]; + + if (is_bool($settingValue)) { + $settingValue = var_export($settingValue, true); + } + + Helpers::line($settingValue); + } +} diff --git a/src/ConsoleVaporClient.php b/src/ConsoleVaporClient.php index a78d5301..dca633ca 100644 --- a/src/ConsoleVaporClient.php +++ b/src/ConsoleVaporClient.php @@ -757,6 +757,19 @@ public function environments($projectId) return $this->request('get', '/api/projects/'.$projectId.'/environments'); } + /** + * Get the environment by a specific name for the given project. + * + * @param string $projectId + * @return array + */ + public function environmentNamed($projectId, $name) + { + return collect($this->environments($projectId))->first(function ($environment) use ($name) { + return $environment['name'] === $name; + }); + } + /** * Delete the given project. * diff --git a/vapor b/vapor index 5ea4cd58..588763b7 100755 --- a/vapor +++ b/vapor @@ -133,10 +133,12 @@ $app->add(new Commands\BalancerDeleteCommand); // Projects... $app->add(new Commands\InitCommand); $app->add(new Commands\ProjectDeleteCommand); +$app->add(new Commands\ProjectDescribeCommand); // Environments... $app->add(new Commands\EnvListCommand); $app->add(new Commands\EnvCommand); +$app->add(new Commands\EnvDescribeCommand); $app->add(new Commands\EnvPullCommand); $app->add(new Commands\EnvPushCommand); $app->add(new Commands\EnvCloneCommand); From 16651031b320f0af8d44b490801c2aff54806e4e Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 1 May 2020 10:44:50 -0500 Subject: [PATCH 07/11] formatting --- src/Commands/EnvDescribeCommand.php | 28 ++++++++++++++----------- src/Commands/ProjectDescribeCommand.php | 19 ++++++++++------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/Commands/EnvDescribeCommand.php b/src/Commands/EnvDescribeCommand.php index 2f36fa88..5c62888d 100644 --- a/src/Commands/EnvDescribeCommand.php +++ b/src/Commands/EnvDescribeCommand.php @@ -10,7 +10,7 @@ class EnvDescribeCommand extends Command { - const DEFAULT_FORMAT = '[%setting-key%] %setting-value%'; + const DEFAULT_FORMAT = '[%attribute-key%] %attribute-value%'; /** * Configure the command options. @@ -22,9 +22,9 @@ protected function configure() $this ->setName('env:describe') ->addArgument('environment', InputArgument::REQUIRED, 'The environment name') - ->addOption('list', 'l', InputOption::VALUE_NONE, 'List settings') - ->addOption('format', 'f', InputOption::VALUE_REQUIRED, 'List format') - ->addArgument('setting-key', null, 'Setting key') + ->addArgument('attribute', null, 'The environment attribute you would like to retrieve') + ->addOption('list', 'l', InputOption::VALUE_NONE, 'Indicate that all attributes should be listed') + ->addOption('format', 'f', InputOption::VALUE_REQUIRED, 'The list format string') ->setDescription('Describe an environment'); } @@ -43,6 +43,7 @@ public function handle() ); $domains = $environment['latest_deployment']['root_domains'] ?: []; + $domain = count($domains) ? $domains[0] : null; $description = [ @@ -53,16 +54,15 @@ public function handle() 'vanity_domain' => $environment['vanity_domain'], 'latest_deployment_id' => $environment['latest_deployment_id'], 'latest_deployment_status' => $environment['latest_deployment']['status'], - 'latest_deployment_url' => 'https://vapor.laravel.com/app/projects/' . $environment['project_id'] . '/environments/' . $environment['name'] . '/deployments/' . $environment['latest_deployment_id'], + 'latest_deployment_url' => 'https://vapor.laravel.com/app/projects/'.$environment['project_id'].'/environments/'.$environment['name'].'/deployments/'.$environment['latest_deployment_id'], 'deployment_status' => $environment['deployment_status'], 'domains' => $domains, 'domain' => $domain, - 'management_url' => 'https://vapor.laravel.com/app/projects/' . $environment['project_id'] . '/environments/' . $environment['name'], - 'vanity_url' => 'https://' . $environment['vanity_domain'], - 'custom_url' => $domain ? 'https://' . $domain : null, + 'management_url' => 'https://vapor.laravel.com/app/projects/'.$environment['project_id'].'/environments/'.$environment['name'], + 'vanity_url' => 'https://'.$environment['vanity_domain'], + 'custom_url' => $domain ? 'https://'.$domain : null, ]; - // List the configuration of the file settings if ($this->option('list')) { $format = $this->option('format') ?: static::DEFAULT_FORMAT; @@ -75,15 +75,19 @@ public function handle() $settingValue = implode(',', $settingValue); } - Helpers::line(str_replace(['%setting-key%', '%setting-value%'], [$settingKey, $settingValue], $format)); + Helpers::line(str_replace( + ['%attribute-key%', '%attribute-value%'], + [$settingKey, $settingValue], + $format + )); } return; } - $settingKey = $this->argument('setting-key'); + $settingKey = $this->argument('attribute'); - if (!$settingKey || !is_string($settingKey)) { + if (! $settingKey || ! is_string($settingKey)) { return; } diff --git a/src/Commands/ProjectDescribeCommand.php b/src/Commands/ProjectDescribeCommand.php index 9125c5f4..d0e363ee 100644 --- a/src/Commands/ProjectDescribeCommand.php +++ b/src/Commands/ProjectDescribeCommand.php @@ -10,7 +10,7 @@ class ProjectDescribeCommand extends Command { - const DEFAULT_FORMAT = '[%setting-key%] %setting-value%'; + const DEFAULT_FORMAT = '[%attribute-key%] %attribute-value%'; /** * Configure the command options. @@ -21,9 +21,9 @@ protected function configure() { $this ->setName('project:describe') - ->addOption('list', 'l', InputOption::VALUE_NONE, 'List settings') - ->addOption('format', 'f', InputOption::VALUE_REQUIRED, 'List format') - ->addArgument('setting-key', null, 'Setting key') + ->addArgument('attribute', null, 'The project attribute you would like to retrieve') + ->addOption('list', 'l', InputOption::VALUE_NONE, 'Indicate that all attributes should be listed') + ->addOption('format', 'f', InputOption::VALUE_REQUIRED, 'The list format string') ->setDescription('Describe the project'); } @@ -36,7 +36,7 @@ public function handle() { Helpers::ensure_api_token_is_available(); - $settingKey = $this->argument('setting-key'); + $settingKey = $this->argument('attribute'); if ($settingKey && $settingKey === 'id') { // If we want the ID, we can just get it. @@ -57,7 +57,6 @@ public function handle() 'management_url' => 'https://vapor.laravel.com/app/projects/' . $project['id'], ]; - // List the configuration of the file settings if ($this->option('list')) { $format = $this->option('format') ?: static::DEFAULT_FORMAT; @@ -66,13 +65,17 @@ public function handle() $settingValue = var_export($settingValue, true); } - Helpers::line(str_replace(['%setting-key%', '%setting-value%'], [$settingKey, $settingValue], $format)); + Helpers::line(str_replace( + ['%attribute-key%', '%attribute-value%'], + [$settingKey, $settingValue], + $format + )); } return; } - if (!$settingKey || !is_string($settingKey)) { + if (! $settingKey || ! is_string($settingKey)) { return; } From 76d60bc24476385d98ad57de3e4241157d0a5a39 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 1 May 2020 10:45:34 -0500 Subject: [PATCH 08/11] wip --- vapor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vapor b/vapor index 588763b7..f539763b 100755 --- a/vapor +++ b/vapor @@ -52,7 +52,7 @@ require __DIR__.'/services.php'; /** * Start the console application. */ -$app = new Application('Laravel Vapor', '1.4.7'); +$app = new Application('Laravel Vapor', '1.5.0'); // Authentication... $app->add(new Commands\LoginCommand); From 00e33c5dea9e680ed71c91c87747fc3d6258dea0 Mon Sep 17 00:00:00 2001 From: Daniel Mason Date: Wed, 6 May 2020 16:20:41 +0100 Subject: [PATCH 09/11] Display actual queue metrics in command output --- src/Commands/MetricsCommand.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Commands/MetricsCommand.php b/src/Commands/MetricsCommand.php index e60b523d..38034802 100644 --- a/src/Commands/MetricsCommand.php +++ b/src/Commands/MetricsCommand.php @@ -42,11 +42,14 @@ public function handle() ], [ ['API Gateway Requests', number_format($metrics['totalRestApiRequests']), '$'.number_format($metrics['estimatedApiCost'], 2).''], ['Web Function Invocations', number_format($metrics['totalFunctionInvocations']), '-'], - ['CLI / Queue Function Invocations', number_format($metrics['totalCliFunctionInvocations']), '-'], + ['CLI Function Invocations', number_format($metrics['totalCliFunctionInvocations']), '-'], + ['Queue Function Invocations', number_format($metrics['totalQueueFunctionInvocations']), '-'], ['Average Web Function Duration', number_format($metrics['averageFunctionDuration'], 0).'ms', '-'], - ['Average CLI / Queue Function Duration', number_format($metrics['averageCliFunctionDuration'], 0).'ms', '-'], + ['Average CLI Function Duration', number_format($metrics['averageCliFunctionDuration'], 0).'ms', '-'], + ['Average Queue Function Duration', number_format($metrics['averageQueueFunctionDuration'], 0).'ms', '-'], ['Total Web Function Duration', number_format($metrics['totalFunctionDuration'] / 1000, 0).'s', '$'.number_format($metrics['estimatedCost'], 2).''], - ['Total CLI / Queue Function Duration', number_format($metrics['totalCliFunctionDuration'] / 1000, 0).'s', '$'.number_format($metrics['estimatedCliCost'], 2).''], + ['Total CLI Function Duration', number_format($metrics['totalCliFunctionDuration'] / 1000, 0).'s', '$'.number_format($metrics['estimatedCliCost'], 2).''], + ['Total Queue Function Duration', number_format($metrics['totalQueueFunctionDuration'] / 1000, 0).'s', '$'.number_format($metrics['estimatedQueueCost'], 2).''], ]); Helpers::line(); From 2ede23069d2b35eddfbabc378c7c8bda23ffc3ef Mon Sep 17 00:00:00 2001 From: Julien Bourdeau Date: Fri, 8 May 2020 10:32:08 +0200 Subject: [PATCH 10/11] Add build step message for user ignored directory --- src/BuildProcess/RemoveIgnoredFiles.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/BuildProcess/RemoveIgnoredFiles.php b/src/BuildProcess/RemoveIgnoredFiles.php index a88c81b2..bbd9d625 100644 --- a/src/BuildProcess/RemoveIgnoredFiles.php +++ b/src/BuildProcess/RemoveIgnoredFiles.php @@ -123,6 +123,8 @@ protected function removeUserIgnoredFiles() [$directory, $filePattern] = $this->parsePattern($pattern); if ($this->files->exists($directory.'/'.$filePattern) && $this->files->isDirectory($directory.'/'.$filePattern)) { + Helpers::step('Removing Ignored Directory: '.$filePattern.'/'); + $this->files->deleteDirectory($directory.'/'.$filePattern, $preserve = false); } else { $files = (new Finder) From 1e712e99eeb077e1c9707dc5fcb63353e70b616d Mon Sep 17 00:00:00 2001 From: Chris Weaver Date: Wed, 13 May 2020 00:01:42 -0400 Subject: [PATCH 11/11] Update version number I'm not sure if this is the right area for this, but this just drove me nuts for awhile seeing 1.4.7 and it was 1.6.2 on the site. --- vapor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vapor b/vapor index f539763b..eb8f391f 100755 --- a/vapor +++ b/vapor @@ -52,7 +52,7 @@ require __DIR__.'/services.php'; /** * Start the console application. */ -$app = new Application('Laravel Vapor', '1.5.0'); +$app = new Application('Laravel Vapor', '1.6.2'); // Authentication... $app->add(new Commands\LoginCommand);