How to use the semver.satisfies 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 huncwotjs / huncwot / cli.js View on Github external
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

const { valid, satisfies, validRange } = require('semver');
const {
  engines: { node: version }
} = require('./package.json');

const expected = validRange(version);
const actual = valid(process.version);

if (!satisfies(actual, expected)) {
  console.error(`Expected node ${expected}, but found ${actual}`);
  process.exit(1);
}

const _argv = require('yargs')
  .version()
  .usage('Usage: $0  [options]')
  .command(['new [dir]', 'init', 'n'], 'Create new project', require('./cli/init'))
  .example('$0 new my-project', 'Create and initialize `my-project` directory')
  .command(['setup [name]'], 'Setup an integration', require('./cli/setup'))
  .command(['start', 'start', 's'], 'Start the application', require('./cli/start'))
  .example('$0 start', 'Start the application')
  .command(['client', 'client', 'c'], 'Start only the client', require('./cli/client'))
  .example('$0 client', 'Start only the client')
  .command(['server [dir]', 'serve', 'se'], 'Serve the directory', require('./cli/server'))
  .example('$0 server --port 4000', 'Serve the directory at the port 4000')
github webhintio / hint / packages / sonarwhal / src / lib / utils / resource-loader.ts View on Github external
const isVersionValid = (resourcePath: string): boolean => {
    try {
        const pkg = getPackage(resourcePath);
        const sonarwhalPkg = getSonarwhalPackage();

        return semver.satisfies(sonarwhalPkg.version, pkg.peerDependencies.sonarwhal);
    } catch (e) {
        // We failed to load the package.json so it's a core resource
        debug(e);

        return true;
    }
};
github jxcore / jxcore / deps / npm / lib / install.js View on Github external
readJson(path.resolve(nm, pkg, "package.json"), log.warn, function (er, d) {
        if (er && er.code !== "ENOENT" && er.code !== "ENOTDIR") return cb(er)
        // error means it's not a package, most likely.
        if (er) return cb(null, [])

        // if it's a bundled dep, then assume that anything there is valid.
        // otherwise, make sure that it's a semver match with what we want.
        var bd = parent.bundleDependencies
        if (bd && bd.indexOf(d.name) !== -1 ||
            semver.satisfies(d.version, deps[d.name] || "*", true) ||
            deps[d.name] === d._resolved) {
          return cb(null, d.name)
        }

        // see if the package had been previously linked
        fs.lstat(path.resolve(nm, pkg), function(err, s) {
          if (err) return cb(null, [])
          if (s.isSymbolicLink()) {
            return cb(null, d.name)
          }

          // something is there, but it's not satisfactory.  Clobber it.
          return cb(null, [])
        })
      })
    }, function (er, inst) {
github rxweb / rxweb / rxweb.io / node_modules / @schematics / update / update / index.js View on Github external
function _validateReversePeerDependencies(name, version, infoMap, logger) {
    for (const [installed, installedInfo] of infoMap.entries()) {
        const installedLogger = logger.createChild(installed);
        installedLogger.debug(`${installed}...`);
        const peers = (installedInfo.target || installedInfo.installed).packageJson.peerDependencies;
        for (const [peer, range] of Object.entries(peers || {})) {
            if (peer != name) {
                // Only check peers to the packages we're updating. We don't care about peers
                // that are unmet but we have no effect on.
                continue;
            }
            // Override the peer version range if it's whitelisted.
            const extendedRange = _updatePeerVersion(infoMap, peer, range);
            if (!semver.satisfies(version, extendedRange)) {
                logger.error([
                    `Package ${JSON.stringify(installed)} has an incompatible peer dependency to`,
                    `${JSON.stringify(name)} (requires`,
                    `${JSON.stringify(range)}${extendedRange == range ? '' : ' (extended)'},`,
                    `would install ${JSON.stringify(version)}).`,
                ].join(' '));
                return true;
            }
        }
    }
    return false;
}
function _validateUpdatePackages(infoMap, force, logger) {
github skbkontur / retail-ui / packages / react-ui-testing / TestPages / webpack.config.js View on Github external
],
          },
        },
      ],
    },
    resolve: {
      extensions: ['.js', '.jsx'],
      alias: { ...alias },
    },
    plugins: [
      new webpack.DefinePlugin({
        'process.env.enableReactTesting': JSON.stringify(true),
        'process.env.hasKebab': JSON.stringify(semver.satisfies(retailUIVersion, '>=0.9.0')),
        'process.env.hasPaging': JSON.stringify(semver.satisfies(retailUIVersion, '>=0.9.0')),
        'process.env.hasSidePage': JSON.stringify(semver.satisfies(retailUIVersion, '>=0.11.0')),
        'process.env.newCombobox': JSON.stringify(semver.satisfies(retailUIVersion, '>=0.7.0')),
        'process.env.retailUIVersion': JSON.stringify(retailUIVersion),
        'process.env.baseUrl': JSON.stringify(`/${reactVersion}/${retailUIVersion}`),
      }),
      new HtmlWebpackPlugin({
        filename: `${reactVersion}/${retailUIVersion}/index.html`,
        template: './src/index.html',
      }),
    ],
    devServer: {
      host: '0.0.0.0',
      port: 8083,
      historyApiFallback: {
        rewrites: versions.map(version => ({
          from: new RegExp(`^/${version['react']}/${version['retail-ui']}/.*`),
          to: `/${version['react']}/${version['retail-ui']}/index.html`,
        })),
github binduwavell / generator-alfresco / generators / common / sdk-versions.js View on Github external
function usesEnhancedAlfrescoMavenPlugin (version) {
  const archetypeVersion = version || _findArchetypeVersion.call(this);
  if (archetypeVersion) {
    if (semver.satisfies(semver.clean(archetypeVersion), '>=3.0.0-SNAPSHOT')) {
      return true;
    }
    return false;
  }
  throw TypeError('Unable to locate SDK version to evaluate.');
}
github teambit / bit / bin / bit.js View on Github external
function getCompatibilityStatus() {
  if (semver.satisfies(nodeVersion, `>=${MINIMUM_NODE_VERSION}`)) {
    return 'current';
  }

  return 'unsupported';
}
github binduwavell / generator-alfresco / generators / app / index.js View on Github external
default () {
    if (this.bail) return;
    try {
      this.out.info('Checking java version for sdk compatibility');
      if (!semver.satisfies(this.javaVersion.replace(/_[0-9]+$/, ''), this.sdk.supportedJavaVersions)) {
        throw new Error('Unfortunately the current version of java (' + this.javaVersion + ') '
          + 'does not match one of the supported versions: ' + this.sdk.supportedJavaVersions + ' '
          + 'for the SDK you have selected (' + this.archetypeVersion + '). '
          + 'Either set JAVA_HOME to point to a valid version of java or install one.');
      }
      this.out.info('Checking maven version for sdk compatibility');
      if (!semver.satisfies(this.mavenVersion, this.sdk.supportedMavenVersions)) {
        throw new Error('Unfortunately the current version of maven (' + this.mavenVersion + ') '
          + 'does not match one of the supported versions: ' + this.sdk.supportedMavenVersions + ' '
          + 'for the SDK you have selected (' + this.archetypeVersion + '). '
          + 'Please install a supported version.');
      }
    } catch (e) {
      this.out.error(e.message);
      this.bail = true;
    }
  }
github binduwavell / generator-alfresco / generators / common / sdk-versions.js View on Github external
function beforeExit () {
  if (this.config.get(constants.PROP_ARCHETYPE_VERSION)) {
    if (semver.satisfies(semver.clean(this.config.get(constants.PROP_ARCHETYPE_VERSION)), '>=2.2.0-SNAPSHOT')
      && semver.satisfies(semver.clean(this.config.get(constants.PROP_ARCHETYPE_VERSION)), '<3.0.0-SNAPSHOT')) {
      fs.writeFileSync(this.destinationPath(constants.FILE_RUN_SH), [
        '#!/bin/bash',
        'echo WARNING: This version of the SDK does not support spring-loaded.',
        'echo WARNING: Please use: run-without-springloaded.sh instead of run.sh.',
      ].join('\n'));
      fs.unlinkSync(this.destinationPath(path.join(constants.FOLDER_SCRIPTS, constants.FILE_RUN_SH)));
    }
  }
}