Skip to content

Commit 6f83821

Browse files
committed
fix: improve suggestion next patch or next minor version
1 parent 7342aff commit 6f83821

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

lib/update_security_release.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,17 +268,27 @@ Summary: ${summary}\n`,
268268
async calculateVersions(affectedVersions, supportedVersions) {
269269
const h1AffectedVersions = [];
270270
const patchedVersions = [];
271+
let isPatchRelease = true;
271272
for (const affectedVersion of affectedVersions) {
272-
const major = affectedVersion.split('.')[0];
273-
const latest = supportedVersions.find((v) => v.major === Number(major)).version;
273+
const affectedMajor = affectedVersion.split('.')[0];
274+
const latest = supportedVersions.find((v) => v.major === Number(affectedMajor)).version;
274275
const version = await this.cli.prompt(
275276
`What is the affected version (<=) for release line ${affectedVersion}?`,
276277
{ questionType: 'input', defaultAnswer: latest });
277278

278-
const nextPatchVersion = parseInt(version.split('.')[2]) + 1;
279+
const [major, minor, patch] = version.split('.');
280+
const nextPatchVersion = `${major}.${minor}.${parseInt(patch) + 1}`;
281+
const nextMinorVersion = `${major}.${parseInt(minor) + 1}.0`;
279282
const patchedVersion = await this.cli.prompt(
280283
`What is the patched version (>=) for release line ${affectedVersion}?`,
281-
{ questionType: 'input', defaultAnswer: nextPatchVersion });
284+
{
285+
questionType: 'input',
286+
defaultAnswer: isPatchRelease ? nextPatchVersion : nextMinorVersion
287+
});
288+
289+
if (patchedVersion !== nextPatchVersion) {
290+
isPatchRelease = false; // is a minor release
291+
}
282292

283293
patchedVersions.push(patchedVersion);
284294
h1AffectedVersions.push({

0 commit comments

Comments
 (0)