|
2 | 2 |
|
3 | 3 | import { $ } from "bun" |
4 | 4 |
|
| 5 | +console.log("=== publishing ===\n") |
| 6 | + |
5 | 7 | const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true" |
6 | 8 | const version = snapshot |
7 | 9 | ? `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` |
@@ -10,24 +12,29 @@ if (!version) { |
10 | 12 | throw new Error("OPENCODE_VERSION is required") |
11 | 13 | } |
12 | 14 | process.env["OPENCODE_VERSION"] = version |
| 15 | +console.log("version:", version) |
13 | 16 |
|
14 | 17 | const pkgjsons = await Array.fromAsync( |
15 | 18 | new Bun.Glob("**/package.json").scan({ |
16 | 19 | absolute: true, |
17 | 20 | }), |
18 | | -) |
| 21 | +).then((arr) => arr.filter((x) => !x.includes("node_modules") && !x.includes("dist"))) |
19 | 22 |
|
20 | 23 | const tree = await $`git add . && git write-tree`.text().then((x) => x.trim()) |
21 | | -for await (const file of new Bun.Glob("**/package.json").scan({ |
22 | | - absolute: true, |
23 | | -})) { |
| 24 | +for (const file of pkgjsons) { |
24 | 25 | let pkg = await Bun.file(file).text() |
25 | 26 | pkg = pkg.replaceAll(/"version": "[^"]+"/g, `"version": "${version}"`) |
| 27 | + console.log("updated:", file) |
26 | 28 | await Bun.file(file).write(pkg) |
27 | 29 | } |
28 | 30 |
|
29 | | -await import(`../packages/opencode/script/publish.ts`) |
| 31 | +console.log("\n=== opencode ===\n") |
| 32 | +// await import(`../packages/opencode/script/publish.ts`) |
| 33 | + |
| 34 | +console.log("\n=== sdk ===\n") |
30 | 35 | await import(`../packages/sdk/js/script/publish.ts`) |
| 36 | + |
| 37 | +console.log("\n=== plugin ===\n") |
31 | 38 | await import(`../packages/plugin/script/publish.ts`) |
32 | 39 | // await import(`../packages/sdk/stainless/generate.ts`) |
33 | 40 |
|
@@ -43,9 +50,7 @@ if (snapshot) { |
43 | 50 | await $`git push origin v${version} --no-verify` |
44 | 51 | await $`git checkout dev` |
45 | 52 | await $`git branch -D snapshot-${version}` |
46 | | - for await (const file of new Bun.Glob("**/package.json").scan({ |
47 | | - absolute: true, |
48 | | - })) { |
49 | | - $`await git checkout ${tree} ${file}` |
| 53 | + for (const file of pkgjsons) { |
| 54 | + await $`git checkout ${tree} ${file}` |
50 | 55 | } |
51 | 56 | } |