@@ -18279,7 +18279,7 @@ const testSet = (set, version, options) => {
18279
18279
18280
18280
const debug = __nccwpck_require__(1159)
18281
18281
const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(5101)
18282
- const { safeRe: re, t } = __nccwpck_require__(5471)
18282
+ const { safeRe: re, safeSrc: src, t } = __nccwpck_require__(5471)
18283
18283
18284
18284
const parseOptions = __nccwpck_require__(356)
18285
18285
const { compareIdentifiers } = __nccwpck_require__(3348)
@@ -18289,7 +18289,7 @@ class SemVer {
18289
18289
18290
18290
if (version instanceof SemVer) {
18291
18291
if (version.loose === !!options.loose &&
18292
- version.includePrerelease === !!options.includePrerelease) {
18292
+ version.includePrerelease === !!options.includePrerelease) {
18293
18293
return version
18294
18294
} else {
18295
18295
version = version.version
@@ -18455,6 +18455,20 @@ class SemVer {
18455
18455
// preminor will bump the version up to the next minor release, and immediately
18456
18456
// down to pre-release. premajor and prepatch work the same way.
18457
18457
inc (release, identifier, identifierBase) {
18458
+ if (release.startsWith('pre')) {
18459
+ if (!identifier && identifierBase === false) {
18460
+ throw new Error('invalid increment argument: identifier is empty')
18461
+ }
18462
+ // Avoid an invalid semver results
18463
+ if (identifier) {
18464
+ const r = new RegExp(`^${this.options.loose ? src[t.PRERELEASELOOSE] : src[t.PRERELEASE]}$`)
18465
+ const match = `-${identifier}`.match(r)
18466
+ if (!match || match[1] !== identifier) {
18467
+ throw new Error(`invalid identifier: ${identifier}`)
18468
+ }
18469
+ }
18470
+ }
18471
+
18458
18472
switch (release) {
18459
18473
case 'premajor':
18460
18474
this.prerelease.length = 0
@@ -18485,6 +18499,12 @@ class SemVer {
18485
18499
}
18486
18500
this.inc('pre', identifier, identifierBase)
18487
18501
break
18502
+ case 'release':
18503
+ if (this.prerelease.length === 0) {
18504
+ throw new Error(`version ${this.raw} is not a prerelease`)
18505
+ }
18506
+ this.prerelease.length = 0
18507
+ break
18488
18508
18489
18509
case 'major':
18490
18510
// If this is a pre-major version, bump up to the same major version.
@@ -18528,10 +18548,6 @@ class SemVer {
18528
18548
case 'pre': {
18529
18549
const base = Number(identifierBase) ? 1 : 0
18530
18550
18531
- if (!identifier && identifierBase === false) {
18532
- throw new Error('invalid increment argument: identifier is empty')
18533
- }
18534
-
18535
18551
if (this.prerelease.length === 0) {
18536
18552
this.prerelease = [base]
18537
18553
} else {
@@ -18790,20 +18806,13 @@ const diff = (version1, version2) => {
18790
18806
return 'major'
18791
18807
}
18792
18808
18793
- // Otherwise it can be determined by checking the high version
18794
-
18795
- if (highVersion.patch) {
18796
- // anything higher than a patch bump would result in the wrong version
18809
+ // If the main part has no difference
18810
+ if (lowVersion.compareMain(highVersion) === 0) {
18811
+ if (lowVersion.minor && !lowVersion.patch) {
18812
+ return 'minor'
18813
+ }
18797
18814
return 'patch'
18798
18815
}
18799
-
18800
- if (highVersion.minor) {
18801
- // anything higher than a minor bump would result in the wrong version
18802
- return 'minor'
18803
- }
18804
-
18805
- // bumping major/minor/patch all have same result
18806
- return 'major'
18807
18816
}
18808
18817
18809
18818
// add the `pre` prefix if we are going to a prerelease version
@@ -19310,6 +19319,7 @@ exports = module.exports = {}
19310
19319
const re = exports.re = []
19311
19320
const safeRe = exports.safeRe = []
19312
19321
const src = exports.src = []
19322
+ const safeSrc = exports.safeSrc = []
19313
19323
const t = exports.t = {}
19314
19324
let R = 0
19315
19325
@@ -19342,6 +19352,7 @@ const createToken = (name, value, isGlobal) => {
19342
19352
debug(name, index, value)
19343
19353
t[name] = index
19344
19354
src[index] = value
19355
+ safeSrc[index] = safe
19345
19356
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
19346
19357
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
19347
19358
}
0 commit comments