work-agent 0.1.0 → 0.1.2
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/postinstall.js +11 -8
- package/bin/work-agent.js +24 -7
- package/package.json +1 -1
package/bin/postinstall.js
CHANGED
|
@@ -41,11 +41,15 @@ if (major < 18) {
|
|
|
41
41
|
if (!fs.existsSync(STANDALONE_SERVER)) {
|
|
42
42
|
console.log('\n[work-agent] Building the app (first install, this may take a minute)...\n');
|
|
43
43
|
|
|
44
|
-
const buildResult = spawnSync(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
const buildResult = spawnSync(
|
|
45
|
+
process.platform === 'win32' ? 'npm.cmd' : 'npm',
|
|
46
|
+
['run', 'build'],
|
|
47
|
+
{
|
|
48
|
+
cwd: PKG_ROOT,
|
|
49
|
+
stdio: 'inherit',
|
|
50
|
+
shell: false,
|
|
51
|
+
}
|
|
52
|
+
);
|
|
49
53
|
|
|
50
54
|
if (buildResult.status !== 0) {
|
|
51
55
|
console.error('\n[work-agent] Build failed. Retry manually:\n');
|
|
@@ -66,15 +70,14 @@ if (fs.existsSync(BSQL3_NODE)) {
|
|
|
66
70
|
console.log('[work-agent] Rebuilding better-sqlite3 for current Node.js version...');
|
|
67
71
|
|
|
68
72
|
const rebuildResult = spawnSync(
|
|
69
|
-
'npm',
|
|
73
|
+
process.platform === 'win32' ? 'npm.cmd' : 'npm',
|
|
70
74
|
['rebuild', 'better-sqlite3'],
|
|
71
75
|
{
|
|
72
76
|
cwd: STANDALONE_DIR,
|
|
73
77
|
stdio: 'inherit',
|
|
74
|
-
shell:
|
|
78
|
+
shell: false,
|
|
75
79
|
env: {
|
|
76
80
|
...process.env,
|
|
77
|
-
// 防止 npm rebuild 触发其他包的 postinstall
|
|
78
81
|
npm_lifecycle_event: 'rebuild',
|
|
79
82
|
},
|
|
80
83
|
}
|
package/bin/work-agent.js
CHANGED
|
@@ -20,12 +20,29 @@ const BSQL3_NODE = path.join(BSQL3_DIR, 'build', 'Release', 'better_sqlite3.node
|
|
|
20
20
|
const PORT = parseInt(process.env.PORT || '11024', 10);
|
|
21
21
|
const HOST = process.env.HOST || '0.0.0.0';
|
|
22
22
|
|
|
23
|
-
// ──
|
|
23
|
+
// ── 检查构建产物是否存在,没有则自动 build ────────────────────────────────────
|
|
24
24
|
if (!fs.existsSync(STANDALONE_SERVER)) {
|
|
25
|
-
console.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
console.log('\n[work-agent] No build found. Building the app (this takes 1-2 minutes on first run)...\n');
|
|
26
|
+
|
|
27
|
+
const buildResult = spawnSync(
|
|
28
|
+
process.platform === 'win32' ? 'npm.cmd' : 'npm',
|
|
29
|
+
['run', 'build'],
|
|
30
|
+
{
|
|
31
|
+
cwd: PKG_ROOT,
|
|
32
|
+
stdio: 'inherit',
|
|
33
|
+
shell: false,
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
if (buildResult.status !== 0) {
|
|
38
|
+
console.error('\n[work-agent] Build failed. Please check the errors above.');
|
|
39
|
+
console.error('You can also build manually:\n');
|
|
40
|
+
console.error(' cd ' + PKG_ROOT);
|
|
41
|
+
console.error(' npm run build\n');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log('\n[work-agent] Build complete.\n');
|
|
29
46
|
}
|
|
30
47
|
|
|
31
48
|
// ── 检查并修复 better-sqlite3 ABI 兼容性 ─────────────────────────────────────
|
|
@@ -91,12 +108,12 @@ function checkAndRebuild() {
|
|
|
91
108
|
console.log('[work-agent] Rebuilding native module (this takes ~10 seconds)...\n');
|
|
92
109
|
|
|
93
110
|
const result = spawnSync(
|
|
94
|
-
'npm',
|
|
111
|
+
process.platform === 'win32' ? 'npm.cmd' : 'npm',
|
|
95
112
|
['rebuild', 'better-sqlite3'],
|
|
96
113
|
{
|
|
97
114
|
cwd: STANDALONE_DIR,
|
|
98
115
|
stdio: 'inherit',
|
|
99
|
-
shell:
|
|
116
|
+
shell: false,
|
|
100
117
|
}
|
|
101
118
|
);
|
|
102
119
|
|