From d0beea4b3734edf26d12ea26dd188db9bf634e6e Mon Sep 17 00:00:00 2001 From: xion Date: Thu, 27 Feb 2025 18:16:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20pack-deploy=20id=20-k=20=20?= =?UTF-8?q?=E4=BD=BF=E7=94=A8inquirer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/command/publish.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/command/publish.ts b/src/command/publish.ts index 1d0f107..1650706 100644 --- a/src/command/publish.ts +++ b/src/command/publish.ts @@ -9,6 +9,7 @@ import ignore from 'ignore'; import FormData from 'form-data'; import { chalk } from '@/module/chalk.ts'; import * as backServices from '@/query/services/index.ts'; +import inquirer from 'inquirer'; // 查找文件(忽略大小写) async function findFileInsensitive(targetFile: string): Promise { const files = fs.readdirSync('.'); @@ -341,7 +342,7 @@ const packCommand = new Command('pack') if (res.code === 200 && opts?.update) { const id = res.data.id; if (opts?.update) { - console.log(chalk.blue('example: '), 'envision pack-deploy', id, ''); + console.log(chalk.blue('example: '), 'envision pack-deploy', id, '-k '); console.log('envision pack-deploy', id); } } @@ -353,10 +354,21 @@ const packCommand = new Command('pack') }); const packDeployCommand = new Command('pack-deploy') .argument('', 'id') - .argument('', 'fileKey, 服务器的部署文件夹的列表') + .option('-k, --key ', 'fileKey, 服务器的部署文件夹的列表') .option('-f --force', 'force') - .action(async (id, fileKey, opts) => { - const { force } = opts || {}; + .action(async (id, opts) => { + let { force, fileKey } = opts || {}; + if (!fileKey) { + const answers = await inquirer.prompt([ + { + type: 'input', + name: 'fileKey', + message: 'Enter your deploy to services fileKey:', + when: () => !fileKey, // 当 username 为空时,提示用户输入 + }, + ]); + fileKey = answers.fileKey || fileKey; + } const res = await deployLoadFn(id, fileKey, force); });