forked from remotion-dev/remotion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
set-version.mjs
73 lines (63 loc) · 1.69 KB
/
set-version.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { execSync } from "child_process";
import {
existsSync,
lstatSync,
readFileSync,
readdirSync,
writeFileSync,
} from "fs";
import path from "path";
let version = process.argv[2];
let noCommit = process.argv.includes("--no-commit");
if (!version) {
throw new Error("Please specify a version");
}
if (version.startsWith("v")) {
version = version.slice(1);
}
const dirs = readdirSync("packages")
.filter((dir) =>
lstatSync(path.join(process.cwd(), "packages", dir)).isDirectory()
)
.filter((dir) =>
existsSync(path.join(process.cwd(), "packages", dir, "package.json"))
);
for (const dir of [path.join("cloudrun", "container"), ...dirs]) {
const packageJsonPath = path.join(
process.cwd(),
"packages",
dir,
"package.json"
);
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
packageJson.version = version;
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
try {
console.log("setting version for", dir);
execSync("pnpm exec prettier --write package.json", {
cwd: path.join(process.cwd(), "packages", dir),
});
} catch (e) {
// console.log(e.message);
}
}
execSync("node ensure-correct-version.js", {
cwd: "packages/core",
});
execSync("pnpm exec vitest src/monorepo --run", {
cwd: "packages/it-tests",
stdio: "inherit",
});
execSync("node build.mjs --all", {
cwd: "packages/renderer",
stdio: "inherit",
});
execSync("pnpm build", {
cwd: "packages/cloudrun",
stdio: "inherit",
});
if (!noCommit) {
execSync("git add .", { stdio: "inherit" });
execSync(`git commit -m "v${version}"`, { stdio: "inherit" });
execSync(`git tag v${version}`, { stdio: "inherit" });
}