generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version-bump.mjs
41 lines (34 loc) · 1.34 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
29
30
31
32
33
34
35
36
37
38
39
40
41
import { readFileSync, writeFileSync } from "fs";
// 버전 타입 확인 (major, minor, patch)
const versionType = process.argv[2] || "patch";
if (!["major", "minor", "patch"].includes(versionType)) {
console.error('Invalid version type. Use "major", "minor", or "patch"');
process.exit(1);
}
// package.json에서 현재 버전을 읽고 버전을 증가시킵니다.
const packageJson = JSON.parse(readFileSync("package.json", "utf8"));
const [major, minor, patch] = packageJson.version.split(".").map(Number);
let newVersion;
switch (versionType) {
case "major":
newVersion = `${major + 1}.0.0`;
break;
case "minor":
newVersion = `${major}.${minor + 1}.0`;
break;
case "patch":
newVersion = `${major}.${minor}.${patch + 1}`;
break;
}
packageJson.version = newVersion;
writeFileSync("package.json", JSON.stringify(packageJson, null, "\t"));
// manifest.json 업데이트
const manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
const { minAppVersion } = manifest;
manifest.version = newVersion;
writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
// versions.json 업데이트
const versions = JSON.parse(readFileSync("versions.json", "utf8"));
versions[newVersion] = minAppVersion;
writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));
console.log(`Version bumped to ${newVersion}`);