@usecontextlayer/ctxs 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
- "ctxs": "./launcher/ctxs.cjs"
3
+ "ctxs": "./launcher/launcher.cjs"
4
4
  },
5
5
  "devDependencies": {
6
6
  "@usecontextlayer/shared": "*",
@@ -9,13 +9,13 @@
9
9
  "consola": "^3.4.2"
10
10
  },
11
11
  "files": [
12
- "launcher/ctxs.cjs"
12
+ "launcher/launcher.cjs"
13
13
  ],
14
14
  "name": "@usecontextlayer/ctxs",
15
15
  "optionalDependencies": {
16
- "@usecontextlayer/ctxs-darwin-arm64": "0.2.10",
17
- "@usecontextlayer/ctxs-linux-arm64": "0.2.10",
18
- "@usecontextlayer/ctxs-linux-x64": "0.2.10"
16
+ "@usecontextlayer/ctxs-darwin-arm64": "0.2.12",
17
+ "@usecontextlayer/ctxs-linux-arm64": "0.2.12",
18
+ "@usecontextlayer/ctxs-linux-x64": "0.2.12"
19
19
  },
20
20
  "scripts": {
21
21
  "build": "bun build ./cli.ts --compile --outfile ./bin/ctxs",
@@ -25,5 +25,5 @@
25
25
  "tsc": "npx tsc -b tsconfig.json"
26
26
  },
27
27
  "type": "module",
28
- "version": "0.2.10"
28
+ "version": "0.2.12"
29
29
  }
package/launcher/ctxs.cjs DELETED
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env node
2
- // Platform launcher for @usecontextlayer/ctxs. Mirror of the ctxb launcher in
3
- // packages/base-cli/launcher/ctxb.cjs — see that file for the rationale on
4
- // .cjs, CommonJS, and the require-based resolution pattern.
5
-
6
- const { spawnSync } = require("node:child_process")
7
-
8
- const PLATFORMS = {
9
- "darwin-arm64": "@usecontextlayer/ctxs-darwin-arm64",
10
- "linux-arm64": "@usecontextlayer/ctxs-linux-arm64",
11
- "linux-x64": "@usecontextlayer/ctxs-linux-x64",
12
- }
13
-
14
- const key = `${process.platform}-${process.arch}`
15
- const binaryFromEnv = process.env.CTXS_BINARY
16
- const pkg = PLATFORMS[key]
17
-
18
- if (!binaryFromEnv && !pkg) {
19
- console.error(
20
- `@usecontextlayer/ctxs: unsupported platform ${key}. ` +
21
- `Supported: ${Object.keys(PLATFORMS).join(", ")}. ` +
22
- `Set CTXS_BINARY to override.`,
23
- )
24
- process.exit(1)
25
- }
26
-
27
- let binary
28
- try {
29
- binary = binaryFromEnv ?? require.resolve(`${pkg}/bin/ctxs`)
30
- } catch {
31
- console.error(
32
- `@usecontextlayer/ctxs: platform package ${pkg} is not installed. ` +
33
- `If you used --omit=optional, re-run npm install with --include=optional.`,
34
- )
35
- process.exit(1)
36
- }
37
-
38
- const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" })
39
- if (result.signal) process.kill(process.pid, result.signal)
40
- else process.exit(result.status ?? 1)