diff options
| author | Dax Raad <[email protected]> | 2025-10-14 14:34:19 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-10-14 14:35:04 -0400 |
| commit | 0c022ef39da2724255794484caf5090b2d30efc4 (patch) | |
| tree | e2403be1972384b598cfdf6074ce5d09e5f17fcd /packages/script | |
| parent | 717b5446331f8ff3034c0d35b95b832e92ffef49 (diff) | |
| download | opencode-0c022ef39da2724255794484caf5090b2d30efc4.tar.gz opencode-0c022ef39da2724255794484caf5090b2d30efc4.zip | |
ci: stuff
Diffstat (limited to 'packages/script')
| -rw-r--r-- | packages/script/package.json | 10 | ||||
| -rw-r--r-- | packages/script/src/index.ts | 35 | ||||
| -rw-r--r-- | packages/script/tsconfig.json | 8 |
3 files changed, 53 insertions, 0 deletions
diff --git a/packages/script/package.json b/packages/script/package.json new file mode 100644 index 000000000..2791305f3 --- /dev/null +++ b/packages/script/package.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json.schemastore.org/package", + "name": "@opencode-ai/script", + "devDependencies": { + "@types/bun": "catalog:" + }, + "exports": { + ".": "./src/index.ts" + } +} diff --git a/packages/script/src/index.ts b/packages/script/src/index.ts new file mode 100644 index 000000000..4237a76a2 --- /dev/null +++ b/packages/script/src/index.ts @@ -0,0 +1,35 @@ +import { $ } from "bun" + +if (process.versions.bun !== "1.3.0") { + throw new Error("This script requires [email protected]") +} + +const TAG = process.env["OPENCODE_TAG"] ?? (await $`git branch --show-current`.text().then((x) => x.trim())) +const IS_PREVIEW = TAG !== "latest" +const VERSION = await (async () => { + if (IS_PREVIEW) return `0.0.0-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` + const version = await fetch("https://registry.npmjs.org/opencode-ai/latest") + .then((res) => { + if (!res.ok) throw new Error(res.statusText) + return res.json() + }) + .then((data: any) => data.version) + const [major, minor, patch] = version.split(".").map((x: string) => Number(x) || 0) + const t = process.env["OPENCODE_BUMP"]?.toLowerCase() + if (t === "major") return `${major + 1}.0.0` + if (t === "minor") return `${major}.${minor + 1}.0` + return `${major}.${minor}.${patch + 1}` +})() + +export const Script = { + get tag() { + return TAG + }, + get version() { + return VERSION + }, + get preview() { + return IS_PREVIEW + }, +} +console.log(`opencode script`, JSON.stringify(Script, null, 2)) diff --git a/packages/script/tsconfig.json b/packages/script/tsconfig.json new file mode 100644 index 000000000..00ef12546 --- /dev/null +++ b/packages/script/tsconfig.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@tsconfig/bun/tsconfig.json", + "compilerOptions": { + "lib": ["ESNext", "DOM", "DOM.Iterable"], + "noUncheckedIndexedAccess": false + } +} |
