How to use the coerce function from semver
Find comprehensive JavaScript semver.coerce code examples handpicked from public code repositorys.
GitHub: qooxdoo/qooxdoo
360 361 362 363 364 365 366 367 368 369
qx.tool.config.Lockfile.getInstance().getVersion(), true ).raw; let fileVersion = lockfileContent && lockfileContent.version ? semver.coerce(lockfileContent.version, true).raw : "1.0.0"; if (semver.major(schemaVersion) > semver.major(fileVersion)) { if (this.argv.force) { let config = {
255
758
77
+ 3 other calls in file
GitHub: DataDog/dd-trace-js
69 70 71 72 73 74 75 76 77 78
.filter(instrumentation => instrumentation.name === moduleName) .forEach(instrumentation => { instrumentation.versions .filter(version => !process.env.RANGE || semver.subset(version, process.env.RANGE)) .forEach(version => { const min = semver.coerce(version).version const max = require(`../../../../versions/${moduleName}@${version}`).version() testVersions.set(min, { range: version, test: min }) testVersions.set(max, { range: version, test: version })
243
449
0
217 218 219 220 221 222 223 224 225 226
* @param {"react-native" | "react-native-macos" | "react-native-windows"} packageName * @param {string} targetVersion * @returns {Record<string, string> | undefined} */ function getPlatformPackage(packageName, targetVersion) { const v = semver.coerce(targetVersion); if (!v) { throw new Error(`Invalid ${packageName} version: ${targetVersion}`); }
55
363
20
768 769 770 771 772 773 774 775 776 777
versions = Object.values(versions) || []; try { versions = versions.sort((a, b) => { let result = 0; try { const a_ver = semver.coerce(a.version); const b_ver = semver.coerce(b.version); if (semver.lt(a_ver, b_ver)) { result = 1; }
45
74
14
+ 2 other calls in file
776 777 778 779 780 781 782 783 784 785
if (!diff.updated) { diff.updated = {}; } diff.updated.channel = updated.channel; } if (semver.neq(semver.coerce(current.orderer), semver.coerce(updated.orderer))) { if (!diff.updated) { diff.updated = {}; } diff.updated.orderer = updated.orderer;
45
72
14
+ 20 other calls in file
1468 1469 1470 1471 1472 1473 1474 1475 1476 1477
let highest = ''; versions.forEach(version => { const revised = version.replace(/_/g, '.'); if (highest) { try { if (semver.lt(semver.coerce(highest), semver.coerce(revised))) { highest = revised; } } catch (err) { console.error(err);
45
72
14
+ 9 other calls in file
GitHub: volumio/volumio3-backend
914 915 916 917 918 919 920 921 922 923
} if (updateMessage && updateMessage.updateavailable === true) { // Always use a loose parse as Volumio versions aren't properly semver. // For example 3.054 isn't valid due to the leading '0'. var updateVersion = semver.coerce(updateMessage.title, { loose: true }); if(updateVersion !== null) { var broken = self.commandRouter.pluginManager.listPluginsBrokenByNewVersion(updateVersion.version); if(broken.length > 0) { updateMessage.description += '<br><p><strong>The following plugins will be broken by this update:</strong></p> ' + broken;
28
20
4
+ 3 other calls in file
12 13 14 15 16 17 18 19 20 21
let published = releases.filter( release => ! release.draft && ! release.prerelease ); let sorted = published.sort( ( a, b ) => semver.rcompare( semver.coerce( a.tag_name ), semver.coerce( b.tag_name ) ) ); let changelog = sorted.reduce( ( changelog, release ) => `${changelog}
2
8
0
119 120 121 122 123 124 125 126 127 128
reject("Error!! Package.json File does not have correct json"); } } //validate if cypress config file is passed and exists cypress_version = semver.coerce(cypress_version).version; // validate cypress.json only in case of cypress<10 if ( semverCompare(cypress_version, "10.0.0") == -1 && lt_config["run_settings"]["cypress_config_file"]
17
4
7
GitHub: uc-cdis/gen3-qa
129 130 131 132 133 134 135 136 137 138
// if peregrine is on version 3.2.0/2023.04 or newer, or on a branch, use // the peregrine endpoint. if not, use the deprecated pidgin endpoint const minSemVer = '3.2.0'; // We need two dots here to achieve proper comparison later with other monthly versions const minMonthlyRelease = semver.coerce('2023.04.0', { loose: true }); const monthlyReleaseCutoff = semver.coerce('2020', { loose: true }); const url = await I.sendGetRequest(peregrineProps.endpoints.version) .then((response) => {
2
4
26
+ 2 other calls in file
GitHub: AMoo-Miki/oss-cdx-demo
94 95 96 97 98 99 100 101 102 103
for (const product of products) { if (!Array.isArray(packageMap[product.name])) continue; for (const package of packageMap[product.name]) { const coercedVersion = semver.coerce(package.version, { loose: true })?.version; const satisfies = semver.satisfies(coercedVersion, product.version, { loose: true }); if (!satisfies) continue; if (ecosystems && !ecosystems.includes(package.ecosystem)) continue;
6
0
1
444 445 446 447 448 449 450 451 452 453
packageInfo, templateInfo, })) ) .then(({ isOnline, packageInfo, templateInfo }) => { let packageVersion = semver.coerce(packageInfo.version); const templatesVersionMinimum = '3.3.0'; // Assume compatibility if we can't test the version.
1
0
2
+ 2 other calls in file
GitHub: keg-hub/keg-cli
55 56 57 58 59 60 61 62 63 64
const curVersion = get(tapPackage, [depKey, repoName]) if(!curVersion) return semver.neq( semver.coerce(cleanVersion(curVersion)), semver.coerce(cleanVersion(repoVersion)) ) && (versionsDiff[repoName] = { current: curVersion, repo: repoVersion } ) }) })
1
0
0
+ 3 other calls in file
101 102 103 104 105 106 107 108 109 110
if (pageVersion !== 'enterprise-server' || existingVersionRangeIsAll) continue const rangeOfVersionToAddIsAll = page.versions[pageVersion] === '*' // see if the version to add is a superset of the existing version const existingVersionIsSubsetOfNewVersion = semver.lt( semver.coerce(page.versions[pageVersion].replace('*', 0)), semver.coerce(imageVersions[pageVersion].replace('*', 0)) ) // only update the version range if the existing range is not '*' or
0
2
0
+ 3 other calls in file
333 334 335 336 337 338 339 340 341 342
if (argv.variant) { envars.VARIANT = true; } if (argv.reactVersion) { envars.REACT_VERSION = semver.coerce(argv.reactVersion); } if (argv.sourceMaps) { // This is off by default because it slows down the test runner, but it's
0
1
1
232 233 234 235 236 237 238 239 240 241 242 243
} function createApp(name, verbose, version, template, useYarn, usePnp) { const unsupportedNodeVersion = !semver.satisfies( // Coerce strings with metadata (i.e. `15.0.0-nightly`). semver.coerce(process.version), '>=14' ); if (unsupportedNodeVersion) {
0
0
1
+ 45 other calls in file
GitHub: ggg520xx/React-Camp
88 89 90 91 92 93 94 95 96 97
error('Warning: React version not specified in eslint-plugin-react settings. ' + 'See https://github.com/jsx-eslint/eslint-plugin-react#configuration .'); warnedForMissingVersion = true; } confVer = /^[0-9]+\.[0-9]+$/.test(confVer) ? `${confVer}.0` : confVer; const result = semver.coerce(confVer.split('.').map((part) => Number(part)).join('.')); if (!result) { error(`Warning: React version specified in eslint-plugin-react-settings must be a valid semver version, or "detect"; got “${confVer}”`); } return result ? result.version : defaultVersion;
0
0
1
+ 3 other calls in file
147 148 149 150 151 152 153 154 155 156
} const coercedActualKibanaVersion = semver_1.coerce(actualKibanaVersion); if (coercedActualKibanaVersion == null) { return false; } const coercedExpectedKibanaVersion = semver_1.coerce(expectedKibanaVersion); if (coercedExpectedKibanaVersion == null) { return false; } // Compare coerced versions, e.g. `1.2.3` ---> `1.2.3` and `7.0.0-alpha1` ---> `7.0.0`.
0
0
0
+ 7 other calls in file
18 19 20 21 22 23 24 25 26 27
if (!dependencies[pkg.name]) { return null } const manifestPath = resolveFrom.silent(workDir, path.join(pkg.name, 'package.json')) const installed = semver.coerce( manifestPath ? readPackageJson(manifestPath).version : dependencies[pkg].replace(/[\D.]/g, '') ) const supported = pkg.supported.join(' || ')
0
0
0
+ 2 other calls in file
semver.gte is the most popular function in semver (528 examples)