@vltpkg/semver 0.0.0-15 → 0.0.0-17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  validRange,
19
19
  increment,
20
20
  satisfies,
21
+ intersects,
21
22
  sort,
22
23
  compare,
23
24
  rsort,
@@ -90,6 +91,8 @@ Unless otherwise noted, they throw an error on invalid versions.
90
91
  valid
91
92
  - `satisfies(version, range)`: Return true if the version satisfies
92
93
  the range.
94
+ - `intersects(range1, range2)`: Return true if the two ranges
95
+ intersect (have any version that satisfies both ranges).
93
96
  - `highest(versions, range)`: Return the highest version in the list
94
97
  that satisfies the range, or `null` if none of them do.
95
98
  - `sortedHighest(versions, range)`: Optimized form of `highest`, if
@@ -125,8 +128,8 @@ Unless otherwise noted, they throw an error on invalid versions.
125
128
  ### Differences from `node-semver` (the one used by `npm`)
126
129
 
127
130
  - The API is slightly different. Most notably, `@vltpkg/semver` lacks
128
- range intersection and other methods that are not needed by `vlt`.
129
- Of course, these may be added eventually if we find a need for them.
131
+ some methods that are not needed by `vlt`. Of course, these may be
132
+ added eventually if we find a need for them.
130
133
 
131
134
  - Build metadata is preserved on `Version` objects and in `toString()`
132
135
  values.
@@ -142,7 +145,6 @@ Unless otherwise noted, they throw an error on invalid versions.
142
145
 
143
146
  - There's no switch for `loose` vs `strict` mode. It just always works
144
147
  the same way.
145
-
146
148
  - A leading `v` or `=` on a version is always allowed
147
149
  - Prereleases _must_ be prefixed by a `-`.
148
150
  - Excessively large numbers in prerelease identifiers are treated as
@@ -195,4 +195,10 @@ export declare const prerelease: (version: Version | string) => (string | number
195
195
  export declare const build: (version: Version | string) => string[] | undefined;
196
196
  /** return all versions that do not have any prerelease identifiers */
197
197
  export declare const stable: <T extends Version | string = string | Version>(versions: T[]) => T[];
198
+ /**
199
+ * Return true if the range r1 intersects any of the ranges r2
200
+ * r1 and r2 are either Range objects or range strings.
201
+ * Returns true if any version would satisfy both ranges.
202
+ */
203
+ export declare const intersects: (r1: Range | string, r2: Range | string, includePrerelease?: boolean) => boolean;
198
204
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGjD,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAE5B,kEAAkE;AAClE,eAAO,MAAM,KAAK,YAAa,OAAO,GAAG,MAAM,wBAO9C,CAAA;AAED,iEAAiE;AACjE,eAAO,MAAM,UAAU,UACd,KAAK,GAAG,MAAM,mDAYtB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,YAAa,OAAO,GAAG,MAAM,YAAqB,CAAA;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,UAAW,KAAK,GAAG,MAAM,YAC3B,CAAA;AAErB;;GAEG;AACH,eAAO,MAAM,SAAS,YACX,OAAO,GAAG,MAAM,SAClB,KAAK,GAAG,MAAM,yCActB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,GAAG,YACL,OAAO,GAAG,MAAM,QACnB,aAAa,yBACI,MAAM,YAKI,CAAA;AAEnC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,MAClB,OAAO,GAAG,MAAM,KAChB,OAAO,GAAG,MAAM,WAUpB,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,OAAO,GAAG,MAAM,2BACvC,CAAC,EAAE,KACR,CAAC,EAAmC,CAAA;AAEvC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,OAAO,GAAG,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AI,CAAC,SAAS,OAAO,GAAG,MAAM,+BACrC,CAAC,EAAE,KACZ,CAAC,EAKA,CAAA;AAEJ;;;;GAIG;AACH,eAAO,MAAM,UAAU,OACjB,KAAK,GAAG,MAAM,MACd,KAAK,GAAG,MAAM,sBACE,OAAO,YAgB5B,CAAA"}
package/dist/esm/index.js CHANGED
@@ -348,4 +348,111 @@ export const stable = (versions) => versions.filter(v => {
348
348
  return false;
349
349
  return !p.prerelease?.length;
350
350
  });
351
+ /**
352
+ * Return true if the range r1 intersects any of the ranges r2
353
+ * r1 and r2 are either Range objects or range strings.
354
+ * Returns true if any version would satisfy both ranges.
355
+ */
356
+ export const intersects = (r1, r2, includePrerelease) => {
357
+ const range1 = typeof r1 === 'string' ? parseRange(r1, includePrerelease) : r1;
358
+ const range2 = typeof r2 === 'string' ? parseRange(r2, includePrerelease) : r2;
359
+ if (!range1 || !range2)
360
+ return false;
361
+ // If either range is 'any', they intersect
362
+ if (range1.isAny || range2.isAny)
363
+ return true;
364
+ // Check if any set from range1 intersects with any set from range2
365
+ return range1.set.some(set1 => range2.set.some(set2 => intersectComparators(set1, set2)));
366
+ };
367
+ /**
368
+ * Check if two comparators can be satisfied simultaneously
369
+ */
370
+ const intersectComparators = (comp1, comp2) => {
371
+ // Collect all tuples from both comparators
372
+ const tuples1 = comp1.tuples.filter((t) => Array.isArray(t));
373
+ const tuples2 = comp2.tuples.filter((t) => Array.isArray(t));
374
+ // Check if there's a satisfiable combination
375
+ return satisfiableRange(tuples1.concat(tuples2));
376
+ };
377
+ /**
378
+ * Check if a set of operator-version tuples represents a satisfiable range
379
+ * This is a simplified implementation that handles the most common cases
380
+ */
381
+ const satisfiableRange = (tuples) => {
382
+ // Find bounds
383
+ let lowerBound = null;
384
+ let lowerInclusive = false;
385
+ let upperBound = null;
386
+ let upperInclusive = false;
387
+ let hasExact = null;
388
+ for (const [op, ver] of tuples) {
389
+ switch (op) {
390
+ case '':
391
+ // Exact match - if we already have a different exact match, no intersection
392
+ if (hasExact && !eq(hasExact, ver))
393
+ return false;
394
+ hasExact = ver;
395
+ break;
396
+ case '>=':
397
+ /* c8 ignore start */
398
+ if (!lowerBound ||
399
+ gt(ver, lowerBound) ||
400
+ (eq(ver, lowerBound) && !lowerInclusive)) {
401
+ lowerBound = ver;
402
+ lowerInclusive = true;
403
+ }
404
+ /* c8 ignore stop */
405
+ break;
406
+ case '>':
407
+ if (!lowerBound || gt(ver, lowerBound)) {
408
+ lowerBound = ver;
409
+ lowerInclusive = false;
410
+ }
411
+ break;
412
+ case '<=':
413
+ if (!upperBound || lt(ver, upperBound)) {
414
+ upperBound = ver;
415
+ upperInclusive = true;
416
+ }
417
+ break;
418
+ case '<':
419
+ /* c8 ignore start */
420
+ if (!upperBound ||
421
+ lt(ver, upperBound) ||
422
+ eq(ver, upperBound)) {
423
+ upperBound = ver;
424
+ upperInclusive = false;
425
+ }
426
+ /* c8 ignore stop */
427
+ break;
428
+ }
429
+ }
430
+ // If we have an exact match, check if it's within bounds
431
+ if (hasExact) {
432
+ if (lowerBound) {
433
+ if (lowerInclusive ?
434
+ lt(hasExact, lowerBound)
435
+ : lte(hasExact, lowerBound)) {
436
+ return false;
437
+ }
438
+ }
439
+ if (upperBound) {
440
+ if (upperInclusive ?
441
+ gt(hasExact, upperBound)
442
+ : gte(hasExact, upperBound)) {
443
+ return false;
444
+ }
445
+ }
446
+ return true;
447
+ }
448
+ // Check if lower bound is less than or equal to upper bound
449
+ if (lowerBound && upperBound) {
450
+ if (gt(lowerBound, upperBound))
451
+ return false;
452
+ if (eq(lowerBound, upperBound) &&
453
+ !(lowerInclusive && upperInclusive))
454
+ return false;
455
+ }
456
+ return true;
457
+ };
351
458
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,C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EAAE,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAA;AACvB,gEAAgE;AAChE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAA;AACvB;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAyB,EAAE,EAAE;IACtD,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAA;IACxB,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAA;IACxB,OAAO,CAAC,CAAC,UAAU,IAAI,EAAE,CAAA;AAC3B,CAAC,CAAA;AACD;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAyB,EAAE,EAAE;IACjD,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAA;IACxB,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAA;IACxB,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAA;AACtB,CAAC,CAAA;AAED,sEAAsE;AACtE,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,QAAa,EACR,EAAE,CACP,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;IAClB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IAClB,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IACpB,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,CAAA;AAC9B,CAAC,CAAC,CAAA","sourcesContent":["import { Range } from './range.ts'\nimport { Version } from './version.ts'\nimport type { IncrementType } from './version.ts'\nimport { syntaxError } from '@vltpkg/error-cause'\n\nexport * from './comparator.ts'\nexport * from './range.ts'\nexport * from './version.ts'\n\n/** Return the parsed version string, or `undefined` if invalid */\nexport const parse = (version: Version | string) => {\n if (version instanceof Version) return version\n try {\n return Version.parse(String(version))\n } catch {\n return undefined\n }\n}\n\n/** Return the parsed version range, or `undefined` if invalid */\nexport const parseRange = (\n range: Range | string,\n includePrerelease = false,\n) => {\n if (typeof range === 'object') {\n if (range.includePrerelease === includePrerelease) return range\n range = range.raw\n }\n try {\n return new Range(range, includePrerelease)\n } catch {\n return undefined\n }\n}\n\n/**\n * return true if the version is valid\n *\n * Note: do not use this if you intend to immediately parse the version if it's\n * valid. Just use {@link parse}, and guard the possible undefined value, or\n * use `Version.parse(..)` to throw on invalid values.\n */\nexport const valid = (version: Version | string) => !!parse(version)\n\n/**\n * return true if the range is valid\n *\n * Note: do not use this if you intend to immediately parse the range if it's\n * valid. Just use {@link parseRange}, and guard the possible undefined value,\n * or use `new Range(..)` to throw on invalid values.\n */\nexport const validRange = (range: Range | string) =>\n !!parseRange(range)\n\n/**\n * Return true if the version satisfies the range.\n */\nexport const satisfies = (\n version: Version | string,\n range: Range | string,\n includePrerelease = false,\n) => {\n if (typeof version === 'string') {\n const parsed = parse(version)\n if (!parsed) return false\n version = parsed\n }\n if (typeof range === 'string') {\n const parsed = parseRange(range, includePrerelease)\n if (!parsed) return false\n range = parsed\n }\n return version.satisfies(range)\n}\n\n/**\n * Increment the specified part of the version, and return the resulting\n * object. If a Version object is provided, it will be modified in-place.\n *\n * See {@link Version.inc} for full description.\n */\nexport const inc = (\n version: Version | string,\n part: IncrementType,\n prereleaseIdentifier?: string,\n) =>\n (typeof version === 'string' ?\n Version.parse(version)\n : version\n ).inc(part, prereleaseIdentifier)\n\n/**\n * The method used by {@link sort}, exported for passing directly to\n * `Array.sort`.\n *\n * Usage:\n *\n * ```ts\n * import { sortMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.sort(sortMethod))\n * // ['1.2.3', '2.3.4', '5.2.3']\n * ```\n */\nexport const sortMethod = (\n a: Version | string,\n b: Version | string,\n) => {\n const pa = parse(a)\n const pb = parse(b)\n /* c8 ignore start - nondeterministic */\n if (!pa && !pb) return String(a).localeCompare(String(b), 'en')\n if (!pa) return 1\n if (!pb) return -1\n /* c8 ignore stop */\n return pa.compare(pb)\n}\n\n/**\n * Sort an array of version strings or objects in ascending SemVer precedence\n * order (ie, lowest versions first).\n *\n * Invalid version strings are sorted to the end of the array in ascending\n * alphabetical order.\n *\n * Note: when using this method, the list is cloned prior to sorting, to\n * prevent surprising mutation. To sort the list in place, see\n * {@link sortMethod}.\n */\nexport const sort = <T extends Version | string = Version | string>(\n list: T[],\n): T[] => list.slice().sort(sortMethod)\n\n/**\n * Sort an array of version strings or objects in descending SemVer\n * precedence order (ie, highest versions first).\n *\n * Invalid version strings are sorted to the end of the array in ascending\n * alphabetical order.\n *\n * Note: when using this method, the list is cloned prior to sorting, to\n * prevent surprising mutation. To sort the list in place, see\n * {@link rsortMethod}.\n */\nexport const rsort = <T extends Version | string = Version | string>(\n list: T[],\n): T[] => list.slice().sort(rsortMethod)\n\n/**\n * The method used by {@link rsort}, exported for passing directly to\n * `Array.sort`.\n *\n * Usage:\n *\n * ```ts\n * import { rsortMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.sort(rsortMethod))\n * // ['5.2.3', '2.3.4', '1.2.3']\n * ```\n */\nexport const rsortMethod = (\n a: Version | string,\n b: Version | string,\n) => {\n const pa = parse(a)\n const pb = parse(b)\n /* c8 ignore start - nondeterministic */\n if (!pa && !pb) return String(a).localeCompare(String(b), 'en')\n if (!pa) return 1\n if (!pb) return -1\n /* c8 ignore stop */\n return pa.rcompare(pb)\n}\n\n/**\n * Method used by {@link filter}, for use in `Array.filter` directly.\n *\n * Usage:\n *\n * ```ts\n * import { filterMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.filter(filterMethod('>=2.x')))\n * // ['5.2.3', '2.3.4']\n * ```\n */\nexport const filterMethod = (\n range: Range | string,\n includePrerelease = false,\n): ((version: Version | string) => boolean) => {\n const r = parseRange(range, includePrerelease)\n return !r ?\n () => false\n : version => satisfies(version, r, r.includePrerelease)\n}\n\n/**\n * Filter a list of versions to find all that match a given range.\n */\nexport const filter = <T extends Version | string = Version | string>(\n list: T[],\n range: Range | string,\n includePrerelease = false,\n): T[] => list.filter(filterMethod(range, includePrerelease))\n\n/**\n * Find the highest-precedence match for a range within a list of versions\n *\n * Returns `undefined` if no match was found.\n */\nexport const highest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n let max: Version | undefined = undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n if (!max) max = version\n else if (version.greaterThan(max)) max = version\n }\n return max\n}\n\n/**\n * Faster form of {@link highest}, for use when the list is sorted\n * in precedence order (lower-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const sortedHighest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n for (let i = list.length - 1; i >= 0; i--) {\n const v = list[i]\n /* c8 ignore next */\n if (!v) continue\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n return version\n }\n}\n\n/**\n * Faster form of {@link highest}, for use when the list is sorted\n * in reverse precedence order (higher-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const rsortedHighest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n return version\n }\n}\n\n/**\n * Find the lowest-precedence match for a range within a list of versions\n *\n * Returns `undefined` if no match was found.\n */\nexport const lowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n let min: Version | undefined = undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n if (!min) min = version\n else if (version.lessThan(min)) min = version\n }\n return min\n}\n\n/**\n * Faster form of {@link lowest}, for use when the list is sorted\n * in precedence order (lower-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const sortedLowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined =>\n rsortedHighest(list, range, includePrerelease)\n\n/**\n * Faster form of {@link lowest}, for use when the list is sorted\n * in reverse precedence order (higher-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const rsortedLowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined =>\n sortedHighest(list, range, includePrerelease)\n\n/**\n * Same as {@link sortMethod}, but throws if either version is not valid.\n * 1 if versionA is higher precedence than versionB\n * -1 if versionA is lower precedence than versionB\n * 0 if they have equal precedence\n */\nexport const compare = (\n versionA: Version | string,\n versionB: Version | string,\n) => {\n const a = parse(versionA)\n if (!a) {\n throw syntaxError('invalid version', { found: versionA })\n }\n const b = parse(versionB)\n if (!b) {\n throw syntaxError('invalid version', { found: versionB })\n }\n return a.compare(b)\n}\n\n/**\n * Inverse of {@link compare}\n *\n * Same as {@link rsortMethod}, but throws if either version is not valid.\n *\n * -1 if versionA is higher precedence than versionB\n * 1 if versionA is lower precedence than versionB\n * 0 if they have equal precedence\n */\nexport const rcompare = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionB, versionA)\n\n/** true if versionA is > versionB. throws on invalid values */\nexport const gt = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) > 0\n/** true if versionA is >= versionB. throws on invalid values */\nexport const gte = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) >= 0\n/** true if versionA is < versionB. throws on invalid values */\nexport const lt = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) < 0\n/** true if versionA is &lt;= versionB. throws on invalid values */\nexport const lte = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) <= 0\n/** true if versionA is not equal to versionB. throws on invalid values */\nexport const neq = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) !== 0\n/** true if versionA is equal to versionB. throws on invalid values */\nexport const eq = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) === 0\n\n/** extract the major version number, or undefined if invalid */\nexport const major = (version: Version | string) =>\n parse(version)?.major\n/** extract the minor version number, or undefined if invalid */\nexport const minor = (version: Version | string) =>\n parse(version)?.minor\n/** extract the patch version number, or undefined if invalid */\nexport const patch = (version: Version | string) =>\n parse(version)?.patch\n/**\n * extract the list of prerelease identifiers, or undefined if the version\n * is invalid. If no prerelease identifiers are present, returns `[]`.\n */\nexport const prerelease = (version: Version | string) => {\n const p = parse(version)\n if (!p) return undefined\n return p.prerelease ?? []\n}\n/**\n * extract the list of build identifiers, or undefined if the version\n * is invalid. If no build identifiers are present, returns `[]`.\n */\nexport const build = (version: Version | string) => {\n const p = parse(version)\n if (!p) return undefined\n return p.build ?? []\n}\n\n/** return all versions that do not have any prerelease identifiers */\nexport const stable = <T extends Version | string = Version | string>(\n versions: T[],\n): T[] =>\n versions.filter(v => {\n const p = parse(v)\n if (!p) return false\n return !p.prerelease?.length\n })\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAE5B,kEAAkE;AAClE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAyB,EAAE,E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AAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YACf,IACE,cAAc,CAAC,CAAC;gBACd,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;gBAC1B,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,EAC3B,CAAC;gBACD,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,4DAA4D;IAC5D,IAAI,UAAU,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;YAAE,OAAO,KAAK,CAAA;QAC5C,IACE,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;YAC1B,CAAC,CAAC,cAAc,IAAI,cAAc,CAAC;YAEnC,OAAO,KAAK,CAAA;IAChB,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import { Range } from './range.ts'\nimport { Version } from './version.ts'\nimport type { Comparator, OVTuple } from './comparator.ts'\nimport type { IncrementType } from './version.ts'\nimport { syntaxError } from '@vltpkg/error-cause'\n\nexport * from './comparator.ts'\nexport * from './range.ts'\nexport * from './version.ts'\n\n/** Return the parsed version string, or `undefined` if invalid */\nexport const parse = (version: Version | string) => {\n if (version instanceof Version) return version\n try {\n return Version.parse(String(version))\n } catch {\n return undefined\n }\n}\n\n/** Return the parsed version range, or `undefined` if invalid */\nexport const parseRange = (\n range: Range | string,\n includePrerelease = false,\n) => {\n if (typeof range === 'object') {\n if (range.includePrerelease === includePrerelease) return range\n range = range.raw\n }\n try {\n return new Range(range, includePrerelease)\n } catch {\n return undefined\n }\n}\n\n/**\n * return true if the version is valid\n *\n * Note: do not use this if you intend to immediately parse the version if it's\n * valid. Just use {@link parse}, and guard the possible undefined value, or\n * use `Version.parse(..)` to throw on invalid values.\n */\nexport const valid = (version: Version | string) => !!parse(version)\n\n/**\n * return true if the range is valid\n *\n * Note: do not use this if you intend to immediately parse the range if it's\n * valid. Just use {@link parseRange}, and guard the possible undefined value,\n * or use `new Range(..)` to throw on invalid values.\n */\nexport const validRange = (range: Range | string) =>\n !!parseRange(range)\n\n/**\n * Return true if the version satisfies the range.\n */\nexport const satisfies = (\n version: Version | string,\n range: Range | string,\n includePrerelease = false,\n) => {\n if (typeof version === 'string') {\n const parsed = parse(version)\n if (!parsed) return false\n version = parsed\n }\n if (typeof range === 'string') {\n const parsed = parseRange(range, includePrerelease)\n if (!parsed) return false\n range = parsed\n }\n return version.satisfies(range)\n}\n\n/**\n * Increment the specified part of the version, and return the resulting\n * object. If a Version object is provided, it will be modified in-place.\n *\n * See {@link Version.inc} for full description.\n */\nexport const inc = (\n version: Version | string,\n part: IncrementType,\n prereleaseIdentifier?: string,\n) =>\n (typeof version === 'string' ?\n Version.parse(version)\n : version\n ).inc(part, prereleaseIdentifier)\n\n/**\n * The method used by {@link sort}, exported for passing directly to\n * `Array.sort`.\n *\n * Usage:\n *\n * ```ts\n * import { sortMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.sort(sortMethod))\n * // ['1.2.3', '2.3.4', '5.2.3']\n * ```\n */\nexport const sortMethod = (\n a: Version | string,\n b: Version | string,\n) => {\n const pa = parse(a)\n const pb = parse(b)\n /* c8 ignore start - nondeterministic */\n if (!pa && !pb) return String(a).localeCompare(String(b), 'en')\n if (!pa) return 1\n if (!pb) return -1\n /* c8 ignore stop */\n return pa.compare(pb)\n}\n\n/**\n * Sort an array of version strings or objects in ascending SemVer precedence\n * order (ie, lowest versions first).\n *\n * Invalid version strings are sorted to the end of the array in ascending\n * alphabetical order.\n *\n * Note: when using this method, the list is cloned prior to sorting, to\n * prevent surprising mutation. To sort the list in place, see\n * {@link sortMethod}.\n */\nexport const sort = <T extends Version | string = Version | string>(\n list: T[],\n): T[] => list.slice().sort(sortMethod)\n\n/**\n * Sort an array of version strings or objects in descending SemVer\n * precedence order (ie, highest versions first).\n *\n * Invalid version strings are sorted to the end of the array in ascending\n * alphabetical order.\n *\n * Note: when using this method, the list is cloned prior to sorting, to\n * prevent surprising mutation. To sort the list in place, see\n * {@link rsortMethod}.\n */\nexport const rsort = <T extends Version | string = Version | string>(\n list: T[],\n): T[] => list.slice().sort(rsortMethod)\n\n/**\n * The method used by {@link rsort}, exported for passing directly to\n * `Array.sort`.\n *\n * Usage:\n *\n * ```ts\n * import { rsortMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.sort(rsortMethod))\n * // ['5.2.3', '2.3.4', '1.2.3']\n * ```\n */\nexport const rsortMethod = (\n a: Version | string,\n b: Version | string,\n) => {\n const pa = parse(a)\n const pb = parse(b)\n /* c8 ignore start - nondeterministic */\n if (!pa && !pb) return String(a).localeCompare(String(b), 'en')\n if (!pa) return 1\n if (!pb) return -1\n /* c8 ignore stop */\n return pa.rcompare(pb)\n}\n\n/**\n * Method used by {@link filter}, for use in `Array.filter` directly.\n *\n * Usage:\n *\n * ```ts\n * import { filterMethod } from '@vltpkg/semver'\n * const versions = ['1.2.3', '5.2.3', '2.3.4']\n * console.log(versions.filter(filterMethod('>=2.x')))\n * // ['5.2.3', '2.3.4']\n * ```\n */\nexport const filterMethod = (\n range: Range | string,\n includePrerelease = false,\n): ((version: Version | string) => boolean) => {\n const r = parseRange(range, includePrerelease)\n return !r ?\n () => false\n : version => satisfies(version, r, r.includePrerelease)\n}\n\n/**\n * Filter a list of versions to find all that match a given range.\n */\nexport const filter = <T extends Version | string = Version | string>(\n list: T[],\n range: Range | string,\n includePrerelease = false,\n): T[] => list.filter(filterMethod(range, includePrerelease))\n\n/**\n * Find the highest-precedence match for a range within a list of versions\n *\n * Returns `undefined` if no match was found.\n */\nexport const highest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n let max: Version | undefined = undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n if (!max) max = version\n else if (version.greaterThan(max)) max = version\n }\n return max\n}\n\n/**\n * Faster form of {@link highest}, for use when the list is sorted\n * in precedence order (lower-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const sortedHighest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n for (let i = list.length - 1; i >= 0; i--) {\n const v = list[i]\n /* c8 ignore next */\n if (!v) continue\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n return version\n }\n}\n\n/**\n * Faster form of {@link highest}, for use when the list is sorted\n * in reverse precedence order (higher-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const rsortedHighest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n return version\n }\n}\n\n/**\n * Find the lowest-precedence match for a range within a list of versions\n *\n * Returns `undefined` if no match was found.\n */\nexport const lowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined => {\n const r = parseRange(range, includePrerelease)\n if (!r) return undefined\n let min: Version | undefined = undefined\n for (const v of list) {\n const version = parse(v)\n if (!version) continue\n if (!version.satisfies(r)) continue\n if (!min) min = version\n else if (version.lessThan(min)) min = version\n }\n return min\n}\n\n/**\n * Faster form of {@link lowest}, for use when the list is sorted\n * in precedence order (lower-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const sortedLowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined =>\n rsortedHighest(list, range, includePrerelease)\n\n/**\n * Faster form of {@link lowest}, for use when the list is sorted\n * in reverse precedence order (higher-precedence versions first).\n *\n * Note: This stops at the first match, and will produce incorrect results\n * when the list is not properly sorted!\n */\nexport const rsortedLowest = (\n list: (Version | string)[],\n range: Range | string,\n includePrerelease = false,\n): Version | undefined =>\n sortedHighest(list, range, includePrerelease)\n\n/**\n * Same as {@link sortMethod}, but throws if either version is not valid.\n * 1 if versionA is higher precedence than versionB\n * -1 if versionA is lower precedence than versionB\n * 0 if they have equal precedence\n */\nexport const compare = (\n versionA: Version | string,\n versionB: Version | string,\n) => {\n const a = parse(versionA)\n if (!a) {\n throw syntaxError('invalid version', { found: versionA })\n }\n const b = parse(versionB)\n if (!b) {\n throw syntaxError('invalid version', { found: versionB })\n }\n return a.compare(b)\n}\n\n/**\n * Inverse of {@link compare}\n *\n * Same as {@link rsortMethod}, but throws if either version is not valid.\n *\n * -1 if versionA is higher precedence than versionB\n * 1 if versionA is lower precedence than versionB\n * 0 if they have equal precedence\n */\nexport const rcompare = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionB, versionA)\n\n/** true if versionA is > versionB. throws on invalid values */\nexport const gt = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) > 0\n/** true if versionA is >= versionB. throws on invalid values */\nexport const gte = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) >= 0\n/** true if versionA is < versionB. throws on invalid values */\nexport const lt = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) < 0\n/** true if versionA is &lt;= versionB. throws on invalid values */\nexport const lte = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) <= 0\n/** true if versionA is not equal to versionB. throws on invalid values */\nexport const neq = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) !== 0\n/** true if versionA is equal to versionB. throws on invalid values */\nexport const eq = (\n versionA: Version | string,\n versionB: Version | string,\n) => compare(versionA, versionB) === 0\n\n/** extract the major version number, or undefined if invalid */\nexport const major = (version: Version | string) =>\n parse(version)?.major\n/** extract the minor version number, or undefined if invalid */\nexport const minor = (version: Version | string) =>\n parse(version)?.minor\n/** extract the patch version number, or undefined if invalid */\nexport const patch = (version: Version | string) =>\n parse(version)?.patch\n/**\n * extract the list of prerelease identifiers, or undefined if the version\n * is invalid. If no prerelease identifiers are present, returns `[]`.\n */\nexport const prerelease = (version: Version | string) => {\n const p = parse(version)\n if (!p) return undefined\n return p.prerelease ?? []\n}\n/**\n * extract the list of build identifiers, or undefined if the version\n * is invalid. If no build identifiers are present, returns `[]`.\n */\nexport const build = (version: Version | string) => {\n const p = parse(version)\n if (!p) return undefined\n return p.build ?? []\n}\n\n/** return all versions that do not have any prerelease identifiers */\nexport const stable = <T extends Version | string = Version | string>(\n versions: T[],\n): T[] =>\n versions.filter(v => {\n const p = parse(v)\n if (!p) return false\n return !p.prerelease?.length\n })\n\n/**\n * Return true if the range r1 intersects any of the ranges r2\n * r1 and r2 are either Range objects or range strings.\n * Returns true if any version would satisfy both ranges.\n */\nexport const intersects = (\n r1: Range | string,\n r2: Range | string,\n includePrerelease?: boolean,\n) => {\n const range1 =\n typeof r1 === 'string' ? parseRange(r1, includePrerelease) : r1\n const range2 =\n typeof r2 === 'string' ? parseRange(r2, includePrerelease) : r2\n\n if (!range1 || !range2) return false\n\n // If either range is 'any', they intersect\n if (range1.isAny || range2.isAny) return true\n\n // Check if any set from range1 intersects with any set from range2\n return range1.set.some(set1 =>\n range2.set.some(set2 => intersectComparators(set1, set2)),\n )\n}\n\n/**\n * Check if two comparators can be satisfied simultaneously\n */\nconst intersectComparators = (\n comp1: Comparator,\n comp2: Comparator,\n): boolean => {\n // Collect all tuples from both comparators\n const tuples1 = comp1.tuples.filter((t): t is OVTuple =>\n Array.isArray(t),\n )\n const tuples2 = comp2.tuples.filter((t): t is OVTuple =>\n Array.isArray(t),\n )\n\n // Check if there's a satisfiable combination\n return satisfiableRange(tuples1.concat(tuples2))\n}\n\n/**\n * Check if a set of operator-version tuples represents a satisfiable range\n * This is a simplified implementation that handles the most common cases\n */\nconst satisfiableRange = (tuples: OVTuple[]): boolean => {\n // Find bounds\n let lowerBound: Version | null = null\n let lowerInclusive = false\n let upperBound: Version | null = null\n let upperInclusive = false\n let hasExact: Version | null = null\n\n for (const [op, ver] of tuples) {\n switch (op) {\n case '':\n // Exact match - if we already have a different exact match, no intersection\n if (hasExact && !eq(hasExact, ver)) return false\n hasExact = ver\n break\n\n case '>=':\n /* c8 ignore start */\n if (\n !lowerBound ||\n gt(ver, lowerBound) ||\n (eq(ver, lowerBound) && !lowerInclusive)\n ) {\n lowerBound = ver\n lowerInclusive = true\n }\n /* c8 ignore stop */\n break\n\n case '>':\n if (!lowerBound || gt(ver, lowerBound)) {\n lowerBound = ver\n lowerInclusive = false\n }\n break\n\n case '<=':\n if (!upperBound || lt(ver, upperBound)) {\n upperBound = ver\n upperInclusive = true\n }\n break\n\n case '<':\n /* c8 ignore start */\n if (\n !upperBound ||\n lt(ver, upperBound) ||\n eq(ver, upperBound)\n ) {\n upperBound = ver\n upperInclusive = false\n }\n /* c8 ignore stop */\n break\n }\n }\n\n // If we have an exact match, check if it's within bounds\n if (hasExact) {\n if (lowerBound) {\n if (\n lowerInclusive ?\n lt(hasExact, lowerBound)\n : lte(hasExact, lowerBound)\n ) {\n return false\n }\n }\n if (upperBound) {\n if (\n upperInclusive ?\n gt(hasExact, upperBound)\n : gte(hasExact, upperBound)\n ) {\n return false\n }\n }\n return true\n }\n\n // Check if lower bound is less than or equal to upper bound\n if (lowerBound && upperBound) {\n if (gt(lowerBound, upperBound)) return false\n if (\n eq(lowerBound, upperBound) &&\n !(lowerInclusive && upperInclusive)\n )\n return false\n }\n\n return true\n}\n"]}
@@ -1,8 +1,12 @@
1
1
  import type { Range } from './range.ts';
2
+ /**
3
+ * Values of valid increment types.
4
+ */
5
+ export declare const versionIncrements: readonly ["major", "minor", "patch", "pre", "premajor", "preminor", "prepatch", "prerelease"];
2
6
  /**
3
7
  * Types of incrementing supported by {@link Version#inc}
4
8
  */
5
- export type IncrementType = 'major' | 'minor' | 'patch' | 'pre' | 'premajor' | 'preminor' | 'prepatch' | 'prerelease';
9
+ export type IncrementType = (typeof versionIncrements)[number];
6
10
  /**
7
11
  * A parsed object representation of a SemVer version string
8
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AA2CvC;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,OAAO,GACP,OAAO,GACP,KAAK,GACL,UAAU,GACV,UAAU,GACV,UAAU,GACV,YAAY,CAAA;AAEhB;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,iDAAiD;IACjD,GAAG,EAAE,MAAM,CAAA;IAEX,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IAChC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAEhB,4CAA4C;IAC5C,QAAQ;IAMR,uDAAuD;IACvD,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM;gBA2C1B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,MAAM,GAAG,SAAS;IA+B3B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAiC/B;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,OAAO;IAInB,6CAA6C;IAC7C,WAAW,CAAC,CAAC,EAAE,OAAO;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M,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,MAAM,GAAG,SAAS;IA+B3B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAiC/B;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,OAAO;IAInB,6CAA6C;IAC7C,WAAW,CAAC,CAAC,EAAE,OAAO;IAItB,8CAA8C;IAC9C,gBAAgB,CAAC,CAAC,EAAE,OAAO;IAI3B,6CAA6C;IAC7C,QAAQ,CAAC,CAAC,EAAE,OAAO;IAInB,iDAAiD;IACjD,aAAa,CAAC,CAAC,EAAE,OAAO;IAIxB,8DAA8D;IAC9D,MAAM,CAAC,CAAC,EAAE,OAAO;IAIjB,kDAAkD;IAClD,WAAW,CAAC,CAAC,EAAE,OAAO;IAQtB,+CAA+C;IAC/C,SAAS,CAAC,CAAC,EAAE,KAAK;IAIlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqDG;IACH,GAAG,CAAC,IAAI,EAAE,aAAa,EAAE,oBAAoB,CAAC,EAAE,MAAM;CAiHvD"}
@@ -24,6 +24,19 @@ const invalidVersion = (version, message) => {
24
24
  const er = syntaxError(`invalid version: ${message}`, { version }, Version);
25
25
  return er;
26
26
  };
27
+ /**
28
+ * Values of valid increment types.
29
+ */
30
+ export const versionIncrements = [
31
+ 'major',
32
+ 'minor',
33
+ 'patch',
34
+ 'pre',
35
+ 'premajor',
36
+ 'preminor',
37
+ 'prepatch',
38
+ 'prerelease',
39
+ ];
27
40
  /**
28
41
  * A parsed object representation of a SemVer version string
29
42
  *
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,q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AO;wBACP,OAAO;wBACP,OAAO;wBACP,UAAU;wBACV,UAAU;wBACV,UAAU;wBACV,YAAY;wBACZ,KAAK;qBACN;iBACF,EACD,IAAI,CAAC,GAAG,CACT,CAAA;QACL,CAAC;QAED,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { syntaxError, typeError } from '@vltpkg/error-cause'\nimport { fastSplit } from '@vltpkg/fast-split'\nimport type { Range } from './range.ts'\n\nconst maybeNumber = (s: string): number | string => {\n if (!/^[0-9]+$/.test(s)) return s\n const n = Number(s)\n return n <= Number.MAX_SAFE_INTEGER ? n : s\n}\n\nconst safeNumber = (\n s: string,\n version: string,\n field: string,\n): number => {\n const n = Number(s)\n if (n > Number.MAX_SAFE_INTEGER) {\n throw invalidVersion(\n version,\n `invalid ${field}, must be <= ${Number.MAX_SAFE_INTEGER}`,\n )\n }\n return n\n}\n\nconst re = {\n prefix: /^[ v=]+/,\n main: /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)/,\n prerelease: /-([0-9a-zA-Z_.-]+)(?:$|\\+)/,\n build: /\\+([0-9a-zA-Z_.-]+)$/,\n full: /^[ v=]*(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9a-zA-Z_.-]+))?(?:\\+([0-9a-zA-Z_.-]+))?$/,\n} as const\n\nconst invalidVersion = (\n version: string,\n message: string,\n): SyntaxError => {\n const er = syntaxError(\n `invalid version: ${message}`,\n { version },\n Version,\n )\n return er\n}\n\n/**\n * Types of incrementing supported by {@link Version#inc}\n */\nexport type IncrementType =\n | 'major'\n | 'minor'\n | 'patch'\n | 'pre'\n | 'premajor'\n | 'preminor'\n | 'prepatch'\n | 'prerelease'\n\n/**\n * A parsed object representation of a SemVer version string\n *\n * This is a bit less forgiving than node-semver, in that prerelease versions\n * MUST start with '-'. Otherwise, the allowed syntax is identical.\n */\nexport class Version {\n /** raw string provided to create this Version */\n raw: string\n\n /** major version number */\n major: number\n /** minor version number */\n minor: number\n /** patch version number */\n patch: number\n /**\n * List of `'.'`-separated strings and numbers indicating that this\n * version is a prerelease.\n *\n * This is undefined if the version does not have a prerelease section.\n */\n prerelease?: (number | string)[]\n /**\n * List of `'.'`-separated strings in the `build` section.\n *\n * This is undefined if the version does not have a build.\n */\n build?: string[]\n\n /** Canonical strict form of this version */\n toString() {\n return `${this.major}.${this.minor}.${this.patch}${\n this.prerelease ? '-' + this.prerelease.join('.') : ''\n }${this.build ? '+' + this.build.join('.') : ''}`\n }\n\n /** Generate a `Version` object from a SemVer string */\n static parse(version: string) {\n version = version.replace(re.prefix, '').trim()\n if (version.length > 256) {\n throw invalidVersion(\n version,\n 'must be less than 256 characters',\n )\n }\n\n const parsed = re.full.exec(version)\n if (!parsed) {\n const main = re.main.exec(version)\n if (!main) {\n throw invalidVersion(\n version,\n 'no Major.minor.patch tuple present',\n )\n } else {\n throw invalidVersion(\n version,\n 'invalid build or patch section',\n )\n }\n }\n const [_, major_, minor_, patch_, prerelease, build] = parsed\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const major = safeNumber(major_!, version, 'major')\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const minor = safeNumber(minor_!, version, 'minor')\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const patch = safeNumber(patch_!, version, 'patch')\n\n return new Version(\n version,\n major,\n minor,\n patch,\n prerelease,\n build,\n )\n }\n\n constructor(\n version: string,\n major: number,\n minor: number,\n patch: number,\n prerelease: string | undefined,\n build: string | undefined,\n ) {\n this.raw = version\n this.major = major\n this.minor = minor\n this.patch = patch\n\n // has prerelease and/or build\n if (prerelease) {\n this.prerelease = fastSplit(prerelease, '.', -1, c => {\n if (!c) {\n throw invalidVersion(\n version,\n 'invalid prerelease, empty identifiers not allowed',\n )\n }\n return maybeNumber(c)\n })\n }\n if (build) {\n this.build = fastSplit(build, '.', -1, c => {\n if (!c) {\n throw invalidVersion(\n version,\n 'invalid build metadata, empty identifiers not allowed',\n )\n }\n })\n }\n }\n\n /**\n * Return 1 if this is > the provided version, -1 if we're less, or 0 if\n * they are equal.\n *\n * No special handling for prerelease versions, this is just a precedence\n * comparison.\n *\n * This can be used to sort a list of versions by precedence:\n *\n * ```ts\n * const versions: Version[] = getVersionsSomehow()\n * const sorted = versions.sort((a, b) => a.compare(b))\n * ```\n */\n compare(v: Version): -1 | 0 | 1 {\n if (this.major > v.major) return 1\n if (this.major < v.major) return -1\n if (this.minor > v.minor) return 1\n if (this.minor < v.minor) return -1\n if (this.patch > v.patch) return 1\n if (this.patch < v.patch) return -1\n // main tuple is equal now\n // if the version has no pr, we're definitely less than or equal to\n if (!v.prerelease?.length)\n return !this.prerelease?.length ? 0 : -1\n // v has a pr. if we don't, we're > it\n if (!this.prerelease?.length) return 1\n // we both have prereleases\n const len = Math.max(this.prerelease.length, v.prerelease.length)\n const me = this.prerelease\n const thee = v.prerelease\n for (let i = 0; i < len; i++) {\n const m = me[i]\n const t = thee[i]\n if (m === t) continue\n // having a field is > not having it\n if (t === undefined) return 1\n if (m === undefined) return -1\n // string parts are higher precedence than\n if (typeof m !== typeof t) {\n return typeof m === 'string' ? 1 : -1\n }\n return m > t ? 1 : -1\n }\n return 0\n }\n\n /**\n * The inverse of compare, for sorting version lists in reverse order\n */\n rcompare(v: Version) {\n return -1 * this.compare(v)\n }\n\n /** true if this version is > the argument */\n greaterThan(v: Version) {\n return this.compare(v) === 1\n }\n\n /** true if this version is >= the argument */\n greaterThanEqual(v: Version) {\n return this.compare(v) > -1\n }\n\n /** true if this version is < the argument */\n lessThan(v: Version) {\n return this.compare(v) === -1\n }\n\n /** true if this version is &lt;= the argument */\n lessThanEqual(v: Version) {\n return this.compare(v) < 1\n }\n\n /** true if these two versions have equal SemVer precedence */\n equals(v: Version) {\n return this.compare(v) === 0\n }\n\n /** just compare the M.m.p parts of the version */\n tupleEquals(v: Version) {\n return (\n this.major === v.major &&\n this.minor === v.minor &&\n this.patch === v.patch\n )\n }\n\n /** true if this version satisfies the range */\n satisfies(r: Range) {\n return r.test(this)\n }\n\n /**\n * Increment the version in place, in the manner specified.\n *\n * Part behaviors:\n *\n * - `'major'` If the version is a `M.0.0-...` version with a prerelease, then\n * simply drop the prerelease. Otherwise, set the minor and patch to 0, and\n * increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes\n * `2.0.0`\n *\n * - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then\n * simply drop the prerelease. Otherwise, set the patch to 0, and increment the\n * minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.\n *\n * - `'patch'` If the version has a prerelease, then simply drop the\n * prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes\n * `1.2.3` and `1.2.3` becomes `1.2.4`.\n *\n * - `'premajor'` Set the patch and minor versions to `0`, increment the major\n * version, and add a prerelease, using the optional identifier.\n *\n * - `'preminor'` Set the patch version to `0`, increment the minor version,\n * and add a prerelease, using the optional identifier.\n *\n * - `'prepatch'` If a prerelease is already present, increment the patch\n * version, otherwise leave it untouched, and add a prerelease, using the\n * optional identifier.\n *\n * - `'prerelease'` If a prerelease version is present, then behave the same as\n * `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.\n *\n * - `'pre'` This is mostly for use by the other prerelease incrementers.\n *\n * - If a prerelease identifier is provided:\n *\n * Update that named portion of the prerelease. For example,\n * `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.\n *\n * If there is no prerelease identifier by that name, then replace the\n * prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`\n * would result in `1.2.3-beta`.\n *\n * If the prerelease identifer is present, but has no numeric value\n * following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`\n * would result in `1.2.3-beta.0`.\n *\n * - If no prerelease identifier is provided:\n *\n * If there is no current prerelease, then set the prerelease to `0`. So,\n * `inc('1.2.3', 'pre')` becomes `1.2.3-0`.\n *\n * If the last item in the prerelease is numeric, then increment it. So,\n * `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.\n */\n inc(part: IncrementType, prereleaseIdentifier?: string) {\n switch (part) {\n case 'premajor':\n this.prerelease = undefined\n this.patch = 0\n this.minor = 0\n this.major++\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'preminor':\n this.prerelease = undefined\n this.patch = 0\n this.minor++\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'prepatch':\n this.prerelease = undefined\n this.inc('patch')\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'prerelease':\n if (!this.prerelease?.length)\n this.inc('patch', prereleaseIdentifier)\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'pre': {\n // this is a bit different than node-semver's logic, but simpler\n // always do zero-based incrementing, and either bump the existing\n // numeric pr value, or add a `.0` after the identifier.\n if (!prereleaseIdentifier) {\n if (!this.prerelease?.length) {\n this.prerelease = [0]\n break\n }\n const last = this.prerelease[this.prerelease.length - 1]\n if (typeof last === 'number') {\n this.prerelease[this.prerelease.length - 1] = last + 1\n } else {\n this.prerelease.push(0)\n }\n break\n }\n if (!this.prerelease?.length) {\n this.prerelease = [prereleaseIdentifier]\n break\n }\n const i = this.prerelease.indexOf(\n maybeNumber(prereleaseIdentifier),\n )\n if (i === -1) {\n this.prerelease = [prereleaseIdentifier]\n break\n }\n const baseValue = this.prerelease[i + 1]\n if (typeof baseValue === 'number') {\n this.prerelease[i + 1] = baseValue + 1\n break\n }\n if (i === this.prerelease.length - 1) {\n this.prerelease.push(0)\n break\n }\n this.prerelease.splice(i + 1, 0, 0)\n break\n }\n\n case 'major':\n if (!this.prerelease?.length || this.minor || this.patch)\n this.major++\n this.prerelease = undefined\n this.patch = 0\n this.minor = 0\n break\n\n case 'minor':\n if (!this.prerelease?.length || this.patch) this.minor++\n this.prerelease = undefined\n this.patch = 0\n break\n\n case 'patch':\n if (!this.prerelease?.length) this.patch++\n this.prerelease = undefined\n break\n\n default:\n throw typeError(\n 'Invalid increment identifier',\n {\n version: this,\n found: part,\n validOptions: [\n 'major',\n 'minor',\n 'patch',\n 'premajor',\n 'preminor',\n 'prepatch',\n 'prerelease',\n 'pre',\n ],\n },\n this.inc,\n )\n }\n\n this.raw = this.toString()\n return this\n }\n}\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,MAAM,WAAW,GAAG,CAAC,CAAS,EAAmB,EAAE;IACjD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAA;IACjC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IACnB,OAAO,CAAC,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC7C,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CACjB,CAAS,EACT,OAAe,EACf,KAAa,EACL,EAAE;IACV,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IACnB,IAAI,CAAC,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAChC,MAAM,cAAc,CAClB,OAAO,EACP,WAAW,KAAK,gBAAgB,MAAM,CAAC,gBAAgB,EAAE,CAC1D,CAAA;IACH,CAAC;IACD,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAED,MAAM,EAAE,GAAG;IACT,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,2CAA2C;IACjD,UAAU,EAAE,4BAA4B;IACxC,KAAK,EAAE,sBAAsB;IAC7B,IAAI,EAAE,iGAAiG;CAC/F,CAAA;AAEV,MAAM,cAAc,GAAG,CACrB,OAAe,EACf,OA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AAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,IAAI,IAAI,CAAC,KAAK;oBAAE,IAAI,CAAC,KAAK,EAAE,CAAA;gBACxD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;gBAC3B,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;gBACd,MAAK;YAEP,KAAK,OAAO;gBACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM;oBAAE,IAAI,CAAC,KAAK,EAAE,CAAA;gBAC1C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;gBAC3B,MAAK;YAEP;gBACE,MAAM,SAAS,CACb,8BAA8B,EAC9B;oBACE,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,IAAI;oBACX,YAAY,EAAE;wBACZ,OAAO;wBACP,OAAO;wBACP,OAAO;wBACP,UAAU;wBACV,UAAU;wBACV,UAAU;wBACV,YAAY;wBACZ,KAAK;qBACN;iBACF,EACD,IAAI,CAAC,GAAG,CACT,CAAA;QACL,CAAC;QAED,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { syntaxError, typeError } from '@vltpkg/error-cause'\nimport { fastSplit } from '@vltpkg/fast-split'\nimport type { Range } from './range.ts'\n\nconst maybeNumber = (s: string): number | string => {\n if (!/^[0-9]+$/.test(s)) return s\n const n = Number(s)\n return n <= Number.MAX_SAFE_INTEGER ? n : s\n}\n\nconst safeNumber = (\n s: string,\n version: string,\n field: string,\n): number => {\n const n = Number(s)\n if (n > Number.MAX_SAFE_INTEGER) {\n throw invalidVersion(\n version,\n `invalid ${field}, must be <= ${Number.MAX_SAFE_INTEGER}`,\n )\n }\n return n\n}\n\nconst re = {\n prefix: /^[ v=]+/,\n main: /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)/,\n prerelease: /-([0-9a-zA-Z_.-]+)(?:$|\\+)/,\n build: /\\+([0-9a-zA-Z_.-]+)$/,\n full: /^[ v=]*(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9a-zA-Z_.-]+))?(?:\\+([0-9a-zA-Z_.-]+))?$/,\n} as const\n\nconst invalidVersion = (\n version: string,\n message: string,\n): SyntaxError => {\n const er = syntaxError(\n `invalid version: ${message}`,\n { version },\n Version,\n )\n return er\n}\n\n/**\n * Values of valid increment types.\n */\nexport const versionIncrements = [\n 'major',\n 'minor',\n 'patch',\n 'pre',\n 'premajor',\n 'preminor',\n 'prepatch',\n 'prerelease',\n] as const\n\n/**\n * Types of incrementing supported by {@link Version#inc}\n */\nexport type IncrementType = (typeof versionIncrements)[number]\n\n/**\n * A parsed object representation of a SemVer version string\n *\n * This is a bit less forgiving than node-semver, in that prerelease versions\n * MUST start with '-'. Otherwise, the allowed syntax is identical.\n */\nexport class Version {\n /** raw string provided to create this Version */\n raw: string\n\n /** major version number */\n major: number\n /** minor version number */\n minor: number\n /** patch version number */\n patch: number\n /**\n * List of `'.'`-separated strings and numbers indicating that this\n * version is a prerelease.\n *\n * This is undefined if the version does not have a prerelease section.\n */\n prerelease?: (number | string)[]\n /**\n * List of `'.'`-separated strings in the `build` section.\n *\n * This is undefined if the version does not have a build.\n */\n build?: string[]\n\n /** Canonical strict form of this version */\n toString() {\n return `${this.major}.${this.minor}.${this.patch}${\n this.prerelease ? '-' + this.prerelease.join('.') : ''\n }${this.build ? '+' + this.build.join('.') : ''}`\n }\n\n /** Generate a `Version` object from a SemVer string */\n static parse(version: string) {\n version = version.replace(re.prefix, '').trim()\n if (version.length > 256) {\n throw invalidVersion(\n version,\n 'must be less than 256 characters',\n )\n }\n\n const parsed = re.full.exec(version)\n if (!parsed) {\n const main = re.main.exec(version)\n if (!main) {\n throw invalidVersion(\n version,\n 'no Major.minor.patch tuple present',\n )\n } else {\n throw invalidVersion(\n version,\n 'invalid build or patch section',\n )\n }\n }\n const [_, major_, minor_, patch_, prerelease, build] = parsed\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const major = safeNumber(major_!, version, 'major')\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const minor = safeNumber(minor_!, version, 'minor')\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const patch = safeNumber(patch_!, version, 'patch')\n\n return new Version(\n version,\n major,\n minor,\n patch,\n prerelease,\n build,\n )\n }\n\n constructor(\n version: string,\n major: number,\n minor: number,\n patch: number,\n prerelease: string | undefined,\n build: string | undefined,\n ) {\n this.raw = version\n this.major = major\n this.minor = minor\n this.patch = patch\n\n // has prerelease and/or build\n if (prerelease) {\n this.prerelease = fastSplit(prerelease, '.', -1, c => {\n if (!c) {\n throw invalidVersion(\n version,\n 'invalid prerelease, empty identifiers not allowed',\n )\n }\n return maybeNumber(c)\n })\n }\n if (build) {\n this.build = fastSplit(build, '.', -1, c => {\n if (!c) {\n throw invalidVersion(\n version,\n 'invalid build metadata, empty identifiers not allowed',\n )\n }\n })\n }\n }\n\n /**\n * Return 1 if this is > the provided version, -1 if we're less, or 0 if\n * they are equal.\n *\n * No special handling for prerelease versions, this is just a precedence\n * comparison.\n *\n * This can be used to sort a list of versions by precedence:\n *\n * ```ts\n * const versions: Version[] = getVersionsSomehow()\n * const sorted = versions.sort((a, b) => a.compare(b))\n * ```\n */\n compare(v: Version): -1 | 0 | 1 {\n if (this.major > v.major) return 1\n if (this.major < v.major) return -1\n if (this.minor > v.minor) return 1\n if (this.minor < v.minor) return -1\n if (this.patch > v.patch) return 1\n if (this.patch < v.patch) return -1\n // main tuple is equal now\n // if the version has no pr, we're definitely less than or equal to\n if (!v.prerelease?.length)\n return !this.prerelease?.length ? 0 : -1\n // v has a pr. if we don't, we're > it\n if (!this.prerelease?.length) return 1\n // we both have prereleases\n const len = Math.max(this.prerelease.length, v.prerelease.length)\n const me = this.prerelease\n const thee = v.prerelease\n for (let i = 0; i < len; i++) {\n const m = me[i]\n const t = thee[i]\n if (m === t) continue\n // having a field is > not having it\n if (t === undefined) return 1\n if (m === undefined) return -1\n // string parts are higher precedence than\n if (typeof m !== typeof t) {\n return typeof m === 'string' ? 1 : -1\n }\n return m > t ? 1 : -1\n }\n return 0\n }\n\n /**\n * The inverse of compare, for sorting version lists in reverse order\n */\n rcompare(v: Version) {\n return -1 * this.compare(v)\n }\n\n /** true if this version is > the argument */\n greaterThan(v: Version) {\n return this.compare(v) === 1\n }\n\n /** true if this version is >= the argument */\n greaterThanEqual(v: Version) {\n return this.compare(v) > -1\n }\n\n /** true if this version is < the argument */\n lessThan(v: Version) {\n return this.compare(v) === -1\n }\n\n /** true if this version is &lt;= the argument */\n lessThanEqual(v: Version) {\n return this.compare(v) < 1\n }\n\n /** true if these two versions have equal SemVer precedence */\n equals(v: Version) {\n return this.compare(v) === 0\n }\n\n /** just compare the M.m.p parts of the version */\n tupleEquals(v: Version) {\n return (\n this.major === v.major &&\n this.minor === v.minor &&\n this.patch === v.patch\n )\n }\n\n /** true if this version satisfies the range */\n satisfies(r: Range) {\n return r.test(this)\n }\n\n /**\n * Increment the version in place, in the manner specified.\n *\n * Part behaviors:\n *\n * - `'major'` If the version is a `M.0.0-...` version with a prerelease, then\n * simply drop the prerelease. Otherwise, set the minor and patch to 0, and\n * increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes\n * `2.0.0`\n *\n * - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then\n * simply drop the prerelease. Otherwise, set the patch to 0, and increment the\n * minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.\n *\n * - `'patch'` If the version has a prerelease, then simply drop the\n * prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes\n * `1.2.3` and `1.2.3` becomes `1.2.4`.\n *\n * - `'premajor'` Set the patch and minor versions to `0`, increment the major\n * version, and add a prerelease, using the optional identifier.\n *\n * - `'preminor'` Set the patch version to `0`, increment the minor version,\n * and add a prerelease, using the optional identifier.\n *\n * - `'prepatch'` If a prerelease is already present, increment the patch\n * version, otherwise leave it untouched, and add a prerelease, using the\n * optional identifier.\n *\n * - `'prerelease'` If a prerelease version is present, then behave the same as\n * `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.\n *\n * - `'pre'` This is mostly for use by the other prerelease incrementers.\n *\n * - If a prerelease identifier is provided:\n *\n * Update that named portion of the prerelease. For example,\n * `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.\n *\n * If there is no prerelease identifier by that name, then replace the\n * prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`\n * would result in `1.2.3-beta`.\n *\n * If the prerelease identifer is present, but has no numeric value\n * following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`\n * would result in `1.2.3-beta.0`.\n *\n * - If no prerelease identifier is provided:\n *\n * If there is no current prerelease, then set the prerelease to `0`. So,\n * `inc('1.2.3', 'pre')` becomes `1.2.3-0`.\n *\n * If the last item in the prerelease is numeric, then increment it. So,\n * `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.\n */\n inc(part: IncrementType, prereleaseIdentifier?: string) {\n switch (part) {\n case 'premajor':\n this.prerelease = undefined\n this.patch = 0\n this.minor = 0\n this.major++\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'preminor':\n this.prerelease = undefined\n this.patch = 0\n this.minor++\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'prepatch':\n this.prerelease = undefined\n this.inc('patch')\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'prerelease':\n if (!this.prerelease?.length)\n this.inc('patch', prereleaseIdentifier)\n this.inc('pre', prereleaseIdentifier)\n break\n\n case 'pre': {\n // this is a bit different than node-semver's logic, but simpler\n // always do zero-based incrementing, and either bump the existing\n // numeric pr value, or add a `.0` after the identifier.\n if (!prereleaseIdentifier) {\n if (!this.prerelease?.length) {\n this.prerelease = [0]\n break\n }\n const last = this.prerelease[this.prerelease.length - 1]\n if (typeof last === 'number') {\n this.prerelease[this.prerelease.length - 1] = last + 1\n } else {\n this.prerelease.push(0)\n }\n break\n }\n if (!this.prerelease?.length) {\n this.prerelease = [prereleaseIdentifier]\n break\n }\n const i = this.prerelease.indexOf(\n maybeNumber(prereleaseIdentifier),\n )\n if (i === -1) {\n this.prerelease = [prereleaseIdentifier]\n break\n }\n const baseValue = this.prerelease[i + 1]\n if (typeof baseValue === 'number') {\n this.prerelease[i + 1] = baseValue + 1\n break\n }\n if (i === this.prerelease.length - 1) {\n this.prerelease.push(0)\n break\n }\n this.prerelease.splice(i + 1, 0, 0)\n break\n }\n\n case 'major':\n if (!this.prerelease?.length || this.minor || this.patch)\n this.major++\n this.prerelease = undefined\n this.patch = 0\n this.minor = 0\n break\n\n case 'minor':\n if (!this.prerelease?.length || this.patch) this.minor++\n this.prerelease = undefined\n this.patch = 0\n break\n\n case 'patch':\n if (!this.prerelease?.length) this.patch++\n this.prerelease = undefined\n break\n\n default:\n throw typeError(\n 'Invalid increment identifier',\n {\n version: this,\n found: part,\n validOptions: [\n 'major',\n 'minor',\n 'patch',\n 'premajor',\n 'preminor',\n 'prepatch',\n 'prerelease',\n 'pre',\n ],\n },\n this.inc,\n )\n }\n\n this.raw = this.toString()\n return this\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/semver",
3
3
  "description": "The semantic version parser used by vlt",
4
- "version": "0.0.0-15",
4
+ "version": "0.0.0-17",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -19,9 +19,9 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@vltpkg/error-cause": "0.0.0-15",
23
- "@vltpkg/fast-split": "0.0.0-15",
24
- "@vltpkg/types": "0.0.0-15"
22
+ "@vltpkg/error-cause": "0.0.0-17",
23
+ "@vltpkg/fast-split": "0.0.0-17",
24
+ "@vltpkg/types": "0.0.0-17"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@eslint/js": "^9.28.0",
@@ -29,7 +29,7 @@
29
29
  "@types/node": "^22.15.29",
30
30
  "@types/semver": "^7.7.0",
31
31
  "eslint": "^9.28.0",
32
- "prettier": "^3.5.3",
32
+ "prettier": "^3.6.0",
33
33
  "semver": "^7.7.2",
34
34
  "tap": "^21.1.0",
35
35
  "tshy": "^3.0.2",