-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathafter-version-change.ts
44 lines (37 loc) · 1.06 KB
/
after-version-change.ts
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
// Script to run after bumping the version.
//
// Runs `npm install` on all examples to ensure their lockfiles have the updated
// version.
import childProcess from "node:child_process";
import path from "node:path";
import { promisify } from "node:util";
import { glob } from "glob";
const execFileAsync = promisify(childProcess.execFile);
const rootDir = path.resolve(import.meta.dirname, "..");
await execFileAsync("npm", ["install", "--no-audit", "--no-fund"], {
cwd: rootDir,
});
await execFileAsync("npm", ["run", "build-package"], {
cwd: rootDir,
});
// Update lockfiles in examples.
await Promise.all(
(await glob("examples/*/*/package.json", { absolute: true, cwd: rootDir }))
.map((examplePackageJsonPath) => path.dirname(examplePackageJsonPath))
.map(async (exampleDir: string) => {
await execFileAsync("pnpm", ["install"], {
cwd: exampleDir,
});
}),
);
await execFileAsync(
"git",
[
"add",
...(await glob("examples/*/*/pnpm-lock.yaml", {
absolute: false,
cwd: rootDir,
})),
],
{ cwd: rootDir },
);