leglas 1.1.1 → 1.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/dist/bin.js +233 -132
- package/dist/index.js +173 -115
- package/dist/shell/assets/index-AbZOXGgP.js +14 -0
- package/dist/shell/assets/index-B1S34Qja.css +1 -0
- package/dist/shell/index.html +2 -2
- package/package.json +1 -1
- package/dist/shell/assets/index-BzaBzGEv.css +0 -1
- package/dist/shell/assets/index-CKmxj5gW.js +0 -14
package/dist/bin.js
CHANGED
|
@@ -84,7 +84,7 @@ function composeEntry(input) {
|
|
|
84
84
|
`, pictures };
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
// ../server/dist/config.js
|
|
87
|
+
// ../server/dist/config/config.js
|
|
88
88
|
var DEFAULT_DEV_SERVER = "http://localhost:3000";
|
|
89
89
|
var DEFAULT_INSTALL_COMMAND = "npm install";
|
|
90
90
|
var IMPLICIT_PREVIEW = { title: "App", url: "/" };
|
|
@@ -229,7 +229,7 @@ function normalizeConfig(raw, options = {}) {
|
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
// ../server/dist/agent-command.js
|
|
232
|
+
// ../server/dist/agents/agent-command.js
|
|
233
233
|
var WATCH_PATH = ".leglas/watch.json";
|
|
234
234
|
var PROMPT_TOKEN = "{prompt}";
|
|
235
235
|
var EXAMPLE = `npx leglas watch --run "claude -p ${PROMPT_TOKEN}"`;
|
|
@@ -311,7 +311,7 @@ function nextRequest(requests, failed) {
|
|
|
311
311
|
return requests.find((request) => request.status === "queued" && !failed.has(request.id)) ?? null;
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
// ../server/dist/agents.js
|
|
314
|
+
// ../server/dist/agents/agents.js
|
|
315
315
|
import { spawn } from "child_process";
|
|
316
316
|
import { constants, readdirSync } from "fs";
|
|
317
317
|
import { access, mkdir, readFile, writeFile } from "fs/promises";
|
|
@@ -319,10 +319,7 @@ import { delimiter, dirname, isAbsolute, join, relative } from "path";
|
|
|
319
319
|
var AGENT_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
320
320
|
var effortFlag = (effort) => effort === null ? [] : ["--effort", effort];
|
|
321
321
|
var codexEffortConfig = (effort) => effort === null ? [] : ["-c", `model_reasoning_effort=${effort}`];
|
|
322
|
-
var CODEX_WORKSPACE_CONFIG = [
|
|
323
|
-
"-c",
|
|
324
|
-
"sandbox_workspace_write.network_access=true"
|
|
325
|
-
];
|
|
322
|
+
var CODEX_WORKSPACE_CONFIG = ["-c", "sandbox_workspace_write.network_access=true"];
|
|
326
323
|
var KNOWN_AGENTS = {
|
|
327
324
|
claude: {
|
|
328
325
|
name: "Claude",
|
|
@@ -338,13 +335,7 @@ var KNOWN_AGENTS = {
|
|
|
338
335
|
"acceptEdits",
|
|
339
336
|
...effortFlag(effort)
|
|
340
337
|
],
|
|
341
|
-
terminalArgs: (prompt, effort = null, _images = []) => [
|
|
342
|
-
"-p",
|
|
343
|
-
prompt,
|
|
344
|
-
"--permission-mode",
|
|
345
|
-
"acceptEdits",
|
|
346
|
-
...effortFlag(effort)
|
|
347
|
-
],
|
|
338
|
+
terminalArgs: (prompt, effort = null, _images = []) => ["-p", prompt, "--permission-mode", "acceptEdits", ...effortFlag(effort)],
|
|
348
339
|
resumeArgs: (sessionId, prompt, effort = null, _images = []) => [
|
|
349
340
|
"-p",
|
|
350
341
|
"--resume",
|
|
@@ -448,13 +439,7 @@ var KNOWN_AGENTS = {
|
|
|
448
439
|
// project is the one the user pointed Leglas at, which is the trust the
|
|
449
440
|
// flag grants. It is the only permission the run needs: with it alone,
|
|
450
441
|
// the edit and the shell command in the same run both executed.
|
|
451
|
-
args: (prompt, _effort = null, _images = []) => [
|
|
452
|
-
"-p",
|
|
453
|
-
prompt,
|
|
454
|
-
"--output-format",
|
|
455
|
-
"stream-json",
|
|
456
|
-
"--trust"
|
|
457
|
-
],
|
|
442
|
+
args: (prompt, _effort = null, _images = []) => ["-p", prompt, "--output-format", "stream-json", "--trust"],
|
|
458
443
|
terminalArgs: (prompt, _effort = null, _images = []) => ["-p", prompt, "--trust"],
|
|
459
444
|
// `--resume [chatId]` is documented alongside `--continue` in the CLI
|
|
460
445
|
// parameter reference, and every stream-json event carries the
|
|
@@ -466,7 +451,15 @@ var KNOWN_AGENTS = {
|
|
|
466
451
|
// Images are accepted and ignored, like its other argument builders:
|
|
467
452
|
// `cursor-agent` documents no flag for them, and the capture paths reach
|
|
468
453
|
// it as text in the prompt either way.
|
|
469
|
-
resumeArgs: (sessionId, prompt, _effort = null, _images = []) => [
|
|
454
|
+
resumeArgs: (sessionId, prompt, _effort = null, _images = []) => [
|
|
455
|
+
"-p",
|
|
456
|
+
"--resume",
|
|
457
|
+
sessionId,
|
|
458
|
+
prompt,
|
|
459
|
+
"--output-format",
|
|
460
|
+
"stream-json",
|
|
461
|
+
"--trust"
|
|
462
|
+
],
|
|
470
463
|
sessionFrom: (event) => typeof event.session_id === "string" && event.session_id !== "" ? event.session_id : null,
|
|
471
464
|
// Read against cursor-agent 2026.09.02: every event carries the id, a
|
|
472
465
|
// resume in this argument order answers under the same id and remembers
|
|
@@ -794,7 +787,7 @@ async function saveAgentChoice(cwd, choice) {
|
|
|
794
787
|
`, "utf8");
|
|
795
788
|
}
|
|
796
789
|
|
|
797
|
-
// ../server/dist/classify.js
|
|
790
|
+
// ../server/dist/branches/classify.js
|
|
798
791
|
var MANIFESTS = /* @__PURE__ */ new Set([
|
|
799
792
|
"package.json",
|
|
800
793
|
"pnpm-lock.yaml",
|
|
@@ -839,7 +832,11 @@ var IN_APP_STEPS = [
|
|
|
839
832
|
'Register it: npx leglas add --title "<title>" --url "/?v-<surface>=<direction>".'
|
|
840
833
|
];
|
|
841
834
|
function classifyDirection(input) {
|
|
842
|
-
const checkout = (reason) => ({
|
|
835
|
+
const checkout = (reason) => ({
|
|
836
|
+
level: "checkout",
|
|
837
|
+
reason,
|
|
838
|
+
steps: CHECKOUT_STEPS
|
|
839
|
+
});
|
|
843
840
|
const manifest = input.changes.find((change) => isManifest(change.path));
|
|
844
841
|
if (manifest !== void 0) {
|
|
845
842
|
return checkout(`${manifest.path} changes the dependency set, and one running server cannot hold two.`);
|
|
@@ -859,7 +856,7 @@ function classifyDirection(input) {
|
|
|
859
856
|
};
|
|
860
857
|
}
|
|
861
858
|
|
|
862
|
-
// ../server/dist/find-config.js
|
|
859
|
+
// ../server/dist/config/find-config.js
|
|
863
860
|
import { existsSync } from "fs";
|
|
864
861
|
import { dirname as dirname2, join as join2, parse } from "path";
|
|
865
862
|
var CONFIG_BASENAMES = [
|
|
@@ -886,7 +883,7 @@ function findConfigFile(startDir) {
|
|
|
886
883
|
}
|
|
887
884
|
}
|
|
888
885
|
|
|
889
|
-
// ../server/dist/load-config.js
|
|
886
|
+
// ../server/dist/config/load-config.js
|
|
890
887
|
import { readFile as readFile2 } from "fs/promises";
|
|
891
888
|
import { relative as relative2 } from "path";
|
|
892
889
|
import { pathToFileURL } from "url";
|
|
@@ -919,7 +916,7 @@ async function loadConfig(cwd) {
|
|
|
919
916
|
};
|
|
920
917
|
}
|
|
921
918
|
|
|
922
|
-
// ../server/dist/local-previews.js
|
|
919
|
+
// ../server/dist/config/local-previews.js
|
|
923
920
|
import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
|
|
924
921
|
import { dirname as dirname3, join as join3 } from "path";
|
|
925
922
|
var LOCAL_PREVIEWS_PATH = ".leglas/previews.json";
|
|
@@ -953,7 +950,10 @@ async function readLocalPreviews(cwd) {
|
|
|
953
950
|
}
|
|
954
951
|
const result2 = normalizeConfig(parsed2, { requireDevCommand: false });
|
|
955
952
|
if (result2.config === null) {
|
|
956
|
-
return {
|
|
953
|
+
return {
|
|
954
|
+
previews: [],
|
|
955
|
+
errors: result2.errors.map((error) => `${LOCAL_PREVIEWS_PATH}: ${error}`)
|
|
956
|
+
};
|
|
957
957
|
}
|
|
958
958
|
return {
|
|
959
959
|
previews: result2.config.previews.map((preview) => ({ ...preview, local: true })),
|
|
@@ -1036,7 +1036,10 @@ function createProxyHandler(options) {
|
|
|
1036
1036
|
function rewriteLocation(location, publicOrigin2) {
|
|
1037
1037
|
if (location === void 0)
|
|
1038
1038
|
return void 0;
|
|
1039
|
-
for (const origin of [
|
|
1039
|
+
for (const origin of [
|
|
1040
|
+
`${target.protocol}//${authority}`,
|
|
1041
|
+
`${target.protocol}//localhost:${port}`
|
|
1042
|
+
]) {
|
|
1040
1043
|
if (location.startsWith(origin))
|
|
1041
1044
|
return publicOrigin2 + location.slice(origin.length);
|
|
1042
1045
|
}
|
|
@@ -1168,7 +1171,7 @@ function startProxyServer(options) {
|
|
|
1168
1171
|
});
|
|
1169
1172
|
}
|
|
1170
1173
|
|
|
1171
|
-
// ../server/dist/browser.js
|
|
1174
|
+
// ../server/dist/capture/browser.js
|
|
1172
1175
|
import { randomBytes } from "crypto";
|
|
1173
1176
|
import nodeProcess from "process";
|
|
1174
1177
|
import { spawn as nodeSpawn } from "child_process";
|
|
@@ -1218,8 +1221,20 @@ function firstOnPath(name, env) {
|
|
|
1218
1221
|
return null;
|
|
1219
1222
|
}
|
|
1220
1223
|
var FOR_TESTING = [
|
|
1221
|
-
[
|
|
1222
|
-
|
|
1224
|
+
[
|
|
1225
|
+
"chrome-mac-arm64",
|
|
1226
|
+
"Google Chrome for Testing.app",
|
|
1227
|
+
"Contents",
|
|
1228
|
+
"MacOS",
|
|
1229
|
+
"Google Chrome for Testing"
|
|
1230
|
+
],
|
|
1231
|
+
[
|
|
1232
|
+
"chrome-mac-x64",
|
|
1233
|
+
"Google Chrome for Testing.app",
|
|
1234
|
+
"Contents",
|
|
1235
|
+
"MacOS",
|
|
1236
|
+
"Google Chrome for Testing"
|
|
1237
|
+
],
|
|
1223
1238
|
["chrome-linux64", "chrome"],
|
|
1224
1239
|
["chrome-linux", "chrome"],
|
|
1225
1240
|
["chrome-win64", "chrome.exe"]
|
|
@@ -1821,7 +1836,7 @@ function createBrowserPool(options = {}) {
|
|
|
1821
1836
|
};
|
|
1822
1837
|
}
|
|
1823
1838
|
|
|
1824
|
-
// ../server/dist/hydration.js
|
|
1839
|
+
// ../server/dist/capture/hydration.js
|
|
1825
1840
|
function hydrationEvidence(messages) {
|
|
1826
1841
|
for (const raw of messages) {
|
|
1827
1842
|
const message2 = raw.split("\n", 1)[0]?.trim() ?? "";
|
|
@@ -1847,7 +1862,7 @@ function hydrationEvidence(messages) {
|
|
|
1847
1862
|
return null;
|
|
1848
1863
|
}
|
|
1849
1864
|
|
|
1850
|
-
// ../server/dist/capture.js
|
|
1865
|
+
// ../server/dist/capture/capture.js
|
|
1851
1866
|
var FRAME_MAX_HEIGHT = 4e3;
|
|
1852
1867
|
var MIN_WIDTH = 320;
|
|
1853
1868
|
var MAX_WIDTH = 3840;
|
|
@@ -2104,7 +2119,7 @@ async function capturePage(browser, input) {
|
|
|
2104
2119
|
return browser.withPage((page) => abortable(render(page, input), abortInput.signal));
|
|
2105
2120
|
}
|
|
2106
2121
|
|
|
2107
|
-
// ../server/dist/attachments.js
|
|
2122
|
+
// ../server/dist/requests/attachments.js
|
|
2108
2123
|
import { copyFile, lstat, mkdir as mkdir3, readdir as readdir2, readFile as readFile5, realpath, rename, rm as rm2, stat as stat2, unlink, writeFile as writeFile3 } from "fs/promises";
|
|
2109
2124
|
import { basename as basename2, extname, join as join5, resolve, sep } from "path";
|
|
2110
2125
|
var CAPTURES_DIR = ".leglas/captures";
|
|
@@ -2419,7 +2434,7 @@ async function pruneReferences(cwd) {
|
|
|
2419
2434
|
}
|
|
2420
2435
|
}
|
|
2421
2436
|
|
|
2422
|
-
// ../server/dist/worktree.js
|
|
2437
|
+
// ../server/dist/branches/worktree.js
|
|
2423
2438
|
import { execFile, spawn as spawn2 } from "child_process";
|
|
2424
2439
|
import { rm as rm3 } from "fs/promises";
|
|
2425
2440
|
import net2 from "net";
|
|
@@ -2566,7 +2581,7 @@ async function startAppProcess(options) {
|
|
|
2566
2581
|
throw new Error(`${options.label} did not start within ${Math.round(readyTimeoutMs / 1e3)}s. Check that its dev command serves the port it is given.`);
|
|
2567
2582
|
}
|
|
2568
2583
|
|
|
2569
|
-
// ../server/dist/branches.js
|
|
2584
|
+
// ../server/dist/branches/branches.js
|
|
2570
2585
|
var BRANCH_IDLE_MS = 10 * 60 * 1e3;
|
|
2571
2586
|
var BRANCH_SWEEP_MS = 3e4;
|
|
2572
2587
|
function publicBranchState(state) {
|
|
@@ -2701,7 +2716,7 @@ function createBranchRegistry(options) {
|
|
|
2701
2716
|
};
|
|
2702
2717
|
}
|
|
2703
2718
|
|
|
2704
|
-
// ../server/dist/failure.js
|
|
2719
|
+
// ../server/dist/agents/failure.js
|
|
2705
2720
|
var NEEDS_TRUST = /not inside a trusted directory|--skip-git-repo-check/i;
|
|
2706
2721
|
var MISSING_BINARY = /\b(ENOENT|EACCES|ENOTDIR)\b/;
|
|
2707
2722
|
var NOT_SIGNED_IN = /not logged in|not signed in|please (?:re-?)?(?:run|sign|log)\s*in|\/login\b|invalid api key|unauthorized|authentication_failed|\b401\b/i;
|
|
@@ -2768,7 +2783,7 @@ function sessionShaped(code) {
|
|
|
2768
2783
|
return code === "agent-error";
|
|
2769
2784
|
}
|
|
2770
2785
|
|
|
2771
|
-
// ../server/dist/annotations.js
|
|
2786
|
+
// ../server/dist/requests/annotations.js
|
|
2772
2787
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
2773
2788
|
import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile4 } from "fs/promises";
|
|
2774
2789
|
import { dirname as dirname4, join as join7 } from "path";
|
|
@@ -2932,7 +2947,7 @@ function describeAnnotations(annotations) {
|
|
|
2932
2947
|
}).join("\n\n");
|
|
2933
2948
|
}
|
|
2934
2949
|
|
|
2935
|
-
// ../server/dist/requests.js
|
|
2950
|
+
// ../server/dist/requests/requests.js
|
|
2936
2951
|
import { mkdir as mkdir5, readFile as readFile7, writeFile as writeFile5 } from "fs/promises";
|
|
2937
2952
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
2938
2953
|
import { dirname as dirname5, join as join8 } from "path";
|
|
@@ -3146,10 +3161,7 @@ async function writeQueue(cwd, requests) {
|
|
|
3146
3161
|
`, "utf8");
|
|
3147
3162
|
}
|
|
3148
3163
|
async function appendRequest(cwd, request, id = newRequestId()) {
|
|
3149
|
-
await writeQueue(cwd, [
|
|
3150
|
-
...await readRequests(cwd),
|
|
3151
|
-
{ ...request, id, status: "queued" }
|
|
3152
|
-
]);
|
|
3164
|
+
await writeQueue(cwd, [...await readRequests(cwd), { ...request, id, status: "queued" }]);
|
|
3153
3165
|
}
|
|
3154
3166
|
function newRequestId() {
|
|
3155
3167
|
return randomBytes3(6).toString("base64url");
|
|
@@ -3201,12 +3213,12 @@ async function clearRequests(cwd) {
|
|
|
3201
3213
|
return { cleared, pending: pending.length };
|
|
3202
3214
|
}
|
|
3203
3215
|
|
|
3204
|
-
// ../server/dist/runner.js
|
|
3216
|
+
// ../server/dist/agents/runner.js
|
|
3205
3217
|
import { spawn as nodeSpawn3 } from "child_process";
|
|
3206
3218
|
import { readFile as readFile9 } from "fs/promises";
|
|
3207
3219
|
import { join as join9, resolve as resolve2, sep as sep2 } from "path";
|
|
3208
3220
|
|
|
3209
|
-
// ../server/dist/claude-agent-session.js
|
|
3221
|
+
// ../server/dist/agents/claude-agent-session.js
|
|
3210
3222
|
import { EventEmitter } from "events";
|
|
3211
3223
|
import { readFile as readFile8, stat as stat3 } from "fs/promises";
|
|
3212
3224
|
import { extname as extname2 } from "path";
|
|
@@ -3617,7 +3629,7 @@ function createClaudeAgentSession(cwd, allowedCommands = [], startup = defaultSt
|
|
|
3617
3629
|
return new PersistentClaudeSession(cwd, allowedCommands, startup);
|
|
3618
3630
|
}
|
|
3619
3631
|
|
|
3620
|
-
// ../server/dist/codex-app-server.js
|
|
3632
|
+
// ../server/dist/agents/codex-app-server.js
|
|
3621
3633
|
import { spawn as nodeSpawn2 } from "child_process";
|
|
3622
3634
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
3623
3635
|
import { PassThrough as PassThrough2 } from "stream";
|
|
@@ -4040,17 +4052,11 @@ var PersistentCodexAppServer = class {
|
|
|
4040
4052
|
});
|
|
4041
4053
|
});
|
|
4042
4054
|
process2.kill("SIGTERM");
|
|
4043
|
-
await Promise.race([
|
|
4044
|
-
ended,
|
|
4045
|
-
new Promise((resolve5) => setTimeout(resolve5, 1e3))
|
|
4046
|
-
]);
|
|
4055
|
+
await Promise.race([ended, new Promise((resolve5) => setTimeout(resolve5, 1e3))]);
|
|
4047
4056
|
if (closed)
|
|
4048
4057
|
return;
|
|
4049
4058
|
process2.kill("SIGKILL");
|
|
4050
|
-
await Promise.race([
|
|
4051
|
-
ended,
|
|
4052
|
-
new Promise((resolve5) => setTimeout(resolve5, 1e3))
|
|
4053
|
-
]);
|
|
4059
|
+
await Promise.race([ended, new Promise((resolve5) => setTimeout(resolve5, 1e3))]);
|
|
4054
4060
|
}
|
|
4055
4061
|
failProcess(process2, error) {
|
|
4056
4062
|
if (this.process !== process2)
|
|
@@ -4095,7 +4101,7 @@ function createCodexAppServer(cwd, spawn5 = defaultSpawn, requestTimeoutMs = REQ
|
|
|
4095
4101
|
return new PersistentCodexAppServer(cwd, spawn5, requestTimeoutMs);
|
|
4096
4102
|
}
|
|
4097
4103
|
|
|
4098
|
-
// ../server/dist/runner.js
|
|
4104
|
+
// ../server/dist/agents/runner.js
|
|
4099
4105
|
var POLL_MS = 2e3;
|
|
4100
4106
|
var OUTPUT_LINES = 20;
|
|
4101
4107
|
var IDLE_RELEASE_MS = 5 * 6e4;
|
|
@@ -4172,10 +4178,7 @@ function defaultSpawn2(command, args, options) {
|
|
|
4172
4178
|
function startRunner(options) {
|
|
4173
4179
|
const spawn5 = options.spawn ?? defaultSpawn2;
|
|
4174
4180
|
const codexAppServer = options.codexAppServer === void 0 ? options.spawn === void 0 ? createCodexAppServer(options.cwd) : null : options.codexAppServer;
|
|
4175
|
-
const claudeAgentSession = options.claudeAgentSession === void 0 ? options.spawn === void 0 ? createClaudeAgentSession(options.cwd, options.leglasCommand === void 0 ? [] : [
|
|
4176
|
-
`${options.leglasCommand} show`,
|
|
4177
|
-
registrationCommand(options.leglasCommand)
|
|
4178
|
-
]) : null : options.claudeAgentSession;
|
|
4181
|
+
const claudeAgentSession = options.claudeAgentSession === void 0 ? options.spawn === void 0 ? createClaudeAgentSession(options.cwd, options.leglasCommand === void 0 ? [] : [`${options.leglasCommand} show`, registrationCommand(options.leglasCommand)]) : null : options.claudeAgentSession;
|
|
4179
4182
|
const setEvery = options.setInterval ?? ((callback, milliseconds) => setInterval(callback, milliseconds));
|
|
4180
4183
|
const clearEvery = options.clearInterval ?? ((handle2) => clearInterval(handle2));
|
|
4181
4184
|
const failed = /* @__PURE__ */ new Set();
|
|
@@ -4554,10 +4557,7 @@ function startRunner(options) {
|
|
|
4554
4557
|
clearEvery(timer);
|
|
4555
4558
|
cancel();
|
|
4556
4559
|
stopPromise = Promise.resolve(ticking).catch(() => {
|
|
4557
|
-
}).then(() => Promise.all([
|
|
4558
|
-
codexAppServer?.close(),
|
|
4559
|
-
claudeAgentSession?.close()
|
|
4560
|
-
])).then(() => {
|
|
4560
|
+
}).then(() => Promise.all([codexAppServer?.close(), claudeAgentSession?.close()])).then(() => {
|
|
4561
4561
|
});
|
|
4562
4562
|
return stopPromise;
|
|
4563
4563
|
};
|
|
@@ -4775,12 +4775,12 @@ Sec-WebSocket-Accept: ${accept}\r
|
|
|
4775
4775
|
};
|
|
4776
4776
|
}
|
|
4777
4777
|
|
|
4778
|
-
// ../server/dist/share.js
|
|
4778
|
+
// ../server/dist/share/share.js
|
|
4779
4779
|
import { randomBytes as randomBytes4, randomUUID, timingSafeEqual } from "crypto";
|
|
4780
4780
|
import http3 from "http";
|
|
4781
4781
|
import { posix } from "path";
|
|
4782
4782
|
|
|
4783
|
-
// ../server/dist/tunnel.js
|
|
4783
|
+
// ../server/dist/share/tunnel.js
|
|
4784
4784
|
import { spawn as spawnChild } from "child_process";
|
|
4785
4785
|
import { Resolver, lookup } from "dns/promises";
|
|
4786
4786
|
import http2 from "http";
|
|
@@ -4901,12 +4901,7 @@ function startTunnel(options, deps = {}) {
|
|
|
4901
4901
|
});
|
|
4902
4902
|
};
|
|
4903
4903
|
report(state);
|
|
4904
|
-
const args = options.provider === "cloudflared" ? [
|
|
4905
|
-
"tunnel",
|
|
4906
|
-
"--url",
|
|
4907
|
-
`http://127.0.0.1:${options.port}`,
|
|
4908
|
-
"--no-autoupdate"
|
|
4909
|
-
] : ["http", String(options.port), "--log", "stdout", "--log-format", "json"];
|
|
4904
|
+
const args = options.provider === "cloudflared" ? ["tunnel", "--url", `http://127.0.0.1:${options.port}`, "--no-autoupdate"] : ["http", String(options.port), "--log", "stdout", "--log-format", "json"];
|
|
4910
4905
|
let child;
|
|
4911
4906
|
try {
|
|
4912
4907
|
child = spawn5(options.provider, args, {
|
|
@@ -5068,7 +5063,7 @@ function startTunnel(options, deps = {}) {
|
|
|
5068
5063
|
};
|
|
5069
5064
|
}
|
|
5070
5065
|
|
|
5071
|
-
// ../server/dist/share.js
|
|
5066
|
+
// ../server/dist/share/share.js
|
|
5072
5067
|
var MAX_REFUSED = 40;
|
|
5073
5068
|
function routeAllowed(routes, url) {
|
|
5074
5069
|
const [rawPath = "/"] = url.split("?", 2);
|
|
@@ -5245,9 +5240,7 @@ function manifestFrom(value, previews) {
|
|
|
5245
5240
|
error: `Directions are not available to share: ${unknown.join(", ")}.`
|
|
5246
5241
|
};
|
|
5247
5242
|
}
|
|
5248
|
-
const branches = [
|
|
5249
|
-
...new Set(titles.filter((title) => byTitle.get(title)?.branch !== void 0))
|
|
5250
|
-
];
|
|
5243
|
+
const branches = [...new Set(titles.filter((title) => byTitle.get(title)?.branch !== void 0))];
|
|
5251
5244
|
if (branches.length > 0) {
|
|
5252
5245
|
return {
|
|
5253
5246
|
ok: false,
|
|
@@ -6092,7 +6085,7 @@ function createShareManager(options) {
|
|
|
6092
6085
|
};
|
|
6093
6086
|
}
|
|
6094
6087
|
|
|
6095
|
-
// ../server/dist/renames.js
|
|
6088
|
+
// ../server/dist/config/renames.js
|
|
6096
6089
|
import { mkdir as mkdir6, readFile as readFile10, writeFile as writeFile6 } from "fs/promises";
|
|
6097
6090
|
import { dirname as dirname6, join as join10 } from "path";
|
|
6098
6091
|
var RENAMES_PATH = ".leglas/renames.json";
|
|
@@ -7218,11 +7211,17 @@ async function startServer(options) {
|
|
|
7218
7211
|
return sendJson2(res, 400, { ok: false, error: "Body needs a known agent." });
|
|
7219
7212
|
}
|
|
7220
7213
|
if (parsed2.run !== void 0 && typeof parsed2.run !== "string") {
|
|
7221
|
-
return sendJson2(res, 400, {
|
|
7214
|
+
return sendJson2(res, 400, {
|
|
7215
|
+
ok: false,
|
|
7216
|
+
error: "The custom run command must be a string."
|
|
7217
|
+
});
|
|
7222
7218
|
}
|
|
7223
7219
|
const effort = parsed2.effort === null || isAgentEffort(parsed2.effort) ? parsed2.effort : void 0;
|
|
7224
7220
|
if (parsed2.effort !== void 0 && effort === void 0) {
|
|
7225
|
-
return sendJson2(res, 400, {
|
|
7221
|
+
return sendJson2(res, 400, {
|
|
7222
|
+
ok: false,
|
|
7223
|
+
error: "Effort must be a supported level or null."
|
|
7224
|
+
});
|
|
7226
7225
|
}
|
|
7227
7226
|
if (parsed2.agent === "custom") {
|
|
7228
7227
|
if (effort !== void 0) {
|
|
@@ -7349,7 +7348,10 @@ async function startServer(options) {
|
|
|
7349
7348
|
return sendJson2(res, 404, { ok: false, error: "No such request." });
|
|
7350
7349
|
}
|
|
7351
7350
|
if (!isEnded(request, runner?.snapshot().failedIds ?? [])) {
|
|
7352
|
-
return sendJson2(res, 400, {
|
|
7351
|
+
return sendJson2(res, 400, {
|
|
7352
|
+
ok: false,
|
|
7353
|
+
error: "Only an ended request can be run again."
|
|
7354
|
+
});
|
|
7353
7355
|
}
|
|
7354
7356
|
try {
|
|
7355
7357
|
const retryId = newRequestId();
|
|
@@ -7481,7 +7483,10 @@ async function startServer(options) {
|
|
|
7481
7483
|
}
|
|
7482
7484
|
const target2 = (await readRequests(cwd)).find((entry2) => entry2.id === parsed2.id);
|
|
7483
7485
|
if (target2 === void 0 || !isEnded(target2, runner?.snapshot().failedIds ?? [])) {
|
|
7484
|
-
return sendJson2(res, 400, {
|
|
7486
|
+
return sendJson2(res, 400, {
|
|
7487
|
+
ok: false,
|
|
7488
|
+
error: "Only an ended request can be dismissed."
|
|
7489
|
+
});
|
|
7485
7490
|
}
|
|
7486
7491
|
try {
|
|
7487
7492
|
if (!await removeRequest(cwd, parsed2.id)) {
|
|
@@ -7525,7 +7530,10 @@ async function startServer(options) {
|
|
|
7525
7530
|
const serveMount = () => {
|
|
7526
7531
|
if (dir !== void 0 && relative6 !== "" && serveFrom(res, dir, relative6))
|
|
7527
7532
|
return;
|
|
7528
|
-
res.writeHead(404, {
|
|
7533
|
+
res.writeHead(404, {
|
|
7534
|
+
"content-type": "text/plain; charset=utf-8",
|
|
7535
|
+
"cache-control": "no-store"
|
|
7536
|
+
});
|
|
7529
7537
|
res.end("Leglas: no such preview file.");
|
|
7530
7538
|
};
|
|
7531
7539
|
if (!context.remote)
|
|
@@ -7546,11 +7554,17 @@ async function startServer(options) {
|
|
|
7546
7554
|
if (shellDir !== null && serveShellFile(res, shellDir, path))
|
|
7547
7555
|
return;
|
|
7548
7556
|
if (shellDir !== null) {
|
|
7549
|
-
res.writeHead(404, {
|
|
7557
|
+
res.writeHead(404, {
|
|
7558
|
+
"content-type": "text/plain; charset=utf-8",
|
|
7559
|
+
"cache-control": "no-store"
|
|
7560
|
+
});
|
|
7550
7561
|
res.end("Leglas: no such path.");
|
|
7551
7562
|
return;
|
|
7552
7563
|
}
|
|
7553
|
-
res.writeHead(200, {
|
|
7564
|
+
res.writeHead(200, {
|
|
7565
|
+
"content-type": "text/html; charset=utf-8",
|
|
7566
|
+
"cache-control": "no-store"
|
|
7567
|
+
});
|
|
7554
7568
|
res.end(PLACEHOLDER);
|
|
7555
7569
|
return;
|
|
7556
7570
|
}
|
|
@@ -7678,15 +7692,30 @@ function realPath(path) {
|
|
|
7678
7692
|
}
|
|
7679
7693
|
var COMMANDS = {
|
|
7680
7694
|
npx: { npm: ["npx"], pnpm: ["pnpm", "dlx"], bun: ["bunx"], yarn: ["yarn", "dlx"] },
|
|
7681
|
-
global: {
|
|
7682
|
-
|
|
7695
|
+
global: {
|
|
7696
|
+
npm: ["npm", "i", "-g"],
|
|
7697
|
+
pnpm: ["pnpm", "add", "-g"],
|
|
7698
|
+
bun: ["bun", "add", "-g"],
|
|
7699
|
+
yarn: ["yarn", "global", "add"]
|
|
7700
|
+
},
|
|
7701
|
+
project: {
|
|
7702
|
+
npm: ["npm", "install"],
|
|
7703
|
+
pnpm: ["pnpm", "up"],
|
|
7704
|
+
bun: ["bun", "update"],
|
|
7705
|
+
yarn: ["yarn", "up"]
|
|
7706
|
+
}
|
|
7683
7707
|
};
|
|
7684
7708
|
var YARN_CLASSIC = ["yarn", "upgrade"];
|
|
7685
7709
|
function commandParts(kind, manager, version2, classic = false) {
|
|
7686
7710
|
return [...classic ? YARN_CLASSIC : COMMANDS[kind][manager], `leglas@${version2}`];
|
|
7687
7711
|
}
|
|
7688
7712
|
function installation(kind, manager, root, classic = false) {
|
|
7689
|
-
return {
|
|
7713
|
+
return {
|
|
7714
|
+
kind,
|
|
7715
|
+
manager,
|
|
7716
|
+
command: commandParts(kind, manager, "latest", classic).join(" "),
|
|
7717
|
+
...root === void 0 ? {} : { root }
|
|
7718
|
+
};
|
|
7690
7719
|
}
|
|
7691
7720
|
function* ancestors(directory) {
|
|
7692
7721
|
const paths = /^[a-z]:\//i.test(directory) ? win32 : posix2;
|
|
@@ -7829,7 +7858,11 @@ function restartCommand(install, argv, latest, port, options) {
|
|
|
7829
7858
|
rest.push("--port", String(port), "--no-open");
|
|
7830
7859
|
const windows = options.platform === "win32";
|
|
7831
7860
|
if (install.kind === "npx") {
|
|
7832
|
-
const runner = [
|
|
7861
|
+
const runner = [
|
|
7862
|
+
...COMMANDS.npx[install.manager],
|
|
7863
|
+
...install.manager === "npm" ? ["-y"] : [],
|
|
7864
|
+
`leglas@${latest}`
|
|
7865
|
+
];
|
|
7833
7866
|
return spawnCommand([...runner, ...rest], options.platform);
|
|
7834
7867
|
}
|
|
7835
7868
|
if (install.kind === "global") {
|
|
@@ -8017,7 +8050,10 @@ function installVersion(install, version2, deps) {
|
|
|
8017
8050
|
if (child.pid === void 0)
|
|
8018
8051
|
child.kill("SIGKILL");
|
|
8019
8052
|
else if (deps.platform === "win32") {
|
|
8020
|
-
const killer = deps.spawn("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
|
|
8053
|
+
const killer = deps.spawn("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
|
|
8054
|
+
stdio: "ignore",
|
|
8055
|
+
shell: false
|
|
8056
|
+
});
|
|
8021
8057
|
killer.once("error", () => child.kill("SIGKILL"));
|
|
8022
8058
|
} else
|
|
8023
8059
|
deps.kill(-child.pid, "SIGKILL");
|
|
@@ -8154,7 +8190,13 @@ function createUpdateService(input) {
|
|
|
8154
8190
|
await handoff(restartCommand(install, argv, version2, port, { execPath, platform, exists }));
|
|
8155
8191
|
} catch (error) {
|
|
8156
8192
|
if (!closed)
|
|
8157
|
-
change({
|
|
8193
|
+
change({
|
|
8194
|
+
phase: {
|
|
8195
|
+
status: "failed",
|
|
8196
|
+
version: version2,
|
|
8197
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
8198
|
+
}
|
|
8199
|
+
});
|
|
8158
8200
|
}
|
|
8159
8201
|
};
|
|
8160
8202
|
return {
|
|
@@ -8307,7 +8349,10 @@ function parseNew(rest) {
|
|
|
8307
8349
|
return { kind: "error", message: `leglas new does not take ${argument}.` };
|
|
8308
8350
|
}
|
|
8309
8351
|
if (surface !== void 0) {
|
|
8310
|
-
return {
|
|
8352
|
+
return {
|
|
8353
|
+
kind: "error",
|
|
8354
|
+
message: `leglas new takes one surface name, received ${JSON.stringify(argument)} as well.`
|
|
8355
|
+
};
|
|
8311
8356
|
}
|
|
8312
8357
|
surface = argument;
|
|
8313
8358
|
}
|
|
@@ -8345,9 +8390,16 @@ function parseAdd(rest) {
|
|
|
8345
8390
|
} else {
|
|
8346
8391
|
value = argument.slice(equals + 1);
|
|
8347
8392
|
}
|
|
8348
|
-
if (![
|
|
8349
|
-
|
|
8350
|
-
|
|
8393
|
+
if (![
|
|
8394
|
+
"--title",
|
|
8395
|
+
"--url",
|
|
8396
|
+
"--note",
|
|
8397
|
+
"--tag",
|
|
8398
|
+
"--branch",
|
|
8399
|
+
"--file",
|
|
8400
|
+
"--based-on",
|
|
8401
|
+
"--asked-for"
|
|
8402
|
+
].includes(flag)) {
|
|
8351
8403
|
return { kind: "error", message: `leglas add does not take ${flag}.` };
|
|
8352
8404
|
}
|
|
8353
8405
|
if (value === void 0 || value === "") {
|
|
@@ -8363,7 +8415,10 @@ function parseAdd(rest) {
|
|
|
8363
8415
|
else tags.push(value);
|
|
8364
8416
|
}
|
|
8365
8417
|
if (title === void 0) {
|
|
8366
|
-
return {
|
|
8418
|
+
return {
|
|
8419
|
+
kind: "error",
|
|
8420
|
+
message: "leglas add needs --title, which is how the preview is identified."
|
|
8421
|
+
};
|
|
8367
8422
|
}
|
|
8368
8423
|
if (url === void 0 && file === void 0) {
|
|
8369
8424
|
return {
|
|
@@ -8470,7 +8525,10 @@ function parseArgs(argv) {
|
|
|
8470
8525
|
if (argument === "--to" || argument.startsWith("--to=")) {
|
|
8471
8526
|
to = argument.includes("=") ? argument.split("=").slice(1).join("=") : rest[index += 1];
|
|
8472
8527
|
if (to === void 0 || to === "") {
|
|
8473
|
-
return {
|
|
8528
|
+
return {
|
|
8529
|
+
kind: "error",
|
|
8530
|
+
message: "--to needs a path, for example --to src/components/hero.tsx"
|
|
8531
|
+
};
|
|
8474
8532
|
}
|
|
8475
8533
|
continue;
|
|
8476
8534
|
}
|
|
@@ -8489,7 +8547,10 @@ function parseArgs(argv) {
|
|
|
8489
8547
|
};
|
|
8490
8548
|
}
|
|
8491
8549
|
if (to === void 0) {
|
|
8492
|
-
return {
|
|
8550
|
+
return {
|
|
8551
|
+
kind: "error",
|
|
8552
|
+
message: "leglas keep needs --to, the path the winner should live at."
|
|
8553
|
+
};
|
|
8493
8554
|
}
|
|
8494
8555
|
return { kind: "keep", title, to, json };
|
|
8495
8556
|
}
|
|
@@ -8600,7 +8661,10 @@ function parseArgs(argv) {
|
|
|
8600
8661
|
continue;
|
|
8601
8662
|
}
|
|
8602
8663
|
if (!/^\d+$/.test(raw)) {
|
|
8603
|
-
return {
|
|
8664
|
+
return {
|
|
8665
|
+
kind: "error",
|
|
8666
|
+
message: `--width needs a number, received ${JSON.stringify(raw)}.`
|
|
8667
|
+
};
|
|
8604
8668
|
}
|
|
8605
8669
|
width = Number(raw);
|
|
8606
8670
|
if (width < MIN_SHOW_WIDTH || width > MAX_SHOW_WIDTH) {
|
|
@@ -8891,7 +8955,10 @@ function planNew(options) {
|
|
|
8891
8955
|
},
|
|
8892
8956
|
{
|
|
8893
8957
|
path: `${dir}/${slug}-a.tsx`,
|
|
8894
|
-
contents: placeholder(
|
|
8958
|
+
contents: placeholder(
|
|
8959
|
+
`${name}A`,
|
|
8960
|
+
`A first direction for ${slug}. Change it and watch it reload.`
|
|
8961
|
+
)
|
|
8895
8962
|
}
|
|
8896
8963
|
];
|
|
8897
8964
|
const gitignore = ignoreEntry(options.gitignore);
|
|
@@ -9232,10 +9299,7 @@ function resolveOrExplain(input, titles, renames) {
|
|
|
9232
9299
|
function renameExport(source, to) {
|
|
9233
9300
|
const match = /export function ([A-Za-z0-9_]+)\s*\(/.exec(source);
|
|
9234
9301
|
if (!match || match[1] === void 0) return source;
|
|
9235
|
-
return source.replace(
|
|
9236
|
-
new RegExp(`\\b${match[1]}\\b`, "g"),
|
|
9237
|
-
to
|
|
9238
|
-
);
|
|
9302
|
+
return source.replace(new RegExp(`\\b${match[1]}\\b`, "g"), to);
|
|
9239
9303
|
}
|
|
9240
9304
|
async function writeLogEntry(options) {
|
|
9241
9305
|
const entry2 = composeEntry({
|
|
@@ -9378,7 +9442,14 @@ async function runNew(options, deps) {
|
|
|
9378
9442
|
}
|
|
9379
9443
|
if (options.print) {
|
|
9380
9444
|
if (options.json) {
|
|
9381
|
-
deps.log(
|
|
9445
|
+
deps.log(
|
|
9446
|
+
JSON.stringify({
|
|
9447
|
+
ok: true,
|
|
9448
|
+
files: plan.writes,
|
|
9449
|
+
instructions: plan.instructions,
|
|
9450
|
+
previews: plan.previews
|
|
9451
|
+
})
|
|
9452
|
+
);
|
|
9382
9453
|
return { exitCode: 0, written: [] };
|
|
9383
9454
|
}
|
|
9384
9455
|
for (const write2 of plan.writes) {
|
|
@@ -9390,7 +9461,9 @@ async function runNew(options, deps) {
|
|
|
9390
9461
|
}
|
|
9391
9462
|
const existing = plan.writes.filter((write2) => existsSync6(join17(options.cwd, write2.path)));
|
|
9392
9463
|
if (existing.length > 0) {
|
|
9393
|
-
return fail(
|
|
9464
|
+
return fail(
|
|
9465
|
+
`${existing[0]?.path} already exists. Delete it first, or pick another surface name.`
|
|
9466
|
+
);
|
|
9394
9467
|
}
|
|
9395
9468
|
const written = [];
|
|
9396
9469
|
for (const write2 of plan.writes) {
|
|
@@ -9405,7 +9478,12 @@ async function runNew(options, deps) {
|
|
|
9405
9478
|
}
|
|
9406
9479
|
if (options.json) {
|
|
9407
9480
|
deps.log(
|
|
9408
|
-
JSON.stringify({
|
|
9481
|
+
JSON.stringify({
|
|
9482
|
+
ok: true,
|
|
9483
|
+
written,
|
|
9484
|
+
instructions: plan.instructions,
|
|
9485
|
+
previews: plan.previews
|
|
9486
|
+
})
|
|
9409
9487
|
);
|
|
9410
9488
|
return { exitCode: 0, written };
|
|
9411
9489
|
}
|
|
@@ -9415,7 +9493,9 @@ async function runNew(options, deps) {
|
|
|
9415
9493
|
deps.log("Then register them so they appear in the interface:");
|
|
9416
9494
|
deps.log("");
|
|
9417
9495
|
for (const preview of plan.previews) {
|
|
9418
|
-
deps.log(
|
|
9496
|
+
deps.log(
|
|
9497
|
+
` npx leglas add --title ${JSON.stringify(preview.title)} --url ${JSON.stringify(preview.url)}`
|
|
9498
|
+
);
|
|
9419
9499
|
}
|
|
9420
9500
|
return { exitCode: 0, written };
|
|
9421
9501
|
}
|
|
@@ -9529,7 +9609,9 @@ async function runAdd(options, deps) {
|
|
|
9529
9609
|
...options.preview.branch === void 0 ? {} : { branch: options.preview.branch },
|
|
9530
9610
|
...options.preview.file === void 0 ? {} : { file: options.preview.file },
|
|
9531
9611
|
note: options.preview.branch === void 0 && options.preview.file === void 0 ? "A running interface picks this up within seconds." : "Restart Leglas to see this preview: branch checkouts and file mounts are built when Leglas starts.",
|
|
9532
|
-
...needsDevCommand ? {
|
|
9612
|
+
...needsDevCommand ? {
|
|
9613
|
+
warning: "The config sets no devCommand, so Leglas cannot start this branch yet. Add devCommand (with {port}) to the config."
|
|
9614
|
+
} : {}
|
|
9533
9615
|
});
|
|
9534
9616
|
} else {
|
|
9535
9617
|
deps.log(
|
|
@@ -9755,7 +9837,8 @@ async function runShow(options, deps) {
|
|
|
9755
9837
|
typeof captured.error === "string" ? captured.error : "The direction could not be captured."
|
|
9756
9838
|
);
|
|
9757
9839
|
}
|
|
9758
|
-
if (typeof captured.file !== "string" || typeof captured.width !== "number" || typeof captured.height !== "number" || typeof captured.viewport !== "number")
|
|
9840
|
+
if (typeof captured.file !== "string" || typeof captured.width !== "number" || typeof captured.height !== "number" || typeof captured.viewport !== "number")
|
|
9841
|
+
return fail("The direction could not be captured.");
|
|
9759
9842
|
envelope2.screenshot = {
|
|
9760
9843
|
file: captured.file,
|
|
9761
9844
|
width: captured.width,
|
|
@@ -9996,10 +10079,14 @@ function localDevServerPort(origin) {
|
|
|
9996
10079
|
}
|
|
9997
10080
|
}
|
|
9998
10081
|
function parseListeningPids(output) {
|
|
9999
|
-
return [
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
10082
|
+
return [
|
|
10083
|
+
...new Set(
|
|
10084
|
+
output.split("\n").flatMap((line) => {
|
|
10085
|
+
if (!/^p\d+$/.test(line)) return [];
|
|
10086
|
+
return [Number(line.slice(1))];
|
|
10087
|
+
})
|
|
10088
|
+
)
|
|
10089
|
+
];
|
|
10003
10090
|
}
|
|
10004
10091
|
function parseOwnerCwds(output) {
|
|
10005
10092
|
const owners = [];
|
|
@@ -10022,11 +10109,10 @@ async function inspectLocalDevServer(origin) {
|
|
|
10022
10109
|
const port = localDevServerPort(origin);
|
|
10023
10110
|
if (port === null || process.platform === "win32") return [];
|
|
10024
10111
|
try {
|
|
10025
|
-
const listeners = await run2(
|
|
10026
|
-
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
);
|
|
10112
|
+
const listeners = await run2("lsof", ["-nP", "-a", `-iTCP:${port}`, "-sTCP:LISTEN", "-Fp"], {
|
|
10113
|
+
maxBuffer: 64 * 1024,
|
|
10114
|
+
timeout: INSPECTION_TIMEOUT_MS
|
|
10115
|
+
});
|
|
10030
10116
|
const pids = parseListeningPids(String(listeners.stdout));
|
|
10031
10117
|
if (pids.length === 0) return [];
|
|
10032
10118
|
const directories = await run2(
|
|
@@ -10133,9 +10219,9 @@ async function run3(options, deps) {
|
|
|
10133
10219
|
}
|
|
10134
10220
|
const config = merged === null ? null : { ...merged, previews };
|
|
10135
10221
|
const configWarnings = [];
|
|
10136
|
-
const projectRoot = await realpath4(
|
|
10137
|
-
|
|
10138
|
-
);
|
|
10222
|
+
const projectRoot = await realpath4(
|
|
10223
|
+
loaded.path === null ? options.cwd : dirname13(loaded.path)
|
|
10224
|
+
).catch(() => resolve4(loaded.path === null ? options.cwd : dirname13(loaded.path)));
|
|
10139
10225
|
const ownerWarning = needsApp && app === null ? inspectLocalDevServer(devServer).then((owners) => devServerOwnerWarning(devServer, projectRoot, owners)).catch(() => null) : Promise.resolve(null);
|
|
10140
10226
|
const serverPromise = startServer({
|
|
10141
10227
|
config,
|
|
@@ -10276,9 +10362,14 @@ function createHandoff() {
|
|
|
10276
10362
|
if (cancelled) return exit(0);
|
|
10277
10363
|
const failed = (error) => {
|
|
10278
10364
|
if (exited) return;
|
|
10279
|
-
const message2 = (error instanceof Error ? error.message : String(error)).replace(
|
|
10280
|
-
|
|
10281
|
-
|
|
10365
|
+
const message2 = (error instanceof Error ? error.message : String(error)).replace(
|
|
10366
|
+
/[.!?]+$/,
|
|
10367
|
+
""
|
|
10368
|
+
);
|
|
10369
|
+
process.stderr.write(
|
|
10370
|
+
`Could not start Leglas again: ${message2}. Start it from your terminal.
|
|
10371
|
+
`
|
|
10372
|
+
);
|
|
10282
10373
|
exit(1);
|
|
10283
10374
|
};
|
|
10284
10375
|
try {
|
|
@@ -10468,7 +10559,13 @@ if (parsed.kind === "show") {
|
|
|
10468
10559
|
}
|
|
10469
10560
|
if (parsed.kind === "new") {
|
|
10470
10561
|
const outcome = await runNew(
|
|
10471
|
-
{
|
|
10562
|
+
{
|
|
10563
|
+
surface: parsed.surface,
|
|
10564
|
+
print: parsed.print,
|
|
10565
|
+
json: parsed.json,
|
|
10566
|
+
from: parsed.from,
|
|
10567
|
+
cwd: process.cwd()
|
|
10568
|
+
},
|
|
10472
10569
|
{ log: (line) => process.stdout.write(`${line}
|
|
10473
10570
|
`) }
|
|
10474
10571
|
);
|
|
@@ -10484,8 +10581,10 @@ var updates = createUpdateService({
|
|
|
10484
10581
|
entry,
|
|
10485
10582
|
argv: process.argv,
|
|
10486
10583
|
cwd: process.cwd(),
|
|
10487
|
-
deps: {
|
|
10488
|
-
|
|
10584
|
+
deps: {
|
|
10585
|
+
log: (line) => (parsed.options.json ? process.stderr : process.stdout).write(`${line}
|
|
10586
|
+
`)
|
|
10587
|
+
}
|
|
10489
10588
|
});
|
|
10490
10589
|
var result = await run3(
|
|
10491
10590
|
{ ...parsed.options, cwd: process.cwd() },
|
|
@@ -10493,11 +10592,13 @@ var result = await run3(
|
|
|
10493
10592
|
`), updates }
|
|
10494
10593
|
);
|
|
10495
10594
|
var { handOff, handedOff } = createHandoff();
|
|
10496
|
-
updates.onRestart(
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
|
|
10595
|
+
updates.onRestart(
|
|
10596
|
+
(command) => handOff(command, result.stop, {
|
|
10597
|
+
spawn: spawn4,
|
|
10598
|
+
exit: (code) => process.exit(code),
|
|
10599
|
+
target: process
|
|
10600
|
+
})
|
|
10601
|
+
);
|
|
10501
10602
|
installShutdown(async () => {
|
|
10502
10603
|
if (handedOff()) return;
|
|
10503
10604
|
await result.stop();
|