// noinspection JSMethodCanBeStatic /** * Compares two versions and determines if an update is available or not * * @since 3.0.0 * @alias lando.updates.updateAvailable * @param {String} version1 The current version. * @param {String} version2 The potential update version * @return {Boolean} Whether an update is avaiable. * @example * // Does our current version need to be updated? * const updateAvailable = lando.updates.updateAvailable('1.0.0', '1.0.1'); */ updateAvailable(version1, version2) { return semver.lt(version1, version2); }
constructor(id, options = {}) { options = _.merge({}, config, options); // Arrayify the hosts if needed if (!_.isArray(options.hosts)) options.hosts = [options.hosts]; // Switch to legacy command if needed if (semver.lt(`${options.version}.0`, '5.0.0')) options.command = '/run.sh phpmyadmin'; // Build the default stuff here const pma = { image: `phpmyadmin/phpmyadmin:${options.version}`, environment: { MYSQL_ROOT_PASSWORD: '', PMA_HOSTS: options.hosts.join(','), PMA_PORT: 3306, PMA_USER: 'root', PMA_PASSWORD: '', UPLOAD_LIMIT: 'NOLIMITS!', }, ports: ['80'], command: options.command, }; // Add some info options.info = {backends: options.hosts}; // Send it downstream super(id, options, {services: _.set({}, options.name, pma)}); }
/** * Check if it has been supported. * @param {SupportInfo} info The support info. * @param {Range} configured The configured version range. */ function isSupported({ backported, supported }, configured) { if ( backported && backported.length >= 2 && !backported.every((v, i) => i === 0 || lt(backported[i - 1], v)) ) { throw new Error("Invalid BackportConfiguration") } if (supported == null) { return false } if (backported == null || backported.length === 0) { return !configured.intersects(getSemverRange(`<${supported}`)) } return !configured.intersects( getSemverRange( [...backported, supported] .map((v, i) => (i === 0 ? `<${v}` : `>=${major(v)}.0.0 <${v}`)) .join(" || ") ) ) }
tuples.sort(function(a, b) { a = a.version; b = b.version; return semver.lt(a, b) ? 1 : -1; });
it('should display a warning when a component is older than recommended', function() { for (var key in expectedComponents) { if (expectedComponents[key].recommendedVersion && key != 'cygwin') { let recommended = expectedComponents[key].recommendedVersion.match(/\d+\.\d+\.\d+/)[0]; if (expectedComponents[key].installedVersion && semver.lt(expectedComponents[key].installedVersion, recommended)) { common.error = true; expect(reqs[key].olderWarning.isDisplayed()).toBe(true); } } } });
router.get("/block-stats", function(req, res, next) { if (semver.lt(global.btcNodeSemver, rpcApi.minRpcVersions.getblockstats)) { res.locals.rpcApiUnsupportedError = {rpc:"getblockstats", version:rpcApi.minRpcVersions.getblockstats}; } coreApi.getBlockchainInfo().then(function(getblockchaininfo) { res.locals.currentBlockHeight = getblockchaininfo.blocks; res.render("block-stats"); next(); }).catch(function(err) { res.locals.userMessage = "Error: " + err; res.render("block-stats"); next(); }); });
request.get(options, (error, response, body) => { if(error) { Logger.error('Update checker failed', error); return; } if(body.length === 0) { return; } const latestVersion = semver.clean(body[0].tag_name); Logger.debug('Latest available version', latestVersion); if(semver.lt(pkg.version, latestVersion)) { Logger.debug('Current version is lower than latest version'); UIActions.notifyUpdateAvailable(); } });
latestVersion(pkg.name, { agent: getProxyAgent() }).then((latest) => { if (semver.lt(pkg.version, latest)) { const chalk = require('chalk'); ui.log( 'You are running an outdated version of Ghost-CLI.\n' + 'It is recommended that you upgrade before continuing.\n' + `Run ${chalk.cyan('`npm install -g ghost-cli@latest`')} to upgrade.\n`, 'yellow' ); } })
async init() { if (this.initialized) { return; } this.provider = this.serverless.getProvider('aws'); this.service = this.serverless.service; this.options.region = this.provider.getRegion(); // bindings this.log = this.log.bind(this); this.main = this.main.bind(this); const version = this.serverless.getVersion(); if (semver.lt(version, '1.34.0')) { this.log(`Error: Please install serverless >= 1.34.0 (current ${this.serverless.getVersion()})`); process.exit(1); } }
async checkUpgrade() { const semver = require('semver'); nconf.set('env:CURR_VERSION', semver.valid(await this.es.getTmplVer(nconf.get('env:ES_MAJOR'))) || '0.0.0'); nconf.set('env:NEW_VERSION', semver.valid(nconf.get('env:APP_VERSION')) || nconf.get('env:CURR_VERSION')); nconf.set('env:KB_VERSION', await this.es.getKBVer()); nconf.set('env:KB_MAJOR', parseInt(nconf.get('env:KB_VERSION').substr(0, 1), 10)); this.env = nconf.get('env'); const upgrade = ( semver.lt(this.env.CURR_VERSION, this.env.NEW_VERSION) || (this.env.KB_MAJOR < this.env.ES_MAJOR) || nconf.get('es_upgrade') === true ); if (upgrade === true) { this.es.logElastic('info', `[UPDATE] ` + `Force: ${nconf.get('es_upgrade')} - ` + `New: ${!this.env.KB_MAJOR} - ` + `Update: ${semver.lt(this.env.CURR_VERSION, this.env.NEW_VERSION)} - ` + `(CURR:${this.env.CURR_VERSION} > NEW:${this.env.NEW_VERSION}) - ` + `Upgrade: ${this.env.KB_MAJOR < this.env.ES_MAJOR} - (KB:${this.env.KB_MAJOR} > ES:${this.env.ES_MAJOR})`); } return upgrade; }
test("node 10.9.0+ url + options, without active trace", done => { if (semver.lt(process.version, "10.9.0")) { // don't run this test for these versions done(); return; } https.get( "https://google.com:80", { port: 443, }, _res => { expect(api._apiForTesting().sentEvents).toEqual([]); done(); } ); });
fs.readdirSync(path.join(__dirname, '../data/raw')).reduce(function (result, file) { var envName = path.basename(file, '.json'); var content = require(path.join(__dirname, '../data/raw', file)); return result.concat(content .filter(function (env) { return semver.patch(env.version) === 0; }) .map(function (env) { return { name: envName, version: env.version.substr(1), date: env.date, lts: env.lts, security: env.security }; })); }, []).sort(function (a, b) { if (semver.gt(a.version, b.version)) return 1; if (semver.lt(a.version, b.version)) return -1; return 0; })
/** * Checks if version a is behind version b * * @param {String} a * @param {String} b * * @returns {Boolean} Whether version a is behind version b */ static isVersionBehind(a, b) { a = (a || '').replace('v', ''); b = (b || '').replace('v', ''); while(a.split('.').length < 3) { a += '.0'; } while(b.split('.').length < 3) { b += '.0'; } if(!SemanticVersion.valid(a) || !SemanticVersion.valid(b)) { throw new Error(`Could not compare version numbers "${a}" and "${b}"`); } return SemanticVersion.lt(a, b); }
test("node 10.9.0+ url + options", done => { if (semver.lt(process.version, "10.9.0")) { // don't run this test for these versions done(); return; } tracker.setTracked(newMockContext()); https.get( "https://google.com:80", { port: 443, }, _res => { expect(api._apiForTesting().sentEvents).toEqual([ expect.objectContaining({ [schema.EVENT_TYPE]: "https", name: "GET", url: "https://google.com:443/", }), ]); done(); } ); });
static LT(v1, v2) { return semver.lt(v1, v2); }