@lifeaitools/clauth 1.5.77 → 1.5.78
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/cli/studio-debug.js +38 -1
- package/package.json +1 -1
package/cli/studio-debug.js
CHANGED
|
@@ -16,6 +16,7 @@ const APP_TARGETS = {
|
|
|
16
16
|
packageName: "@regen/studio",
|
|
17
17
|
command: "pnpm --filter @regen/studio dev",
|
|
18
18
|
url: "http://localhost:3011/editor/local-test-target",
|
|
19
|
+
hmrUrl: "http://localhost:3011/_next/webpack-hmr",
|
|
19
20
|
},
|
|
20
21
|
"studio-test": {
|
|
21
22
|
appSlug: "studio_test",
|
|
@@ -23,6 +24,7 @@ const APP_TARGETS = {
|
|
|
23
24
|
packageName: "@regen/studio",
|
|
24
25
|
command: "pnpm --filter @regen/studio dev",
|
|
25
26
|
url: "http://localhost:3011/editor/local-test-target",
|
|
27
|
+
hmrUrl: "http://localhost:3011/_next/webpack-hmr",
|
|
26
28
|
},
|
|
27
29
|
prt: {
|
|
28
30
|
appSlug: "prt",
|
|
@@ -30,6 +32,7 @@ const APP_TARGETS = {
|
|
|
30
32
|
packageName: "@regen/prt-portal",
|
|
31
33
|
command: "pnpm --filter @regen/prt-portal dev",
|
|
32
34
|
url: "http://localhost:3006",
|
|
35
|
+
hmrUrl: "http://localhost:3006/_next/webpack-hmr",
|
|
33
36
|
},
|
|
34
37
|
"prt-portal": {
|
|
35
38
|
appSlug: "prt",
|
|
@@ -37,6 +40,7 @@ const APP_TARGETS = {
|
|
|
37
40
|
packageName: "@regen/prt-portal",
|
|
38
41
|
command: "pnpm --filter @regen/prt-portal dev",
|
|
39
42
|
url: "http://localhost:3006",
|
|
43
|
+
hmrUrl: "http://localhost:3006/_next/webpack-hmr",
|
|
40
44
|
},
|
|
41
45
|
};
|
|
42
46
|
|
|
@@ -110,6 +114,21 @@ async function isUrlReachable(url) {
|
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
116
|
|
|
117
|
+
async function isNextDevServer(target) {
|
|
118
|
+
if (!target.hmrUrl) return true;
|
|
119
|
+
try {
|
|
120
|
+
const response = await fetch(target.hmrUrl, {
|
|
121
|
+
method: "GET",
|
|
122
|
+
redirect: "manual",
|
|
123
|
+
signal: AbortSignal.timeout(1_500),
|
|
124
|
+
});
|
|
125
|
+
const contentType = response.headers.get("content-type") || "";
|
|
126
|
+
return response.status === 200 && contentType.includes("text/event-stream");
|
|
127
|
+
} catch {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
113
132
|
function resolveTarget(input = {}) {
|
|
114
133
|
const slug = String(input.appSlug || input.brandSlug || "prt").toLowerCase();
|
|
115
134
|
const configured = APP_TARGETS[slug];
|
|
@@ -133,6 +152,7 @@ function resolveTarget(input = {}) {
|
|
|
133
152
|
brandSlug: input.brandSlug || base.brandSlug || input.appSlug || base.appSlug,
|
|
134
153
|
command: input.devCommand || base.command,
|
|
135
154
|
url: input.devUrl || base.url,
|
|
155
|
+
hmrUrl: input.hmrUrl || base.hmrUrl,
|
|
136
156
|
cwd: input.cwd || input.repoRoot || process.cwd(),
|
|
137
157
|
};
|
|
138
158
|
}
|
|
@@ -194,8 +214,25 @@ export class StudioDebugSessionStore {
|
|
|
194
214
|
return { ok: false, error: target.error, message: target.message, status: "error" };
|
|
195
215
|
}
|
|
196
216
|
|
|
197
|
-
const reachable = await isUrlReachable(target.url);
|
|
198
217
|
const shouldLaunch = input.launchDevServer !== false;
|
|
218
|
+
const reachable = await isUrlReachable(target.url);
|
|
219
|
+
const devReady = reachable ? await isNextDevServer(target) : false;
|
|
220
|
+
if (reachable && shouldLaunch && !devReady && target.hmrUrl) {
|
|
221
|
+
return {
|
|
222
|
+
ok: false,
|
|
223
|
+
error: "non_dev_server",
|
|
224
|
+
message: `${target.url} is reachable, but ${target.hmrUrl} is not a Next dev HMR stream. Stop the process on that port and start ${target.command}.`,
|
|
225
|
+
status: "error",
|
|
226
|
+
launch: {
|
|
227
|
+
started: false,
|
|
228
|
+
alreadyRunning: true,
|
|
229
|
+
command: target.command,
|
|
230
|
+
url: target.url,
|
|
231
|
+
pid: null,
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
199
236
|
const launch = reachable
|
|
200
237
|
? { started: false, command: target.command, url: target.url, alreadyRunning: true }
|
|
201
238
|
: shouldLaunch
|