本文整理汇总了TypeScript中semver.SemVer类的典型用法代码示例。如果您正苦于以下问题:TypeScript SemVer类的具体用法?TypeScript SemVer怎么用?TypeScript SemVer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SemVer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: get
public get(entity: Entity, client: string, version: SemVer): Marshaller<Entity> {
let className: string = entity.constructor.name;
if (className.startsWith('Cart_')) {
if (version.compare(new SemVer('1.0.0')) === 0) {
return new CartMarshaller_01_00_00();
}
return new CartMarshaller_01_00_01();
}
if (className == 'Void') {
return new VoidMarshaller();
}
if (className.startsWith('HomeWidgets_')) {
if (client.startsWith('web')) {
if (version.compare(new SemVer('1.10.0')) >= 0) {
return new HomeWidgetsMarshaller_01_10_00();
}
}
return new HomeWidgetsMarshaller_01_00_00();
}
return null;
}
示例2: patch
export default function patch(args: string[], opts: any, logger: logging.Logger): void {
const newVersion = args[0];
const incFn = opts.patch ? (v: SemVer) => v.inc('patch') : (v: SemVer) => v;
if (!newVersion) {
logger.fatal('Need to pass in a new version.');
return;
}
const { packages } = require('../../../lib/packages');
const rootPackageJson = path.join(__dirname, '../../../package.json');
for (const packageName of Object.keys(packages)) {
if (packageName == 'angular-cli') {
// Skip the main package.
continue;
}
const pkgJson = require(packages[packageName].packageJson);
const version = new SemVer(pkgJson['version']);
const oldVersion = version.toString();
pkgJson['version'] = incFn(version).toString();
fs.writeFileSync(packages[packageName].packageJson, JSON.stringify(pkgJson, null, 2) + '\n');
logger.info(`${packageName}: ${oldVersion} => ${pkgJson['version']}`);
}
// Do the main package.
const angularCliPackageJson = require(rootPackageJson);
angularCliPackageJson['version'] = newVersion;
fs.writeFileSync(rootPackageJson, JSON.stringify(angularCliPackageJson, null, 2) + '\n');
}
示例3: exitHandler
process.on('uncaughtException', () => exitHandler({ exit: true }));
}
let cli;
try {
const projectLocalCli = resolve(
'@angular/cli',
{
checkGlobal: false,
basedir: process.cwd(),
preserveSymlinks: true,
},
);
// This was run from a global, check local version.
const globalVersion = new SemVer(packageJson['version']);
let localVersion;
let shouldWarn = false;
try {
localVersion = _fromPackageJson();
shouldWarn = localVersion != null && globalVersion.compare(localVersion) > 0;
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
shouldWarn = true;
}
if (shouldWarn && isWarningEnabled('versionMismatch')) {
const warning = terminal.yellow(tags.stripIndents`
Your global Angular CLI version (${globalVersion}) is greater than your local
示例4:
comparatorResult = semver.rcompareIdentifiers(str, str);
versionsArr = semver.sort(['', new semver.SemVer('')]);
versionsArr = semver.rsort(['', new semver.SemVer('')]);
diff = semver.diff(v1, v2, loose);
// Ranges
str = semver.validRange(str, loose);
bool = semver.satisfies(version, str, loose);
str = semver.maxSatisfying(versions, str, loose);
str = semver.minSatisfying(versions, str, loose);
bool = semver.gtr(version, str, loose);
bool = semver.ltr(version, str, loose);
bool = semver.outside(version, str, '<', loose);
bool = semver.intersects(str, str, loose);
let ver = new semver.SemVer(str, bool);
str = ver.raw;
bool = ver.loose;
str = ver.format();
str = ver.inspect();
str = ver.toString();
num = ver.major;
num = ver.minor;
num = ver.patch;
str = ver.version;
strArr = ver.build;
strArr = ver.prerelease;
comparatorResult = ver.compare(ver);
comparatorResult = ver.compareMain(ver);
示例5:
bool = semver.neq(v1, v2, loose);
bool = semver.cmp(v1, x, v2, loose);
num = semver.compare(v1, v2, loose);
num = semver.rcompare(v1, v2, loose);
diff = semver.diff(v1, v2, loose);
// Ranges
str = semver.validRange(str, loose);
bool = semver.satisfies(version, str, loose);
str = semver.maxSatisfying(versions, str, loose);
str = semver.minSatisfying(versions, str, loose);
bool = semver.gtr(version, str, loose);
bool = semver.ltr(version, str, loose);
bool = semver.outside(version, str, str, loose);
var ver = new semver.SemVer(str, bool);
str = ver.raw;
bool = ver.loose;
str = ver.format();
str = ver.inspect();
str = ver.toString();
num = ver.major;
num = ver.minor;
num = ver.patch;
str = ver.version;
strArr = ver.build;
strArr = ver.prerelease;
num = ver.compare(ver);
num = ver.compareMain(ver);
示例6: function
function (error: Error, projectLocalCli: string) {
let cli;
if (error) {
// If there is an error, resolve could not find the ng-cli
// library from a package.json. Instead, include it from a relative
// path to this script file (which is likely a globally installed
// npm package). Most common cause for hitting this is `ng new`
cli = require('./cli');
} else {
// This was run from a global, check local version.
const globalVersion = new SemVer(packageJson['version']);
let localVersion;
let shouldWarn = false;
try {
localVersion = _fromPackageJson();
shouldWarn = localVersion && globalVersion.compare(localVersion) > 0;
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
shouldWarn = true;
}
if (shouldWarn && isWarningEnabled('versionMismatch')) {
let warning = yellow(stripIndents`
Your global Angular CLI version (${globalVersion}) is greater than your local
version (${localVersion}). The local Angular CLI version is used.
To disable this warning use "ng set --global warnings.versionMismatch=false".
`);
// Don't show warning colorised on `ng completion`
if (process.argv[2] !== 'completion') {
// eslint-disable-next-line no-console
console.log(warning);
} else {
// eslint-disable-next-line no-console
console.error(warning);
process.exit(1);
}
}
// No error implies a projectLocalCli, which will load whatever
// version of ng-cli you have installed in a local package.json
cli = require(projectLocalCli);
}
if ('default' in cli) {
cli = cli['default'];
}
let standardInput;
try {
standardInput = process.stdin;
} catch (e) {
delete process.stdin;
process.stdin = new events.EventEmitter();
standardInput = process.stdin;
}
cli({
cliArgs: process.argv.slice(2),
inputStream: standardInput,
outputStream: process.stdout
}).then(function (exitCode: number) {
process.exit(exitCode);
}).catch(function(err: Error) {
console.log('Unknown error: ' + err.toString());
process.exit(127);
});
}
示例7:
bool = semver.neq(v1, v2, loose);
bool = semver.cmp(v1, x, v2, loose);
num = semver.compare(v1, v2, loose);
num = semver.rcompare(v1, v2, loose);
diff = semver.diff(v1, v2, loose);
// Ranges
str = semver.validRange(str, loose);
bool = semver.satisfies(version, str, loose);
str = semver.maxSatisfying(versions, str, loose);
str = semver.minSatisfying(versions, str, loose);
bool = semver.gtr(version, str, loose);
bool = semver.ltr(version, str, loose);
bool = semver.outside(version, str, str, loose);
let ver = new semver.SemVer(str, bool);
str = ver.raw;
bool = ver.loose;
str = ver.format();
str = ver.inspect();
str = ver.toString();
num = ver.major;
num = ver.minor;
num = ver.patch;
str = ver.version;
strArr = ver.build;
strArr = ver.prerelease;
num = ver.compare(ver);
num = ver.compareMain(ver);