GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — opencode/script/publish-fork.ts at lenstr · lenstr/opencode

Expand file tree

/

publish-fork.ts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
63 lines (53 loc) · 2.3 KB
/

publish-fork.ts

Copy path

File metadata and controls

executable file
·
63 lines (53 loc) · 2.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env bun
import { $ } from "bun"
import { fileURLToPath } from "url"
const scope = "@lenstr"
const name = "lencode"
const targets = ["linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64"]
process.chdir(fileURLToPath(new URL("../packages/opencode", import.meta.url)))
console.log("=== building ===\n")
await $`bun run build`
// Collect binaries for target platforms
const deps: Record<string, string> = {}
let version = ""
for (const filepath of new Bun.Glob("*/package.json").scanSync({ cwd: "./dist" })) {
const p = await Bun.file(`./dist/${filepath}`).json()
if (!targets.some((t) => p.name.endsWith(t))) continue
const scoped = `${scope}/${p.name}`
version = p.version
deps[scoped] = version
p.name = scoped
await Bun.file(`./dist/${p.name.split("/")[1]}/package.json`).write(JSON.stringify(p, null, 2))
}
if (!version) {
console.error("No binaries built")
process.exit(1)
}
console.log("binaries:", deps, "\n")
// Publish platform binaries
for (const scoped of Object.keys(deps)) {
console.log(`publishing ${scoped}@${version}`)
await $`npm publish --access public --tag latest`.cwd(`./dist/${scoped.split("/")[1]}`)
}
// Build meta-package
await $`mkdir -p ./dist/meta/bin`
// Patch bin script to resolve @lenstr/ scoped packages instead of unscoped
const bin = (await Bun.file("./bin/opencode").text())
.replace('const base = "opencode-"', `const base = "${scope}/opencode-"`)
await Bun.file("./dist/meta/bin/opencode").write(bin)
await $`chmod +x ./dist/meta/bin/opencode`
const postinstall = (await Bun.file("./script/postinstall.mjs").text())
.replace("const packageName = `opencode-", `const packageName = \`${scope}/opencode-`)
await Bun.file("./dist/meta/postinstall.mjs").write(postinstall)
await Bun.file("./dist/meta/LICENSE").write(await Bun.file("../../LICENSE").text())
await Bun.file("./dist/meta/package.json").write(JSON.stringify({
name: `${scope}/${name}`,
version,
bin: { [name]: "./bin/opencode" },
scripts: { postinstall: "bun ./postinstall.mjs || node ./postinstall.mjs" },
license: (await Bun.file("./package.json").json()).license,
optionalDependencies: deps,
}, null, 2))
console.log(`\npublishing ${scope}/${name}@${version}`)
await $`npm publish --access public --tag latest`.cwd(`./dist/meta`)
console.log(`\n=== done ===\nInstall: bunx -y ${scope}/${name}`)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.