azure-sdk-for-js/eng/tools/versioning/set-version.js

92 строки
2.5 KiB
JavaScript
Исходник Постоянная ссылка Обычный вид История

Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
let argv = require("yargs")
.options({
"artifact-name": {
type: "string",
describe:
"name of the artifact to be set (e.g. azure-keyvault-secrets), will be translated to @azure/(package) format",
demandOption: true
},
"new-version": {
type: "string",
describe: "package version string",
demandOption: true
},
"release-date": {
type: "string",
default: new Date().toISOString().slice(0, 10),
describe: "the date of intended release",
demandOption: false
},
"replace-latest-entry-title": {
type: "string",
default: true,
describe: "indicates if to replace the latest changelog entry",
demandOption: false
},
Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
"repo-root": {
type: "string",
default: "../../../",
describe: "root of the repository (e.g. ../../../)",
demandOption: true
},
"dry-run": {
type: "boolean"
}
})
.help().argv;
const path = require("path");
const versionUtils = require("./VersionUtils");
const packageUtils = require("@azure-tools/eng-package-utils");
Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
async function main(argv) {
const artifactName = argv["artifact-name"];
const newVersion = argv["new-version"];
const releaseDate = argv["release-date"];
const replaceLatestEntryTitle = argv["replace-latest-entry-title"];
Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
const repoRoot = argv["repo-root"];
const dryRun = argv["dry-run"];
const rushSpec = await packageUtils.getRushSpec(repoRoot);
Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
const targetPackage = rushSpec.projects.find(
(packageSpec) => packageSpec.packageName.replace("@", "").replace("/", "-") == artifactName
Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
);
const targetPackagePath = path.join(repoRoot, targetPackage.projectFolder);
const packageJsonLocation = path.join(targetPackagePath, "package.json");
const packageJsonContents = await packageUtils.readFileJson(packageJsonLocation);
Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
const oldVersion = packageJsonContents.version;
console.log(`${packageJsonContents.name}: ${oldVersion} -> ${newVersion}`);
Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
if (dryRun) {
console.log("Dry run only, no changes");
return;
}
const updatedPackageJson = {
...packageJsonContents,
version: newVersion
};
await packageUtils.writePackageJson(packageJsonLocation, updatedPackageJson);
Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
await versionUtils.updatePackageConstants(targetPackagePath, packageJsonContents, newVersion);
const updateStatus = versionUtils.updateChangelog(
Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
targetPackagePath,
artifactName,
repoRoot,
newVersion,
false,
replaceLatestEntryTitle,
releaseDate
Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
);
if (!updateStatus) {
process.exit(1);
}
Add utility to change versions (#5598) * add versioning utilities remove index.js, update package.json to describe what to do use path.join and DRY up fetching rush.json contnets fix a couple bugs output only version update information use template for testing publishing step add doc exception for versioning add some progress for eng tools package.json files include metadata pointing to files which contain hard coded version constants use a non-global regex to find the first instance of a semver string in a file synchronize version strings in constants files with package.json refactor constants generation code, add set-version add ability to skip unit test and analyze steps give more information about values console.log where appropriate remove extra console.logs reset app-configuration package version to original value rename version constant variables to `packageVersion` to match what AutoRest generates (also ncludes whitespace changes) Revert "rename version constant variables to `packageVersion` to match what AutoRest generates also includes whitespace changes)" This reverts commit 6c8ce02e18b6bb47bdacf29bd12bb9c150e8363e. use path/prefix for constant paths to narrow down version numbers add support for expanded metadata and prefix regex use promisify to get rid of experimental warnings update dev package procedure and add ability to scope dev version setting add in options to manage release template remove sync-constants.js set prerelease properly versioning utilities remove skip conditions update documentation remove sync-constants.js add README documentation [skip ci] remove skip instructions from template/ci.yml set default for increment, set-dev, and set-version update versioning docs revert formatting change for keyvault-certificates/src/index.ts remove reference to sdk-build-tools ref
2019-10-29 23:17:31 +03:00
}
main(argv);