Browse Source

feat(deploy): JWT 密钥生成命令,添加强制执行选项

runphp 7 tháng trước cách đây
mục cha
commit
b833ddf377
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      src/Command/JWTGenerateSecretCommand.php

+ 4 - 2
src/Command/JWTGenerateSecretCommand.php

@@ -4,6 +4,7 @@ declare(strict_types=1);
 namespace SixShop\Auth\Command;
 
 use think\console\Command;
+use think\console\input\Option;
 use think\helper\Str;
 
 class JWTGenerateSecretCommand extends Command
@@ -11,7 +12,8 @@ class JWTGenerateSecretCommand extends Command
     public function configure(): void
     {
         $this->setName('jwt:secret')
-            ->setDescription('Set the JWTAuth secret key used to sign the tokens');
+            ->setDescription('Set the JWTAuth secret key used to sign the tokens')
+            ->addOption('force', 'f', Option::VALUE_NONE, 'Force the operation to run when in production');
     }
 
     public function handle(): void
@@ -27,7 +29,7 @@ class JWTGenerateSecretCommand extends Command
             file_put_contents($path, PHP_EOL . "JWT_SECRET=$key" . PHP_EOL, FILE_APPEND);
         } else {
 
-            if ($this->isConfirmed() === false) {
+            if ($this->input->getOption('force') === false && $this->isConfirmed() === false) {
                 $this->output->writeln('Phew... No changes were made to your secret key.');
 
                 return;