@gradial/aci 0.1.33 → 0.1.34

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.
package/bin/aci.js CHANGED
@@ -23,7 +23,7 @@ const platformKey = `${process.platform}-${process.arch}`;
23
23
  const packageName = platformPackages[platformKey];
24
24
 
25
25
  if (!packageName) {
26
- console.error(`Unsupported platform for gradial-aci: ${platformKey}`);
26
+ console.error(`Unsupported platform for aci: ${platformKey}`);
27
27
  process.exit(1);
28
28
  }
29
29
 
@@ -36,57 +36,86 @@ if (argv[0] === 'init') {
36
36
  process.exit(0);
37
37
  }
38
38
 
39
- function resolveBundledBinary() {
40
- const binaryPath = join(shimDir, `aci-${platformKey}${process.platform === 'win32' ? '.exe' : ''}`);
41
- if (existsSync(binaryPath)) return binaryPath;
42
- // Local development fallback for packages built before platform-suffixed bins.
43
- const legacyPath = join(shimDir, binName);
44
- return existsSync(legacyPath) ? legacyPath : null;
45
- }
39
+ // ── Binary resolution ──────────────────────────────────────────────
40
+ //
41
+ // Resolution order (no fallback chain — exactly one path wins):
42
+ //
43
+ // 1. ACI_CLI_BIN env var — explicit override for debugging / CI.
44
+ // 2. Platform npm package — the published distribution channel.
45
+ // Resolved via require.resolve('$packageName/package.json').
46
+ // 3. Monorepo workspace — for local development inside this repo.
47
+ // Looks at packages/cli-<platform>/bin/<binary>.
48
+ // 4. `go run` dev fallback — when working on the Go CLI source
49
+ // inside this monorepo and no binary has been built yet.
50
+
51
+ function resolveBinary() {
52
+ // 1. Explicit override
53
+ const envBin = process.env.ACI_CLI_BIN;
54
+ if (envBin) {
55
+ if (!existsSync(envBin)) {
56
+ console.error(`ACI_CLI_BIN points to ${envBin} but it does not exist.`);
57
+ process.exit(1);
58
+ }
59
+ return { kind: 'binary', path: envBin };
60
+ }
46
61
 
47
- function resolvePackagedBinary() {
62
+ // 2. Platform npm package (installed via optionalDependencies)
48
63
  try {
49
64
  const packageJsonPath = require.resolve(`${packageName}/package.json`);
50
65
  const binaryPath = join(dirname(packageJsonPath), 'bin', binName);
51
-
52
- return existsSync(binaryPath) ? binaryPath : null;
66
+ if (existsSync(binaryPath)) {
67
+ return { kind: 'binary', path: binaryPath };
68
+ }
53
69
  } catch {
54
- return null;
70
+ // Not installed — continue
55
71
  }
56
- }
57
72
 
58
- function resolveWorkspaceBinary() {
59
- const binaryPath = resolve(repoRoot, 'packages', `cli-${platformKey}`, 'bin', binName);
73
+ // 3. Monorepo workspace (local dev: binary built by ./scripts/build-cli.sh)
74
+ const workspaceBin = resolve(repoRoot, 'packages', `cli-${platformKey}`, 'bin', binName);
75
+ if (existsSync(workspaceBin)) {
76
+ return { kind: 'binary', path: workspaceBin };
77
+ }
60
78
 
61
- return existsSync(binaryPath) ? binaryPath : null;
62
- }
79
+ // 4. Go run fallback (monorepo dev without a built binary)
80
+ const goModPath = join(repoRoot, 'go.mod');
81
+ const commandDir = join(repoRoot, 'cmd', 'aci');
82
+ if (existsSync(goModPath) && existsSync(commandDir)) {
83
+ return {
84
+ kind: 'go-run',
85
+ command: 'go',
86
+ args: ['run', './cmd/aci', ...normalizeArgsForGoFallback(argv)],
87
+ cwd: repoRoot,
88
+ };
89
+ }
63
90
 
64
- const binaryPath = resolveBundledBinary() ?? resolvePackagedBinary() ?? resolveWorkspaceBinary();
65
- if (binaryPath) {
66
- try { chmodSync(binaryPath, 0o755); } catch {}
91
+ return null;
67
92
  }
68
- const fallback = binaryPath ? null : resolveGoFallback();
69
93
 
70
- if (!binaryPath && !fallback) {
94
+ const resolved = resolveBinary();
95
+
96
+ if (!resolved) {
71
97
  console.error(
72
- [
73
- `Could not find the aci binary for ${platformKey}.`,
74
- `Install ${packageName} or build the local CLI package with ./scripts/build-cli.sh.`,
75
- ].join(' '),
98
+ `Platform package ${packageName} is not installed.\n` +
99
+ `Install it with: npm install ${packageName}\n` +
100
+ `Or, if using the @gradial/aci SDK, ensure optionalDependencies resolved for your platform.`,
76
101
  );
77
102
  process.exit(1);
78
103
  }
79
104
 
80
- const child = binaryPath
81
- ? spawn(binaryPath, argv, {
105
+ if (resolved.kind === 'binary') {
106
+ try { chmodSync(resolved.path, 0o755); } catch {}
107
+ }
108
+
109
+ const child = resolved.kind === 'binary'
110
+ ? spawn(resolved.path, argv, {
82
111
  env: {
83
112
  ...process.env,
84
113
  ACI_PACKAGE_ROOT: resolve(shimDir, '..'),
85
114
  },
86
115
  stdio: 'inherit',
87
116
  })
88
- : spawn(fallback.command, fallback.args, {
89
- cwd: fallback.cwd,
117
+ : spawn(resolved.command, resolved.args, {
118
+ cwd: resolved.cwd,
90
119
  env: {
91
120
  ...process.env,
92
121
  ACI_PACKAGE_ROOT: resolve(shimDir, '..'),
@@ -95,7 +124,7 @@ const child = binaryPath
95
124
  });
96
125
 
97
126
  child.on('error', (error) => {
98
- console.error(`Failed to run gradial-aci: ${error.message}`);
127
+ console.error(`Failed to run aci: ${error.message}`);
99
128
  process.exit(1);
100
129
  });
101
130
 
@@ -108,21 +137,6 @@ child.on('exit', (code, signal) => {
108
137
  process.exit(code ?? 1);
109
138
  });
110
139
 
111
- function resolveGoFallback() {
112
- const goModPath = join(repoRoot, 'go.mod');
113
- const commandDir = join(repoRoot, 'cmd', 'aci');
114
-
115
- if (!existsSync(goModPath) || !existsSync(commandDir)) {
116
- return null;
117
- }
118
-
119
- return {
120
- command: 'go',
121
- args: ['run', './cmd/aci', ...normalizeArgsForGoFallback(argv)],
122
- cwd: repoRoot,
123
- };
124
- }
125
-
126
140
  function normalizeArgsForGoFallback(args) {
127
141
  const pathFlags = new Set(['-s', '--site-dir', '--content', '--out']);
128
142
  const normalized = [];
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@gradial/aci",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "files": [
8
8
  "dist",
9
9
  "bin/aci.js",
10
- "bin/aci-*",
11
10
  "src/cli/*.mjs",
12
11
  "src/types/*.ts",
13
12
  "templates/common",
@@ -95,7 +94,7 @@
95
94
  "build:cli": "cd ../.. && ./scripts/build-cli.sh",
96
95
  "generate-starters": "cd ../.. && tsx scripts/generate-starters.ts",
97
96
  "compile-registry": "tsx src/cli/compile-registry.mjs",
98
- "prepack": "npm run generate-starters && npm run build && npm run build:cli && node scripts/ensure-bin-modes.mjs"
97
+ "prepack": "npm run generate-starters && npm run build && node scripts/ensure-bin-modes.mjs"
99
98
  },
100
99
  "dependencies": {
101
100
  "markdown-it": "^14.1.0",
@@ -134,5 +133,13 @@
134
133
  "tsx": "^4.20.0",
135
134
  "typescript": "^5.9.3",
136
135
  "zod": "^4.0.0"
136
+ },
137
+ "optionalDependencies": {
138
+ "@gradial/aci-cli-darwin-arm64": "0.1.34",
139
+ "@gradial/aci-cli-darwin-x64": "0.1.34",
140
+ "@gradial/aci-cli-linux-arm64": "0.1.34",
141
+ "@gradial/aci-cli-linux-x64": "0.1.34",
142
+ "@gradial/aci-cli-win32-arm64": "0.1.34",
143
+ "@gradial/aci-cli-win32-x64": "0.1.34"
137
144
  }
138
145
  }
Binary file