From 319a7e9092a140b074c97d5f045d36c748663c46 Mon Sep 17 00:00:00 2001 From: a145789 <2091927351@qq.com> Date: Fri, 29 Mar 2024 10:40:26 +0800 Subject: [PATCH] feat: multiple version confirmation is supported --- src/release.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/release.ts b/src/release.ts index a3f4f58..3aa0e57 100644 --- a/src/release.ts +++ b/src/release.ts @@ -119,8 +119,8 @@ async function confirmVersion(currentVersion: string, expectVersion: string) { const ret = await prompt([ { name, - type: 'confirm', - message: `All packages version ${currentVersion} -> ${expectVersion}:`, + type: 'list', + choices: [`All packages version ${currentVersion} -> ${expectVersion}:`, 'back'], }, ]) @@ -189,13 +189,16 @@ export async function release(options: ReleaseCommandOptions) { return } - const type = await getReleaseType() - const isPreRelease = type.startsWith('pre') - let expectVersion = semver.inc(currentVersion, type, `alpha.${Date.now()}`) as string - expectVersion = isPreRelease ? expectVersion.slice(0, -2) : expectVersion + let confirmVersionRet = 'back' + let isPreRelease = false + let expectVersion = '' + while (confirmVersionRet === 'back') { + const type = await getReleaseType() + isPreRelease = type.startsWith('pre') + expectVersion = semver.inc(currentVersion, type, `alpha.${Date.now()}`) as string + expectVersion = isPreRelease ? expectVersion.slice(0, -2) : expectVersion - if (!(await confirmVersion(currentVersion, expectVersion))) { - return + confirmVersionRet = await confirmVersion(currentVersion, expectVersion) } updateVersion(expectVersion)