lunel-cli 0.1.98 → 0.1.100
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 +40 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25,7 +25,6 @@ if (DEBUG_MODE) {
|
|
|
25
25
|
process.env.LUNEL_DEBUG = "1";
|
|
26
26
|
process.env.LUNEL_DEBUG_AI = "1";
|
|
27
27
|
}
|
|
28
|
-
const APPLE_REVIEW_CODE = "abcd";
|
|
29
28
|
import { createRequire } from "module";
|
|
30
29
|
const __require = createRequire(import.meta.url);
|
|
31
30
|
const VERSION = __require("../package.json").version;
|
|
@@ -249,7 +248,6 @@ function parseExtraPortsFromArgs(args) {
|
|
|
249
248
|
return Array.from(parsed).sort((a, b) => a - b);
|
|
250
249
|
}
|
|
251
250
|
const EXTRA_PORTS = parseExtraPortsFromArgs(CLI_ARGS);
|
|
252
|
-
const USE_APPLE_REVIEW_CODE = hasAnyFlag(CLI_ARGS, "--abcd-code");
|
|
253
251
|
const FORCE_NEW_CODE = hasAnyFlag(CLI_ARGS, "--new", "-n");
|
|
254
252
|
const trackedProxyPorts = new Set(EXTRA_PORTS);
|
|
255
253
|
function samePortSet(a, b) {
|
|
@@ -1527,7 +1525,7 @@ function handleProcessesList() {
|
|
|
1527
1525
|
}
|
|
1528
1526
|
return { processes: result };
|
|
1529
1527
|
}
|
|
1530
|
-
function handleProcessesSpawn(payload) {
|
|
1528
|
+
async function handleProcessesSpawn(payload) {
|
|
1531
1529
|
const command = payload.command;
|
|
1532
1530
|
const args = payload.args || [];
|
|
1533
1531
|
const cwd = payload.cwd;
|
|
@@ -1541,7 +1539,31 @@ function handleProcessesSpawn(payload) {
|
|
|
1541
1539
|
stdio: ["pipe", "pipe", "pipe"],
|
|
1542
1540
|
shell: false,
|
|
1543
1541
|
});
|
|
1544
|
-
const pid =
|
|
1542
|
+
const pid = await new Promise((resolve, reject) => {
|
|
1543
|
+
let settled = false;
|
|
1544
|
+
const handleSpawn = () => {
|
|
1545
|
+
if (settled)
|
|
1546
|
+
return;
|
|
1547
|
+
settled = true;
|
|
1548
|
+
proc.removeListener("error", handleError);
|
|
1549
|
+
if (!proc.pid) {
|
|
1550
|
+
reject(Object.assign(new Error(`Failed to spawn "${command}"`), { code: "ERROR" }));
|
|
1551
|
+
return;
|
|
1552
|
+
}
|
|
1553
|
+
resolve(proc.pid);
|
|
1554
|
+
};
|
|
1555
|
+
const handleError = (err) => {
|
|
1556
|
+
if (settled)
|
|
1557
|
+
return;
|
|
1558
|
+
settled = true;
|
|
1559
|
+
proc.removeListener("spawn", handleSpawn);
|
|
1560
|
+
reject(Object.assign(new Error(err.message || `Failed to spawn "${command}"`), {
|
|
1561
|
+
code: err.code || "ERROR",
|
|
1562
|
+
}));
|
|
1563
|
+
};
|
|
1564
|
+
proc.once("spawn", handleSpawn);
|
|
1565
|
+
proc.once("error", handleError);
|
|
1566
|
+
});
|
|
1545
1567
|
const channel = `proc-${pid}`;
|
|
1546
1568
|
const managedProc = {
|
|
1547
1569
|
pid,
|
|
@@ -1571,6 +1593,17 @@ function handleProcessesSpawn(payload) {
|
|
|
1571
1593
|
};
|
|
1572
1594
|
proc.stdout?.on("data", sendOutput("stdout"));
|
|
1573
1595
|
proc.stderr?.on("data", sendOutput("stderr"));
|
|
1596
|
+
proc.on("error", (err) => {
|
|
1597
|
+
const message = err.message || `Process "${command}" failed`;
|
|
1598
|
+
processOutputBuffers.set(channel, (processOutputBuffers.get(channel) || "") + `${message}\n`);
|
|
1599
|
+
emitAppEvent({
|
|
1600
|
+
v: 1,
|
|
1601
|
+
id: `evt-${Date.now()}`,
|
|
1602
|
+
ns: "processes",
|
|
1603
|
+
action: "output",
|
|
1604
|
+
payload: { pid, channel, stream: "stderr", data: `${message}\n` },
|
|
1605
|
+
});
|
|
1606
|
+
});
|
|
1574
1607
|
proc.on("close", (code, signal) => {
|
|
1575
1608
|
const msg = {
|
|
1576
1609
|
v: 1,
|
|
@@ -2567,7 +2600,7 @@ async function processMessage(message) {
|
|
|
2567
2600
|
result = handleProcessesList();
|
|
2568
2601
|
break;
|
|
2569
2602
|
case "spawn":
|
|
2570
|
-
result = handleProcessesSpawn(payload);
|
|
2603
|
+
result = await handleProcessesSpawn(payload);
|
|
2571
2604
|
break;
|
|
2572
2605
|
case "kill":
|
|
2573
2606
|
result = handleProcessesKill(payload);
|
|
@@ -3086,14 +3119,7 @@ async function main() {
|
|
|
3086
3119
|
});
|
|
3087
3120
|
let sessionCodeToUse = null;
|
|
3088
3121
|
let sessionPasswordToUse;
|
|
3089
|
-
if (
|
|
3090
|
-
console.log(`Using fixed review code: ${APPLE_REVIEW_CODE}`);
|
|
3091
|
-
const assembled = await assembleWithCode(APPLE_REVIEW_CODE);
|
|
3092
|
-
sessionCodeToUse = assembled.code;
|
|
3093
|
-
sessionPasswordToUse = assembled.password;
|
|
3094
|
-
await saveSessionForRoot(sessionCodeToUse, sessionPasswordToUse);
|
|
3095
|
-
}
|
|
3096
|
-
else if (!FORCE_NEW_CODE && savedSession) {
|
|
3122
|
+
if (!FORCE_NEW_CODE && savedSession) {
|
|
3097
3123
|
console.log(`Using saved session for ${ROOT_DIR}`);
|
|
3098
3124
|
sessionCodeToUse = savedSession.sessionCode;
|
|
3099
3125
|
sessionPasswordToUse = savedSession.sessionPassword;
|
|
@@ -3128,8 +3154,7 @@ async function main() {
|
|
|
3128
3154
|
}
|
|
3129
3155
|
catch (error) {
|
|
3130
3156
|
const message = error instanceof Error ? error.message : String(error);
|
|
3131
|
-
if (
|
|
3132
|
-
usedSavedSession &&
|
|
3157
|
+
if (usedSavedSession &&
|
|
3133
3158
|
/invalid|revoked|not found|expired|password invalid|password revoked/i.test(message)) {
|
|
3134
3159
|
await clearSavedSessionForRoot().catch(() => { });
|
|
3135
3160
|
}
|