devchain-cli 0.1.0 → 0.1.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.
- package/package.json +3 -2
- package/scripts/postinstall.js +78 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devchain-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "AI driven development platform",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"files": [
|
|
40
40
|
"dist/**",
|
|
41
41
|
"prebuilds/**",
|
|
42
|
+
"scripts/postinstall.js",
|
|
42
43
|
"README.md",
|
|
43
44
|
"LICENSE"
|
|
44
45
|
],
|
|
@@ -101,5 +102,5 @@
|
|
|
101
102
|
"socket.io-client": "4.8.1",
|
|
102
103
|
"tailwind-merge": "3.3.1",
|
|
103
104
|
"zod": "^3.22.4"
|
|
104
|
-
}
|
|
105
|
+
}
|
|
105
106
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Postinstall verifier for native deps.
|
|
3
|
+
- Verifies better-sqlite3 can load.
|
|
4
|
+
- If not, attempts a rebuild.
|
|
5
|
+
- Provides actionable errors without failing install unless absolutely necessary.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/* eslint-disable no-console */
|
|
9
|
+
const { spawnSync } = require('child_process');
|
|
10
|
+
const { dirname } = require('path');
|
|
11
|
+
|
|
12
|
+
function tryLoad() {
|
|
13
|
+
try {
|
|
14
|
+
const Database = require('better-sqlite3');
|
|
15
|
+
const db = new Database(':memory:');
|
|
16
|
+
db.prepare('select 1').get();
|
|
17
|
+
return true;
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.warn('[devchain] better-sqlite3 failed to load:', String(e && e.message || e));
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function main() {
|
|
25
|
+
if (process.env.DEVCHAIN_SKIP_POSTINSTALL) {
|
|
26
|
+
console.log('[devchain] Skipping postinstall per DEVCHAIN_SKIP_POSTINSTALL');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (tryLoad()) {
|
|
31
|
+
console.log('[devchain] better-sqlite3 prebuild present.');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Prefer fetching upstream prebuilds for better-sqlite3
|
|
36
|
+
try {
|
|
37
|
+
const prebuildInstallBin = require.resolve('prebuild-install/bin.js');
|
|
38
|
+
const betterPkg = require.resolve('better-sqlite3/package.json');
|
|
39
|
+
const betterDir = dirname(betterPkg);
|
|
40
|
+
console.log('[devchain] Attempting to fetch better-sqlite3 prebuilds via prebuild-install...');
|
|
41
|
+
const pr = spawnSync(process.execPath, [prebuildInstallBin], {
|
|
42
|
+
stdio: 'inherit',
|
|
43
|
+
cwd: betterDir,
|
|
44
|
+
});
|
|
45
|
+
if (pr.status === 0 && tryLoad()) {
|
|
46
|
+
console.log('[devchain] better-sqlite3 prebuild installed.');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.warn('[devchain] prebuild-install not available or failed:', String(e && e.message || e));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log('[devchain] Attempting `npm rebuild better-sqlite3` to compile native binary...');
|
|
54
|
+
const res = spawnSync(process.env.npm_execpath || 'npm', ['rebuild', 'better-sqlite3'], {
|
|
55
|
+
stdio: 'inherit',
|
|
56
|
+
shell: process.platform === 'win32',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (res.status !== 0) {
|
|
60
|
+
console.warn('[devchain] Rebuild failed. You may need build tools (python3, make, C/C++ toolchain).');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!tryLoad()) {
|
|
64
|
+
const supported = (process.platform === 'linux' || process.platform === 'darwin') &&
|
|
65
|
+
(process.arch === 'x64' || process.arch === 'arm64');
|
|
66
|
+
console.error('[devchain] better-sqlite3 is not available. Devchain may not run without it.');
|
|
67
|
+
if (!supported) {
|
|
68
|
+
console.error(`[devchain] Unsupported platform/arch for prebuilds: ${process.platform}-${process.arch}.`);
|
|
69
|
+
console.error('Please use a supported platform (linux/darwin x64/arm64) or install build tools to compile from source.');
|
|
70
|
+
} else {
|
|
71
|
+
console.error('If you lack compilers, ensure your platform is supported by better-sqlite3 prebuilds or install build tools.');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
main().catch((e) => {
|
|
77
|
+
console.error('[devchain] postinstall error:', e);
|
|
78
|
+
});
|