當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。