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({