Compare commits

..
18 Commits
Author SHA1 Message Date
Chromatic 1bbb581925 v16.10.1 2026-05-15 16:18:27 +00:00
Chromatic e3eb8ec361 v16.10.0 2026-05-11 17:28:17 +00:00
Chromatic 8d925269a4 v16.9.1 2026-05-07 14:53:46 +00:00
Chromatic 84e0c70520 v16.9.0 2026-05-06 17:23:55 +00:00
Chromatic a200f3ba3f v16.8.0 2026-05-05 14:56:27 +00:00
Chromatic fd9f084892 v16.7.0 2026-05-04 17:05:35 +00:00
Chromatic 42839e8c28 v16.6.3 2026-04-29 19:50:53 +00:00
Chromatic ca45e22652 v16.6.2 2026-04-29 19:10:30 +00:00
Chromatic 7d51ab74df v16.6.1 2026-04-28 17:33:25 +00:00
Chromatic cad40970f6 v16.6.0 2026-04-23 13:02:40 +00:00
Chromatic 67fce75c41 v16.5.0 2026-04-21 19:35:43 +00:00
Chromatic 4a6485da4e v16.4.0 2026-04-21 15:42:56 +00:00
Chromatic 5c6ec06f45 v16.3.0 2026-04-14 17:22:46 +00:00
Chromatic 688adae582 v16.2.0 2026-04-09 17:05:52 +00:00
Chromatic 8a2b82547a v16.1.0 2026-04-02 15:43:53 +00:00
Chromatic f191a0224b v16.0.0 2026-03-23 16:26:00 +00:00
Chromatic eea1606238 v15.3.1 2026-03-23 15:24:49 +00:00
Chromatic 0794e6939f v15.3.0 2026-03-16 16:15:56 +00:00
60 changed files with 7036 additions and 719 deletions
+271
View File
@@ -1,3 +1,274 @@
# v16.10.1 (Fri May 15 2026)
#### 🐛 Bug Fix
- Fix `getUncommittedHash` in Windows environments [#1332](https://github.com/chromaui/chromatic-cli/pull/1332) ([@codykaup](https://github.com/codykaup))
- Increase flaky test timeout [#1326](https://github.com/chromaui/chromatic-cli/pull/1326) ([@codykaup](https://github.com/codykaup))
- Refactor `initialize` task to use typed inputs and outputs [#1323](https://github.com/chromaui/chromatic-cli/pull/1323) ([@justin-thurman](https://github.com/justin-thurman))
#### Authors: 2
- Cody Kaup ([@codykaup](https://github.com/codykaup))
- Justin Thurman ([@justin-thurman](https://github.com/justin-thurman))
---
# v16.10.0 (Mon May 11 2026)
#### 🚀 Enhancement
- Add `share()` to Node API [#1284](https://github.com/chromaui/chromatic-cli/pull/1284) ([@codykaup](https://github.com/codykaup) [@katiebayes](https://github.com/katiebayes))
#### 🐛 Bug Fix
- Migrate `gitInfo` task to typed inputs and outputs [#1314](https://github.com/chromaui/chromatic-cli/pull/1314) ([@justin-thurman](https://github.com/justin-thurman))
- Add config option for building multiple Android architectures [#1321](https://github.com/chromaui/chromatic-cli/pull/1321) ([@jmhobbs](https://github.com/jmhobbs))
#### Authors: 4
- Cody Kaup ([@codykaup](https://github.com/codykaup))
- John Hobbs ([@jmhobbs](https://github.com/jmhobbs))
- Justin Thurman ([@justin-thurman](https://github.com/justin-thurman))
- Katie Bayes ([@katiebayes](https://github.com/katiebayes))
---
# v16.9.1 (Thu May 07 2026)
#### 🐛 Bug Fix
- Add additional environment variables to RN build [#1319](https://github.com/chromaui/chromatic-cli/pull/1319) ([@jmhobbs](https://github.com/jmhobbs))
#### Authors: 1
- John Hobbs ([@jmhobbs](https://github.com/jmhobbs))
---
# v16.9.0 (Wed May 06 2026)
#### 🚀 Enhancement
- Allow skip without a project token [#1310](https://github.com/chromaui/chromatic-cli/pull/1310) ([@codykaup](https://github.com/codykaup))
#### Authors: 1
- Cody Kaup ([@codykaup](https://github.com/codykaup))
---
# v16.8.0 (Tue May 05 2026)
#### 🚀 Enhancement
- Add test for external storybook config changes and TS [#1316](https://github.com/chromaui/chromatic-cli/pull/1316) ([@tmeasday](https://github.com/tmeasday))
#### 🐛 Bug Fix
- Move `xcodebuild` to shared executor [#1318](https://github.com/chromaui/chromatic-cli/pull/1318) ([@jmhobbs](https://github.com/jmhobbs))
- Only build Android ABI for x86_64 [#1308](https://github.com/chromaui/chromatic-cli/pull/1308) ([@jmhobbs](https://github.com/jmhobbs))
- Add output environment variable to RN builds [#1307](https://github.com/chromaui/chromatic-cli/pull/1307) ([@jmhobbs](https://github.com/jmhobbs))
#### Authors: 2
- John Hobbs ([@jmhobbs](https://github.com/jmhobbs))
- Tom Coleman ([@tmeasday](https://github.com/tmeasday))
---
# v16.7.0 (Mon May 04 2026)
#### 🚀 Enhancement
- Add React Native build stage [#1297](https://github.com/chromaui/chromatic-cli/pull/1297) ([@jmhobbs](https://github.com/jmhobbs))
- Make Storybook metadata output generic [#1311](https://github.com/chromaui/chromatic-cli/pull/1311) ([@codykaup](https://github.com/codykaup))
#### 🐛 Bug Fix
- Migrate `setStorybookInfo` task to typed inputs and outputs [#1306](https://github.com/chromaui/chromatic-cli/pull/1306) ([@justin-thurman](https://github.com/justin-thurman))
- Scaffolding for removing `Context` from CLI task bodies [#1302](https://github.com/chromaui/chromatic-cli/pull/1302) ([@justin-thurman](https://github.com/justin-thurman))
#### Authors: 3
- Cody Kaup ([@codykaup](https://github.com/codykaup))
- John Hobbs ([@jmhobbs](https://github.com/jmhobbs))
- Justin Thurman ([@justin-thurman](https://github.com/justin-thurman))
---
# v16.6.3 (Wed Apr 29 2026)
#### 🐛 Bug Fix
- Retry file upload if file deduplication fails [#1296](https://github.com/chromaui/chromatic-cli/pull/1296) ([@codykaup](https://github.com/codykaup))
#### Authors: 1
- Cody Kaup ([@codykaup](https://github.com/codykaup))
---
# v16.6.2 (Wed Apr 29 2026)
#### 🐛 Bug Fix
- Fix crash when checking for CLI updates [#1305](https://github.com/chromaui/chromatic-cli/pull/1305) ([@annaet](https://github.com/annaet) [@codykaup](https://github.com/codykaup))
#### Authors: 2
- Anna Thomas ([@annaet](https://github.com/annaet))
- Cody Kaup ([@codykaup](https://github.com/codykaup))
---
# v16.6.1 (Tue Apr 28 2026)
#### 🐛 Bug Fix
- On React Native builds check for ABI compatibility before upload [#1295](https://github.com/chromaui/chromatic-cli/pull/1295) ([@jmhobbs](https://github.com/jmhobbs))
#### Authors: 1
- John Hobbs ([@jmhobbs](https://github.com/jmhobbs))
---
# v16.6.0 (Thu Apr 23 2026)
#### 🚀 Enhancement
- Send analytics for Storybook build failures [#1287](https://github.com/chromaui/chromatic-cli/pull/1287) ([@justin-thurman](https://github.com/justin-thurman))
#### Authors: 1
- Justin Thurman ([@justin-thurman](https://github.com/justin-thurman))
---
# v16.5.0 (Tue Apr 21 2026)
#### 🚀 Enhancement
- [WFL-208] Extract `refs` field from Storybook and pass when announcing build [#1283](https://github.com/chromaui/chromatic-cli/pull/1283) ([@ax-vasquez](https://github.com/ax-vasquez))
- Validate `@storybook/react-native` version [#1288](https://github.com/chromaui/chromatic-cli/pull/1288) ([@codykaup](https://github.com/codykaup))
#### 🐛 Bug Fix
- Add a React Native section to the config file [#1289](https://github.com/chromaui/chromatic-cli/pull/1289) ([@jmhobbs](https://github.com/jmhobbs))
#### Authors: 3
- Armando Vasquez ([@ax-vasquez](https://github.com/ax-vasquez))
- Cody Kaup ([@codykaup](https://github.com/codykaup))
- John Hobbs ([@jmhobbs](https://github.com/jmhobbs))
---
# v16.4.0 (Tue Apr 21 2026)
#### 🚀 Enhancement
- Upgrade to Storybook 10 [#1268](https://github.com/chromaui/chromatic-cli/pull/1268) ([@jmhobbs](https://github.com/jmhobbs))
- React Native build command [#1274](https://github.com/chromaui/chromatic-cli/pull/1274) ([@jmhobbs](https://github.com/jmhobbs))
#### 🐛 Bug Fix
- Upgrade to `tsdown` [#1282](https://github.com/chromaui/chromatic-cli/pull/1282) ([@jmhobbs](https://github.com/jmhobbs))
#### Authors: 1
- John Hobbs ([@jmhobbs](https://github.com/jmhobbs))
---
# v16.3.0 (Tue Apr 14 2026)
#### 🚀 Enhancement
- feat: add `--vitest` flag for `@chromatic-com/vitest` integration [#1252](https://github.com/chromaui/chromatic-cli/pull/1252) ([@AriPerkkio](https://github.com/AriPerkkio))
- Show more information on invalid React Native builds [#1271](https://github.com/chromaui/chromatic-cli/pull/1271) ([@codykaup](https://github.com/codykaup))
#### Authors: 2
- Ari Perkkiö ([@AriPerkkio](https://github.com/AriPerkkio))
- Cody Kaup ([@codykaup](https://github.com/codykaup))
---
# v16.2.0 (Thu Apr 09 2026)
#### 🚀 Enhancement
- Improve merge queue support [#1256](https://github.com/chromaui/chromatic-cli/pull/1256) ([@codykaup](https://github.com/codykaup))
#### 🐛 Bug Fix
- test: improve chromatic-e2e related tests [#1273](https://github.com/chromaui/chromatic-cli/pull/1273) ([@AriPerkkio](https://github.com/AriPerkkio))
- test: update Vitest to v4 [#1266](https://github.com/chromaui/chromatic-cli/pull/1266) ([@AriPerkkio](https://github.com/AriPerkkio))
- Throw error on React Native projects using TurboSnap [#1267](https://github.com/chromaui/chromatic-cli/pull/1267) ([@codykaup](https://github.com/codykaup))
#### Authors: 2
- Ari Perkkiö ([@AriPerkkio](https://github.com/AriPerkkio))
- Cody Kaup ([@codykaup](https://github.com/codykaup))
---
# v16.1.0 (Thu Apr 02 2026)
#### 🚀 Enhancement
- Best effort alternative to tree-kill that swallows errors [#1261](https://github.com/chromaui/chromatic-cli/pull/1261) ([@jmhobbs](https://github.com/jmhobbs) [@justin-thurman](https://github.com/justin-thurman))
#### 🐛 Bug Fix
- Merge pull request #1265 from chromaui/CAP-4242-unit-tests [#1265](https://github.com/chromaui/chromatic-cli/pull/1265) ([@justin-thurman](https://github.com/justin-thurman))
- Create workflow for action-canary release [#1255](https://github.com/chromaui/chromatic-cli/pull/1255) ([@jmhobbs](https://github.com/jmhobbs))
- Upgrade `eslint` version [#1253](https://github.com/chromaui/chromatic-cli/pull/1253) ([@jmhobbs](https://github.com/jmhobbs))
#### Authors: 2
- John Hobbs ([@jmhobbs](https://github.com/jmhobbs))
- Justin Thurman ([@justin-thurman](https://github.com/justin-thurman))
---
# v16.0.0 (Mon Mar 23 2026)
#### 💥 Breaking Change
- Drop support for Node 18 and update GitHub Action to Node 24 [#1251](https://github.com/chromaui/chromatic-cli/pull/1251) ([@codykaup](https://github.com/codykaup))
#### Authors: 1
- Cody Kaup ([@codykaup](https://github.com/codykaup))
---
# v15.3.1 (Mon Mar 23 2026)
#### 🐛 Bug Fix
- Properly timeout process tree in shell commands [#1254](https://github.com/chromaui/chromatic-cli/pull/1254) ([@codykaup](https://github.com/codykaup))
#### Authors: 1
- Cody Kaup ([@codykaup](https://github.com/codykaup))
---
# v15.3.0 (Mon Mar 16 2026)
#### 🚀 Enhancement
- Integrate manifest generation script [#1244](https://github.com/chromaui/chromatic-cli/pull/1244) ([@codykaup](https://github.com/codykaup))
#### Authors: 1
- Cody Kaup ([@codykaup](https://github.com/codykaup))
---
# v15.2.0 (Mon Feb 23 2026)
#### 🚀 Enhancement
+5 -2
View File
@@ -116,6 +116,9 @@ inputs:
uploadMetadata:
description: 'Upload Chromatic metadata files as part of the published Storybook'
required: false
vitest:
description: 'Run build against `@chromatic-com/vitest` test archives'
required: false
workingDir:
description: 'Working directory for the package.json file'
required: false
@@ -153,5 +156,5 @@ outputs:
description: 'The number of inherited (not captured) snapshots (e.g. due to TurboSnap)'
runs:
main: action/register.js
using: node20 # Sync with `target` in tsup.config.ts
main: action/register.cjs
using: node24
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2669
View File
File diff suppressed because one or more lines are too long
+677 -680
View File
File diff suppressed because one or more lines are too long
+15
View File
@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+665
View File
File diff suppressed because it is too large Load Diff
Generated Vendored Executable
+191
View File
@@ -0,0 +1,191 @@
#!/usr/bin/env node
// Standalone semver comparison program.
// Exits successfully and prints matching version(s) if
// any supplied version is valid and passes all tests.
'use strict'
const argv = process.argv.slice(2)
let versions = []
const range = []
let inc = null
const version = require('../package.json').version
let loose = false
let includePrerelease = false
let coerce = false
let rtl = false
let identifier
let identifierBase
const semver = require('../')
const parseOptions = require('../internal/parse-options')
let reverse = false
let options = {}
const main = () => {
if (!argv.length) {
return help()
}
while (argv.length) {
let a = argv.shift()
const indexOfEqualSign = a.indexOf('=')
if (indexOfEqualSign !== -1) {
const value = a.slice(indexOfEqualSign + 1)
a = a.slice(0, indexOfEqualSign)
argv.unshift(value)
}
switch (a) {
case '-rv': case '-rev': case '--rev': case '--reverse':
reverse = true
break
case '-l': case '--loose':
loose = true
break
case '-p': case '--include-prerelease':
includePrerelease = true
break
case '-v': case '--version':
versions.push(argv.shift())
break
case '-i': case '--inc': case '--increment':
switch (argv[0]) {
case 'major': case 'minor': case 'patch': case 'prerelease':
case 'premajor': case 'preminor': case 'prepatch':
case 'release':
inc = argv.shift()
break
default:
inc = 'patch'
break
}
break
case '--preid':
identifier = argv.shift()
break
case '-r': case '--range':
range.push(argv.shift())
break
case '-n':
identifierBase = argv.shift()
if (identifierBase === 'false') {
identifierBase = false
}
break
case '-c': case '--coerce':
coerce = true
break
case '--rtl':
rtl = true
break
case '--ltr':
rtl = false
break
case '-h': case '--help': case '-?':
return help()
default:
versions.push(a)
break
}
}
options = parseOptions({ loose, includePrerelease, rtl })
versions = versions.map((v) => {
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
}).filter((v) => {
return semver.valid(v, options)
})
if (!versions.length) {
return fail()
}
if (inc && (versions.length !== 1 || range.length)) {
return failInc()
}
for (let i = 0, l = range.length; i < l; i++) {
versions = versions.filter((v) => {
return semver.satisfies(v, range[i], options)
})
if (!versions.length) {
return fail()
}
}
versions
.sort((a, b) => semver[reverse ? 'rcompare' : 'compare'](a, b, options))
.map(v => semver.clean(v, options))
.map(v => inc ? semver.inc(v, inc, options, identifier, identifierBase) : v)
.forEach(v => console.log(v))
}
const failInc = () => {
console.error('--inc can only be used on a single version with no range')
fail()
}
const fail = () => process.exit(1)
const help = () => console.log(
`SemVer ${version}
A JavaScript implementation of the https://semver.org/ specification
Copyright Isaac Z. Schlueter
Usage: semver [options] <version> [<version> [...]]
Prints valid versions sorted by SemVer precedence
Options:
-r --range <range>
Print versions that match the specified range.
-i --increment [<level>]
Increment a version by the specified level. Level can
be one of: major, minor, patch, premajor, preminor,
prepatch, prerelease, or release. Default level is 'patch'.
Only one version may be specified.
--preid <identifier>
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.
-l --loose
Interpret versions and ranges loosely
-p --include-prerelease
Always include prerelease versions in range matching
-c --coerce
Coerce a string into SemVer if possible
(does not imply --loose)
--rtl
Coerce version strings right to left
--ltr
Coerce version strings left to right (default)
-n <base>
Base number to be used for the prerelease identifier.
Can be either 0 or 1, or false to omit the number altogether.
Defaults to 0.
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
If no satisfying versions are found, then exits failure.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.`)
main()
+143
View File
@@ -0,0 +1,143 @@
'use strict'
const ANY = Symbol('SemVer ANY')
// hoisted class for cyclic dependency
class Comparator {
static get ANY () {
return ANY
}
constructor (comp, options) {
options = parseOptions(options)
if (comp instanceof Comparator) {
if (comp.loose === !!options.loose) {
return comp
} else {
comp = comp.value
}
}
comp = comp.trim().split(/\s+/).join(' ')
debug('comparator', comp, options)
this.options = options
this.loose = !!options.loose
this.parse(comp)
if (this.semver === ANY) {
this.value = ''
} else {
this.value = this.operator + this.semver.version
}
debug('comp', this)
}
parse (comp) {
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
const m = comp.match(r)
if (!m) {
throw new TypeError(`Invalid comparator: ${comp}`)
}
this.operator = m[1] !== undefined ? m[1] : ''
if (this.operator === '=') {
this.operator = ''
}
// if it literally is just '>' or '' then allow anything.
if (!m[2]) {
this.semver = ANY
} else {
this.semver = new SemVer(m[2], this.options.loose)
}
}
toString () {
return this.value
}
test (version) {
debug('Comparator.test', version, this.options.loose)
if (this.semver === ANY || version === ANY) {
return true
}
if (typeof version === 'string') {
try {
version = new SemVer(version, this.options)
} catch (er) {
return false
}
}
return cmp(version, this.operator, this.semver, this.options)
}
intersects (comp, options) {
if (!(comp instanceof Comparator)) {
throw new TypeError('a Comparator is required')
}
if (this.operator === '') {
if (this.value === '') {
return true
}
return new Range(comp.value, options).test(this.value)
} else if (comp.operator === '') {
if (comp.value === '') {
return true
}
return new Range(this.value, options).test(comp.semver)
}
options = parseOptions(options)
// Special cases where nothing can possibly be lower
if (options.includePrerelease &&
(this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
return false
}
if (!options.includePrerelease &&
(this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
return false
}
// Same direction increasing (> or >=)
if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
return true
}
// Same direction decreasing (< or <=)
if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
return true
}
// same SemVer and both sides are inclusive (<= or >=)
if (
(this.semver.version === comp.semver.version) &&
this.operator.includes('=') && comp.operator.includes('=')) {
return true
}
// opposite directions less than
if (cmp(this.semver, '<', comp.semver, options) &&
this.operator.startsWith('>') && comp.operator.startsWith('<')) {
return true
}
// opposite directions greater than
if (cmp(this.semver, '>', comp.semver, options) &&
this.operator.startsWith('<') && comp.operator.startsWith('>')) {
return true
}
return false
}
}
module.exports = Comparator
const parseOptions = require('../internal/parse-options')
const { safeRe: re, t } = require('../internal/re')
const cmp = require('../functions/cmp')
const debug = require('../internal/debug')
const SemVer = require('./semver')
const Range = require('./range')
+7
View File
@@ -0,0 +1,7 @@
'use strict'
module.exports = {
SemVer: require('./semver.js'),
Range: require('./range.js'),
Comparator: require('./comparator.js'),
}
+557
View File
File diff suppressed because it is too large Load Diff
+333
View File
@@ -0,0 +1,333 @@
'use strict'
const debug = require('../internal/debug')
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
const { safeRe: re, t } = require('../internal/re')
const parseOptions = require('../internal/parse-options')
const { compareIdentifiers } = require('../internal/identifiers')
class SemVer {
constructor (version, options) {
options = parseOptions(options)
if (version instanceof SemVer) {
if (version.loose === !!options.loose &&
version.includePrerelease === !!options.includePrerelease) {
return version
} else {
version = version.version
}
} else if (typeof version !== 'string') {
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
}
if (version.length > MAX_LENGTH) {
throw new TypeError(
`version is longer than ${MAX_LENGTH} characters`
)
}
debug('SemVer', version, options)
this.options = options
this.loose = !!options.loose
// this isn't actually relevant for versions, but keep it so that we
// don't run into trouble passing this.options around.
this.includePrerelease = !!options.includePrerelease
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
if (!m) {
throw new TypeError(`Invalid Version: ${version}`)
}
this.raw = version
// these are actually numbers
this.major = +m[1]
this.minor = +m[2]
this.patch = +m[3]
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
throw new TypeError('Invalid major version')
}
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
throw new TypeError('Invalid minor version')
}
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
throw new TypeError('Invalid patch version')
}
// numberify any prerelease numeric ids
if (!m[4]) {
this.prerelease = []
} else {
this.prerelease = m[4].split('.').map((id) => {
if (/^[0-9]+$/.test(id)) {
const num = +id
if (num >= 0 && num < MAX_SAFE_INTEGER) {
return num
}
}
return id
})
}
this.build = m[5] ? m[5].split('.') : []
this.format()
}
format () {
this.version = `${this.major}.${this.minor}.${this.patch}`
if (this.prerelease.length) {
this.version += `-${this.prerelease.join('.')}`
}
return this.version
}
toString () {
return this.version
}
compare (other) {
debug('SemVer.compare', this.version, this.options, other)
if (!(other instanceof SemVer)) {
if (typeof other === 'string' && other === this.version) {
return 0
}
other = new SemVer(other, this.options)
}
if (other.version === this.version) {
return 0
}
return this.compareMain(other) || this.comparePre(other)
}
compareMain (other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options)
}
if (this.major < other.major) {
return -1
}
if (this.major > other.major) {
return 1
}
if (this.minor < other.minor) {
return -1
}
if (this.minor > other.minor) {
return 1
}
if (this.patch < other.patch) {
return -1
}
if (this.patch > other.patch) {
return 1
}
return 0
}
comparePre (other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options)
}
// NOT having a prerelease is > having one
if (this.prerelease.length && !other.prerelease.length) {
return -1
} else if (!this.prerelease.length && other.prerelease.length) {
return 1
} else if (!this.prerelease.length && !other.prerelease.length) {
return 0
}
let i = 0
do {
const a = this.prerelease[i]
const b = other.prerelease[i]
debug('prerelease compare', i, a, b)
if (a === undefined && b === undefined) {
return 0
} else if (b === undefined) {
return 1
} else if (a === undefined) {
return -1
} else if (a === b) {
continue
} else {
return compareIdentifiers(a, b)
}
} while (++i)
}
compareBuild (other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options)
}
let i = 0
do {
const a = this.build[i]
const b = other.build[i]
debug('build compare', i, a, b)
if (a === undefined && b === undefined) {
return 0
} else if (b === undefined) {
return 1
} else if (a === undefined) {
return -1
} else if (a === b) {
continue
} else {
return compareIdentifiers(a, b)
}
} while (++i)
}
// preminor will bump the version up to the next minor release, and immediately
// down to pre-release. premajor and prepatch work the same way.
inc (release, identifier, identifierBase) {
if (release.startsWith('pre')) {
if (!identifier && identifierBase === false) {
throw new Error('invalid increment argument: identifier is empty')
}
// Avoid an invalid semver results
if (identifier) {
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])
if (!match || match[1] !== identifier) {
throw new Error(`invalid identifier: ${identifier}`)
}
}
}
switch (release) {
case 'premajor':
this.prerelease.length = 0
this.patch = 0
this.minor = 0
this.major++
this.inc('pre', identifier, identifierBase)
break
case 'preminor':
this.prerelease.length = 0
this.patch = 0
this.minor++
this.inc('pre', identifier, identifierBase)
break
case 'prepatch':
// If this is already a prerelease, it will bump to the next version
// drop any prereleases that might already exist, since they are not
// relevant at this point.
this.prerelease.length = 0
this.inc('patch', identifier, identifierBase)
this.inc('pre', identifier, identifierBase)
break
// If the input is a non-prerelease version, this acts the same as
// prepatch.
case 'prerelease':
if (this.prerelease.length === 0) {
this.inc('patch', identifier, identifierBase)
}
this.inc('pre', identifier, identifierBase)
break
case 'release':
if (this.prerelease.length === 0) {
throw new Error(`version ${this.raw} is not a prerelease`)
}
this.prerelease.length = 0
break
case 'major':
// If this is a pre-major version, bump up to the same major version.
// Otherwise increment major.
// 1.0.0-5 bumps to 1.0.0
// 1.1.0 bumps to 2.0.0
if (
this.minor !== 0 ||
this.patch !== 0 ||
this.prerelease.length === 0
) {
this.major++
}
this.minor = 0
this.patch = 0
this.prerelease = []
break
case 'minor':
// If this is a pre-minor version, bump up to the same minor version.
// Otherwise increment minor.
// 1.2.0-5 bumps to 1.2.0
// 1.2.1 bumps to 1.3.0
if (this.patch !== 0 || this.prerelease.length === 0) {
this.minor++
}
this.patch = 0
this.prerelease = []
break
case 'patch':
// If this is not a pre-release version, it will increment the patch.
// If it is a pre-release it will bump up to the same patch version.
// 1.2.0-5 patches to 1.2.0
// 1.2.0 patches to 1.2.1
if (this.prerelease.length === 0) {
this.patch++
}
this.prerelease = []
break
// This probably shouldn't be used publicly.
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
case 'pre': {
const base = Number(identifierBase) ? 1 : 0
if (this.prerelease.length === 0) {
this.prerelease = [base]
} else {
let i = this.prerelease.length
while (--i >= 0) {
if (typeof this.prerelease[i] === 'number') {
this.prerelease[i]++
i = -2
}
}
if (i === -1) {
// didn't increment anything
if (identifier === this.prerelease.join('.') && identifierBase === false) {
throw new Error('invalid increment argument: identifier already exists')
}
this.prerelease.push(base)
}
}
if (identifier) {
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
let prerelease = [identifier, base]
if (identifierBase === false) {
prerelease = [identifier]
}
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
if (isNaN(this.prerelease[1])) {
this.prerelease = prerelease
}
} else {
this.prerelease = prerelease
}
}
break
}
default:
throw new Error(`invalid increment argument: ${release}`)
}
this.raw = this.format()
if (this.build.length) {
this.raw += `+${this.build.join('.')}`
}
return this
}
}
module.exports = SemVer
+8
View File
@@ -0,0 +1,8 @@
'use strict'
const parse = require('./parse')
const clean = (version, options) => {
const s = parse(version.trim().replace(/^[=v]+/, ''), options)
return s ? s.version : null
}
module.exports = clean
+54
View File
@@ -0,0 +1,54 @@
'use strict'
const eq = require('./eq')
const neq = require('./neq')
const gt = require('./gt')
const gte = require('./gte')
const lt = require('./lt')
const lte = require('./lte')
const cmp = (a, op, b, loose) => {
switch (op) {
case '===':
if (typeof a === 'object') {
a = a.version
}
if (typeof b === 'object') {
b = b.version
}
return a === b
case '!==':
if (typeof a === 'object') {
a = a.version
}
if (typeof b === 'object') {
b = b.version
}
return a !== b
case '':
case '=':
case '==':
return eq(a, b, loose)
case '!=':
return neq(a, b, loose)
case '>':
return gt(a, b, loose)
case '>=':
return gte(a, b, loose)
case '<':
return lt(a, b, loose)
case '<=':
return lte(a, b, loose)
default:
throw new TypeError(`Invalid operator: ${op}`)
}
}
module.exports = cmp
+62
View File
@@ -0,0 +1,62 @@
'use strict'
const SemVer = require('../classes/semver')
const parse = require('./parse')
const { safeRe: re, t } = require('../internal/re')
const coerce = (version, options) => {
if (version instanceof SemVer) {
return version
}
if (typeof version === 'number') {
version = String(version)
}
if (typeof version !== 'string') {
return null
}
options = options || {}
let match = null
if (!options.rtl) {
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE])
} else {
// Find the right-most coercible string that does not share
// a terminus with a more left-ward coercible string.
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
// With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
//
// Walk through the string checking with a /g regexp
// Manually set the index so as to pick up overlapping matches.
// Stop when we get a match that ends at the string end, since no
// coercible string can be more right-ward without the same terminus.
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]
let next
while ((next = coerceRtlRegex.exec(version)) &&
(!match || match.index + match[0].length !== version.length)
) {
if (!match ||
next.index + next[0].length !== match.index + match[0].length) {
match = next
}
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length
}
// leave it in a clean state
coerceRtlRegex.lastIndex = -1
}
if (match === null) {
return null
}
const major = match[2]
const minor = match[3] || '0'
const patch = match[4] || '0'
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ''
const build = options.includePrerelease && match[6] ? `+${match[6]}` : ''
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)
}
module.exports = coerce
+9
View File
@@ -0,0 +1,9 @@
'use strict'
const SemVer = require('../classes/semver')
const compareBuild = (a, b, loose) => {
const versionA = new SemVer(a, loose)
const versionB = new SemVer(b, loose)
return versionA.compare(versionB) || versionA.compareBuild(versionB)
}
module.exports = compareBuild
+5
View File
@@ -0,0 +1,5 @@
'use strict'
const compare = require('./compare')
const compareLoose = (a, b) => compare(a, b, true)
module.exports = compareLoose
+7
View File
@@ -0,0 +1,7 @@
'use strict'
const SemVer = require('../classes/semver')
const compare = (a, b, loose) =>
new SemVer(a, loose).compare(new SemVer(b, loose))
module.exports = compare
+60
View File
@@ -0,0 +1,60 @@
'use strict'
const parse = require('./parse.js')
const diff = (version1, version2) => {
const v1 = parse(version1, null, true)
const v2 = parse(version2, null, true)
const comparison = v1.compare(v2)
if (comparison === 0) {
return null
}
const v1Higher = comparison > 0
const highVersion = v1Higher ? v1 : v2
const lowVersion = v1Higher ? v2 : v1
const highHasPre = !!highVersion.prerelease.length
const lowHasPre = !!lowVersion.prerelease.length
if (lowHasPre && !highHasPre) {
// Going from prerelease -> no prerelease requires some special casing
// If the low version has only a major, then it will always be a major
// Some examples:
// 1.0.0-1 -> 1.0.0
// 1.0.0-1 -> 1.1.1
// 1.0.0-1 -> 2.0.0
if (!lowVersion.patch && !lowVersion.minor) {
return 'major'
}
// If the main part has no difference
if (lowVersion.compareMain(highVersion) === 0) {
if (lowVersion.minor && !lowVersion.patch) {
return 'minor'
}
return 'patch'
}
}
// add the `pre` prefix if we are going to a prerelease version
const prefix = highHasPre ? 'pre' : ''
if (v1.major !== v2.major) {
return prefix + 'major'
}
if (v1.minor !== v2.minor) {
return prefix + 'minor'
}
if (v1.patch !== v2.patch) {
return prefix + 'patch'
}
// high and low are prereleases
return 'prerelease'
}
module.exports = diff
+5
View File
@@ -0,0 +1,5 @@
'use strict'
const compare = require('./compare')
const eq = (a, b, loose) => compare(a, b, loose) === 0
module.exports = eq
+5
View File
@@ -0,0 +1,5 @@
'use strict'
const compare = require('./compare')
const gt = (a, b, loose) => compare(a, b, loose) > 0
module.exports = gt
+5
View File
@@ -0,0 +1,5 @@
'use strict'
const compare = require('./compare')
const gte = (a, b, loose) => compare(a, b, loose) >= 0
module.exports = gte
+21
View File
@@ -0,0 +1,21 @@
'use strict'
const SemVer = require('../classes/semver')
const inc = (version, release, options, identifier, identifierBase) => {
if (typeof (options) === 'string') {
identifierBase = identifier
identifier = options
options = undefined
}
try {
return new SemVer(
version instanceof SemVer ? version.version : version,
options
).inc(release, identifier, identifierBase).version
} catch (er) {
return null
}
}
module.exports = inc
+5
View File
@@ -0,0 +1,5 @@
'use strict'
const compare = require('./compare')
const lt = (a, b, loose) => compare(a, b, loose) < 0
module.exports = lt
+5
View File
@@ -0,0 +1,5 @@
'use strict'
const compare = require('./compare')
const lte = (a, b, loose) => compare(a, b, loose) <= 0
module.exports = lte
+5
View File
@@ -0,0 +1,5 @@
'use strict'
const SemVer = require('../classes/semver')
const major = (a, loose) => new SemVer(a, loose).major
module.exports = major
+5
View File
@@ -0,0 +1,5 @@
'use strict'
const SemVer = require('../classes/semver')
const minor = (a, loose) => new SemVer(a, loose).minor
module.exports = minor
+5
View File
@@ -0,0 +1,5 @@
'use strict'
const compare = require('./compare')
const neq = (a, b, loose) => compare(a, b, loose) !== 0
module.exports = neq

Some files were not shown because too many files have changed in this diff Show More