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
|
|
|
|
},
|
2021-01-07 03:02:27 +03:00
|
|
|
"release-date": {
|
|
|
|
type: "string",
|
|
|
|
default: new Date().toISOString().slice(0, 10),
|
|
|
|
describe: "the date of intended release",
|
|
|
|
demandOption: false
|
|
|
|
},
|
2021-11-02 23:39:28 +03:00
|
|
|
"replace-latest-entry-title": {
|
|
|
|
type: "string",
|
|
|
|
default: true,
|
|
|
|
describe: "indicates if to replace the latest changelog entry",
|
|
|
|
demandOption: false
|
|
|
|
},
|
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");
|
2022-06-22 15:44:37 +03:00
|
|
|
const packageUtils = require("@azure-tools/eng-package-utils");
|
2019-10-29 23:17:31 +03:00
|
|
|
|
|
|
|
async function main(argv) {
|
|
|
|
const artifactName = argv["artifact-name"];
|
|
|
|
const newVersion = argv["new-version"];
|
2021-01-07 03:02:27 +03:00
|
|
|
const releaseDate = argv["release-date"];
|
2021-11-02 23:39:28 +03:00
|
|
|
const replaceLatestEntryTitle = argv["replace-latest-entry-title"];
|
2019-10-29 23:17:31 +03:00
|
|
|
const repoRoot = argv["repo-root"];
|
|
|
|
const dryRun = argv["dry-run"];
|
|
|
|
|
2020-04-01 05:59:04 +03:00
|
|
|
const rushSpec = await packageUtils.getRushSpec(repoRoot);
|
2019-10-29 23:17:31 +03:00
|
|
|
|
|
|
|
const targetPackage = rushSpec.projects.find(
|
2021-01-07 03:02:27 +03:00
|
|
|
(packageSpec) => packageSpec.packageName.replace("@", "").replace("/", "-") == artifactName
|
2019-10-29 23:17:31 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
const targetPackagePath = path.join(repoRoot, targetPackage.projectFolder);
|
|
|
|
const packageJsonLocation = path.join(targetPackagePath, "package.json");
|
|
|
|
|
2021-01-07 03:02:27 +03:00
|
|
|
const packageJsonContents = await packageUtils.readFileJson(packageJsonLocation);
|
2019-10-29 23:17:31 +03:00
|
|
|
|
|
|
|
const oldVersion = packageJsonContents.version;
|
2020-12-05 01:04:06 +03:00
|
|
|
console.log(`${packageJsonContents.name}: ${oldVersion} -> ${newVersion}`);
|
2019-10-29 23:17:31 +03:00
|
|
|
|
|
|
|
if (dryRun) {
|
|
|
|
console.log("Dry run only, no changes");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const updatedPackageJson = {
|
|
|
|
...packageJsonContents,
|
|
|
|
version: newVersion
|
|
|
|
};
|
2020-04-01 05:59:04 +03:00
|
|
|
await packageUtils.writePackageJson(packageJsonLocation, updatedPackageJson);
|
2019-10-29 23:17:31 +03:00
|
|
|
|
2021-01-07 03:02:27 +03:00
|
|
|
await versionUtils.updatePackageConstants(targetPackagePath, packageJsonContents, newVersion);
|
|
|
|
|
|
|
|
const updateStatus = versionUtils.updateChangelog(
|
2019-10-29 23:17:31 +03:00
|
|
|
targetPackagePath,
|
2021-01-07 03:02:27 +03:00
|
|
|
artifactName,
|
|
|
|
repoRoot,
|
|
|
|
newVersion,
|
|
|
|
false,
|
2021-11-02 23:39:28 +03:00
|
|
|
replaceLatestEntryTitle,
|
2021-01-07 03:02:27 +03:00
|
|
|
releaseDate
|
2019-10-29 23:17:31 +03:00
|
|
|
);
|
2020-03-27 01:58:35 +03:00
|
|
|
if (!updateStatus) {
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2019-10-29 23:17:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
main(argv);
|