@@ -4454,7 +4454,7 @@ const testSet = (set, version, options) => {
4454
4454
4455
4455
const debug = __nccwpck_require__(1159)
4456
4456
const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(5101)
4457
- const { safeRe: re, t } = __nccwpck_require__(5471)
4457
+ const { safeRe: re, safeSrc: src, t } = __nccwpck_require__(5471)
4458
4458
4459
4459
const parseOptions = __nccwpck_require__(356)
4460
4460
const { compareIdentifiers } = __nccwpck_require__(3348)
@@ -4464,7 +4464,7 @@ class SemVer {
4464
4464
4465
4465
if (version instanceof SemVer) {
4466
4466
if (version.loose === !!options.loose &&
4467
- version.includePrerelease === !!options.includePrerelease) {
4467
+ version.includePrerelease === !!options.includePrerelease) {
4468
4468
return version
4469
4469
} else {
4470
4470
version = version.version
@@ -4630,6 +4630,20 @@ class SemVer {
4630
4630
// preminor will bump the version up to the next minor release, and immediately
4631
4631
// down to pre-release. premajor and prepatch work the same way.
4632
4632
inc (release, identifier, identifierBase) {
4633
+ if (release.startsWith('pre')) {
4634
+ if (!identifier && identifierBase === false) {
4635
+ throw new Error('invalid increment argument: identifier is empty')
4636
+ }
4637
+ // Avoid an invalid semver results
4638
+ if (identifier) {
4639
+ const r = new RegExp(`^${this.options.loose ? src[t.PRERELEASELOOSE] : src[t.PRERELEASE]}$`)
4640
+ const match = `-${identifier}`.match(r)
4641
+ if (!match || match[1] !== identifier) {
4642
+ throw new Error(`invalid identifier: ${identifier}`)
4643
+ }
4644
+ }
4645
+ }
4646
+
4633
4647
switch (release) {
4634
4648
case 'premajor':
4635
4649
this.prerelease.length = 0
@@ -4660,6 +4674,12 @@ class SemVer {
4660
4674
}
4661
4675
this.inc('pre', identifier, identifierBase)
4662
4676
break
4677
+ case 'release':
4678
+ if (this.prerelease.length === 0) {
4679
+ throw new Error(`version ${this.raw} is not a prerelease`)
4680
+ }
4681
+ this.prerelease.length = 0
4682
+ break
4663
4683
4664
4684
case 'major':
4665
4685
// If this is a pre-major version, bump up to the same major version.
@@ -4703,10 +4723,6 @@ class SemVer {
4703
4723
case 'pre': {
4704
4724
const base = Number(identifierBase) ? 1 : 0
4705
4725
4706
- if (!identifier && identifierBase === false) {
4707
- throw new Error('invalid increment argument: identifier is empty')
4708
- }
4709
-
4710
4726
if (this.prerelease.length === 0) {
4711
4727
this.prerelease = [base]
4712
4728
} else {
@@ -4965,20 +4981,13 @@ const diff = (version1, version2) => {
4965
4981
return 'major'
4966
4982
}
4967
4983
4968
- // Otherwise it can be determined by checking the high version
4969
-
4970
- if (highVersion.patch) {
4971
- // anything higher than a patch bump would result in the wrong version
4984
+ // If the main part has no difference
4985
+ if (lowVersion.compareMain(highVersion) === 0) {
4986
+ if (lowVersion.minor && !lowVersion.patch) {
4987
+ return 'minor'
4988
+ }
4972
4989
return 'patch'
4973
4990
}
4974
-
4975
- if (highVersion.minor) {
4976
- // anything higher than a minor bump would result in the wrong version
4977
- return 'minor'
4978
- }
4979
-
4980
- // bumping major/minor/patch all have same result
4981
- return 'major'
4982
4991
}
4983
4992
4984
4993
// add the `pre` prefix if we are going to a prerelease version
@@ -5485,6 +5494,7 @@ exports = module.exports = {}
5485
5494
const re = exports.re = []
5486
5495
const safeRe = exports.safeRe = []
5487
5496
const src = exports.src = []
5497
+ const safeSrc = exports.safeSrc = []
5488
5498
const t = exports.t = {}
5489
5499
let R = 0
5490
5500
@@ -5517,6 +5527,7 @@ const createToken = (name, value, isGlobal) => {
5517
5527
debug(name, index, value)
5518
5528
t[name] = index
5519
5529
src[index] = value
5530
+ safeSrc[index] = safe
5520
5531
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
5521
5532
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
5522
5533
}
0 commit comments