From 20e3072a44fae625436c54f94d24427db76c8422 Mon Sep 17 00:00:00 2001 From: "fengbo.lucky" Date: Mon, 29 Aug 2022 16:39:52 +0800 Subject: [PATCH] chore: publish --- .../src/commands/compress/utils.ts | 1 + .../src/commands/publish/index.ts | 90 +++++++++---------- 2 files changed, 44 insertions(+), 47 deletions(-) diff --git a/packages/mona-service/src/commands/compress/utils.ts b/packages/mona-service/src/commands/compress/utils.ts index 598183123..4b8063717 100644 --- a/packages/mona-service/src/commands/compress/utils.ts +++ b/packages/mona-service/src/commands/compress/utils.ts @@ -38,6 +38,7 @@ export async function compressDir(inputPath: string, ignoreList: string[] = []) return outputPath; } + export function compressDirToZip(inputPath: string, outputPath: string) { return new Promise((resolve, reject) => { const output = fs.createWriteStream(outputPath); diff --git a/packages/mona-service/src/commands/publish/index.ts b/packages/mona-service/src/commands/publish/index.ts index 639c1ffbc..b86a61150 100644 --- a/packages/mona-service/src/commands/publish/index.ts +++ b/packages/mona-service/src/commands/publish/index.ts @@ -40,38 +40,36 @@ const publish: IPlugin = ctx => { if (isLightApp) { // ask desc - const answer = await inquirer.prompt( - [ - { - type: 'input', - name: 'version', - message: '请输入版本号,例如1.0.0', - validate(input: string) { - if (!input) { - return '版本号不能为空'; - } else if (!/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(input)) { - return '无效的版本号,请输入三位的版本号,如1.0.0'; - } else { - return true; - } - }, + const answer = await inquirer.prompt([ + { + type: 'input', + name: 'version', + message: '请输入版本号,例如1.0.0', + validate(input: string) { + if (!input) { + return '版本号不能为空'; + } else if (!/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(input)) { + return '无效的版本号,请输入三位的版本号,如1.0.0'; + } else { + return true; + } }, - { - type: 'input', - name: 'desc', - message: '请输入版本描述', - validate(input: string) { - if (!input) { - return '版本描述不能为空'; - } else if (input.length > 200) { - return '版本描述长度应小于200'; - } else { - return true; - } - }, + }, + { + type: 'input', + name: 'desc', + message: '请输入版本描述', + validate(input: string) { + if (!input) { + return '版本描述不能为空'; + } else if (input.length > 200) { + return '版本描述长度应小于200'; + } else { + return true; + } }, - ], - ); + }, + ]); // upload const { fileId, fileName } = await upload(output, user.userId, args); @@ -88,24 +86,22 @@ const publish: IPlugin = ctx => { } else { const shouldEdit = latestVersionStatus && [2, 3, 5, 7].indexOf(latestVersionStatus) !== -1; // ask desc - const answer = await inquirer.prompt( - [ - { - type: 'input', - name: 'desc', - message: '请输入版本描述', - validate(input: string) { - if (!input) { - return '版本描述不能为空'; - } else if (input.length > 200) { - return '版本描述长度应小于200'; - } else { - return true; - } - }, + const answer = await inquirer.prompt([ + { + type: 'input', + name: 'desc', + message: '请输入版本描述', + validate(input: string) { + if (!input) { + return '版本描述不能为空'; + } else if (input.length > 200) { + return '版本描述长度应小于200'; + } else { + return true; + } }, - ], - ); + }, + ]); // upload const { fileId, fileName } = await upload(output, user.userId, args);