Skip to content

Commit e63945f

Browse files
authored
Merge pull request #21 from 0xranx/fix/linux_native_bindings
feat: add CLI smoke test workflow and improve error handling in nativ…
2 parents e6ddad1 + f20905b commit e63945f

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

.github/workflows/cli-smoke.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CLI smoke test (no publish)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
linux-cli-smoke:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
13+
- name: Setup Node.js
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: "22"
17+
18+
- name: Install dependencies
19+
run: npm install
20+
21+
- name: Install CLI from repo (no publish)
22+
run: npm install -g .
23+
24+
- name: CLI help
25+
run: oc --help
26+
27+
- name: CLI init (expected to pass; if it fails, we capture logs)
28+
run: oc init

src/core/native.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const path = require('path');
1313

1414
let native = null;
1515
let nativeError = null;
16+
let npmError = null;
17+
let localError = null;
1618
let initialized = false;
1719
let loadedFrom = null;
1820

@@ -29,6 +31,7 @@ function loadNative() {
2931
loadedFrom = 'npm';
3032
return;
3133
} catch (e) {
34+
npmError = e;
3235
// Not installed via npm, try local
3336
}
3437

@@ -38,6 +41,7 @@ function loadNative() {
3841
native = require(nativePath);
3942
loadedFrom = 'local';
4043
} catch (e) {
44+
localError = e;
4145
nativeError = e;
4246
}
4347
}
@@ -72,7 +76,9 @@ function get() {
7276
`OpenContext native bindings not available.\n` +
7377
` If installed via npm: try reinstalling the package\n` +
7478
` If developing locally: cd crates/opencontext-node && npm run build\n` +
75-
`Error: ${nativeError?.message || 'unknown'}`
79+
` If optional deps were skipped: npm install -g @aicontextlab/cli --include=optional\n` +
80+
`Error (npm): ${npmError?.message || 'unknown'}\n` +
81+
`Error (local): ${localError?.message || 'unknown'}`
7682
);
7783
}
7884
return native;
@@ -88,7 +94,9 @@ function require_() {
8894
`OpenContext native bindings not available.\n` +
8995
` If installed via npm: try reinstalling the package\n` +
9096
` If developing locally: cd crates/opencontext-node && npm run build\n` +
91-
`Error: ${nativeError?.message || 'unknown'}`
97+
` If optional deps were skipped: npm install -g @aicontextlab/cli --include=optional\n` +
98+
`Error (npm): ${npmError?.message || 'unknown'}\n` +
99+
`Error (local): ${localError?.message || 'unknown'}`
92100
);
93101
}
94102
}

0 commit comments

Comments
 (0)