From 8c987f5b399fb9cf1bb10710bf9cc6e206a15ad9 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Tue, 22 Nov 2022 21:27:21 +0000 Subject: [PATCH] Revert "[1.x] Renders error from the `SecretCommand` (#202)" (#204) This reverts commit 01ecf3e42dba13501324b25142fbe821fcba84a0. --- src/Commands/SecretCommand.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Commands/SecretCommand.php b/src/Commands/SecretCommand.php index 352ac682..5ea03325 100644 --- a/src/Commands/SecretCommand.php +++ b/src/Commands/SecretCommand.php @@ -3,6 +3,7 @@ namespace Laravel\VaporCli\Commands; use Laravel\VaporCli\Helpers; +use Laravel\VaporCli\Manifest; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; @@ -27,12 +28,32 @@ protected function configure() /** * Execute the command. * - * @return int + * @return void */ public function handle() { - Helpers::danger('Secrets have been deprecated. Instead, please utilize environment variables and / or encrypted environment files.'); + Helpers::ensure_api_token_is_available(); + + $this->vapor->storeSecret( + Manifest::id(), + $this->argument('environment'), + $this->option('name') ?? Helpers::ask('Name'), + $this->option('value') ?? $this->determineValue() + ); + + Helpers::info('Secret stored successfully.'); + Helpers::line('You should deploy the project using the "deploy" command to ensure the new secrets are available.'); + } - return 1; + /** + * Determine the secret's value. + * + * @return string + */ + protected function determineValue() + { + return $this->option('file') + ? file_get_contents($this->option('file')) + : Helpers::ask('Value'); } }