diffwiki 0.17.1 → 0.17.2-rc.202608211158.540e6fb
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 +50 -6
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -163,6 +163,21 @@ function waitForServer(url, timeoutMs = 3e4) {
|
|
|
163
163
|
tick();
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
+
function childExited(child, timeoutMs = 0) {
|
|
167
|
+
if (timeoutMs === 0) return Promise.resolve(child.exitCode !== null || child.signalCode !== null);
|
|
168
|
+
return new Promise((resolve) => {
|
|
169
|
+
const onExit = () => {
|
|
170
|
+
clearTimeout(timer);
|
|
171
|
+
resolve(true);
|
|
172
|
+
};
|
|
173
|
+
const timer = setTimeout(() => {
|
|
174
|
+
child.off("exit", onExit);
|
|
175
|
+
resolve(false);
|
|
176
|
+
}, timeoutMs);
|
|
177
|
+
child.once("exit", onExit);
|
|
178
|
+
if (child.exitCode !== null || child.signalCode !== null) onExit();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
166
181
|
async function startUi(port = DEFAULT_PORT) {
|
|
167
182
|
const { cmd, args } = resolveAppLaunch();
|
|
168
183
|
const child = spawn(cmd, [...args, "--port", String(port)], {
|
|
@@ -184,7 +199,7 @@ async function startUi(port = DEFAULT_PORT) {
|
|
|
184
199
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
185
200
|
};
|
|
186
201
|
await writeState(state);
|
|
187
|
-
return state;
|
|
202
|
+
return { state, child };
|
|
188
203
|
}
|
|
189
204
|
async function stopUi() {
|
|
190
205
|
const state = await readState();
|
|
@@ -576,17 +591,45 @@ async function lintAction(opts) {
|
|
|
576
591
|
${result.fileCount} file(s), ${result.errorCount} error(s), ${result.warnCount} warning(s)`);
|
|
577
592
|
if (result.errorCount > 0) process.exitCode = 1;
|
|
578
593
|
}
|
|
594
|
+
function exitReason(child) {
|
|
595
|
+
if (child.exitCode !== null) return `exit ${child.exitCode}`;
|
|
596
|
+
if (child.signalCode !== null) return `signal ${child.signalCode}`;
|
|
597
|
+
return "unexpectedly";
|
|
598
|
+
}
|
|
579
599
|
async function upAction(opts) {
|
|
580
600
|
const existing = await readState();
|
|
581
601
|
if (existing && isAlive(existing.pid)) {
|
|
582
602
|
console.log(`UI already running at ${existing.url} (pid ${existing.pid})`);
|
|
583
603
|
return;
|
|
584
604
|
}
|
|
585
|
-
const state = await startUi(Number(opts.port));
|
|
605
|
+
const { state, child } = await startUi(Number(opts.port));
|
|
586
606
|
const ok = await waitForServer(state.url);
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
607
|
+
const exited = await childExited(child, ok ? 2e3 : 0);
|
|
608
|
+
if (exited) {
|
|
609
|
+
await stopUi();
|
|
610
|
+
if (ok) {
|
|
611
|
+
const held = await waitForServer(state.url, 1500);
|
|
612
|
+
if (held) {
|
|
613
|
+
console.error(`Port ${state.port} is already in use by another process \u2014 the diffwiki app could not bind.`);
|
|
614
|
+
console.error(`Stop that process, or start the UI on a free port: \`diffwiki ui up --port <port>\`.`);
|
|
615
|
+
} else {
|
|
616
|
+
console.error(
|
|
617
|
+
`The diffwiki app started serving on ${state.url} but exited again (${exitReason(child)}) \u2014 check \`diffwiki ui status\`.`
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
} else {
|
|
621
|
+
console.error(
|
|
622
|
+
`The diffwiki app exited (${exitReason(child)}) before it could serve ${state.url} \u2014 check \`diffwiki ui status\`.`
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
process.exitCode = 1;
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
if (ok) {
|
|
629
|
+
console.log(`UI started at ${state.url} (pid ${state.pid})`);
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
console.log(`Launched (pid ${state.pid}) but ${state.url} did not respond yet \u2014 check \`diffwiki ui status\``);
|
|
590
633
|
}
|
|
591
634
|
async function downAction() {
|
|
592
635
|
const stopped = await stopUi();
|
|
@@ -603,7 +646,8 @@ async function statusAction() {
|
|
|
603
646
|
async function openAction(opts) {
|
|
604
647
|
let state = await readState();
|
|
605
648
|
if (!state || !isAlive(state.pid)) {
|
|
606
|
-
|
|
649
|
+
const started = await startUi(Number(opts.port));
|
|
650
|
+
state = started.state;
|
|
607
651
|
await waitForServer(state.url);
|
|
608
652
|
}
|
|
609
653
|
const coll = await resolveCwdCollection(process.cwd());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diffwiki",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2-rc.202608211158.540e6fb",
|
|
4
4
|
"description": "diffwiki command-line interface",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@logtape/logtape": "^2.2.4",
|
|
19
19
|
"@logtape/file": "^2.2.4",
|
|
20
20
|
"commander": "^13.0.0",
|
|
21
|
-
"diffwiki-core": "0.17.
|
|
21
|
+
"diffwiki-core": "0.17.2-rc.202608211158.540e6fb"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^22.0.0"
|