@theholocron/cli 5.0.0-alpha.580 → 5.0.0-alpha.581

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/cli.mjs CHANGED
@@ -14052,20 +14052,24 @@ function environmentProblems(declared, have) {
14052
14052
  *
14053
14053
  * Read-only. The environments that must exist are the ones `setup` creates (when an `environments`
14054
14054
  * provider is configured) and every environment `repo.secrets.environments` names, since a secret can only be
14055
- * set on one that exists. An environment that exists but is not expected is never a problem. With no provider and
14055
+ * set on one that exists. An environment that exists but is not expected is never a problem; it is listed as an
14056
+ * information row (`environments-undeclared`) unless `doctor.manualEnvironments` names it. With no provider and
14056
14057
  * nothing named, nothing is declared; with no provider but some named, the row is a skip with the reason.
14057
14058
  */
14058
14059
  const ID$6 = "environments";
14059
14060
  const TITLE$6 = "environments exist";
14061
+ const UNDECLARED_ID = "environments-undeclared";
14062
+ const UNDECLARED_TITLE = "environments nothing declares";
14060
14063
  async function runDoctorEnvironments(input) {
14061
14064
  const print = input.print ?? ((line) => console.log(line));
14062
14065
  const logger = input.logger ?? getLogger();
14063
14066
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
14064
14067
  await loader.load();
14065
14068
  assertPluginsResolvable(loader, "doctor environments");
14066
- const row = await checkEnvironments(loader, Object.keys(input.loaded.resolved.repo?.secrets?.environments ?? {}), input.loaded.resolved.repo?.environments ?? []);
14067
- printCheckRows([row], print);
14068
- const summary = summariseChecks([row]);
14069
+ const rows = await checkEnvironments(loader, Object.keys(input.loaded.resolved.repo?.secrets?.environments ?? {}), input.loaded.resolved.repo?.environments ?? [], input.loaded.resolved.doctor?.manualEnvironments ?? []);
14070
+ const row = rows[0];
14071
+ printCheckRows(rows, print);
14072
+ const summary = summariseChecks(rows);
14069
14073
  printCheckSummary(summary, print);
14070
14074
  logger.info({
14071
14075
  ...summary,
@@ -14073,12 +14077,12 @@ async function runDoctorEnvironments(input) {
14073
14077
  }, "doctor environments");
14074
14078
  return {
14075
14079
  status: row.status,
14076
- rows: [row],
14080
+ rows,
14077
14081
  summary,
14078
14082
  ...row.status === "skip" ? { reason: row.detail } : {}
14079
14083
  };
14080
14084
  }
14081
- async function checkEnvironments(loader, named, declared) {
14085
+ async function checkEnvironments(loader, named, declared, manual) {
14082
14086
  const make = (status, detail, problems = []) => ({
14083
14087
  id: ID$6,
14084
14088
  title: TITLE$6,
@@ -14087,18 +14091,36 @@ async function checkEnvironments(loader, named, declared) {
14087
14091
  problems
14088
14092
  });
14089
14093
  const names = [...new Set([...declaredEnvironments(declared).map((env) => env.name), ...named].map((n) => n.toLowerCase()))];
14090
- if (names.length === 0) return make("ok", "none declared");
14091
- if (!loader.has("environments")) return make("skip", whyMissing(loader, "environments", "no `environments` provider to check them with"));
14094
+ const known = /* @__PURE__ */ new Set([...names, ...manual.map((n) => n.toLowerCase())]);
14095
+ const undeclaredRows = (have) => {
14096
+ const undeclared = have.map((env) => env.name).filter((name) => !known.has(name.toLowerCase()));
14097
+ return undeclared.length === 0 ? [] : [{
14098
+ id: UNDECLARED_ID,
14099
+ title: UNDECLARED_TITLE,
14100
+ status: "skip",
14101
+ detail: `${undeclared.length} not declared: ${undeclared.join(", ")}`,
14102
+ problems: []
14103
+ }];
14104
+ };
14105
+ if (names.length === 0) {
14106
+ if (!loader.has("environments")) return [make("ok", "none declared")];
14107
+ try {
14108
+ return [make("ok", "none declared"), ...undeclaredRows(await loader.get("environments").listEnvironments())];
14109
+ } catch {
14110
+ return [make("ok", "none declared")];
14111
+ }
14112
+ }
14113
+ if (!loader.has("environments")) return [make("skip", whyMissing(loader, "environments", "no `environments` provider to check them with"))];
14092
14114
  try {
14093
14115
  const have = await loader.get("environments").listEnvironments();
14094
14116
  const problems = [...declaredVsActual(new Map(names.map((name) => [name, true])), new Map(have.map((env) => [env.name.toLowerCase(), true])), {
14095
14117
  noun: "environment",
14096
14118
  flagExtra: false
14097
14119
  }), ...environmentProblems(declared, have)];
14098
- return problems.length > 0 ? make("fail", `${problems.length} problem(s)`, problems) : make("ok", `${names.length} of ${names.length} exist`);
14120
+ return [problems.length > 0 ? make("fail", `${problems.length} problem(s)`, problems) : make("ok", `${names.length} of ${names.length} exist`), ...undeclaredRows(have)];
14099
14121
  } catch (err) {
14100
14122
  const noToken = missingTokenReason(err);
14101
- return noToken !== void 0 ? make("skip", noToken) : make("fail", errorMessage(err));
14123
+ return [noToken !== void 0 ? make("skip", noToken) : make("fail", errorMessage(err))];
14102
14124
  }
14103
14125
  }
14104
14126
  // src/commands/doctor-environments/doctor-environments.command.ts