@nice-code/commander 0.96.0 → 0.97.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/build/cli.cjs CHANGED
@@ -444,6 +444,29 @@ function withDependencies(processes, ids) {
444
444
  return closed;
445
445
  }
446
446
  /**
447
+ * What stopping `direct` AND its dependencies may take down. A dependency is kept when a live
448
+ * process outside the stop set still needs it — and keeping one keeps what IT needs, hence the
449
+ * loop. Dependencies that simply are not running are not reported either way.
450
+ */
451
+ function stopSetWithDependencies(processes, direct, isLive) {
452
+ const stop = withDependencies(processes, direct);
453
+ const kept = [];
454
+ for (let changed = true; changed;) {
455
+ changed = false;
456
+ const needed = withDependencies(processes, processes.filter((proc) => !stop.has(proc.id) && isLive(proc.id)).map((proc) => proc.id));
457
+ for (const id of [...stop]) {
458
+ if (direct.includes(id) || !needed.has(id)) continue;
459
+ stop.delete(id);
460
+ if (isLive(id)) kept.push(id);
461
+ changed = true;
462
+ }
463
+ }
464
+ return {
465
+ stop: orderByDependency(processes, stop),
466
+ kept
467
+ };
468
+ }
469
+ /**
447
470
  * Resolve CLI/UI selection terms against the model. An empty `terms` is the caller's problem
448
471
  * (bare `up` consults `defaultSelection` before ever reaching here).
449
472
  */
@@ -24097,11 +24120,17 @@ function checkEnvReport(value) {
24097
24120
  warnings
24098
24121
  };
24099
24122
  }
24100
- function checkIds(value) {
24123
+ function checkStop(value) {
24101
24124
  const record = asRecord(value);
24102
24125
  if (record == null) return "expected an object";
24103
24126
  const ids = asIdList(record["ids"]);
24104
- return ids == null ? "ids: expected an array of process ids" : { ids };
24127
+ if (ids == null) return "ids: expected an array of process ids";
24128
+ const withDependencies = record["withDependencies"];
24129
+ if (withDependencies != null && typeof withDependencies !== "boolean") return "withDependencies: expected a boolean";
24130
+ return withDependencies === true ? {
24131
+ ids,
24132
+ withDependencies
24133
+ } : { ids };
24105
24134
  }
24106
24135
  function checkRunSuite(value) {
24107
24136
  const record = asRecord(value);
@@ -24242,7 +24271,7 @@ const commanderControlDomain = createActionRootDomain({ domain: "commander" }).c
24242
24271
  actions: {
24243
24272
  ports: actionSchema().input({ schema: handSchema(checkPortsInput) }).output({ schema: handSchema(checkPortsReport) }),
24244
24273
  start: actionSchema().input({ schema: handSchema(checkStart) }).output({ schema: handSchema(checkReport) }),
24245
- stop: actionSchema().input({ schema: handSchema(checkIds) }).output({ schema: handSchema(checkReport) }),
24274
+ stop: actionSchema().input({ schema: handSchema(checkStop) }).output({ schema: handSchema(checkReport) }),
24246
24275
  restart: actionSchema().input({ schema: handSchema(checkStart) }).output({ schema: handSchema(checkReport) }),
24247
24276
  runSuite: actionSchema().input({ schema: handSchema(checkRunSuite) }).output({ schema: handSchema(checkRunSuiteReport) }),
24248
24277
  saveFilter: actionSchema().input({ schema: handSchema(checkSaveFilter) }).output({ schema: handSchema(checkOk) }),
@@ -26420,7 +26449,7 @@ async function withTimeout(ctx, run) {
26420
26449
  async function main() {
26421
26450
  const argv = process.argv.slice(2);
26422
26451
  if (argv[0] === "daemon") {
26423
- const { runCommanderDaemon } = await Promise.resolve().then(() => require("./main-BBRM0ZOp.cjs"));
26452
+ const { runCommanderDaemon } = await Promise.resolve().then(() => require("./main-Xo-6rWk6.cjs"));
26424
26453
  return runCommanderDaemon(argv.slice(1));
26425
26454
  }
26426
26455
  const parsed = parseCliArgs(argv);
@@ -26505,6 +26534,7 @@ exports.resolveCommanderDataDir = resolveCommanderDataDir;
26505
26534
  exports.runTaskPool = runTaskPool;
26506
26535
  exports.savedFilterId = savedFilterId;
26507
26536
  exports.serveChannel = serveChannel;
26537
+ exports.stopSetWithDependencies = stopSetWithDependencies;
26508
26538
  exports.validateCommanderConfig = validateCommanderConfig;
26509
26539
  exports.withDependencies = withDependencies;
26510
26540
  exports.writeInstanceRecord = writeInstanceRecord;