smithue-cli 0.8.0 → 0.9.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/dist/cli.js +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -4
- package/dist/portfile.d.ts.map +1 -1
- package/dist/portfile.js +18 -6
- package/dist/proc.d.ts +2 -0
- package/dist/proc.d.ts.map +1 -0
- package/dist/proc.js +21 -0
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -15,7 +15,7 @@ const program = new Command();
|
|
|
15
15
|
const require = createRequire(import.meta.url);
|
|
16
16
|
const { version: cliVersion } = require('../package.json');
|
|
17
17
|
program
|
|
18
|
-
.name('smithue')
|
|
18
|
+
.name('smithue-cli')
|
|
19
19
|
.description('CLI for SmithUE Unreal Engine plugin')
|
|
20
20
|
.version(cliVersion)
|
|
21
21
|
.option('--pid <pid>', 'target SmithUE instance by PID', parseInt)
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE5E,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,mBAAmB;IAMvC,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,CAAC,OAAO;YAID,SAAS;YAwBT,QAAQ;YAQR,OAAO;IAOrB,OAAO,CAAC,qBAAqB;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"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O,CAAC,mBAAmB;IAI3B,OAAO,CAAC,QAAQ;YAIF,KAAK;CAGpB"}
|
package/dist/client.js
CHANGED
|
@@ -47,7 +47,12 @@ export class SmithUEClient {
|
|
|
47
47
|
}, timeoutMs);
|
|
48
48
|
}
|
|
49
49
|
normalizeRequestError(err, command) {
|
|
50
|
-
const
|
|
50
|
+
const error = err;
|
|
51
|
+
// Check AbortError FIRST — AbortError can have any message including 'fetch failed'
|
|
52
|
+
if (error.name === 'AbortError') {
|
|
53
|
+
return new Error(`SmithUE plugin timed out. Command: ${command} (port: ${this.port})`);
|
|
54
|
+
}
|
|
55
|
+
const msg = error.message ?? '';
|
|
51
56
|
if (msg.includes('ECONNREFUSED') ||
|
|
52
57
|
msg.includes('fetch failed') ||
|
|
53
58
|
msg.includes('Failed to fetch') ||
|
|
@@ -55,9 +60,6 @@ export class SmithUEClient {
|
|
|
55
60
|
msg.includes('connect ECONNREFUSED')) {
|
|
56
61
|
return new Error(`SmithUE plugin unreachable at ${this.host}:${this.port}. Start UE Editor with SmithUE plugin enabled.`);
|
|
57
62
|
}
|
|
58
|
-
if (err.name === 'AbortError') {
|
|
59
|
-
return new Error(`SmithUE plugin timed out. Command: ${command} (port: ${this.port})`);
|
|
60
|
-
}
|
|
61
63
|
return err instanceof Error ? err : new Error(String(err));
|
|
62
64
|
}
|
|
63
65
|
async execute(command, params = {}) {
|
package/dist/portfile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfile.d.ts","sourceRoot":"","sources":["../src/portfile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"portfile.d.ts","sourceRoot":"","sources":["../src/portfile.ts"],"names":[],"mappings":"AASA,qBAAa,YAAa,SAAQ,KAAK;aAGnB,QAAQ,EAAE,MAAM;gBADhC,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM;CAKnC;AAMD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAMD,wBAAgB,cAAc,IAAI,MAAM,CASvC;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC,CAAC,CAuBrG;AA8CD,wBAAsB,YAAY,CAAC,IAAI,GAAE,YAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAmFnF"}
|
package/dist/portfile.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readdir, readFile, unlink } from 'fs/promises';
|
|
2
2
|
import { join } from 'path';
|
|
3
|
+
import { isProcessAlive } from './proc.js';
|
|
3
4
|
// ---------------------------------------------------------------------------
|
|
4
5
|
// Error class
|
|
5
6
|
// ---------------------------------------------------------------------------
|
|
@@ -45,23 +46,34 @@ export async function readPortfiles(dir) {
|
|
|
45
46
|
}
|
|
46
47
|
return portfiles;
|
|
47
48
|
}
|
|
48
|
-
async function checkLiveness(port, filePath) {
|
|
49
|
+
async function checkLiveness(port, filePath, pid) {
|
|
50
|
+
const timeoutMs = parseInt(process.env['SMITHUE_PROBE_TIMEOUT'] ?? '10000', 10);
|
|
49
51
|
try {
|
|
50
52
|
await fetch(`http://127.0.0.1:${port}/ready`, {
|
|
51
|
-
signal: AbortSignal.timeout(
|
|
53
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
52
54
|
});
|
|
53
55
|
// any HTTP response = server is alive (including 503 during startup)
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
|
-
catch {
|
|
57
|
-
|
|
58
|
+
catch (err) {
|
|
59
|
+
const error = err;
|
|
60
|
+
// Timeout means the editor may be busy running a long command.
|
|
61
|
+
// Keep the portfile and treat the instance as alive/busy.
|
|
62
|
+
if (error.name === 'AbortError') {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const processAlive = pid > 0 && isProcessAlive(pid);
|
|
66
|
+
if (processAlive) {
|
|
67
|
+
throw new SmithUEError(`SmithUE instance on port ${port} is unreachable, but process ${pid} is still running. Try again or restart the editor.`, 2);
|
|
68
|
+
}
|
|
69
|
+
// Connection-level failure is stale only when the owning process is dead.
|
|
58
70
|
try {
|
|
59
71
|
await unlink(filePath);
|
|
60
72
|
}
|
|
61
73
|
catch {
|
|
62
74
|
// best effort
|
|
63
75
|
}
|
|
64
|
-
throw new SmithUEError(`SmithUE instance on port ${port} is not responding. Stale portfile removed.`, 2);
|
|
76
|
+
throw new SmithUEError(`SmithUE instance on port ${port} is not responding and process ${pid} is dead. Stale portfile removed.`, 2);
|
|
65
77
|
}
|
|
66
78
|
}
|
|
67
79
|
// ---------------------------------------------------------------------------
|
|
@@ -122,7 +134,7 @@ export async function discoverPort(opts = {}) {
|
|
|
122
134
|
}
|
|
123
135
|
// 7. Single candidate — liveness check
|
|
124
136
|
const { file, data } = candidates[0];
|
|
125
|
-
await checkLiveness(data.port, file);
|
|
137
|
+
await checkLiveness(data.port, file, data.pid);
|
|
126
138
|
return {
|
|
127
139
|
port: data.port,
|
|
128
140
|
pid: data.pid,
|
package/dist/proc.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proc.d.ts","sourceRoot":"","sources":["../src/proc.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAqBnD"}
|
package/dist/proc.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function isProcessAlive(pid) {
|
|
2
|
+
if (pid <= 0) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
try {
|
|
6
|
+
process.kill(pid, 0);
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error && typeof error === 'object' && 'code' in error) {
|
|
11
|
+
const code = error.code;
|
|
12
|
+
if (code === 'EPERM') {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (code === 'ESRCH') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smithue-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/cli.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"commander": "^15.0.0"
|
|
24
24
|
},
|
|
25
|
-
"bin": {
|
|
26
|
-
"smithue-cli": "
|
|
27
|
-
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"smithue-cli": "dist/cli.js"
|
|
27
|
+
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": "\u003e=18"
|
|
30
30
|
},
|