diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/semver | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) | |
download | wallet-core-bbff7403fbf46f9ad92240ac213df8d30ef31b64.tar.xz |
update packages
Diffstat (limited to 'node_modules/semver')
-rw-r--r-- | node_modules/semver/README.md | 24 | ||||
-rwxr-xr-x | node_modules/semver/bin/semver | 14 | ||||
-rw-r--r-- | node_modules/semver/package.json | 4 | ||||
-rw-r--r-- | node_modules/semver/range.bnf | 4 | ||||
-rw-r--r-- | node_modules/semver/semver.js | 28 |
5 files changed, 67 insertions, 7 deletions
diff --git a/node_modules/semver/README.md b/node_modules/semver/README.md index fd5151ab3..9f7161e2c 100644 --- a/node_modules/semver/README.md +++ b/node_modules/semver/README.md @@ -20,6 +20,8 @@ semver.clean(' =v1.2.3 ') // '1.2.3' semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true semver.gt('1.2.3', '9.8.7') // false semver.lt('1.2.3', '9.8.7') // true +semver.valid(semver.coerce('v2')) // '2.0.0' +semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7' ``` As a command-line utility: @@ -52,6 +54,10 @@ Options: -l --loose Interpret versions and ranges loosely +-c --coerce + Coerce a string into SemVer if possible + (does not imply --loose) + Program exits successfully if any valid version satisfies all supplied ranges, and prints all satisfying versions. @@ -268,7 +274,7 @@ logical-or ::= ( ' ' ) * '||' ( ' ' ) * range ::= hyphen | simple ( ' ' simple ) * | '' hyphen ::= partial ' - ' partial simple ::= primitive | partial | tilde | caret -primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | ) partial +primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )? xr ::= 'x' | 'X' | '*' | nr nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) * @@ -364,3 +370,19 @@ satisfy the range. If you want to know if a version satisfies or does not satisfy a range, use the `satisfies(version, range)` function. + +### Coercion + +* `coerce(version)`: Coerces a string to semver if possible + +This aims to provide a very forgiving translation of a non-semver +string to semver. It looks for the first digit in a string, and +consumes all remaining characters which satisfy at least a partial semver +(e.g., `1`, `1.2`, `1.2.3`) up to the max permitted length (256 characters). +Longer versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). +All surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes `3.4.0`). +Only text which lacks digits will fail coercion (`version one` is not valid). +The maximum length for any semver component considered for coercion is 16 characters; +longer components will be ignored (`10000000000000000.4.7.4` becomes `4.7.4`). +The maximum value for any semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; +higher value components are invalid (`9999999999999999.4.7.4` is likely invalid). diff --git a/node_modules/semver/bin/semver b/node_modules/semver/bin/semver index c5f2e857e..dddbcdf11 100755 --- a/node_modules/semver/bin/semver +++ b/node_modules/semver/bin/semver @@ -12,6 +12,7 @@ var argv = process.argv.slice(2) , inc = null , version = require("../package.json").version , loose = false + , coerce = false , identifier = undefined , semver = require("../semver") , reverse = false @@ -54,6 +55,9 @@ function main () { case "-r": case "--range": range.push(argv.shift()) break + case "-c": case "--coerce": + coerce = true + break case "-h": case "--help": case "-?": return help() default: @@ -62,8 +66,10 @@ function main () { } } - versions = versions.filter(function (v) { - return semver.valid(v, loose) + versions = versions.map(function (v) { + return coerce ? (semver.coerce(v) || {version: v}).version : v + }).filter(function (v) { + return semver.valid(v) }) if (!versions.length) return fail() if (inc && (versions.length !== 1 || range.length)) @@ -122,6 +128,10 @@ function help () { ,"-l --loose" ," Interpret versions and ranges loosely" ,"" + ,"-c --coerce" + ," Coerce a string into SemVer if possible" + ," (does not imply --loose)" + ,"" ,"Program exits successfully if any valid version satisfies" ,"all supplied ranges, and prints all satisfying versions." ,"" diff --git a/node_modules/semver/package.json b/node_modules/semver/package.json index ca7e4b416..b92d3578e 100644 --- a/node_modules/semver/package.json +++ b/node_modules/semver/package.json @@ -1,13 +1,13 @@ { "name": "semver", - "version": "5.4.1", + "version": "5.5.1", "description": "The semantic version parser used by npm.", "main": "semver.js", "scripts": { "test": "tap test/*.js --cov -J" }, "devDependencies": { - "tap": "^10.7.0" + "tap": "^12.0.1" }, "license": "ISC", "repository": "https://github.com/npm/node-semver", diff --git a/node_modules/semver/range.bnf b/node_modules/semver/range.bnf index 25ebd5c83..d4c6ae0d7 100644 --- a/node_modules/semver/range.bnf +++ b/node_modules/semver/range.bnf @@ -3,10 +3,10 @@ logical-or ::= ( ' ' ) * '||' ( ' ' ) * range ::= hyphen | simple ( ' ' simple ) * | '' hyphen ::= partial ' - ' partial simple ::= primitive | partial | tilde | caret -primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | ) partial +primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )? xr ::= 'x' | 'X' | '*' | nr -nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) * +nr ::= '0' | [1-9] ( [0-9] ) * tilde ::= '~' partial caret ::= '^' partial qualifier ::= ( '-' pre )? ( '+' build )? diff --git a/node_modules/semver/semver.js b/node_modules/semver/semver.js index 389cb4467..9cf9f6e57 100644 --- a/node_modules/semver/semver.js +++ b/node_modules/semver/semver.js @@ -21,6 +21,9 @@ exports.SEMVER_SPEC_VERSION = '2.0.0'; var MAX_LENGTH = 256; var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; +// Max safe segment length for coercion. +var MAX_SAFE_COMPONENT_LENGTH = 16; + // The actual regexps go on exports.re var re = exports.re = []; var src = exports.src = []; @@ -156,6 +159,15 @@ src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$'; var XRANGELOOSE = R++; src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; +// Coercion. +// Extract anything that could conceivably be a part of a valid semver +var COERCE = R++; +src[COERCE] = '(?:^|[^\\d])' + + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + + '(?:$|[^\\d])'; + // Tilde ranges. // Meaning is "reasonably at or greater than" var LONETILDE = R++; @@ -1294,3 +1306,19 @@ function intersects(r1, r2, loose) { r2 = new Range(r2, loose) return r1.intersects(r2) } + +exports.coerce = coerce; +function coerce(version) { + if (version instanceof SemVer) + return version; + + if (typeof version !== 'string') + return null; + + var match = version.match(re[COERCE]); + + if (match == null) + return null; + + return parse((match[1] || '0') + '.' + (match[2] || '0') + '.' + (match[3] || '0')); +} |