@docyrus/docyrus 0.0.58 → 0.0.59
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/main.js +47 -2
- package/main.js.map +2 -2
- package/package.json +1 -1
- package/server-loader.js +29 -4
- package/server-loader.js.map +2 -2
package/package.json
CHANGED
package/server-loader.js
CHANGED
|
@@ -45709,6 +45709,7 @@ async function createAgentServer(params) {
|
|
|
45709
45709
|
let devProcess = null;
|
|
45710
45710
|
let devUrl = null;
|
|
45711
45711
|
const DEV_URL_PATTERN = /https?:\/\/(?:localhost|127\.0\.0\.1):\d+/;
|
|
45712
|
+
const ANSI_ESCAPE_PATTERN = /\x1b\[[0-9;]*[a-zA-Z]/g;
|
|
45712
45713
|
const DEV_STARTUP_TIMEOUT_MS = 3e4;
|
|
45713
45714
|
const DEV_PROBE_TIMEOUT_MS = 3e3;
|
|
45714
45715
|
async function probeUrl(url2) {
|
|
@@ -45871,9 +45872,19 @@ async function createAgentServer(params) {
|
|
|
45871
45872
|
}
|
|
45872
45873
|
return c.json({ status: "stopped", url: null, managed: false, project, env, docyrusCliVersion });
|
|
45873
45874
|
});
|
|
45874
|
-
app.post("/api/env/serve", (c) => {
|
|
45875
|
+
app.post("/api/env/serve", async (c) => {
|
|
45875
45876
|
if (devProcess && devProcess.exitCode === null) {
|
|
45876
|
-
|
|
45877
|
+
if (!devUrl) {
|
|
45878
|
+
const detected = await detectDevPort(context.cwd);
|
|
45879
|
+
if (detected) {
|
|
45880
|
+
const probeTarget = `http://localhost:${detected}`;
|
|
45881
|
+
const httpStatus = await probeUrl(probeTarget);
|
|
45882
|
+
if (httpStatus !== null) {
|
|
45883
|
+
devUrl = probeTarget;
|
|
45884
|
+
}
|
|
45885
|
+
}
|
|
45886
|
+
}
|
|
45887
|
+
return c.json({ status: devUrl ? "running" : "starting", url: devUrl });
|
|
45877
45888
|
}
|
|
45878
45889
|
devUrl = null;
|
|
45879
45890
|
const proc = (0, import_node_child_process3.spawn)("pnpm", ["dev"], {
|
|
@@ -45893,7 +45904,8 @@ async function createAgentServer(params) {
|
|
|
45893
45904
|
resolveResponse(response);
|
|
45894
45905
|
}
|
|
45895
45906
|
function checkOutput(text3) {
|
|
45896
|
-
const
|
|
45907
|
+
const clean = text3.replace(ANSI_ESCAPE_PATTERN, "");
|
|
45908
|
+
const match2 = clean.match(DEV_URL_PATTERN);
|
|
45897
45909
|
if (match2) {
|
|
45898
45910
|
devUrl = match2[0];
|
|
45899
45911
|
settle(c.json({ status: "running", url: devUrl }));
|
|
@@ -45911,7 +45923,20 @@ async function createAgentServer(params) {
|
|
|
45911
45923
|
proc.on("error", (err2) => {
|
|
45912
45924
|
settle(c.json({ status: "error", error: err2.message }, 500));
|
|
45913
45925
|
});
|
|
45914
|
-
setTimeout(() => {
|
|
45926
|
+
setTimeout(async () => {
|
|
45927
|
+
if (resolved) {
|
|
45928
|
+
return;
|
|
45929
|
+
}
|
|
45930
|
+
const detected = await detectDevPort(context.cwd);
|
|
45931
|
+
if (detected) {
|
|
45932
|
+
const probeTarget = `http://localhost:${detected}`;
|
|
45933
|
+
const httpStatus = await probeUrl(probeTarget);
|
|
45934
|
+
if (httpStatus !== null) {
|
|
45935
|
+
devUrl = probeTarget;
|
|
45936
|
+
settle(c.json({ status: "running", url: devUrl }));
|
|
45937
|
+
return;
|
|
45938
|
+
}
|
|
45939
|
+
}
|
|
45915
45940
|
settle(c.json({ status: "error", error: stderr || "Timed out waiting for dev server URL" }, 500));
|
|
45916
45941
|
}, DEV_STARTUP_TIMEOUT_MS);
|
|
45917
45942
|
});
|