@elaraai/east-c-cli 1.0.42 → 1.0.43

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/bin/east-c.mjs +65 -0
  2. package/package.json +11 -7
package/bin/east-c.mjs ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Copyright (c) 2025 Elara AI Pty Ltd
4
+ * Licensed under BSL 1.1. See LICENSE.md for details.
5
+ */
6
+
7
+ /**
8
+ * Launcher for the native east-c binary.
9
+ *
10
+ * Resolves the per-platform package (`@elaraai/east-c-cli-<os>-<cpu>`, pulled
11
+ * in as an optionalDependency gated on os/cpu) and execs the binary it ships,
12
+ * forwarding argv, stdio and the exit code.
13
+ *
14
+ * The launcher — not the per-platform packages — owns the `east-c` bin, because
15
+ * npm does not reliably create `node_modules/.bin/east-c` for a bin that comes
16
+ * from an optionalDependency. A direct dependency's bin is always linked, so
17
+ * `.bin/east-c` exists after a plain `npm install`. (Same reason esbuild, turbo
18
+ * and Biome ship a launcher rather than relying on the platform package's bin.)
19
+ */
20
+
21
+ import { createRequire } from 'node:module';
22
+ import { dirname, join } from 'node:path';
23
+ import { spawnSync } from 'node:child_process';
24
+
25
+ const require = createRequire(import.meta.url);
26
+
27
+ // process.platform-process.arch -> published per-platform package suffix.
28
+ const TARGETS = new Set(['linux-x64', 'linux-arm64', 'darwin-arm64', 'darwin-x64', 'win32-x64']);
29
+
30
+ const key = `${process.platform}-${process.arch}`;
31
+ if (!TARGETS.has(key)) {
32
+ console.error(
33
+ `east-c: no prebuilt binary for ${key}. Supported platforms: ${[...TARGETS].join(', ')}.`,
34
+ );
35
+ process.exit(1);
36
+ }
37
+
38
+ const pkg = `@elaraai/east-c-cli-${key}`;
39
+ const exeName = process.platform === 'win32' ? 'east-c.exe' : 'east-c';
40
+
41
+ let binPath;
42
+ try {
43
+ // Resolve the package's manifest (always resolvable) and take the binary
44
+ // sibling — the extensionless binary itself is not a resolvable specifier.
45
+ binPath = join(dirname(require.resolve(`${pkg}/package.json`)), exeName);
46
+ } catch {
47
+ console.error(
48
+ `east-c: the platform package ${pkg} is not installed.\n` +
49
+ `It should install automatically as an optionalDependency of @elaraai/east-c-cli.\n` +
50
+ `Reinstall it with: npm install ${pkg} (or: npm rebuild ${pkg})`,
51
+ );
52
+ process.exit(1);
53
+ }
54
+
55
+ const result = spawnSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
56
+ if (result.error) {
57
+ console.error(`east-c: failed to run ${binPath}: ${result.error.message}`);
58
+ process.exit(1);
59
+ }
60
+ // Re-raise a terminating signal so callers see the real cause; otherwise
61
+ // propagate the child's exit code.
62
+ if (result.signal) {
63
+ process.kill(process.pid, result.signal);
64
+ }
65
+ process.exit(result.status ?? 1);
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@elaraai/east-c-cli",
3
- "version": "1.0.42",
4
- "description": "Pulls in the native east-c binary for your platform via optional dependencies. The matching per-platform package (@elaraai/east-c-cli-<target>) provides the `east-c` bin directly.",
3
+ "version": "1.0.43",
4
+ "description": "Provides the `east-c` bin. A tiny launcher resolves the native binary for your platform from the matching per-platform package (@elaraai/east-c-cli-<target>), pulled in via optional dependencies.",
5
+ "bin": {
6
+ "east-c": "bin/east-c.mjs"
7
+ },
5
8
  "files": [
9
+ "bin",
6
10
  "README.md",
7
11
  "LICENSE.md",
8
12
  "CONTRIBUTING.md",
@@ -28,11 +32,11 @@
28
32
  "node": ">=18.0.0"
29
33
  },
30
34
  "optionalDependencies": {
31
- "@elaraai/east-c-cli-linux-x64": "1.0.42",
32
- "@elaraai/east-c-cli-linux-arm64": "1.0.42",
33
- "@elaraai/east-c-cli-darwin-arm64": "1.0.42",
34
- "@elaraai/east-c-cli-darwin-x64": "1.0.42",
35
- "@elaraai/east-c-cli-win32-x64": "1.0.42"
35
+ "@elaraai/east-c-cli-linux-x64": "1.0.43",
36
+ "@elaraai/east-c-cli-linux-arm64": "1.0.43",
37
+ "@elaraai/east-c-cli-darwin-arm64": "1.0.43",
38
+ "@elaraai/east-c-cli-darwin-x64": "1.0.43",
39
+ "@elaraai/east-c-cli-win32-x64": "1.0.43"
36
40
  },
37
41
  "scripts": {}
38
42
  }