本文整理汇总了TypeScript中semver.inc函数的典型用法代码示例。如果您正苦于以下问题:TypeScript inc函数的具体用法?TypeScript inc怎么用?TypeScript inc使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了inc函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getNextVersionNumber
export function getNextVersionNumber(
version: string,
channel: Channel
): string {
const semanticVersion = parse(version)
if (semanticVersion == null) {
throw new Error(`Unable to parse input '${version}' into version`)
}
switch (channel) {
case 'production':
if (isBetaTag(semanticVersion)) {
throw new Error(
`Unable to draft production release using beta version '${version}'`
)
}
if (isTestTag(semanticVersion)) {
throw new Error(
`Unable to draft production release using test version '${version}'`
)
}
const nextVersion = inc(version, 'patch')
if (nextVersion == null) {
throw new Error(
`Unable to increment next production version from release version '${version}'`
)
}
return nextVersion
case 'beta':
if (isTestTag(semanticVersion)) {
throw new Error(
`Unable to draft beta release using test version '${version}'`
)
}
const betaNumber = tryGetBetaNumber(semanticVersion)
if (betaNumber) {
return semanticVersion.version.replace(
`-beta${betaNumber}`,
`-beta${betaNumber + 1}`
)
} else {
const nextVersion = inc(semanticVersion, 'patch')
const firstBeta = `${nextVersion}-beta1`
return firstBeta
}
default:
throw new Error(
`Resolving the next version is not implemented for channel ${channel}`
)
}
}
示例2: getVersionUtility
export function getVersionUtility(versionRadio: string, highestVersion: string): string {
switch(versionRadio) {
case "patch":
return semver.inc(highestVersion, "patch");
case "minor":
return semver.inc(highestVersion, "minor");
case "major":
return semver.inc(highestVersion, "major");
default:
return null;
}
}
示例3:
.map(w => {
const obj = pendingWorkspaces[w];
return {
...obj,
versionNext: semver.inc(obj.version, obj.type)
};
})
示例4: calculateNextVersion
async function calculateNextVersion(
name: string,
version: string,
changes: Array<Commit>
): Promise<string> {
const tags = await getTagsFor(name);
return tags.length || version !== '0.0.0'
? semver.inc(version, calculateReleaseType(changes))
: version;
}
示例5: reject
}, ( error: Error | null, recommendedBump: RecommendedBump ) => {
// Handle errors
if ( error ) {
reject( new Error( `An error occured while evaluating the next version. [${ error.message }]` ) );
return;
}
const newVersion: string = semver.inc( oldVersion, recommendedBump.releaseType );
resolve( newVersion );
} );
示例6: bumpVersion
/**
* @param {string} type
* @returns {NodeJS.ReadableStream}
*/
function bumpVersion(type:string):void
{
// No tsd yet.
const bump = require('gulp-bump');
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
// increment version
var newVer = semver.inc(pkg.version, type);
return gulp.src(['./bower.json', './package.json'])
.pipe(bump({version: newVer}))
.pipe(gulp.dest('./'));
}
示例7: bumpVersion
/**
* Bumps the version of the given package descriptor and then saves the result to disk.
*
* @param packageDescriptor The package descriptor representing the 'package.json' file.
* @param packagePath The path to the package.
* @param versionBump The string representation of a version or a [[VersionBump]] value.
*
* @returns The modified package descriptor.
*/
function bumpVersion(packageDescriptor: PackageDescriptor, packagePath: string, versionBump: string | VersionBump): PackageDescriptor {
let version: string;
if (typeof versionBump === "string") {
let versionBumpValue: string = VersionBump[VersionBump[versionBump]];
version = versionBumpValue
? semver.inc(packageDescriptor["version"], versionBump)
: semver.valid(versionBump);
if (!version) {
throw new Error(`'${versionBump}' is not a valid version.`);
}
}
else {
version = semver.inc(packageDescriptor["version"], VersionBump[versionBump]);
}
Logger.verbose(`Bumping workspace package '${util.colors.cyan(packageDescriptor["name"])}' to version '${version}'`);
packageDescriptor["version"] = version;
return packageDescriptor;
}
示例8: switch
.then(manifest => {
switch (version) {
case 'major':
case 'minor':
case 'patch':
return { manifest, version: semver.inc(manifest.version, version) };
default:
const updatedVersion = semver.valid(version);
if (!updatedVersion) {
return Promise.reject(`Invalid version ${ version }`);
}
return { manifest, version: updatedVersion };
}
}).then(({ manifest, version }) => {
示例9: task
task('release.copyProdVersion', () => {
// Increment the version and update the source package file
const sourcePackageJSON = require(`${PROJECT_ROOT}/package.json`);
sourcePackageJSON.version = semver.inc(sourcePackageJSON.version, promptAnswers.release, true);
const sourcePrettyPrintedJson = JSON.stringify(sourcePackageJSON, null, 2);
writeFileSync(`${PROJECT_ROOT}/package.json`, sourcePrettyPrintedJson);
// Copy the source package version and update it in the build package file
const packageJsonToUpdate = require(`${DIST_BUILD_ROOT}/package.json`);
packageJsonToUpdate.version = sourcePackageJSON.version;
const prettyPrintedJson = JSON.stringify(packageJsonToUpdate, null, 2);
writeFileSync(`${DIST_BUILD_ROOT}/package.json`, prettyPrintedJson);
});
示例10: prePublish
function prePublish(type: "patch" | "minor" | "major") {
const pkg = JSON.parse(fs.readFileSync(`package.json`, "utf-8"));
pkg.version = semver.inc(pkg.version, type);
fs.writeFileSync(`package.json`, JSON.stringify(pkg, null, " "));
}