From a37f17539a340da4ac817381b631c1f87ad7bff1 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..df636d75 100644 --- a/lib/update_security_release.js +++ b/lib/update_security_release.js @@ -12,6 +12,7 @@ import fs from 'node:fs'; import auth from './auth.js'; import Request from './request.js'; import nv from '@pkgjs/nv'; +import semver from 'semver'; export default class UpdateSecurityRelease extends SecurityRelease { async sync() { @@ -268,17 +269,26 @@ 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 nextPatchVersion = semver.inc(version, 'patch'); + const nextMinorVersion = semver.inc(version, 'minor'); 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({