@orkestrel/sea 0.0.8 → 0.0.9
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.
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
3
|
let node_zlib = require("node:zlib");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
|
-
let
|
|
5
|
+
let _orkestrel_process_server = require("@orkestrel/process/server");
|
|
6
6
|
let node_crypto = require("node:crypto");
|
|
7
7
|
let _orkestrel_emitter = require("@orkestrel/emitter");
|
|
8
8
|
let node_sea = require("node:sea");
|
|
@@ -313,33 +313,21 @@ function runShell(command, options) {
|
|
|
313
313
|
const [cmd, ...args] = command;
|
|
314
314
|
if (cmd === void 0) throw new SEAError("STATE", "Command array must not be empty");
|
|
315
315
|
if (options?.signal?.aborted === true) throw new SEAError("ABORT", "Shell command aborted", { command: redactCommand(command) });
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
});
|
|
332
|
-
} catch (thrown) {
|
|
333
|
-
if (!(thrown instanceof Error)) throw thrown;
|
|
334
|
-
const redacted = redactCommand(command);
|
|
335
|
-
if (("code" in thrown && typeof thrown.code === "string" ? thrown.code : void 0) === "ETIMEDOUT") throw new SEAError("TIMEOUT", "Shell command timed out", {
|
|
336
|
-
command: redacted,
|
|
337
|
-
timeout: options?.timeout
|
|
338
|
-
});
|
|
339
|
-
const stdout = "stdout" in thrown && Buffer.isBuffer(thrown.stdout) ? thrown.stdout : Buffer.alloc(0);
|
|
340
|
-
const stderr = "stderr" in thrown && Buffer.isBuffer(thrown.stderr) ? thrown.stderr : Buffer.alloc(0);
|
|
341
|
-
throw new ShellError("Command failed: " + redacted.join(" "), stdout, stderr);
|
|
342
|
-
}
|
|
316
|
+
const result = (0, _orkestrel_process_server.runSync)({
|
|
317
|
+
file: cmd,
|
|
318
|
+
arguments: args,
|
|
319
|
+
...options?.env !== void 0 ? { environment: options.env } : {}
|
|
320
|
+
}, {
|
|
321
|
+
...options?.cwd !== void 0 ? { workspace: options.cwd } : {},
|
|
322
|
+
...options?.timeout !== void 0 ? { timeout: options.timeout } : {},
|
|
323
|
+
strict: false
|
|
324
|
+
});
|
|
325
|
+
if (result.expired) throw new SEAError("TIMEOUT", "Shell command timed out", {
|
|
326
|
+
command: redactCommand(command),
|
|
327
|
+
timeout: options?.timeout
|
|
328
|
+
});
|
|
329
|
+
if (result.failed) throw new ShellError("Command failed: " + redactCommand(command).join(" "), Buffer.from(result.stdout, "utf-8"), Buffer.from(result.stderr, "utf-8"));
|
|
330
|
+
return Buffer.from(result.stdout, "utf-8");
|
|
343
331
|
}
|
|
344
332
|
/**
|
|
345
333
|
* Compute a size comparison between original and compressed byte counts.
|
|
@@ -969,13 +957,14 @@ function patchSentinelFuse(executable, fuse) {
|
|
|
969
957
|
* A best-effort launch for bundled local-UI apps: dispatches by
|
|
970
958
|
* `process.platform` (`win32` -> `rundll32 url.dll,FileProtocolHandler`,
|
|
971
959
|
* `darwin` -> `open`, else -> `xdg-open`), each invoked with an argv array
|
|
972
|
-
* (never a shell) so the URL cannot be
|
|
973
|
-
*
|
|
974
|
-
*
|
|
975
|
-
*
|
|
976
|
-
*
|
|
977
|
-
*
|
|
978
|
-
*
|
|
960
|
+
* through `@orkestrel/process`'s `detach` (never a shell) so the URL cannot be
|
|
961
|
+
* interpreted as a flag or injected into a command line. `detach` spawns the
|
|
962
|
+
* child detached, with its stdio discarded and unreferenced, so the opener
|
|
963
|
+
* outlives the host app and never keeps it alive, and it swallows the async
|
|
964
|
+
* host fault an absent opener binary raises. Only `http:` and `https:` URLs
|
|
965
|
+
* are accepted — any other scheme (including a string that merely looks like a
|
|
966
|
+
* CLI flag, e.g. `'-e ...'`) fails to parse as an http(s) URL and is rejected
|
|
967
|
+
* before anything is spawned.
|
|
979
968
|
*
|
|
980
969
|
* @param url - Absolute http or https URL to open
|
|
981
970
|
* @throws SEAError with code `'BROWSER'` when `url` is not a parseable absolute URL
|
|
@@ -997,18 +986,17 @@ function openBrowser(url) {
|
|
|
997
986
|
url,
|
|
998
987
|
protocol: parsed.protocol
|
|
999
988
|
});
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
child.unref();
|
|
989
|
+
const command = process.platform === "win32" ? {
|
|
990
|
+
file: "rundll32",
|
|
991
|
+
arguments: ["url.dll,FileProtocolHandler", parsed.href]
|
|
992
|
+
} : process.platform === "darwin" ? {
|
|
993
|
+
file: "open",
|
|
994
|
+
arguments: [parsed.href]
|
|
995
|
+
} : {
|
|
996
|
+
file: "xdg-open",
|
|
997
|
+
arguments: [parsed.href]
|
|
998
|
+
};
|
|
999
|
+
(0, _orkestrel_process_server.detach)(command);
|
|
1012
1000
|
}
|
|
1013
1001
|
//#endregion
|
|
1014
1002
|
//#region src/server/injectors/Injector.ts
|