@lunora/cli 1.0.0-alpha.67 → 1.0.0-alpha.68

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.
@@ -1,5 +1,5 @@
1
1
  import { spawnSync, spawn } from 'node:child_process';
2
- import { detectAgentRules, claimDevServerState, clearDevServerState, readDevServerState, readLiveDevServerState, readProjectDependencyNames, DEV_HANDOFF_ENV, isRecordedProcessCurrent, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_DAEMON_ENV, detectAiAgent, resolveRemoteEnabled, readProjectRemotePreference, detectFramework, inferLunoraBindings, packageNamesFromBindings, ensureDevVarsExample, ensureDevVariables, isInteractive, DEV_VARS_FILE, DEV_VARS_EXAMPLE_FILE, fillDevSecrets, updateDevServerState, claimAgentRulesHint, AGENT_RULES_HINT, discoverContainerInfo, streamContainerLogs, materializeRemoteWranglerConfig, formatLunoraEvent } from '@lunora/config';
2
+ import { detectAgentRules, claimDevServerState, clearDevServerState, readDevServerState, readLiveDevServerState, readProjectDependencyNames, DEV_HANDOFF_ENV, isRecordedProcessCurrent, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_DAEMON_ENV, updateDevServerState, detectAiAgent, resolveRemoteEnabled, readProjectRemotePreference, detectFramework, inferLunoraBindings, packageNamesFromBindings, ensureDevVarsExample, ensureDevVariables, isInteractive, DEV_VARS_FILE, DEV_VARS_EXAMPLE_FILE, fillDevSecrets, claimAgentRulesHint, AGENT_RULES_HINT, discoverContainerInfo, streamContainerLogs, materializeRemoteWranglerConfig, formatLunoraEvent } from '@lunora/config';
3
3
  import { p as parseApiSpec } from '../packem_shared/api-spec-Bx0iKbxA.mjs';
4
4
  import { existsSync, watch, readFileSync, statSync, openSync, readSync, closeSync, mkdirSync } from 'node:fs';
5
5
  import { join, dirname } from 'node:path';
@@ -437,11 +437,18 @@ const runDevBackground = async (options) => {
437
437
  for (const line of readLogTail(logPath, FAILURE_LOG_TAIL_LINES)) {
438
438
  logger.error(` ${line}`);
439
439
  }
440
- clearDevServerState(cwd, child.pid);
440
+ clearDevServerState(cwd, child.pid ?? process.pid);
441
441
  return { code: outcome.exitCode === 0 ? 1 : outcome.exitCode };
442
442
  }
443
+ if (child.pid !== void 0) {
444
+ const current = readDevServerState(cwd);
445
+ if (current?.pid === process.pid) {
446
+ updateDevServerState(cwd, { logFile: logPath, pid: child.pid });
447
+ }
448
+ }
449
+ const pidHint = child.pid === void 0 ? "" : ` (pid ${String(child.pid)})`;
443
450
  logger.warn(
444
- `dev server did not confirm ready within ${String(Math.round(timeout / 1e3))}s — it may still be compiling. Check \`lunora dev status\` and \`lunora dev logs\`; \`lunora dev stop\` shuts it down.`
451
+ `dev server did not confirm ready within ${String(Math.round(timeout / 1e3))}s — it may still be compiling${pidHint}. Check \`lunora dev status\` and \`lunora dev logs\`; \`lunora dev stop\` shuts it down.`
445
452
  );
446
453
  return { code: 1 };
447
454
  };
@@ -516,10 +523,10 @@ const processGroupId = (pid) => {
516
523
  return void 0;
517
524
  }
518
525
  };
519
- const forceKillRecordedServer = (state, signal) => {
520
- if (process.platform === "win32") {
526
+ const forceKillRecordedServer = (state, signal, platform = process.platform, spawnSyncImpl = spawnSync) => {
527
+ if (platform === "win32") {
521
528
  try {
522
- spawnSync("taskkill", ["/pid", String(state.pid), "/T", "/F"], { stdio: "ignore" });
529
+ spawnSyncImpl("taskkill", ["/pid", String(state.pid), "/T", "/F"], { stdio: "ignore" });
523
530
  } catch {
524
531
  }
525
532
  return;
@@ -536,6 +543,16 @@ const forceKillRecordedServer = (state, signal) => {
536
543
  } catch {
537
544
  }
538
545
  };
546
+ const reportSurvivedForceKill = (state, options) => {
547
+ if (options.json) {
548
+ printJson({ pid: state.pid, stopped: false });
549
+ } else {
550
+ options.logger.error(
551
+ `dev server (pid ${String(state.pid)}) survived the force-kill — record kept; retry \`lunora dev stop\` or kill the process manually.`
552
+ );
553
+ }
554
+ return { code: 1 };
555
+ };
539
556
  const runDevStop = async (options) => {
540
557
  const { cwd, logger } = options;
541
558
  const state = readDevServerState(cwd);
@@ -545,6 +562,8 @@ const runDevStop = async (options) => {
545
562
  });
546
563
  const pollInterval = options.pollIntervalMs ?? POLL_INTERVAL_MS;
547
564
  const grace = options.stopGraceMs ?? STOP_GRACE_MS;
565
+ const platform = options.platform ?? process.platform;
566
+ const spawnSyncImpl = options.spawnSyncImpl ?? spawnSync;
548
567
  if (state === void 0 || !alive(state.pid)) {
549
568
  if (state !== void 0) {
550
569
  clearDevServerState(cwd, state.pid);
@@ -565,7 +584,11 @@ const runDevStop = async (options) => {
565
584
  await sleep(pollInterval);
566
585
  }
567
586
  if (alive(state.pid)) {
568
- forceKillRecordedServer(state, signal);
587
+ forceKillRecordedServer(state, signal, platform, spawnSyncImpl);
588
+ await sleep(pollInterval);
589
+ if (alive(state.pid)) {
590
+ return reportSurvivedForceKill(state, options);
591
+ }
569
592
  }
570
593
  clearDevServerState(cwd, state.pid);
571
594
  if (options.json) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/cli",
3
- "version": "1.0.0-alpha.67",
3
+ "version": "1.0.0-alpha.68",
4
4
  "description": "The Lunora CLI: init, dev, deploy, codegen, run, reset, and migrate commands",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -51,13 +51,13 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@bomb.sh/tab": "0.0.17",
55
- "@lunora/codegen": "1.0.0-alpha.33",
56
- "@lunora/config": "1.0.0-alpha.55",
57
- "@lunora/container": "1.0.0-alpha.6",
58
- "@lunora/d1": "1.0.0-alpha.23",
59
- "@lunora/errors": "1.0.0-alpha.1",
60
- "@lunora/seed": "1.0.0-alpha.16",
54
+ "@bomb.sh/tab": "0.0.16",
55
+ "@lunora/codegen": "1.0.0-alpha.34",
56
+ "@lunora/config": "1.0.0-alpha.56",
57
+ "@lunora/container": "1.0.0-alpha.7",
58
+ "@lunora/d1": "1.0.0-alpha.24",
59
+ "@lunora/errors": "1.0.0-alpha.2",
60
+ "@lunora/seed": "1.0.0-alpha.17",
61
61
  "@visulima/cerebro": "3.0.0-alpha.32",
62
62
  "@visulima/error": "6.0.0-alpha.34",
63
63
  "@visulima/fs": "5.0.0-alpha.32",