@usecontextlayer/ctxb 0.2.10 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+ // Platform launcher — SHARED, GENERIC, PARAMETER-FREE. Byte-for-byte identical
3
+ // in every @usecontextlayer CLI package (ctxb, ctxe, ctxs, …). It derives its
4
+ // ENTIRE identity at runtime from its own package.json, so there is nothing in
5
+ // this file to edit per CLI. DO NOT add CLI-specific values here.
6
+ //
7
+ // ── Adding a new CLI `ctxX` ─────────────────────────────────────────────────
8
+ // 1. Copy this file VERBATIM to packages/<x>-cli/launcher/launcher.cjs.
9
+ // Do NOT rename or edit it. Preserve the executable bit: `chmod 0755`.
10
+ // 2. In packages/<x>-cli/package.json set:
11
+ // "bin": { "ctxX": "./launcher/launcher.cjs" }
12
+ // "files": ["launcher/launcher.cjs"]
13
+ // "optionalDependencies": {
14
+ // "@usecontextlayer/ctxX-darwin-arm64": "<this package's current version>",
15
+ // "@usecontextlayer/ctxX-linux-arm64": "<this package's current version>",
16
+ // "@usecontextlayer/ctxX-linux-x64": "<this package's current version>"
17
+ // }
18
+ // Pin each to a REAL x.y.z (copy this package's own `version` field) — not a
19
+ // literal placeholder. You don't maintain these afterward: `bun
20
+ // scripts/release.ts <version>` rewrites every @usecontextlayer/* pin in
21
+ // lockstep and auto-discovers the package. `scripts/check-workspace-
22
+ // references.ts` verifies the entries point at real workspace packages.
23
+ // 3. Done. From package.json `name` + `optionalDependencies` this file derives
24
+ // the CLI name, the supported platforms, the per-platform package, the
25
+ // `CTXX_BINARY` dev-override env var, and the resolved binary path.
26
+ //
27
+ // Resolution: spawns the compiled bun binary shipped inside the host's
28
+ // platform-binary package (an optionalDependency). `<CLI>_BINARY` (the
29
+ // uppercased CLI name) bypasses resolution for local dev / integration tests.
30
+ //
31
+ // CommonJS (.cjs) is required: the wrapper package.json carries "type":
32
+ // "module" for the dev workspace; .cjs forces CJS regardless. The require-based
33
+ // pattern (from Biome's launcher) loads faster than ESM-plus-createRequire.
34
+
35
+ const { spawnSync } = require("node:child_process")
36
+
37
+ const manifest = require("../package.json")
38
+ const name = manifest.name // @usecontextlayer/ctxb
39
+ const cli = name.slice(name.lastIndexOf("/") + 1) // ctxb
40
+ const prefix = `${name}-` // @usecontextlayer/ctxb-
41
+
42
+ // Supported platforms ARE the platform-binary optionalDependencies. Adding a
43
+ // platform = adding an optionalDependency; this file never changes for it.
44
+ const platforms = {}
45
+ for (const dep of Object.keys(manifest.optionalDependencies ?? {})) {
46
+ if (dep.startsWith(prefix)) platforms[dep.slice(prefix.length)] = dep
47
+ }
48
+
49
+ const key = `${process.platform}-${process.arch}`
50
+ const binaryFromEnv = process.env[`${cli.toUpperCase()}_BINARY`]
51
+ const pkg = platforms[key]
52
+
53
+ if (!binaryFromEnv && !pkg) {
54
+ console.error(
55
+ `${name}: unsupported platform ${key}. ` +
56
+ `Supported: ${Object.keys(platforms).join(", ")}. ` +
57
+ `Set ${cli.toUpperCase()}_BINARY to override.`,
58
+ )
59
+ process.exit(1)
60
+ }
61
+
62
+ let binary
63
+ try {
64
+ binary = binaryFromEnv ?? require.resolve(`${pkg}/bin/${cli}`)
65
+ } catch {
66
+ console.error(
67
+ `${name}: platform package ${pkg} is not installed. ` +
68
+ `If you used --omit=optional, re-run npm install with --include=optional.`,
69
+ )
70
+ process.exit(1)
71
+ }
72
+
73
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" })
74
+ if (result.signal) process.kill(process.pid, result.signal)
75
+ else process.exit(result.status ?? 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "bin": {
3
- "ctxb": "./launcher/ctxb.cjs"
3
+ "ctxb": "./launcher/launcher.cjs"
4
4
  },
5
5
  "devDependencies": {
6
6
  "@clack/prompts": "^1.4.0",
@@ -15,7 +15,7 @@
15
15
  "commander": "^14.0.3",
16
16
  "consola": "^3.4.2",
17
17
  "execa": "^9.6.1",
18
- "hono": "^4.12.21",
18
+ "hono": "^4.12.23",
19
19
  "nanostores": "^1.3.0",
20
20
  "postgres": "^3.4.9",
21
21
  "smol-toml": "^1.6.1",
@@ -23,13 +23,13 @@
23
23
  "zod": "^4.4.3"
24
24
  },
25
25
  "files": [
26
- "launcher/ctxb.cjs"
26
+ "launcher/launcher.cjs"
27
27
  ],
28
28
  "name": "@usecontextlayer/ctxb",
29
29
  "optionalDependencies": {
30
- "@usecontextlayer/ctxb-darwin-arm64": "0.2.10",
31
- "@usecontextlayer/ctxb-linux-arm64": "0.2.10",
32
- "@usecontextlayer/ctxb-linux-x64": "0.2.10"
30
+ "@usecontextlayer/ctxb-darwin-arm64": "0.2.12",
31
+ "@usecontextlayer/ctxb-linux-arm64": "0.2.12",
32
+ "@usecontextlayer/ctxb-linux-x64": "0.2.12"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "bun build ./cli.ts --compile --outfile ./bin/ctxb",
@@ -38,9 +38,8 @@
38
38
  "postbuild": "rm -f .*.bun-build",
39
39
  "prebuild": "rm -rf bin",
40
40
  "test": "npx vitest run --config vitest.config.ts",
41
- "test:integration": "npx vitest run --config vitest.integration.config.ts --passWithNoTests",
42
41
  "tsc": "npx tsc -b tsconfig.json"
43
42
  },
44
43
  "type": "module",
45
- "version": "0.2.10"
44
+ "version": "0.2.12"
46
45
  }
package/launcher/ctxb.cjs DELETED
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env node
2
- // Platform launcher for @usecontextlayer/ctxb. Resolves the host's
3
- // platform-binary package via optionalDependencies and spawns the compiled
4
- // bun binary inside it. The CTXB_BINARY env var bypasses resolution for local
5
- // development and integration tests.
6
- //
7
- // CommonJS (.cjs) is required because the wrapper package's package.json
8
- // carries "type": "module" for the dev workspace; .cjs forces CJS semantics
9
- // regardless. The spec's `require`-based pattern (from Biome's launcher)
10
- // loads faster than the ESM-plus-createRequire alternative.
11
-
12
- const { spawnSync } = require("node:child_process")
13
-
14
- const PLATFORMS = {
15
- "darwin-arm64": "@usecontextlayer/ctxb-darwin-arm64",
16
- "linux-arm64": "@usecontextlayer/ctxb-linux-arm64",
17
- "linux-x64": "@usecontextlayer/ctxb-linux-x64",
18
- }
19
-
20
- const key = `${process.platform}-${process.arch}`
21
- const binaryFromEnv = process.env.CTXB_BINARY
22
- const pkg = PLATFORMS[key]
23
-
24
- if (!binaryFromEnv && !pkg) {
25
- console.error(
26
- `@usecontextlayer/ctxb: unsupported platform ${key}. ` +
27
- `Supported: ${Object.keys(PLATFORMS).join(", ")}. ` +
28
- `Set CTXB_BINARY to override.`,
29
- )
30
- process.exit(1)
31
- }
32
-
33
- let binary
34
- try {
35
- binary = binaryFromEnv ?? require.resolve(`${pkg}/bin/ctxb`)
36
- } catch {
37
- console.error(
38
- `@usecontextlayer/ctxb: platform package ${pkg} is not installed. ` +
39
- `If you used --omit=optional, re-run npm install with --include=optional.`,
40
- )
41
- process.exit(1)
42
- }
43
-
44
- const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" })
45
- if (result.signal) process.kill(process.pid, result.signal)
46
- else process.exit(result.status ?? 1)