Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* @flow */
import semver, {Comparator, Range, SemVer} from 'semver';
new SemVer('^3.2.0');
(semver.cmp('1.2.3', '>', '1.2.4'): boolean);
// Comparator
const comp = new Comparator('>=3.2.0');
comp.test('5.3.2');
(comp.operator: string);
(comp.value: string);
// comparator object as a ctor arg is okay
new Comparator(comp);
// static/exported properties
(semver.SEMVER_SPEC_VERSION: string);
semver.re.forEach(r => r.test('foo'));
semver.src.forEach(r => r.match(/foo/));
} catch (_) {
console.error(bold(red(stripIndents`
You seem to not be depending on "@angular/core". This is an error.
`)));
process.exit(2);
}
// Just check @angular/core.
if (pkgJson && pkgJson['version']) {
const v = new Version(pkgJson['version']);
if (v.isLocal()) {
console.warn(yellow('Using a local version of angular. Proceeding with care...'));
} else {
// Check if major is not 0, so that we stay compatible with local compiled versions
// of angular.
if (!v.isGreaterThanOrEqualTo(new SemVer('2.3.1')) && v.major != 0) {
console.error(bold(red(stripIndents`
This version of CLI is only compatible with angular version 2.3.1 or better. Please
upgrade your angular version, e.g. by running:
npm install @angular/core@latest
` + '\n')));
process.exit(3);
}
}
} else {
console.error(bold(red(stripIndents`
You seem to not be depending on "@angular/core". This is an error.
`)));
process.exit(2);
}
}
function _fromPackageJson(cwd = process.cwd()): SemVer | null {
do {
const packageJsonPath = path.join(cwd, 'node_modules/@angular/cli/package.json');
if (fs.existsSync(packageJsonPath)) {
const content = fs.readFileSync(packageJsonPath, 'utf-8');
if (content) {
const { version } = JSON.parse(content);
if (version) {
return new SemVer(version);
}
}
}
// Check the parent.
cwd = path.dirname(cwd);
} while (cwd != path.dirname(cwd));
return null;
}
public static async fetchVersionFromNpm(name: string): Promise {
const execAsync = promisify(exec);
try {
const { stdout } = await execAsync(`npm view ${name}@latest version`);
const version = new semver.SemVer(stdout.trim());
return `${name}@^${version.major}.${version.minor}.0`;
} catch (error) {
return name;
}
}
function normalizeVersion(version) {
if ( version == null ) {
return version;
}
const v = new Version(version);
return v.major + "." + v.minor;
}
constructor(_version = null) {
this._version = _version;
this._semver = null;
this._semver = _version ? new semver_1.SemVer(_version) : null;
}
isAlpha() { return this.qualifier == 'alpha'; }
WindowsReleaseService.normVersion = function(tag) {
var parts = new semver.SemVer(tag);
var prerelease = '';
if (parts.prerelease && parts.prerelease.length > 0) {
prerelease = hashPrerelease(parts.prerelease);
}
return [
parts.major,
parts.minor,
parts.patch
].join('.') + (prerelease ? '.' + prerelease : '');
};
const path = require('path');
const runCommand = require('../utility/run-command');
const semver = require('semver').SemVer;
const fs = require('fs');
const exec = require('child_process').exec;
const minNgCliVersion = new semver('8.0.0');
function runSchematicCommand(schematicCommand, options, evaluatingOptions) {
const collectionName = 'devextreme-schematics';
let collectionPath = collectionName;
if(options['c']) {
collectionPath = `${path.join(process.cwd(), options['c'])}`;
delete options['c'];
}
const additionalOptions = [];
for(let option in options) {
const schematicOption = `--${option}=${options[option]}`;
additionalOptions.push(schematicOption);
};
public isProcessEngineOlderThanInternal(solutionEntry: ISolutionEntry): boolean {
if (this.internalProcessEngineVersion === 'null') {
return false;
}
const internalPEVersion = new SemVer(this.internalProcessEngineVersion);
const solutionEntryPEVersion = new SemVer(solutionEntry.processEngineVersion);
return internalPEVersion.major > solutionEntryPEVersion.major;
}
if (currentVersion) currentVersion = semver.clean(currentVersion)
if (expectVersion) {
if (currentVersion) {
if (semver.satisfies(currentVersion, expectVersion)) {
return {
statusCode: StatusCode.GOOD,
messages: [`${meName} version: ${currentVersion}`]
}
} else {
const currentV = new semver.SemVer(currentVersion, { includePrerelease: true })
try {
const expectV = new semver.SemVer(stripVersion(expectVersion), { includePrerelease: true })
const message = `Version mismatch: ${meName} version: "${currentVersion}" does not satisfy expected version of ${theyName}: "${expectVersion}"` + (fixMessage ? ` (${fixMessage})` : '')
if (!expectV || !currentV) {
return {
statusCode: StatusCode.BAD,
messages: [message]
}
} else if (expectV.major !== currentV.major) {
return {
statusCode: StatusCode.BAD,
messages: [message]
}
} else if (expectV.minor !== currentV.minor) {
return {
statusCode: StatusCode.WARNING_MAJOR,