@proagentstore/cli 0.4.111 → 0.4.113
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/index.js +70 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1107,7 +1107,7 @@ import { Command as Command7 } from "commander";
|
|
|
1107
1107
|
// src/commands/runner/process.ts
|
|
1108
1108
|
import { spawn as spawn2 } from "child_process";
|
|
1109
1109
|
import { existsSync as existsSync6 } from "fs";
|
|
1110
|
-
import { resolve as resolve4 } from "path";
|
|
1110
|
+
import { resolve as resolve4, win32 } from "path";
|
|
1111
1111
|
import { createServer as createServer2 } from "net";
|
|
1112
1112
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1113
1113
|
import { createRequire } from "module";
|
|
@@ -1156,6 +1156,9 @@ function runsFromSource() {
|
|
|
1156
1156
|
function bundledRunnerPath() {
|
|
1157
1157
|
return fileURLToPath2(new URL("./browser-runner/index.js", import.meta.url));
|
|
1158
1158
|
}
|
|
1159
|
+
function spawnNeedsShell(command, platform = process.platform) {
|
|
1160
|
+
return platform === "win32" && !win32.isAbsolute(command);
|
|
1161
|
+
}
|
|
1159
1162
|
function runnerSpawnSpec(opts) {
|
|
1160
1163
|
const root = findWorkspaceRoot();
|
|
1161
1164
|
const localPackage = resolve4(root, "packages", "browser-runner", "src", "index.ts");
|
|
@@ -1172,7 +1175,7 @@ function runnerSpawnSpec(opts) {
|
|
|
1172
1175
|
command = process.execPath;
|
|
1173
1176
|
args = [bundledPackage, ...runnerArgs];
|
|
1174
1177
|
}
|
|
1175
|
-
return { command, args, cwd };
|
|
1178
|
+
return { command, args, cwd, shell: spawnNeedsShell(command) };
|
|
1176
1179
|
}
|
|
1177
1180
|
function startRunnerForeground(opts) {
|
|
1178
1181
|
const spec = runnerSpawnSpec(opts);
|
|
@@ -1180,7 +1183,7 @@ function startRunnerForeground(opts) {
|
|
|
1180
1183
|
const child = spawn2(spec.command, spec.args, {
|
|
1181
1184
|
cwd: spec.cwd,
|
|
1182
1185
|
stdio: "inherit",
|
|
1183
|
-
shell:
|
|
1186
|
+
shell: spec.shell
|
|
1184
1187
|
});
|
|
1185
1188
|
child.on("error", reject);
|
|
1186
1189
|
child.on("exit", (code) => {
|
|
@@ -2797,7 +2800,7 @@ function createRunnerCommand() {
|
|
|
2797
2800
|
const runner = spawn4(spec.command, spec.args, {
|
|
2798
2801
|
cwd: spec.cwd,
|
|
2799
2802
|
stdio: ["ignore", "pipe", "pipe"],
|
|
2800
|
-
shell:
|
|
2803
|
+
shell: spec.shell,
|
|
2801
2804
|
// #896: the runtime answers `/health` with the lock's identity and stops for a
|
|
2802
2805
|
// request quoting its nonce — so a contender can prove who is on that port, and a
|
|
2803
2806
|
// replace is an authorisation rather than a signal aimed at a name pattern.
|
|
@@ -2953,7 +2956,6 @@ function createRunnerCommand() {
|
|
|
2953
2956
|
var runnerCommand = createRunnerCommand();
|
|
2954
2957
|
|
|
2955
2958
|
// src/commands/up.ts
|
|
2956
|
-
import { execFileSync as execFileSync3 } from "child_process";
|
|
2957
2959
|
import { createRequire as createRequire2 } from "module";
|
|
2958
2960
|
import { Command as Command8 } from "commander";
|
|
2959
2961
|
import { hostname as hostname6 } from "os";
|
|
@@ -3075,6 +3077,65 @@ async function waitForKey(keys, onInterrupt) {
|
|
|
3075
3077
|
});
|
|
3076
3078
|
}
|
|
3077
3079
|
|
|
3080
|
+
// src/commands/up-restart.ts
|
|
3081
|
+
import { spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "child_process";
|
|
3082
|
+
var UP_LAUNCHER_ENV = "PAGS_UP_LAUNCHER";
|
|
3083
|
+
function upRestartMode(env, platform, canExecve) {
|
|
3084
|
+
if (env[SERVICE_ENV] === "1") return "service";
|
|
3085
|
+
if (env[RESTART_COMMAND_ENV]?.trim()) return "command";
|
|
3086
|
+
if (env[UP_LAUNCHER_ENV] === "1") return "launcher-child";
|
|
3087
|
+
return platform !== "win32" && canExecve ? "exec" : "launcher";
|
|
3088
|
+
}
|
|
3089
|
+
function processRestartDeps() {
|
|
3090
|
+
const execve = process.execve;
|
|
3091
|
+
return {
|
|
3092
|
+
env: process.env,
|
|
3093
|
+
platform: process.platform,
|
|
3094
|
+
execPath: process.execPath,
|
|
3095
|
+
execArgv: process.execArgv,
|
|
3096
|
+
script: process.argv[1],
|
|
3097
|
+
execve: typeof execve === "function" ? execve.bind(process) : void 0,
|
|
3098
|
+
spawn: nodeSpawn,
|
|
3099
|
+
spawnSync: nodeSpawnSync,
|
|
3100
|
+
exit: (code) => process.exit(code),
|
|
3101
|
+
log: () => {
|
|
3102
|
+
}
|
|
3103
|
+
};
|
|
3104
|
+
}
|
|
3105
|
+
function restartPagsUp(args, extraEnv, deps) {
|
|
3106
|
+
const env = { ...deps.env, ...extraEnv };
|
|
3107
|
+
const argv = [...deps.execArgv, deps.script, ...args];
|
|
3108
|
+
const mode = upRestartMode(env, deps.platform, !!deps.execve);
|
|
3109
|
+
if (mode === "service" || mode === "command") {
|
|
3110
|
+
leaveForRestart(mode, { spawn: deps.spawn, exit: deps.exit });
|
|
3111
|
+
return;
|
|
3112
|
+
}
|
|
3113
|
+
if (mode === "launcher-child") {
|
|
3114
|
+
deps.exit(RUNNER_RESTART_EXIT_CODE);
|
|
3115
|
+
return;
|
|
3116
|
+
}
|
|
3117
|
+
if (mode === "exec") {
|
|
3118
|
+
try {
|
|
3119
|
+
deps.execve(deps.execPath, [deps.execPath, ...argv], env);
|
|
3120
|
+
} catch (e) {
|
|
3121
|
+
deps.log(`Restart failed (${e instanceof Error ? e.message : String(e)}) \u2014 the runner is NOT running. Run 'pags up' again.`);
|
|
3122
|
+
deps.exit(1);
|
|
3123
|
+
}
|
|
3124
|
+
return;
|
|
3125
|
+
}
|
|
3126
|
+
for (let first = true; ; first = false) {
|
|
3127
|
+
const r = deps.spawnSync(deps.execPath, argv, { stdio: "inherit", env: { ...env, [UP_LAUNCHER_ENV]: "1", ...first ? {} : { PAGS_NO_PROMPT: "1" } } });
|
|
3128
|
+
if (r.status === RUNNER_RESTART_EXIT_CODE) continue;
|
|
3129
|
+
if (r.error || r.status !== 0) {
|
|
3130
|
+
deps.log(`Restart failed${typeof r.status === "number" ? ` (exit ${r.status})` : ""} \u2014 the runner is NOT running. Run 'pags up' again.`);
|
|
3131
|
+
deps.exit(typeof r.status === "number" && r.status !== 0 ? r.status : 1);
|
|
3132
|
+
return;
|
|
3133
|
+
}
|
|
3134
|
+
deps.exit(0);
|
|
3135
|
+
return;
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
|
|
3078
3139
|
// src/runner-replace.ts
|
|
3079
3140
|
var REPLACE_EXIT_TIMEOUT_MS = 3e4;
|
|
3080
3141
|
function describeWork(work) {
|
|
@@ -3355,16 +3416,10 @@ var upCommand = new Command8("up").description("Start the browser runner for all
|
|
|
3355
3416
|
});
|
|
3356
3417
|
function restartUp(why, env = {}) {
|
|
3357
3418
|
writeLine(` ${why}`);
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
} catch (e) {
|
|
3363
|
-
const status = e.status;
|
|
3364
|
-
writeLine(` Restart failed${typeof status === "number" ? ` (exit ${status})` : ""} \u2014 the runner is NOT running. Run 'pags up' again.`);
|
|
3365
|
-
process.exit(typeof status === "number" && status !== 0 ? status : 1);
|
|
3366
|
-
}
|
|
3367
|
-
process.exit(0);
|
|
3419
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
3420
|
+
process.stdin.pause();
|
|
3421
|
+
restartPagsUp(restartUpArgs(opts), env, { ...processRestartDeps(), log: (line) => writeLine(` ${line}`) });
|
|
3422
|
+
process.exit(1);
|
|
3368
3423
|
}
|
|
3369
3424
|
const shutdown = () => {
|
|
3370
3425
|
child.kill();
|