From 6f8382106d1acdf99fee02d8b5c8383f8406a789 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Thu, 11 Dec 2025 19:36:19 -0300 Subject: [PATCH] fix: improve suggestion next patch or next minor version --- lib/update_security_release.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/update_security_release.js b/lib/update_security_release.js index ffe56df6..efa56618 100644 --- a/lib/update_security_release.js +++ b/lib/update_security_release.js @@ -268,17 +268,27 @@ Summary: ${summary}\n`, async calculateVersions(affectedVersions, supportedVersions) { const h1AffectedVersions = []; const patchedVersions = []; + let isPatchRelease = true; for (const affectedVersion of affectedVersions) { - const major = affectedVersion.split('.')[0]; - const latest = supportedVersions.find((v) => v.major === Number(major)).version; + const affectedMajor = affectedVersion.split('.')[0]; + const latest = supportedVersions.find((v) => v.major === Number(affectedMajor)).version; const version = await this.cli.prompt( `What is the affected version (<=) for release line ${affectedVersion}?`, { questionType: 'input', defaultAnswer: latest }); - const nextPatchVersion = parseInt(version.split('.')[2]) + 1; + const [major, minor, patch] = version.split('.'); + const nextPatchVersion = `${major}.${minor}.${parseInt(patch) + 1}`; + const nextMinorVersion = `${major}.${parseInt(minor) + 1}.0`; const patchedVersion = await this.cli.prompt( `What is the patched version (>=) for release line ${affectedVersion}?`, - { questionType: 'input', defaultAnswer: nextPatchVersion }); + { + questionType: 'input', + defaultAnswer: isPatchRelease ? nextPatchVersion : nextMinorVersion + }); + + if (patchedVersion !== nextPatchVersion) { + isPatchRelease = false; // is a minor release + } patchedVersions.push(patchedVersion); h1AffectedVersions.push({