chore: reformat with 2 spaces
This commit is contained in:
parent
d659e4bed9
commit
7670d7f808
1577 changed files with 70010 additions and 70042 deletions
|
@ -14,7 +14,7 @@ const repositoryURL = process.env.CI_REPO_LINK;
|
|||
const forgeURL = process.env.CI_FORGE_URL;
|
||||
|
||||
const getManifestUrl = (channel) =>
|
||||
`${forgeURL}/api/packages/${repositoryOwner}/generic/${repositoryName}/${channel}/${packageType}.json`;
|
||||
`${forgeURL}/api/packages/${repositoryOwner}/generic/${repositoryName}/${channel}/${packageType}.json`;
|
||||
const getDownloadURL = (version) => `${repositoryURL}/releases/download/${version}/${repositoryName}.zip`;
|
||||
const bugsURL = `${repositoryURL}/issues`;
|
||||
const getChangelogURL = (version) => `${repositoryURL}/releases/tag/${version}`;
|
||||
|
@ -28,9 +28,9 @@ const manifestPath = `${packageType}.json`;
|
|||
* @returns {unknown} An object describing the manifest
|
||||
*/
|
||||
function getManifest() {
|
||||
if (fs.existsSync(manifestPath)) {
|
||||
return fs.readJSONSync(manifestPath);
|
||||
}
|
||||
if (fs.existsSync(manifestPath)) {
|
||||
return fs.readJSONSync(manifestPath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,11 +40,11 @@ function getManifest() {
|
|||
* @returns {string | null} The target version
|
||||
*/
|
||||
function getTargetVersion(currentVersion, release) {
|
||||
if (["major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease"].includes(release)) {
|
||||
return semver.inc(currentVersion, release);
|
||||
} else {
|
||||
return semver.valid(release);
|
||||
}
|
||||
if (["major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease"].includes(release)) {
|
||||
return semver.inc(currentVersion, release);
|
||||
} else {
|
||||
return semver.valid(release);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,7 +53,7 @@ function getTargetVersion(currentVersion, release) {
|
|||
* @returns {"latest" | "beta"} The channel for the version
|
||||
*/
|
||||
function getChannel(version) {
|
||||
return version.includes("-") ? "beta" : "latest";
|
||||
return version.includes("-") ? "beta" : "latest";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,43 +61,43 @@ function getChannel(version) {
|
|||
* @param {semver.ReleaseType | string} release Either a semver release type or a valid semver version
|
||||
*/
|
||||
function bumpVersion(release) {
|
||||
if (!release) {
|
||||
throw new Error("Missing release type");
|
||||
}
|
||||
if (!release) {
|
||||
throw new Error("Missing release type");
|
||||
}
|
||||
|
||||
const packageJson = fs.readJSONSync("package.json");
|
||||
const manifest = getManifest();
|
||||
if (!manifest) throw new Error("Manifest JSON not found");
|
||||
const packageJson = fs.readJSONSync("package.json");
|
||||
const manifest = getManifest();
|
||||
if (!manifest) throw new Error("Manifest JSON not found");
|
||||
|
||||
const currentVersion = packageJson.version;
|
||||
const targetVersion = getTargetVersion(currentVersion, release);
|
||||
const currentVersion = packageJson.version;
|
||||
const targetVersion = getTargetVersion(currentVersion, release);
|
||||
|
||||
if (!targetVersion) {
|
||||
throw new Error("Incorrect version arguments");
|
||||
}
|
||||
if (targetVersion === currentVersion) {
|
||||
throw new Error("Target version is identical to current version");
|
||||
}
|
||||
if (!targetVersion) {
|
||||
throw new Error("Incorrect version arguments");
|
||||
}
|
||||
if (targetVersion === currentVersion) {
|
||||
throw new Error("Target version is identical to current version");
|
||||
}
|
||||
|
||||
console.log(`Bumping version number to '${targetVersion}'`);
|
||||
packageJson.version = targetVersion;
|
||||
fs.writeJSONSync("package.json", packageJson, { spaces: 4 });
|
||||
manifest.version = targetVersion;
|
||||
manifest.url = repositoryURL;
|
||||
manifest.manifest = getManifestUrl(getChannel(targetVersion));
|
||||
manifest.download = getDownloadURL(targetVersion);
|
||||
manifest.bugs = bugsURL;
|
||||
manifest.changelog = getChangelogURL(targetVersion);
|
||||
manifest.readme = getReadmeURL(targetVersion);
|
||||
manifest.license = getLicenseURL(targetVersion);
|
||||
fs.writeJSONSync(manifestPath, manifest, { spaces: 4 });
|
||||
console.log(`Bumping version number to '${targetVersion}'`);
|
||||
packageJson.version = targetVersion;
|
||||
fs.writeJSONSync("package.json", packageJson, { spaces: 2 });
|
||||
manifest.version = targetVersion;
|
||||
manifest.url = repositoryURL;
|
||||
manifest.manifest = getManifestUrl(getChannel(targetVersion));
|
||||
manifest.download = getDownloadURL(targetVersion);
|
||||
manifest.bugs = bugsURL;
|
||||
manifest.changelog = getChangelogURL(targetVersion);
|
||||
manifest.readme = getReadmeURL(targetVersion);
|
||||
manifest.license = getLicenseURL(targetVersion);
|
||||
fs.writeJSONSync(manifestPath, manifest, { spaces: 2 });
|
||||
}
|
||||
|
||||
const argv = yargs(hideBin(process.argv)).usage("Usage: $0").option("release", {
|
||||
alias: "r",
|
||||
type: "string",
|
||||
demandOption: true,
|
||||
description: "Either a semver release type or a valid semver version",
|
||||
alias: "r",
|
||||
type: "string",
|
||||
demandOption: true,
|
||||
description: "Either a semver release type or a valid semver version",
|
||||
}).argv;
|
||||
const release = argv.r;
|
||||
bumpVersion(release);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue