-
Notifications
You must be signed in to change notification settings - Fork 425
Expand file tree
/
Copy pathbump.js
More file actions
57 lines (51 loc) · 1.66 KB
/
Copy pathbump.js
File metadata and controls
57 lines (51 loc) · 1.66 KB
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
import { exec, spawnSync } from "child_process";
import { defineCommand, runMain } from "citty";
import fs from "fs/promises";
import { globSync } from "tinyglobby";
import { promisify } from "util";
const command = defineCommand({
args: {
vinxi: {
description: "Bump vinxi packages to latest version",
},
},
async run({ args }) {
const extPackageNames = ["solid-js"];
if (args.vinxi) {
extPackageNames.push(
...[
"vinxi",
"@vinxi/plugin-directives",
"@vinxi/server-components",
"@vinxi/server-functions",
"@vinxi/plugin-mdx",
],
);
}
const execAsync = promisify(exec);
const packages = await Promise.all(
extPackageNames.map(async name => {
const proc = await execAsync(`npm view ${name} version`);
return { name, version: proc.stdout.toString().trim() };
}),
);
await Promise.all(
globSync(["package.json", "packages/*/package.json", "examples/*/package.json"]).map(
async path => {
const packageJson = JSON.parse(await fs.readFile(path));
let deps = packages;
for (const dep of deps) {
packageJson.dependencies?.[dep.name] &&
(packageJson.dependencies[dep.name] = `^${dep.version}`);
packageJson.devDependencies?.[dep.name] &&
(packageJson.devDependencies[dep.name] = `^${dep.version}`);
}
await fs.writeFile(path, JSON.stringify(packageJson, null, 2) + "\n");
},
),
);
console.log("Updating lock file...\n");
spawnSync("pnpm i", { shell: true, stdio: "inherit" });
},
});
runMain(command);