From 6c5c98456bee5e1eb706af9b15be3f4f6235144a Mon Sep 17 00:00:00 2001 From: Ryan Waskiewicz Date: Fri, 14 Apr 2023 10:16:35 -0400 Subject: [PATCH] chore(release): fix tagging behavior for prod (#4257) this commit fixes a regression introduced in https://github.com/ionic-team/stencil/pull/4235. the commit made the assumption that the npm tag will always be present: https://github.com/ionic-team/stencil/commit/d19538eb33b297c14419e94b73c322a9c790c67a#diff-a8c342d5def4847ce523d42113bc62856f35e802a444ec746839c39018f62017L180-R229. when in fact that is not the case. an npm tag is assumed to be the 'latest' when it is empty. with this commit, the precedence of npm tags is updated to prefer specified tags, a valid npm tag, then null (previously a valid npm tag, a specified tag, then 'UNKNOWN') was preferred). this allows for a specified tag to continue to take priority over a 'latest' tag, while reintroducing 'null' for the latest tag. --- scripts/release-prompts.ts | 8 ++++---- scripts/test/release-prompts.spec.ts | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/release-prompts.ts b/scripts/release-prompts.ts index a05433ae4b7..a866ef8906e 100644 --- a/scripts/release-prompts.ts +++ b/scripts/release-prompts.ts @@ -106,7 +106,7 @@ export async function promptRelease(opts: BuildOptions): Promise { const tagToUse = determineAnsweredTagToUse(answers); - const tagPart = ` and tag this release in npm as ${color.yellow(tagToUse)}`; + const tagPart = tagToUse ? ` and tag this release in npm as ${color.yellow(tagToUse)}` : ''; return `Will publish ${opts.vermoji} ${color.yellow(opts.version)}${tagPart}. Continue?`; }, }, @@ -144,8 +144,8 @@ export async function promptRelease(opts: BuildOptions): Promise { it.each<[ReleasePromptAnswers, string]>([ - [{ tag: '1.0.0', specifiedTag: '2.0.0', confirm: true, otp: '' }, '1.0.0'], + [{ tag: '1.0.0', specifiedTag: '2.0.0', confirm: true, otp: '' }, '2.0.0'], [{ tag: '1.0.0', confirm: true, otp: '' }, '1.0.0'], [{ specifiedTag: '2.0.0', confirm: true, otp: '' }, '2.0.0'], - [{ tag: '', specifiedTag: '', confirm: true, otp: '' }, 'UNKNOWN'], - [{ tag: '', confirm: true, otp: '' }, 'UNKNOWN'], - [{ specifiedTag: '', confirm: true, otp: '' }, 'UNKNOWN'], - [{ confirm: true, otp: '' }, 'UNKNOWN'], + [{ tag: undefined, specifiedTag: '2.0.0', confirm: true, otp: '' }, '2.0.0'], + [{ tag: null, specifiedTag: '2.0.0', confirm: true, otp: '' }, '2.0.0'], + [{ tag: '', specifiedTag: '', confirm: true, otp: '' }, null], + [{ tag: '', confirm: true, otp: '' }, null], + [{ specifiedTag: '', confirm: true, otp: '' }, null], + [{ confirm: true, otp: '' }, null], ])('%s returns "%s"', (answers, expected) => { expect(determineAnsweredTagToUse(answers)).toBe(expected); });