-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathversion-bump.mjs
28 lines (23 loc) · 1.04 KB
/
version-bump.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { readFileSync, writeFileSync } from "fs";
// Get the new version
let newVersion = process.argv[2];
if (!newVersion) {
// If no version provided, bump the patch version
const currentVersion = JSON.parse(readFileSync("package.json", "utf8")).version;
const [major, minor, patch] = currentVersion.split('.').map(Number);
newVersion = `${major}.${minor}.${patch + 1}`;
}
// Update package.json
let packageJson = JSON.parse(readFileSync("package.json", "utf8"));
packageJson.version = newVersion;
writeFileSync("package.json", JSON.stringify(packageJson, null, "\t"));
// Update manifest.json
let manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
const { minAppVersion } = manifest;
manifest.version = newVersion;
writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
// Update versions.json
let versions = JSON.parse(readFileSync("versions.json", "utf8"));
versions[newVersion] = minAppVersion;
writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));
console.log(`Updated to version ${newVersion}`);