How to use the semver.minor 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 runtools / run / cli / old / tool-reference.js View on Github external
} else {
      throw new Error(
        `Version range '${version}' is not supported. Use caret, tilde or 1.x.x range types.`
      );
    }

    version = range.split(' ')[0].slice(2);
    // Let's find out the minimum compatible version:
    // For caret: 1.7.8 => 1.0.0 but 0.5.9 => 0.5.0
    // For tilde: 1.7.8 => 1.7.0 and 0.5.9 => 0.5.0
    const pre = semver.prerelease(version);
    const major = semver.major(version);
    if (type === 'caret' && major >= 1) {
      version = `${major}.x.x`;
    } else {
      const minor = semver.minor(version);
      version = `${major}.${minor}.x`;
    }
    if (pre) {
      version += '-' + pre.join('.');
    }

    return version;
  }
}
github microsoft / rushstack / apps / rush-lib / src / api / RushConfiguration.ts View on Github external
throw new Error(
          `${rushJsonBaseName} is version ${expectedRushVersion}, which is too old for this tool. ` +
            `The minimum supported version is ${MINIMUM_SUPPORTED_RUSH_JSON_VERSION}.`
        );
      }

      // Make sure the requested version isn't too new.
      //
      // If the major/minor versions are the same, then we consider the file to be compatible.
      // This is somewhat lax, e.g. "5.0.2-dev.3" will be assumed to be loadable by rush-lib 5.0.0.
      //
      // IMPORTANT: Whenever a breaking change is introduced for one of the config files, we must
      // increment the minor version number for Rush.
      if (
        semver.major(Rush.version) !== semver.major(expectedRushVersion) ||
        semver.minor(Rush.version) !== semver.minor(expectedRushVersion)
      ) {
        // If the major/minor are different, then make sure it's an older version.
        if (semver.lt(Rush.version, expectedRushVersion)) {
          throw new Error(
            `Unable to load ${rushJsonBaseName} because its RushVersion is` +
              ` ${rushConfigurationJson.rushVersion}, whereas @microsoft/rush-lib is version ${Rush.version}.` +
              ` Consider upgrading the library.`
          );
        }
      }
    }

    RushConfiguration._jsonSchema.validateObject(rushConfigurationJson, resolvedRushJsonFilename);

    return new RushConfiguration(rushConfigurationJson, resolvedRushJsonFilename);
  }
github doyensec / electronegativity / src / finder / checks / GlobalChecks / AvailableSecurityFixesGlobalCheck.js View on Github external
async checkSecurityFixes(version, releases) {
    const majorVersion = major(version);
    const minorVersion = minor(version);
    const family = `${majorVersion}.${minorVersion}.x`;

    var latestRelease = releases.filter(release => satisfies(release.version, family))[0];

    const semverTarget = `>${version} <=${latestRelease.version}`;
    var followingReleases = releases.filter(release => satisfies(release.version, semverTarget));
    var securityFixes = false;
    for (let release of followingReleases) {
      for (let regex of this.releaseNoteSecurityFixRegex)
        if (regex.test(release.body))
          securityFixes = true;
    }
    return securityFixes;
  }
github arangodb / arangodb / js / common / modules / @arangodb / deprecated.js View on Github external
function deprecated (version, graceReleases, message) {
  if (typeof version === 'number') {
    version = String(version);
  }
  if (typeof version === 'string' && !semver.valid(version)) {
    if (semver.valid(version + '.0.0')) {
      version += '.0.0';
    } else if (semver.valid(version + '.0')) {
      version += '.0';
    }
  }
  const arangoVersion = require('internal').version;
  const arangoMajor = semver.major(arangoVersion);
  const arangoMinor = semver.minor(arangoVersion);
  const deprecateMajor = semver.major(version);
  const deprecateMinor = semver.minor(version);
  if (!message && typeof graceReleases === 'string') {
    message = graceReleases;
    graceReleases = 1;
  }
  if (!message) {
    message = 'This feature is deprecated.';
  }
  if (arangoMajor >= deprecateMajor) {
    const error = new Error(`DEPRECATED: ${message}`);
    if (arangoMajor > deprecateMajor || arangoMinor >= deprecateMinor) {
      throw error;
    }
    if (arangoMinor >= (deprecateMinor - graceReleases)) {
      console.warn(error.stack);
    }
  }
github wix / Detox / examples / demo-react-native / scripts / postinstall.js View on Github external
function patchHermesLocationForRN60Android() {
  const semver = require('semver');
  const fs = require('fs-extra');
  const path = require('path');

  if (semver.minor(rnVersion) === 60) {
    console.log('Detox post-install: Detected RN .60...');

    const HERMES_PATH_ROOT = path.join('node_modules', 'hermesvm');
    const HERMES_PATH_RN = path.join('node_modules', 'react-native', 'node_modules', 'hermesvm');

    const hermesIsInRoot = fs.existsSync(HERMES_PATH_ROOT);
    const hermesIsInRN = fs.existsSync(HERMES_PATH_RN);

    if (hermesIsInRoot && !hermesIsInRN) {
      console.log('Detox post-install: Applying hermes-vm patch for RN .60...');
      fs.ensureDirSync(path.join(HERMES_PATH_RN, 'android'));
      fs.copySync(path.join(HERMES_PATH_ROOT, 'android'), path.join(HERMES_PATH_RN, 'android'));
    } else {
      console.log('Detox post-install: hermes-vm patch not needed:', hermesIsInRoot, hermesIsInRN);
    }
  }
github microsoft / react-native-windows / local-cli / rnpm / wpf / src / wpf.js View on Github external
function getReactNativeVersion() {
  console.log('Reading react-native version from node_modules...');
  if (fs.existsSync(REACT_NATIVE_PACKAGE_JSON_PATH())) {
    const version = JSON.parse(fs.readFileSync(REACT_NATIVE_PACKAGE_JSON_PATH(), 'utf-8')).version;
    return `${semver.major(version)}.${semver.minor(version)}.*`;
  }
}
github zeit / pkg-fetch / lib / places.js View on Github external
function tagFromVersion (version) {
  const mj = major(version);
  const mn = minor(version);
  return `v${mj}.${mn}`;
}
github govau / pancake / bin / pancake-cream.js View on Github external
var HighlightDiff = function HighlightDiff(oldVersion, newVersion) {
	if (!Semver.valid(oldVersion)) {
		Log.error('Version is not a valid semver version: ' + Chalk.yellow(oldVersion));
	}

	if (!Semver.valid(newVersion)) {
		Log.error('Version is not a valid semver version: ' + Chalk.yellow(newVersion));
	}

	if (Semver.major(oldVersion) !== Semver.major(newVersion)) {
		return Chalk.magenta(newVersion);
	}

	if (Semver.minor(oldVersion) !== Semver.minor(newVersion)) {
		return Semver.major(newVersion) + '.' + Chalk.magenta(Semver.minor(newVersion) + '.' + Semver.patch(newVersion));
	}

	if (Semver.patch(oldVersion) !== Semver.patch(newVersion)) {
		return Semver.major(newVersion) + '.' + Semver.minor(newVersion) + '.' + Chalk.magenta('' + Semver.patch(newVersion));
	}
};
github Thorium-Sim / thorium / src / containers / FlightDirector / Welcome.js View on Github external
.then(res => {
          if (
            semver.gt(res[0].name, require("../../../package.json").version)
          ) {
            this.setState({ outdated: res[0].name });
          }
          if (
            semver.minor(res[0].name) >
              semver.minor(require("../../../package.json").version) ||
            semver.major(res[0].name) >
              semver.major(require("../../../package.json").version)
          ) {
            this.setState({ major: true });
          }
        })
        .catch(() => {
github electrode-io / electrode-native / ern-core / src / resolveNativeDependenciesVersions.js View on Github external
export function containsVersionMismatch (
  versions: Array,
  mismatchLevel: 'major' | 'minor' | 'patch') : boolean {
  const minVersion = semver.minSatisfying(versions, '*')
  const maxVersion = semver.maxSatisfying(versions, '*')
  const majorMismatch = semver.major(maxVersion) !== semver.major(minVersion)
  const minorMismatch = semver.minor(maxVersion) !== semver.minor(minVersion)
  const patchMismatch = semver.patch(maxVersion) !== semver.patch(minVersion)
  return majorMismatch ||
        (minorMismatch && (mismatchLevel === 'minor' || mismatchLevel === 'patch')) ||
        (patchMismatch && mismatchLevel === 'patch')
}