How to use the semver.maxSatisfying function in semver

To help you get started, we’ve selected a few semver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / semver_v5.1.x / test_semver.js View on Github external
(semver.major('1.2.3'): number);
(semver.major(new SemVer('1.2.3')): number);
(semver.minor('1.2.3'): number);
(semver.minor(new SemVer('1.2.3')): number);
(semver.patch('1.2.3'): number);
(semver.patch(new SemVer('1.2.3')): number);
semver.sort(['9.8.7', new SemVer('1.2.3')]).forEach(x => console.log(x));
semver.rsort(['9.8.7', new SemVer('1.2.3')]).forEach(x => console.log(x));
semver.compareIdentifiers('9.8.7', new SemVer('1.2.3'));
semver.rcompareIdentifiers('9.8.7', new SemVer('1.2.3'));

semver.validRange('3.x || 4.x');
semver.validRange(new Range('3.x || 4.x'));
semver.satisfies('3.5.0', new Range('3.x || 4.x'));
semver.satisfies('3.5.0', '3.x || 4.x', true);
semver.maxSatisfying(['3.5.0', new SemVer('3.15.10')], '3.x || 4.x');
semver.gtr('3.5.0', '3.x || 4.x');
semver.gtr(new SemVer('3.5.0'), new Range('3.x || 4.x'));
semver.ltr('3.5.0', '3.x || 4.x');
semver.ltr(new SemVer('3.5.0'), new Range('3.x || 4.x'));
semver.outside('2.5.0', '3.x || 4.x', '<');
semver.outside(new SemVer('2.5.0'), new Range('3.x || 4.x'), '>', true);
semver.parse('3.5.2');
semver.parse('3.5.2', true);
semver.toComparators('3.x || 4.x');
semver.toComparators(new Range('3.x || 4.x'), true);

// $ExpectError
semver.cmp('1.2.3', '> ', '1.2.4');

// $ExpectError
semver.outside('1.2.3', '1.2', '> ');
github johandb / svg-drawing-tool / node_modules / @schematics / update / update / index.js View on Github external
installedVersion = semver.maxSatisfying(Object.keys(npmPackageJson.versions), packageJsonRange);
    }
    const installedPackageJson = npmPackageJson.versions[installedVersion] || packageContent;
    if (!installedPackageJson) {
        throw new schematics_1.SchematicsException(`An unexpected error happened; package ${name} has no version ${installedVersion}.`);
    }
    let targetVersion = packages.get(name);
    if (targetVersion) {
        if (npmPackageJson['dist-tags'][targetVersion]) {
            targetVersion = npmPackageJson['dist-tags'][targetVersion];
        }
        else if (targetVersion == 'next') {
            targetVersion = npmPackageJson['dist-tags']['latest'];
        }
        else {
            targetVersion = semver.maxSatisfying(Object.keys(npmPackageJson.versions), targetVersion);
        }
    }
    if (targetVersion && semver.lte(targetVersion, installedVersion)) {
        logger.debug(`Package ${name} already satisfied by package.json (${packageJsonRange}).`);
        targetVersion = undefined;
    }
    const target = targetVersion
        ? {
            version: targetVersion,
            packageJson: npmPackageJson.versions[targetVersion],
            updateMetadata: _getUpdateMetadata(npmPackageJson.versions[targetVersion], logger),
        }
        : undefined;
    // Check if there's an installed version.
    return {
        name,
github connyay / openshift-iojs / bin / iojs / lib / node_modules / npm / lib / cache / add-named.js View on Github external
engineFilter(data)

    log.silly("addNameRange", "versions"
             , [data.name, Object.keys(data.versions || {})])

    // if the tagged version satisfies, then use that.
    var tagged = data["dist-tags"][npm.config.get("tag")]
    if (tagged
        && data.versions[tagged]
        && semver.satisfies(tagged, range, true)) {
      return addNamed(name, tagged, data.versions[tagged], cb)
    }

    // find the max satisfying version.
    var versions = Object.keys(data.versions || {})
    var ms = semver.maxSatisfying(versions, range, true)
    if (!ms) {
      return cb(installTargetsError(range, data))
    }

    // if we don't have a registry connection, try to see if
    // there's a cached copy that will be ok.
    addNamed(name, ms, data.versions[ms], cb)
  }
}
github groupon / selenium-download / lib / selenium / version.js View on Github external
function parseSeleniumMinor(result) {
  try {
    const prefixes = result.ListBucketResult.CommonPrefixes.reduce(
      addPrefix,
      {}
    );
    // Once 4.x is stable, we can go back to '*' or '<5' as our base range.
    const latest = Semver.maxSatisfying(Object.keys(prefixes), '<4');
    return prefixes[latest];
  } catch (parseError) {
    return { error: parseError, minorVersion: null };
  }
}
github charlieschwabacher / gestalt / node_modules / gulp-nsp / node_modules / nsp / node_modules / nodesecurity-npm-utils / index.js View on Github external
client.get(options.registry + module.name, {}, function (err, pkg) {

    if (err) {
      return cb(err);
    }

    if (pkg.time && pkg.time.unpublished) {
      var error = new Error('404 - Unpublished module');
      error.code = 'E404';
      error.pkgid = module.name;

      return cb(error);
    }

    // try to get a version
    var version = Semver.maxSatisfying(Object.keys(pkg.versions), module.version);

    // check dist tags if none found
    if (!version) {
      version = pkg['dist-tags'] && pkg['dist-tags'].latest;
    }

    var doc;
    if (pkg.versions) {
      doc = pkg.versions[version];
    }

    if (!doc) {
      error = new Error('404 - Unknown module');
      error.code = 'E404';
      error.pkgid = module.name;
github bower / bower / lib / util / semver.js View on Github external
});
        if (version) {
            return version;
        }
    }

    range = typeof range === 'string' ? range.trim() : range;

    // When strict match is enabled give priority to non-pre-releases
    // We do this by filtering every pre-release version
    if (strictMatch) {
        filteredVersions = versions.map(function(version) {
            return !isPreRelease(version) ? version : null;
        });

        version = semver.maxSatisfying(filteredVersions, range);
        if (version) {
            return version;
        }
    }

    // Fallback to regular semver max satisfies
    return semver.maxSatisfying(versions, range);
}
github opsmezzo / quill / lib / quill / commands / systems.js View on Github external
systems.forEach(function (system) {
      rows.push([
        system.name,
        semver.maxSatisfying(Object.keys(system.versions), '*'),
        system.description
      ]);
    });
github spmjs / spmjs.io / sync-from-npm / _index.js View on Github external
function *getVersion(name, range) {
  var url = 'http://' + registry + '/' + name;
  log.info('npm request', url);
  var result = yield request(url);
  if (result.statusCode === 404) {
    throw Error(format('pkg %s not found on npm', name))
  }
  var data = JSON.parse(result.body);
  var versions = Object.keys(data.versions);

  var version = semver.maxSatisfying(versions, range);
  if (!version) {
    throw Error('pkg version `' + range + '` of ' + name + ' is invalid');
  }
  return version;
}
github componentjs / component / lib / remote-dependencies.js View on Github external
if ('remote' != node.type) return setImmediate(done);
    var repo = node.repository;
    var key = repo.string;
    var peg = node.peg;

    var match = semver.maxSatisfying(versions[key], peg);
    if (!match) {
      var err = new Error('Version not found.');
      err.type = 'version_not_found';
      err.repository = repo;
      err.version = peg;
      return done(err);
    }

    var range = values(pegs[key]).join(' ') + ' ' + peg;
    match = semver.maxSatisfying(versions[key], range);
    if (!match) {
      var err = new Error('Version mismatch.');
      err.type = 'version_mismatch';
      err.repository = repo;
      err.versions = pegs[key];
      return done(err);
    }

    node.version = match;
    components.push(node);
    components[key] = components[key] || {};
    components[key] = node;
    done();
  }
github macor161 / quantal / src / compiler / load-compiler.js View on Github external
function getFormattedVersion(version = LATEST_VERSION) {
  return maxSatisfying(supportedSolcVersions[getOs()], version)
}