本文整理汇总了TypeScript中semver.prerelease函数的典型用法代码示例。如果您正苦于以下问题:TypeScript prerelease函数的具体用法?TypeScript prerelease怎么用?TypeScript prerelease使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prerelease函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
Object.keys(packages).forEach((name: string) => {
// If there's _ANY_ prerelease information, it's on.
if (semver.prerelease(packages[name].version)) {
betaOrRc = true;
version = packages[name].version;
}
});
示例2: getLatestCompatibleVersion
public async getLatestCompatibleVersion(packageName: string, referenceVersion?: string): Promise<string> {
referenceVersion = referenceVersion || this.$staticConfig.version;
const isPreReleaseVersion = semver.prerelease(referenceVersion) !== null;
// if the user has some v.v.v-prerelease-xx.xx pre-release version, include pre-release versions in the search query.
const compatibleVersionRange = isPreReleaseVersion
? `~${referenceVersion}`
: `~${semver.major(referenceVersion)}.${semver.minor(referenceVersion)}.0`;
const latestVersion = await this.getLatestVersion(packageName);
if (semver.satisfies(latestVersion, compatibleVersionRange)) {
return latestVersion;
}
const data = await this.$npm.view(packageName, { "versions": true });
const maxSatisfying = semver.maxSatisfying(data, compatibleVersionRange);
return maxSatisfying || latestVersion;
}
示例3: validatePackageJson
/**
* Validate the package json file, verifying that everything needed for a successful release is defined properly
*
* @param packageJson - Package json content
*/
function validatePackageJson( packageJson: PackageJson ): void {
// Check the 'version' field
if ( !packageJson.hasOwnProperty( 'version' ) ) {
throw new Error( `The "package.json" file defines no version.` );
}
if ( semver.valid( packageJson.version ) === null ) { // 'null' means invalid
throw new Error( `The "package.json" file defines the version "${ packageJson.version }"; regarding semantic versioning this is not a valid version number.` );
}
if ( semver.prerelease( packageJson.version ) !== null ) { // 'null' means no pre-release components exist
throw new Error( `The "package.json" file defines the version "${ packageJson.version }"; pre-release versions are not supported by automatic-release.` );
}
// Check the 'repository' field
if ( !packageJson.hasOwnProperty( 'repository' ) || !packageJson.repository.hasOwnProperty( 'url' ) ) {
throw new Error( 'The "package.json" file defines no repository URL.' );
}
}
示例4: handlePackage
/**
* Handle an individual package on the path - update the dependency.
*/
async function handlePackage(packagePath: string): Promise<string[]> {
const cmds: string[] = [];
// Read in the package.json.
packagePath = path.join(packagePath, 'package.json');
let data: any;
try {
data = utils.readJSONFile(packagePath);
} catch (e) {
console.log('Skipping package ' + packagePath);
return cmds;
}
if (data.private) {
return cmds;
}
const pkg = data.name;
let npmData = await packageJson(pkg, { allVersions: true });
let versions = Object.keys(npmData.versions).sort(semver.rcompare);
let tags = npmData['dist-tags'];
// Go through the versions. The latest prerelease is 'next', the latest
// non-prerelease should be 'stable'.
let next = semver.prerelease(versions[0]) ? versions[0] : undefined;
let latest = versions.find(i => !semver.prerelease(i));
if (latest && latest !== tags.latest) {
cmds.push(`npm dist-tag add ${pkg}@${latest} latest`);
}
// If next is defined, but not supposed to be, remove it. If next is supposed
// to be defined, but is not the same as the current next, change it.
if (!next && tags.next) {
cmds.push(`npm dist-tag rm ${pkg} next`);
} else if (next && next !== tags.next) {
cmds.push(`npm dist-tag add ${pkg}@${next} next`);
}
return cmds;
}
示例5: getSemanticVersion
export function getSemanticVersion() {
const options = minimist(process.argv.slice(2), {});
let version = options.version;
if (!version) {
version = "0.0.0";
console.log("No version argument provided, fallback to default version: " + version);
} else {
console.log("Found version: " + version);
}
if (!semver.valid(version)) {
throw new Error("Package: invalid semver version: " + version);
}
let patch = semver.patch(version);
if (!options.noversiontransform) {
patch *= 1000;
const prerelease = semver.prerelease(version);
if (prerelease) {
patch += parseInt(prerelease[1], 10);
} else {
patch += 999;
}
}
const result = {
major: semver.major(version),
minor: semver.minor(version),
patch,
getVersionString() {
return this.major.toString() + "." + this.minor.toString() + "." + this.patch.toString();
},
};
console.log("Extension Version: " + result.getVersionString());
return result;
}
示例6: isPrereleaseCli
export async function isPrereleaseCli() {
const angularCliPkgJson = JSON.parse(await readFile('node_modules/@angular/cli/package.json'));
return prerelease(angularCliPkgJson.version).length > 0;
}
示例7:
let latest = versions.find(i => !semver.prerelease(i));
示例8:
strn = semver.clean(str);
strn = semver.valid(str, loose);
strn = semver.clean(str, loose);
strn = semver.inc(str, "major", loose);
strn = semver.inc(str, "premajor", loose);
strn = semver.inc(str, "minor", loose);
strn = semver.inc(str, "preminor", loose);
strn = semver.inc(str, "patch", loose);
strn = semver.inc(str, "prepatch", loose);
strn = semver.inc(str, "prerelease", loose);
strn = semver.inc(str, "prerelease", loose, "alpha");
num = semver.major(str, loose);
num = semver.minor(str, loose);
num = semver.patch(str, loose);
strArr = semver.prerelease(str, loose);
// Comparison
bool = semver.gt(v1, v2, loose);
bool = semver.gte(v1, v2, loose);
bool = semver.lt(v1, v2, loose);
bool = semver.lte(v1, v2, loose);
bool = semver.eq(v1, v2, loose);
bool = semver.neq(v1, v2, loose);
bool = semver.cmp(v1, op, v2, loose);
comparatorResult = semver.compare(v1, v2, loose);
comparatorResult = semver.rcompare(v1, v2, loose);
comparatorResult = semver.compareIdentifiers(str, str);
comparatorResult = semver.rcompareIdentifiers(str, str);
versionsArr = semver.sort(['', new semver.SemVer('')]);
versionsArr = semver.rsort(['', new semver.SemVer('')]);
示例9: switch
github.authenticate({
type: "basic",
username: endpointAuth.parameters["Username"],
password: endpointAuth.parameters["Password"]
});
var tagName = tl.getInput("tagName", true);
var prereleaseMode = tl.getInput("prereleaseMode", true);
var prerelease = false;
switch (prereleaseMode)
{
case "1":
prerelease = true;
break;
case "3":
var prereleaseComponents = semver.prerelease(tagName);
prerelease = (prereleaseComponents !== null);
break;
case "2":
default:
prerelease = false;
break;
}
github.repos.createRelease({
user:repositoryInfo.user,
repo: repositoryInfo.repo,
tag_name: tagName,
target_commitish: buildSourceVersion,
name: tl.getInput("releaseName", false),
body: tl.getInput("releaseBody", false),
示例10: isStableSdk
export function isStableSdk(sdkVersion?: string): boolean {
// We'll consider empty versions as dev; stable versions will likely always
// be shipped with valid version files.
return !!(sdkVersion && !semver.prerelease(sdkVersion));
}