@usecontextlayer/ctxb 0.2.1

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.
Files changed (2) hide show
  1. package/launcher/ctxb.cjs +46 -0
  2. package/package.json +46 -0
@@ -0,0 +1,46 @@
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)
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "bin": {
3
+ "ctxb": "./launcher/ctxb.cjs"
4
+ },
5
+ "devDependencies": {
6
+ "@clack/prompts": "^1.4.0",
7
+ "@hono/cli": "^0.1.10",
8
+ "@hono/zod-validator": "^0.8.0",
9
+ "@usecontextlayer/base-schemas": "*",
10
+ "@usecontextlayer/base-shared": "*",
11
+ "@usecontextlayer/pgx": "^0.3.0",
12
+ "@usecontextlayer/shared": "*",
13
+ "atomically": "^2.1.1",
14
+ "better-auth": "^1.6.11",
15
+ "commander": "^14.0.3",
16
+ "consola": "^3.4.2",
17
+ "execa": "^9.6.1",
18
+ "hono": "^4.12.19",
19
+ "nanostores": "^1.3.0",
20
+ "postgres": "^3.4.9",
21
+ "smol-toml": "^1.6.1",
22
+ "yaml": "^2.9.0",
23
+ "zod": "^4.4.3"
24
+ },
25
+ "files": [
26
+ "launcher/ctxb.cjs"
27
+ ],
28
+ "name": "@usecontextlayer/ctxb",
29
+ "optionalDependencies": {
30
+ "@usecontextlayer/ctxb-darwin-arm64": "0.2.1",
31
+ "@usecontextlayer/ctxb-linux-arm64": "0.2.1",
32
+ "@usecontextlayer/ctxb-linux-x64": "0.2.1"
33
+ },
34
+ "scripts": {
35
+ "build": "bun build ./cli.ts --compile --outfile ./bin/ctxb",
36
+ "clean": "rm -rf bin *.tsbuildinfo .*.bun-build",
37
+ "hono": "npx @hono/cli",
38
+ "postbuild": "rm -f .*.bun-build",
39
+ "prebuild": "rm -rf bin",
40
+ "test": "npx vitest run --config vitest.config.ts",
41
+ "test:integration": "npx vitest run --config vitest.integration.config.ts --passWithNoTests",
42
+ "tsc": "npx tsc -b tsconfig.json"
43
+ },
44
+ "type": "module",
45
+ "version": "0.2.1"
46
+ }