当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript semver.inc函数代码示例

本文整理汇总了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}`
      )
  }
}
开发者ID:ghmoore,项目名称:desktop,代码行数:59,代码来源:version.ts

示例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;
    }
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:12,代码来源:ArtifactToolUtilities.ts

示例3:

 .map(w => {
   const obj = pendingWorkspaces[w];
   return {
     ...obj,
     versionNext: semver.inc(obj.version, obj.type)
   };
 })
开发者ID:skatejs,项目名称:skatejs,代码行数:7,代码来源:get-changes.ts

示例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;
}
开发者ID:skatejs,项目名称:skatejs,代码行数:10,代码来源:get-changed.ts

示例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 );

		} );
开发者ID:dominique-mueller,项目名称:automatic-release,代码行数:12,代码来源:information.ts

示例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('./'));

}
开发者ID:wanderer06,项目名称:TypeScript.NET,代码行数:18,代码来源:bumpVersion.ts

示例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;
}
开发者ID:i-e-b,项目名称:gulp-npmworkspace,代码行数:33,代码来源:PublishPackages.ts

示例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 }) => {
开发者ID:waderyan,项目名称:vscode-vsce,代码行数:16,代码来源:publish.ts

示例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);
});
开发者ID:HugoHeneault,项目名称:ionic,代码行数:17,代码来源:release.ts

示例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, "  "));
}
开发者ID:brn,项目名称:react-mvi,代码行数:5,代码来源:semver.ts


注:本文中的semver.inc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。