@theholocron/cli 5.0.0-alpha.484 → 5.0.0-alpha.486

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
@@ -7552,8 +7552,8 @@ const SETUP_ENVIRONMENTS = ["staging", "production"];
7552
7552
  * set on one that exists. An environment that exists but is not expected is never a problem. With no provider and
7553
7553
  * nothing named, nothing is declared; with no provider but some named, the row is a skip with the reason.
7554
7554
  */
7555
- const ID$4 = "environments";
7556
- const TITLE$4 = "environments exist";
7555
+ const ID$5 = "environments";
7556
+ const TITLE$5 = "environments exist";
7557
7557
  async function runDoctorEnvironments(input) {
7558
7558
  const print = input.print ?? ((line) => console.log(line));
7559
7559
  const logger = input.logger ?? getLogger();
@@ -7577,8 +7577,8 @@ async function runDoctorEnvironments(input) {
7577
7577
  }
7578
7578
  async function checkEnvironments(loader, named) {
7579
7579
  const make = (status, detail, problems = []) => ({
7580
- id: ID$4,
7581
- title: TITLE$4,
7580
+ id: ID$5,
7581
+ title: TITLE$5,
7582
7582
  status,
7583
7583
  detail,
7584
7584
  problems
@@ -8103,9 +8103,87 @@ const doctorLogsCommand = {
8103
8103
  })).status === "fail") process.exitCode = 1;
8104
8104
  }
8105
8105
  };
8106
+ // src/commands/workspace-configs/workspace-configs.ts
8107
+ /** The extensions a `holocron.config` can have. */
8108
+ const CONFIG_EXTENSIONS$1 = [
8109
+ "ts",
8110
+ "js",
8111
+ "mjs",
8112
+ "cjs",
8113
+ "json"
8114
+ ];
8115
+ /**
8116
+ * The config of every workspace package that has a `holocron.config.*` of its own (`apps/sentinel`, `apps/comlink`), in
8117
+ * workspace order. A package whose config cannot be loaded is still listed, with the reason, so a caller decides whether
8118
+ * leaving it out is safe (`workspaceProviders()` does, `readWorkspaceMonitoring()` does not). Where the workspace itself
8119
+ * cannot be read (no `pnpm-workspace.yaml`, a bad one) there are none. Nothing is written and no provider is loaded.
8120
+ */
8121
+ async function readWorkspaceConfigs(repoRoot) {
8122
+ let packages;
8123
+ try {
8124
+ packages = readWorkspacePackages(repoRoot);
8125
+ } catch {
8126
+ return [];
8127
+ }
8128
+ const found = [];
8129
+ for (const pkg of packages) {
8130
+ const path = pkg.path ?? `${pkg.dir}/${pkg.slug}`;
8131
+ const dir = join(repoRoot, path);
8132
+ if (!CONFIG_EXTENSIONS$1.some((ext) => existsSync(join(dir, `holocron.config.${ext}`)))) continue;
8133
+ try {
8134
+ found.push({
8135
+ path,
8136
+ dir,
8137
+ resolved: (await loadConfig(dir)).resolved
8138
+ });
8139
+ } catch (err) {
8140
+ found.push({
8141
+ path,
8142
+ dir,
8143
+ error: errorMessage(err)
8144
+ });
8145
+ }
8146
+ }
8147
+ return found;
8148
+ }
8149
+ // src/commands/workspace-monitoring/workspace-monitoring.ts
8150
+ /**
8151
+ * The checks, dashboards and status pages the workspace packages' configs declare, read through the `monitoring`
8152
+ * capability of a loader built over each package's config (the same walk as `workspaceProviders()`), so the command
8153
+ * knows no vendor's option names. Only the declarations are read: the plugin is built, no credential provider is asked
8154
+ * for a value and nothing is requested from the provider. A package with no `monitoring` provider declares nothing; one
8155
+ * whose config cannot be loaded, or whose provider cannot be built, is named in `unreadable`, because "declared
8156
+ * nowhere" cannot be known without it.
8157
+ */
8158
+ async function readWorkspaceMonitoring(context) {
8159
+ const out = {
8160
+ checks: [],
8161
+ dashboards: [],
8162
+ statusPages: [],
8163
+ unreadable: []
8164
+ };
8165
+ for (const pkg of await readWorkspaceConfigs(context.repoRoot)) {
8166
+ if ("error" in pkg) {
8167
+ out.unreadable.push(`${pkg.path}: ${pkg.error}`);
8168
+ continue;
8169
+ }
8170
+ if (!pkg.resolved.providers.monitoring) continue;
8171
+ const loader = new PluginLoader(pkg.resolved, context, void 0, { readCredentials: false });
8172
+ await loader.load();
8173
+ if (!loader.has("monitoring")) {
8174
+ out.unreadable.push(`${pkg.path}: ${whyMissing(loader, "monitoring", "its monitoring provider is not available")}`);
8175
+ continue;
8176
+ }
8177
+ const monitoring = loader.get("monitoring");
8178
+ out.checks.push(...monitoring.checks);
8179
+ out.dashboards.push(...monitoring.dashboards ?? []);
8180
+ out.statusPages.push(...monitoring.statusPages ?? []);
8181
+ }
8182
+ return out;
8183
+ }
8106
8184
  // src/commands/doctor-monitoring/dashboard-rows/dashboard-rows.ts
8107
- const ID$3 = "monitoring-dashboards";
8108
- const TITLE$3 = "monitoring dashboards match";
8185
+ const ID$4 = "monitoring-dashboards";
8186
+ const TITLE$4 = "monitoring dashboards match";
8109
8187
  /** The tags as comparable text: sorted and de-duplicated. */
8110
8188
  const tagsText = (tags) => [...new Set(tags)].sort().join(", ") || "none";
8111
8189
  /** What differs between a declared dashboard and the one the account holds. Privacy is always compared (default private). */
@@ -8137,7 +8215,7 @@ async function dashboardRows(monitoring) {
8137
8215
  detail,
8138
8216
  problems: []
8139
8217
  });
8140
- if (!monitoring.inspectDashboard) return [skip(ID$3, TITLE$3, "provider does not implement inspectDashboard")];
8218
+ if (!monitoring.inspectDashboard) return [skip(ID$4, TITLE$4, "provider does not implement inspectDashboard")];
8141
8219
  try {
8142
8220
  const names = new Set(declared.map((d) => d.name));
8143
8221
  const problems = [];
@@ -8148,14 +8226,14 @@ async function dashboardRows(monitoring) {
8148
8226
  for (const other of have.others) if (!names.has(other)) extra.add(other);
8149
8227
  }
8150
8228
  const rows = [problems.length > 0 ? {
8151
- id: ID$3,
8152
- title: TITLE$3,
8229
+ id: ID$4,
8230
+ title: TITLE$4,
8153
8231
  status: "fail",
8154
8232
  detail: `${problems.length} problem(s)`,
8155
8233
  problems
8156
8234
  } : {
8157
- id: ID$3,
8158
- title: TITLE$3,
8235
+ id: ID$4,
8236
+ title: TITLE$4,
8159
8237
  status: "ok",
8160
8238
  detail: `${declared.length} of ${declared.length} match`,
8161
8239
  problems: []
@@ -8164,10 +8242,10 @@ async function dashboardRows(monitoring) {
8164
8242
  return rows;
8165
8243
  } catch (err) {
8166
8244
  const noToken = missingTokenReason(err);
8167
- if (noToken !== void 0) return [skip(ID$3, TITLE$3, noToken)];
8245
+ if (noToken !== void 0) return [skip(ID$4, TITLE$4, noToken)];
8168
8246
  return [{
8169
- id: ID$3,
8170
- title: TITLE$3,
8247
+ id: ID$4,
8248
+ title: TITLE$4,
8171
8249
  status: "fail",
8172
8250
  detail: errorMessage(err),
8173
8251
  problems: []
@@ -8180,8 +8258,8 @@ async function dashboardRows(monitoring) {
8180
8258
  * (a tag the config states is compared too; one it leaves out is not), and a heartbeat the account holds beyond the
8181
8259
  * config is an `info` row (shown as skipped). Names only: the ping URL is never read here.
8182
8260
  */
8183
- const ID$2 = "monitoring-heartbeats";
8184
- const TITLE$2 = "monitoring heartbeats match";
8261
+ const ID$3 = "monitoring-heartbeats";
8262
+ const TITLE$3 = "monitoring heartbeats match";
8185
8263
  const show = (b) => new Map([
8186
8264
  ["period", `${b.period} ${b.periodUnit}`],
8187
8265
  ["grace", `${b.grace} ${b.graceUnit}`],
@@ -8192,8 +8270,8 @@ async function heartbeatRows(monitoring) {
8192
8270
  const declared = monitoring.heartbeats ?? [];
8193
8271
  if (declared.length === 0) return [];
8194
8272
  const skip = (detail) => ({
8195
- id: ID$2,
8196
- title: TITLE$2,
8273
+ id: ID$3,
8274
+ title: TITLE$3,
8197
8275
  status: "skip",
8198
8276
  detail,
8199
8277
  problems: []
@@ -8217,14 +8295,14 @@ async function heartbeatRows(monitoring) {
8217
8295
  }));
8218
8296
  }
8219
8297
  const rows = [problems.length > 0 ? {
8220
- id: ID$2,
8221
- title: TITLE$2,
8298
+ id: ID$3,
8299
+ title: TITLE$3,
8222
8300
  status: "fail",
8223
8301
  detail: `${problems.length} problem(s)`,
8224
8302
  problems
8225
8303
  } : {
8226
- id: ID$2,
8227
- title: TITLE$2,
8304
+ id: ID$3,
8305
+ title: TITLE$3,
8228
8306
  status: "ok",
8229
8307
  detail: `${declared.length} of ${declared.length} match`,
8230
8308
  problems: []
@@ -8232,7 +8310,7 @@ async function heartbeatRows(monitoring) {
8232
8310
  const declaredNames = new Set(declared.map((b) => b.name));
8233
8311
  const extras = [...have.keys()].filter((name) => !declaredNames.has(name)).sort();
8234
8312
  if (extras.length > 0) rows.push({
8235
- id: `${ID$2}-extra`,
8313
+ id: `${ID$3}-extra`,
8236
8314
  title: "heartbeats beyond the config",
8237
8315
  status: "skip",
8238
8316
  detail: `info: the account also holds ${extras.length}: ${extras.join(", ")}`,
@@ -8243,8 +8321,8 @@ async function heartbeatRows(monitoring) {
8243
8321
  const noToken = missingTokenReason(err);
8244
8322
  if (noToken !== void 0) return [skip(noToken)];
8245
8323
  return [{
8246
- id: ID$2,
8247
- title: TITLE$2,
8324
+ id: ID$3,
8325
+ title: TITLE$3,
8248
8326
  status: "fail",
8249
8327
  detail: errorMessage(err),
8250
8328
  problems: []
@@ -8347,6 +8425,35 @@ async function statusPageRows(monitoring) {
8347
8425
  }
8348
8426
  return rows;
8349
8427
  }
8428
+ // src/commands/doctor-monitoring/undeclared-check-rows/undeclared-check-rows.ts
8429
+ const ID$2 = "monitoring-undeclared";
8430
+ const TITLE$2 = "checks no config declares";
8431
+ function undeclaredCheckRows({ monitoring, workspace, have }) {
8432
+ if (have === void 0) return [];
8433
+ const tags = new Set([
8434
+ ...monitoring.dashboards ?? [],
8435
+ ...workspace.dashboards,
8436
+ ...[...monitoring.statusPages ?? [], ...workspace.statusPages].flatMap((p) => p.components)
8437
+ ].flatMap((x) => x.tags));
8438
+ if (tags.size === 0) return [];
8439
+ const row = (status, detail) => [{
8440
+ id: ID$2,
8441
+ title: TITLE$2,
8442
+ status,
8443
+ detail,
8444
+ problems: []
8445
+ }];
8446
+ if (workspace.unreadable.length > 0) return row("skip", `info: not compared, a package's config could not be read: ${workspace.unreadable.join("; ")}`);
8447
+ const declared = new Set([...monitoring.checks, ...workspace.checks].map((c) => c.name));
8448
+ const picked = have.map((c) => ({
8449
+ name: c.name,
8450
+ tags: c.tags ?? []
8451
+ })).filter((c) => c.tags.some((t) => tags.has(t)));
8452
+ const undeclared = picked.filter((c) => !declared.has(c.name)).sort((a, b) => a.name.localeCompare(b.name));
8453
+ if (undeclared.length === 0) return row("ok", `${picked.length} compared, all declared`);
8454
+ const shown = undeclared.map((c) => `${c.name} (${[...c.tags].sort().join(", ")})`);
8455
+ return row("skip", `info: ${undeclared.length} check(s) a declared dashboard or component picks up, declared nowhere: ${shown.join(", ")}`);
8456
+ }
8350
8457
  // src/commands/doctor-monitoring/doctor-monitoring.ts
8351
8458
  /**
8352
8459
  * `holocron doctor monitoring` — do the checks the `monitoring` provider declares exist in its account, as declared?
@@ -8358,6 +8465,10 @@ async function statusPageRows(monitoring) {
8358
8465
  * lacks fails, an extra tag on it does not. A provider that cannot list its checks, a missing
8359
8466
  * provider that failed to load, or a missing token is a skip with the reason, not a failure.
8360
8467
  *
8468
+ * One more `info` row, `monitoring-undeclared` (`undeclared-check-rows/`), names the account's checks that a declared
8469
+ * dashboard or status page component picks up by tag and that no config declares, the root's or a workspace package's
8470
+ * (`readWorkspaceMonitoring()`). It reuses the checks row's one read of the account and is never a failure.
8471
+ *
8361
8472
  * Heartbeats are one more row (`heartbeat-rows/`): each declared one must exist with the declared period and grace, and
8362
8473
  * the account's others are an `info` row. Names only.
8363
8474
  *
@@ -8372,7 +8483,17 @@ async function runDoctorMonitoring(input) {
8372
8483
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
8373
8484
  await loader.load();
8374
8485
  assertPluginsResolvable(loader, "doctor monitoring");
8375
- const rows = [await checkRow(loader)];
8486
+ const checks = await checkRow(loader);
8487
+ const rows = [checks.row];
8488
+ if (loader.has("monitoring")) {
8489
+ const monitoring = loader.get("monitoring");
8490
+ const workspace = input.workspaceMonitoring ?? await readWorkspaceMonitoring(input.context);
8491
+ rows.push(...undeclaredCheckRows({
8492
+ monitoring,
8493
+ workspace,
8494
+ have: checks.have
8495
+ }));
8496
+ }
8376
8497
  if (loader.has("monitoring")) rows.push(...await dashboardRows(loader.get("monitoring")));
8377
8498
  if (loader.has("monitoring")) rows.push(...await statusPageRows(loader.get("monitoring")));
8378
8499
  rows.push(...await heartbeatRowsOf(loader));
@@ -8391,60 +8512,63 @@ async function runDoctorMonitoring(input) {
8391
8512
  ...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
8392
8513
  };
8393
8514
  }
8515
+ /** The checks row and, when it read them, the checks the account holds (the one read `monitoring-undeclared` reuses). */
8394
8516
  async function checkRow(loader) {
8395
- const skip = (detail) => ({
8517
+ const skip = (detail) => ({ row: {
8396
8518
  id: ID$1,
8397
8519
  title: TITLE$1,
8398
8520
  status: "skip",
8399
8521
  detail,
8400
8522
  problems: []
8401
- });
8402
- if (!loader.has("monitoring")) {
8403
- if (loader.loadFailures().some((f) => f.key === "monitoring")) return skip(whyMissing(loader, "monitoring", "no `monitoring` provider is available"));
8404
- return {
8405
- id: ID$1,
8406
- title: TITLE$1,
8407
- status: "ok",
8408
- detail: "none declared",
8409
- problems: []
8410
- };
8411
- }
8412
- const monitoring = loader.get("monitoring");
8413
- if (monitoring.checks.length === 0) return {
8523
+ } });
8524
+ const none = () => ({ row: {
8414
8525
  id: ID$1,
8415
8526
  title: TITLE$1,
8416
8527
  status: "ok",
8417
8528
  detail: "none declared",
8418
8529
  problems: []
8419
- };
8530
+ } });
8531
+ if (!loader.has("monitoring")) {
8532
+ if (loader.loadFailures().some((f) => f.key === "monitoring")) return skip(whyMissing(loader, "monitoring", "no `monitoring` provider is available"));
8533
+ return none();
8534
+ }
8535
+ const monitoring = loader.get("monitoring");
8536
+ if (monitoring.checks.length === 0) return none();
8420
8537
  if (!monitoring.listChecks) return skip("provider does not implement listChecks");
8421
8538
  try {
8422
- const problems = compareChecks(monitoring.checks, await monitoring.listChecks());
8539
+ const have = await monitoring.listChecks();
8540
+ const problems = compareChecks(monitoring.checks, have);
8423
8541
  if (problems.length > 0) return {
8424
- id: ID$1,
8425
- title: TITLE$1,
8426
- status: "fail",
8427
- detail: `${problems.length} problem(s)`,
8428
- problems
8542
+ row: {
8543
+ id: ID$1,
8544
+ title: TITLE$1,
8545
+ status: "fail",
8546
+ detail: `${problems.length} problem(s)`,
8547
+ problems
8548
+ },
8549
+ have
8429
8550
  };
8430
8551
  const n = monitoring.checks.length;
8431
8552
  return {
8432
- id: ID$1,
8433
- title: TITLE$1,
8434
- status: "ok",
8435
- detail: `${n} of ${n} match`,
8436
- problems: []
8553
+ row: {
8554
+ id: ID$1,
8555
+ title: TITLE$1,
8556
+ status: "ok",
8557
+ detail: `${n} of ${n} match`,
8558
+ problems: []
8559
+ },
8560
+ have
8437
8561
  };
8438
8562
  } catch (err) {
8439
8563
  const noToken = missingTokenReason(err);
8440
8564
  if (noToken !== void 0) return skip(noToken);
8441
- return {
8565
+ return { row: {
8442
8566
  id: ID$1,
8443
8567
  title: TITLE$1,
8444
8568
  status: "fail",
8445
8569
  detail: errorMessage(err),
8446
8570
  problems: []
8447
- };
8571
+ } };
8448
8572
  }
8449
8573
  }
8450
8574
  /** The heartbeat rows, only when a monitoring provider is loaded and declares heartbeats. */
@@ -14811,14 +14935,6 @@ function tokenExpectations(tokens, filter = {}) {
14811
14935
  return found;
14812
14936
  }
14813
14937
  // src/commands/workspace-providers/workspace-providers.ts
14814
- /** The extensions a `holocron.config` can have. */
14815
- const CONFIG_EXTENSIONS$1 = [
14816
- "ts",
14817
- "js",
14818
- "mjs",
14819
- "cjs",
14820
- "json"
14821
- ];
14822
14938
  /**
14823
14939
  * The providers the configs of the workspace's packages name (`apps/sentinel` names `vercel` for its `deployment`) that
14824
14940
  * `config` does not: what `doctor tokens` and `probe` load by name next to the repo's own, so the token a package's
@@ -14829,23 +14945,12 @@ const CONFIG_EXTENSIONS$1 = [
14829
14945
  async function workspaceProviders(repoRoot, config) {
14830
14946
  const known = new Set(providerTuples(config.providers).map((t) => t.provider));
14831
14947
  const found = [];
14832
- let packages;
14833
- try {
14834
- packages = readWorkspacePackages(repoRoot);
14835
- } catch {
14836
- return found;
14837
- }
14838
- for (const pkg of packages) {
14839
- const dir = join(repoRoot, pkg.path ?? `${pkg.dir}/${pkg.slug}`);
14840
- if (!CONFIG_EXTENSIONS$1.some((ext) => existsSync(join(dir, `holocron.config.${ext}`)))) continue;
14841
- try {
14842
- for (const tuple of providerTuples((await loadConfig(dir)).resolved.providers)) {
14843
- if (known.has(tuple.provider)) continue;
14844
- known.add(tuple.provider);
14845
- found.push(tuple);
14846
- }
14847
- } catch {
14848
- continue;
14948
+ for (const pkg of await readWorkspaceConfigs(repoRoot)) {
14949
+ if ("error" in pkg) continue;
14950
+ for (const tuple of providerTuples(pkg.resolved.providers)) {
14951
+ if (known.has(tuple.provider)) continue;
14952
+ known.add(tuple.provider);
14953
+ found.push(tuple);
14849
14954
  }
14850
14955
  }
14851
14956
  return found;