kandev 0.3.0 → 0.4.0

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/dev.js CHANGED
@@ -37,17 +37,20 @@ async function runDev({ repoRoot, backendPort, webPort }) {
37
37
  supervisor.children.push(backendProc);
38
38
  (0, shared_1.attachBackendExitHandler)(backendProc, supervisor);
39
39
  const healthTimeoutMs = (0, health_1.resolveHealthTimeoutMs)(constants_1.HEALTH_TIMEOUT_MS_DEV);
40
+ console.log("[kandev] starting backend...");
40
41
  await (0, health_1.waitForHealth)(ports.backendUrl, backendProc, healthTimeoutMs);
41
42
  console.log(`[kandev] backend ready at ${ports.backendUrl}`);
42
43
  const webUrl = `http://localhost:${ports.webPort}`;
43
- (0, web_1.launchWebApp)({
44
+ console.log("[kandev] starting web...");
45
+ const webProc = (0, web_1.launchWebApp)({
44
46
  command: "pnpm",
45
47
  args: ["-C", "apps", "--filter", "@kandev/web", "dev"],
46
48
  cwd: repoRoot,
47
49
  env: webEnv,
48
- url: webUrl,
49
50
  supervisor,
50
51
  label: "web",
51
52
  });
53
+ await (0, health_1.waitForUrlReady)(webUrl, webProc, healthTimeoutMs);
52
54
  console.log(`[kandev] web ready at ${webUrl}`);
55
+ (0, web_1.openBrowser)(webUrl);
53
56
  }
package/dist/health.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.delay = delay;
4
4
  exports.resolveHealthTimeoutMs = resolveHealthTimeoutMs;
5
5
  exports.waitForHealth = waitForHealth;
6
+ exports.waitForUrlReady = waitForUrlReady;
6
7
  function delay(ms) {
7
8
  return new Promise((resolve) => setTimeout(resolve, ms));
8
9
  }
@@ -47,3 +48,20 @@ async function waitForHealth(baseUrl, proc, timeoutMs) {
47
48
  }
48
49
  throw new Error(`Backend healthcheck timed out after ${timeoutMs}ms`);
49
50
  }
51
+ async function waitForUrlReady(url, proc, timeoutMs) {
52
+ const deadline = Date.now() + timeoutMs;
53
+ while (Date.now() < deadline) {
54
+ if (proc.exitCode !== null) {
55
+ throw new Error("Web process exited before URL became reachable");
56
+ }
57
+ try {
58
+ await fetch(url);
59
+ return;
60
+ }
61
+ catch {
62
+ // ignore until timeout
63
+ }
64
+ await delay(300);
65
+ }
66
+ throw new Error(`Web URL readiness timed out after ${timeoutMs}ms (${url})`);
67
+ }
package/dist/run.js CHANGED
@@ -187,24 +187,27 @@ function launchReleaseApps(prepared) {
187
187
  if (!webServerPath) {
188
188
  throw new Error("Web server entry (server.js) not found in bundle");
189
189
  }
190
+ return { supervisor, backendProc, webServerPath };
191
+ }
192
+ async function runRelease({ version, backendPort, webPort }) {
193
+ const prepared = await prepareReleaseBundle({ version, backendPort, webPort });
194
+ const { supervisor, backendProc, webServerPath } = launchReleaseApps(prepared);
195
+ const healthTimeoutMs = (0, health_1.resolveHealthTimeoutMs)(constants_1.HEALTH_TIMEOUT_MS_RELEASE);
196
+ console.log("[kandev] starting backend...");
197
+ await (0, health_1.waitForHealth)(prepared.backendUrl, backendProc, healthTimeoutMs);
198
+ console.log(`[kandev] backend ready at ${prepared.backendUrl}`);
190
199
  const webUrl = `http://localhost:${prepared.webPort}`;
191
- (0, web_1.launchWebApp)({
200
+ console.log("[kandev] starting web...");
201
+ const webProc = (0, web_1.launchWebApp)({
192
202
  command: "node",
193
203
  args: [webServerPath],
194
204
  cwd: node_path_1.default.dirname(webServerPath),
195
205
  env: prepared.webEnv,
196
- url: webUrl,
197
206
  supervisor,
198
207
  label: "web",
208
+ quiet: true,
199
209
  });
200
- return { supervisor, backendProc, webServerPath };
201
- }
202
- async function runRelease({ version, backendPort, webPort }) {
203
- const prepared = await prepareReleaseBundle({ version, backendPort, webPort });
204
- const { backendProc } = launchReleaseApps(prepared);
205
- // Wait for backend before announcing the web URL.
206
- const healthTimeoutMs = (0, health_1.resolveHealthTimeoutMs)(constants_1.HEALTH_TIMEOUT_MS_RELEASE);
207
- await (0, health_1.waitForHealth)(prepared.backendUrl, backendProc, healthTimeoutMs);
208
- console.log(`[kandev] backend ready at ${prepared.backendUrl}`);
209
- console.log(`[kandev] web ready at http://localhost:${prepared.webPort}`);
210
+ await (0, health_1.waitForUrlReady)(webUrl, webProc, healthTimeoutMs);
211
+ console.log(`[kandev] web ready at ${webUrl}`);
212
+ (0, web_1.openBrowser)(webUrl);
210
213
  }
package/dist/start.js CHANGED
@@ -107,19 +107,22 @@ async function runStart({ repoRoot, backendPort, webPort, verbose = false, debug
107
107
  }
108
108
  (0, shared_1.attachBackendExitHandler)(backendProc, supervisor);
109
109
  const healthTimeoutMs = (0, health_1.resolveHealthTimeoutMs)(constants_1.HEALTH_TIMEOUT_MS_RELEASE);
110
+ console.log("[kandev] starting backend...");
110
111
  await (0, health_1.waitForHealth)(ports.backendUrl, backendProc, healthTimeoutMs);
112
+ console.log(`[kandev] backend ready at ${ports.backendUrl}`);
111
113
  // Use standalone server.js directly (not pnpm start)
112
114
  const webUrl = `http://localhost:${ports.webPort}`;
113
- (0, web_1.launchWebApp)({
115
+ console.log("[kandev] starting web...");
116
+ const webProc = (0, web_1.launchWebApp)({
114
117
  command: "node",
115
118
  args: [webServerPath],
116
119
  cwd: webStandaloneDir,
117
120
  env: webEnv,
118
- url: webUrl,
119
121
  supervisor,
120
122
  label: "web",
121
123
  quiet: !showOutput,
122
124
  });
123
- console.log(`[kandev] backend ready at ${ports.backendUrl}`);
125
+ await (0, health_1.waitForUrlReady)(webUrl, webProc, healthTimeoutMs);
124
126
  console.log(`[kandev] web ready at ${webUrl}`);
127
+ (0, web_1.openBrowser)(webUrl);
125
128
  }
package/dist/web.js CHANGED
@@ -32,7 +32,7 @@ function openBrowser(url) {
32
32
  // ignore browser launch errors
33
33
  }
34
34
  }
35
- function launchWebApp({ command, args, cwd, env, url, supervisor, label, quiet = false, }) {
35
+ function launchWebApp({ command, args, cwd, env, supervisor, label, quiet = false, }) {
36
36
  const stdio = quiet ? ["ignore", "pipe", "pipe"] : "inherit";
37
37
  const proc = (0, node_child_process_1.spawn)(command, args, { cwd, env, stdio });
38
38
  supervisor.children.push(proc);
@@ -45,6 +45,5 @@ function launchWebApp({ command, args, cwd, env, url, supervisor, label, quiet =
45
45
  const exitCode = signal ? 0 : (code ?? 1);
46
46
  void supervisor.shutdown(`${label} exit`).then(() => process.exit(exitCode));
47
47
  });
48
- openBrowser(url);
49
48
  return proc;
50
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kandev",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "description": "NPX launcher for Kandev",
6
6
  "license": "AGPL-3.0-only",