@theholocron/cli 5.0.0-alpha.386 → 5.0.0-alpha.387
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/README.md +3 -2
- package/dist/cli.mjs +213 -36
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-Bf62wgAK.d.mts → config-system-u0AcPQ77.d.mts} +1 -1
- package/dist/{index-DDeY-heX.d.mts → index-nzzQsd0r.d.mts} +21 -1
- package/dist/index.d.mts +3 -3
- package/dist/plugin/capabilities.d.mts +2 -2
- package/dist/presets.d.mts +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -249,8 +249,8 @@ provider the config does not use is ignored. The org area is shared: a config in
|
|
|
249
249
|
also reads the repository root's `.holocron/org.ts` (the nearest ancestor with a `.git`), and its own
|
|
250
250
|
`.holocron/org.ts` wins for a key set in both, option by option; that is not an error, so an identifier written in the
|
|
251
251
|
root file needs no copy in the app. The other areas (`repo`, `notifications`) describe the repository and are not
|
|
252
|
-
shared. Anything CI needs (`
|
|
253
|
-
`
|
|
252
|
+
shared. Anything CI needs (`HOLOCRON_CLOUDFLARE_ACCOUNT_ID`,
|
|
253
|
+
`HOLOCRON_TURBO_TEAM`, `HOLOCRON_AXIOM_DATASET`) stays out: it lives in 1Password and syncs to a GitHub variable (`repo.variables.sync`),
|
|
254
254
|
and nothing else carries a copy. `.holocron/org.md` (the agent contract the CLI embeds) is not an area: only
|
|
255
255
|
`.ts`, `.js`, `.mjs`, `.cjs` and `.json` are read.
|
|
256
256
|
|
|
@@ -630,6 +630,7 @@ commands and the config are provider-neutral; Discord is the first provider.
|
|
|
630
630
|
| `holocron doctor variables` | Do the Actions variables `repo.variables` declares exist, with those values (and, for the organization's, that visibility)? One row for the repository and one for the organization, each only when declared. Read-only. A `repo.variables.sync` entry adds one row that checks its names exist (no value is read or shown). An undeclared variable counts only with `prune`; a scope that cannot be read (no provider, no org token) is a skip, not a failure |
|
|
631
631
|
| `holocron doctor ci` | Has the repo moved to the flat task vocabulary? One row each for the `tasks:` entries (a deprecated alias, with the id that replaces it), the generated callers (file, workflow and job name equal the task id), the `ci` aggregate's `expected` list (no id missing or stale) and where the callers point (`theholocron/.github` or holocron `ci-v1`). Read-only, no provider needed; exits 1 on a failure. The ruleset's checks are `doctor repo`'s |
|
|
632
632
|
| `holocron doctor github-app` | Does each GitHub App instance in `githubApps` (`{ name, manifest, environment }`) have what its manifest file (`default_permissions`, `default_events`) declares? Reads the App's id and key from the vault `environment` in memory (never printed), calls `GET /app` and `GET /app/installations` with the App's JWT. Rows per instance: `reachable`, `events` (all subscribed), `permissions` (each granted at least at the manifest's level, `read < write < admin`), `installations` (none lags the App, a pending update fails). Extras on the App are `info` in a row's detail, never a failure. A gap ends with the App's settings page (user- or organization-owned) and, for an installation, its own page. Credentials that cannot be read are a skip; an unreadable manifest or a rejected JWT fails. Read-only |
|
|
633
|
+
| `holocron doctor logs` | Does each Axiom dataset the setup ships logs to exist, and does the token reach it? Rows: `token is accepted` (a 401 fails), one `dataset for <service>` for the CLI (`HOLOCRON_AXIOM_DATASET`, resolved by the logger's own chain), Sentinel (`SENTINEL_AXIOM_DATASET`) and any other `dev.serve.logging.datasetVar` (a 404 fails and names the fix), `organization` (`HOLOCRON_AXIOM_ORG`, then `AXIOM_ORG`), and an `info` row per dataset with the `retentionDays` Axiom reports (or says it reported none). Reads through the optional `Logs.readDataset` / `Logs.checkToken`; never creates a dataset or prints a token. A name or token that cannot be read is a skip. Read-only |
|
|
633
634
|
| `holocron doctor environments` | Do the deployment environments exist? The ones `repo setup` creates (`staging`, `production`, when an `environments` provider is configured) plus every environment `repo.secrets.environments` names. One row. A missing one fails; an extra one is never a problem; no provider with some named is a skip |
|
|
634
635
|
| `holocron doctor project [--post [channel]]` | Does each board `providers.projects.boards` declares exist and match its template? One row per board, status list, field, view and automation rule; the board's extras and the items `project reconcile` would fix (no status, closed but not done, open blocker but not blocked, blocked without a blocker) are `info` rows, never a failure. A template file that does not read fails, naming the file. Read-only; `--post` shares the failing rows through the `notifications` bot. |
|
|
635
636
|
| `holocron doctor credentials` | Does the credentials environment exist, and does it hold every variable the configured plugins take? One row per variable and provider (`ok`, `fail` when missing, `skip` for an optional one not set), listing names only: it never reads a value, and says which spelling of the environment's name matched. |
|
package/dist/cli.mjs
CHANGED
|
@@ -759,6 +759,7 @@ const COMMAND_CONTEXTS = {
|
|
|
759
759
|
"doctor environments": "workspace",
|
|
760
760
|
"doctor credentials": "workspace",
|
|
761
761
|
"doctor project": "workspace",
|
|
762
|
+
"doctor logs": "workspace",
|
|
762
763
|
"doctor github-app": "workspace",
|
|
763
764
|
"project move": "workspace",
|
|
764
765
|
"repo properties apply": "workspace",
|
|
@@ -1516,12 +1517,12 @@ async function runDoctorTokens(input) {
|
|
|
1516
1517
|
try {
|
|
1517
1518
|
module = await importer(pkg);
|
|
1518
1519
|
} catch (err) {
|
|
1519
|
-
rows.push(row$
|
|
1520
|
+
rows.push(row$9(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
|
|
1520
1521
|
continue;
|
|
1521
1522
|
}
|
|
1522
|
-
for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
|
|
1523
|
+
for (const token of module.tokens ?? []) rows.push(await checkToken$1(token, module, env, readToken, now()));
|
|
1523
1524
|
}
|
|
1524
|
-
if (rows.length === 0) rows.push(row$
|
|
1525
|
+
if (rows.length === 0) rows.push(row$9("tokens", "skip", "no configured plugin lists the tokens it takes"));
|
|
1525
1526
|
printCheckRows(rows, print);
|
|
1526
1527
|
const summary = summariseChecks(rows);
|
|
1527
1528
|
printCheckSummary(summary, print);
|
|
@@ -1553,11 +1554,11 @@ async function loadCredentials(input) {
|
|
|
1553
1554
|
try {
|
|
1554
1555
|
await loader.load();
|
|
1555
1556
|
} catch (err) {
|
|
1556
|
-
return [row$
|
|
1557
|
+
return [row$9("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
|
|
1557
1558
|
}
|
|
1558
|
-
return loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$
|
|
1559
|
+
return loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$9(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
|
|
1559
1560
|
}
|
|
1560
|
-
function row$
|
|
1561
|
+
function row$9(id, status, detail) {
|
|
1561
1562
|
return {
|
|
1562
1563
|
id,
|
|
1563
1564
|
title: id,
|
|
@@ -1566,26 +1567,26 @@ function row$8(id, status, detail) {
|
|
|
1566
1567
|
problems: []
|
|
1567
1568
|
};
|
|
1568
1569
|
}
|
|
1569
|
-
async function checkToken(token, module, env, readToken, now) {
|
|
1570
|
+
async function checkToken$1(token, module, env, readToken, now) {
|
|
1570
1571
|
const { keyringKey, envName, vendorEnvName } = token;
|
|
1571
1572
|
const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
|
|
1572
1573
|
const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
|
|
1573
1574
|
const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
|
|
1574
|
-
if (!value) return row$
|
|
1575
|
+
if (!value) return row$9(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron auth set ${keyringKey}\`)`);
|
|
1575
1576
|
const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
|
|
1576
|
-
if (!verify) return row$
|
|
1577
|
+
if (!verify) return row$9(keyringKey, "skip", "set, but its plugin cannot verify it");
|
|
1577
1578
|
const from = fromEnv ?? stored?.source ?? "keyring";
|
|
1578
1579
|
try {
|
|
1579
1580
|
const verified = await verify(value);
|
|
1580
|
-
if (!verified.ok) return row$
|
|
1581
|
+
if (!verified.ok) return row$9(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
|
|
1581
1582
|
const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
|
|
1582
|
-
if (!expiry) return row$
|
|
1583
|
+
if (!expiry) return row$9(keyringKey, "ok", `${verified.subject} (${from})`);
|
|
1583
1584
|
return expiry.soon ? {
|
|
1584
|
-
...row$
|
|
1585
|
+
...row$9(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
|
|
1585
1586
|
problems: [`${expiry.text}: renew it`]
|
|
1586
|
-
} : row$
|
|
1587
|
+
} : row$9(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
|
|
1587
1588
|
} catch (err) {
|
|
1588
|
-
return row$
|
|
1589
|
+
return row$9(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
|
|
1589
1590
|
}
|
|
1590
1591
|
}
|
|
1591
1592
|
// src/commands/doctor-tokens/doctor-tokens.command.ts
|
|
@@ -2055,6 +2056,13 @@ const doctorGitHubAppEntry = {
|
|
|
2055
2056
|
positionals: [],
|
|
2056
2057
|
supportsDryRun: false
|
|
2057
2058
|
};
|
|
2059
|
+
// src/commands/doctor-logs/doctor-logs.entry.ts
|
|
2060
|
+
const doctorLogsEntry = {
|
|
2061
|
+
name: "doctor logs",
|
|
2062
|
+
description: "Check the Axiom datasets the setup ships logs to exist and the token reaches them (read-only)",
|
|
2063
|
+
positionals: [],
|
|
2064
|
+
supportsDryRun: false
|
|
2065
|
+
};
|
|
2058
2066
|
// src/commands/doctor-monitoring/doctor-monitoring.entry.ts
|
|
2059
2067
|
const doctorMonitoringEntry = {
|
|
2060
2068
|
name: "doctor monitoring",
|
|
@@ -2599,6 +2607,7 @@ const registry = createCommandRegistry([
|
|
|
2599
2607
|
doctorCredentialsEntry,
|
|
2600
2608
|
doctorProjectEntry,
|
|
2601
2609
|
doctorGitHubAppEntry,
|
|
2610
|
+
doctorLogsEntry,
|
|
2602
2611
|
projectMoveEntry,
|
|
2603
2612
|
{
|
|
2604
2613
|
name: "repo properties apply",
|
|
@@ -4878,7 +4887,7 @@ async function runDoctorCredentials(input) {
|
|
|
4878
4887
|
};
|
|
4879
4888
|
}
|
|
4880
4889
|
/** A row for the provider as a whole, or for one of its variables when `name` is given. */
|
|
4881
|
-
function row$
|
|
4890
|
+
function row$8(provider, status, detail, name) {
|
|
4882
4891
|
return name === void 0 ? {
|
|
4883
4892
|
id: provider,
|
|
4884
4893
|
title: provider,
|
|
@@ -4895,32 +4904,32 @@ function row$7(provider, status, detail, name) {
|
|
|
4895
4904
|
}
|
|
4896
4905
|
async function checkCredentials(input, loader) {
|
|
4897
4906
|
const { resolved } = input.loaded;
|
|
4898
|
-
if (!resolved.providers.credentials) return [row$
|
|
4899
|
-
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$
|
|
4907
|
+
if (!resolved.providers.credentials) return [row$8("credentials", "skip", "no `credentials` provider is configured")];
|
|
4908
|
+
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$8(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
|
|
4900
4909
|
if (!loader.has("credentials")) return rows;
|
|
4901
4910
|
const expected = await expectedTokens(input);
|
|
4902
4911
|
const { tuples } = resolved.providers.credentials;
|
|
4903
4912
|
for (const impl of loader.get("credentials")) {
|
|
4904
4913
|
const tuple = tuples.find((t) => t.provider === impl.providerName);
|
|
4905
4914
|
const environment = tuple && credentialsEnvironment(tuple, resolved);
|
|
4906
|
-
rows.push(...environment ? await checkProvider(impl, environment, expected) : [row$
|
|
4915
|
+
rows.push(...environment ? await checkProvider(impl, environment, expected) : [row$8(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set")]);
|
|
4907
4916
|
}
|
|
4908
4917
|
return rows;
|
|
4909
4918
|
}
|
|
4910
4919
|
async function checkProvider(impl, environment, expected) {
|
|
4911
4920
|
const provider = impl.providerName;
|
|
4912
|
-
if (!impl.inspect) return [row$
|
|
4913
|
-
if (expected.length === 0) return [row$
|
|
4921
|
+
if (!impl.inspect) return [row$8(provider, "skip", "cannot list the variables without reading their values")];
|
|
4922
|
+
if (expected.length === 0) return [row$8(provider, "skip", "no configured plugin lists the tokens it takes")];
|
|
4914
4923
|
try {
|
|
4915
4924
|
const found = await impl.inspect(environment);
|
|
4916
4925
|
const held = new Set(found.names);
|
|
4917
4926
|
const where = found.environment === environment ? `"${found.environment}"` : `"${found.environment}" (the config writes "${environment}")`;
|
|
4918
4927
|
return expected.map(({ name, optional }) => {
|
|
4919
|
-
if (held.has(name)) return row$
|
|
4920
|
-
return optional ? row$
|
|
4928
|
+
if (held.has(name)) return row$8(provider, "ok", `present in ${where}`, name);
|
|
4929
|
+
return optional ? row$8(provider, "skip", `optional, not set in ${where}`, name) : row$8(provider, "fail", `missing from ${where}`, name);
|
|
4921
4930
|
});
|
|
4922
4931
|
} catch (err) {
|
|
4923
|
-
return [row$
|
|
4932
|
+
return [row$8(provider, "fail", errorMessage(err))];
|
|
4924
4933
|
}
|
|
4925
4934
|
}
|
|
4926
4935
|
/**
|
|
@@ -5751,7 +5760,7 @@ async function runDoctorDns(input) {
|
|
|
5751
5760
|
});
|
|
5752
5761
|
else if (!loader.has("dns")) {
|
|
5753
5762
|
const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
|
|
5754
|
-
for (const zone of zones) rows.push(row$
|
|
5763
|
+
for (const zone of zones) rows.push(row$7(zone, "skip", why));
|
|
5755
5764
|
for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
|
|
5756
5765
|
} else {
|
|
5757
5766
|
const dns = loader.get("dns");
|
|
@@ -5773,7 +5782,7 @@ async function runDoctorDns(input) {
|
|
|
5773
5782
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
5774
5783
|
};
|
|
5775
5784
|
}
|
|
5776
|
-
function row$
|
|
5785
|
+
function row$7(zone, status, detail, problems = []) {
|
|
5777
5786
|
return {
|
|
5778
5787
|
id: `dns-${zone}`,
|
|
5779
5788
|
title: `${zone} records exist`,
|
|
@@ -5802,7 +5811,7 @@ async function checkDomain(dns, deploy, project, hostname) {
|
|
|
5802
5811
|
return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
|
|
5803
5812
|
}
|
|
5804
5813
|
}
|
|
5805
|
-
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$
|
|
5814
|
+
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$7(zone, ...args)) {
|
|
5806
5815
|
try {
|
|
5807
5816
|
const have = await dns.listRecords(zone);
|
|
5808
5817
|
const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
|
|
@@ -5937,7 +5946,7 @@ function installationSettingsUrl(account, id) {
|
|
|
5937
5946
|
return `https://github.com/settings/installations/${id}`;
|
|
5938
5947
|
}
|
|
5939
5948
|
// src/commands/doctor-github-app/app-rows.ts
|
|
5940
|
-
const row$
|
|
5949
|
+
const row$6 = (name, what, problems, ok) => ({
|
|
5941
5950
|
id: `${name}:${what}`,
|
|
5942
5951
|
title: `${name}: ${what}`,
|
|
5943
5952
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -5964,9 +5973,9 @@ function appRows(name, manifest, app, installations) {
|
|
|
5964
5973
|
return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
|
|
5965
5974
|
});
|
|
5966
5975
|
return [
|
|
5967
|
-
row$
|
|
5968
|
-
row$
|
|
5969
|
-
row$
|
|
5976
|
+
row$6(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
|
|
5977
|
+
row$6(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
|
|
5978
|
+
row$6(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
|
|
5970
5979
|
];
|
|
5971
5980
|
}
|
|
5972
5981
|
// src/commands/doctor-github-app/parse-manifest.ts
|
|
@@ -6024,7 +6033,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
6024
6033
|
assertPluginsResolvable$1(loader, "doctor github-app");
|
|
6025
6034
|
}
|
|
6026
6035
|
const rows = [];
|
|
6027
|
-
if (instances.length === 0) rows.push(row$
|
|
6036
|
+
if (instances.length === 0) rows.push(row$5("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
6028
6037
|
for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
|
|
6029
6038
|
printCheckRows(rows, print);
|
|
6030
6039
|
const summary = summariseChecks(rows);
|
|
@@ -6041,7 +6050,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
6041
6050
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
6042
6051
|
};
|
|
6043
6052
|
}
|
|
6044
|
-
function row$
|
|
6053
|
+
function row$5(name, what, status, detail) {
|
|
6045
6054
|
return {
|
|
6046
6055
|
id: `${name}:${what}`,
|
|
6047
6056
|
title: `${name}: ${what}`,
|
|
@@ -6084,19 +6093,19 @@ async function checkInstance(instance, loader, input) {
|
|
|
6084
6093
|
try {
|
|
6085
6094
|
manifest = parseManifest(readManifest(instance.manifest));
|
|
6086
6095
|
} catch (err) {
|
|
6087
|
-
return [row$
|
|
6096
|
+
return [row$5(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
|
|
6088
6097
|
}
|
|
6089
6098
|
const read = await readCredentials(instance, loader);
|
|
6090
|
-
if ("reason" in read) return [row$
|
|
6099
|
+
if ("reason" in read) return [row$5(name, "reachable", "skip", read.reason)];
|
|
6091
6100
|
const api = input.api ?? defaultApi;
|
|
6092
6101
|
const secrets = [read.creds.privateKey];
|
|
6093
6102
|
try {
|
|
6094
6103
|
const app = await api.getApp(read.creds);
|
|
6095
6104
|
const installations = await api.listAppInstallations(read.creds);
|
|
6096
6105
|
const owner = app.owner ? `, owned by ${app.owner.login}` : "";
|
|
6097
|
-
return [row$
|
|
6106
|
+
return [row$5(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
|
|
6098
6107
|
} catch (err) {
|
|
6099
|
-
return [row$
|
|
6108
|
+
return [row$5(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed(err, secrets)}`)];
|
|
6100
6109
|
}
|
|
6101
6110
|
}
|
|
6102
6111
|
// src/commands/doctor-github-app/doctor-github-app.command.ts
|
|
@@ -6118,6 +6127,161 @@ const doctorGitHubAppCommand = {
|
|
|
6118
6127
|
})).status === "fail") process.exitCode = 1;
|
|
6119
6128
|
}
|
|
6120
6129
|
};
|
|
6130
|
+
// src/commands/doctor-logs/dataset-targets.ts
|
|
6131
|
+
const SENTINEL_VARIABLE = "SENTINEL_AXIOM_DATASET";
|
|
6132
|
+
/** `SENTINEL_AXIOM_DATASET` to `sentinel`: the part before `_AXIOM_DATASET`, lower case. */
|
|
6133
|
+
const idOf = (variable) => variable.replace(/_AXIOM_DATASET$/, "").toLowerCase();
|
|
6134
|
+
/**
|
|
6135
|
+
* The datasets this repo's setup ships logs to, each resolved the way its service resolves it (ADR-0019): the CLI's
|
|
6136
|
+
* through the logger's own chain (`HOLOCRON_AXIOM_DATASET`, then `AXIOM_DATASET`, then `log.axiom.dataset`, then the
|
|
6137
|
+
* `credentials` providers), Sentinel's and any other service's through the environment then the `credentials`
|
|
6138
|
+
* providers. Another service is the one `dev.serve.logging.datasetVar` names, when it is not one of those two.
|
|
6139
|
+
* Comlink does not log to Axiom yet, so it is not listed.
|
|
6140
|
+
*/
|
|
6141
|
+
function datasetTargets(config) {
|
|
6142
|
+
const targets = [{
|
|
6143
|
+
id: "cli",
|
|
6144
|
+
label: "the CLI",
|
|
6145
|
+
variable: `${PREFIX}_AXIOM_DATASET`,
|
|
6146
|
+
name: resolveCliDataset({ configAxiomDataset: config.log?.axiom?.dataset }, false),
|
|
6147
|
+
fix: "run `holocron repo setup`, which provisions it"
|
|
6148
|
+
}, {
|
|
6149
|
+
id: "sentinel",
|
|
6150
|
+
label: "Sentinel",
|
|
6151
|
+
variable: SENTINEL_VARIABLE,
|
|
6152
|
+
name: resolveValue$2([SENTINEL_VARIABLE]),
|
|
6153
|
+
fix: "create it in Axiom (setup provisions only the CLI's dataset)"
|
|
6154
|
+
}];
|
|
6155
|
+
const other = config.dev?.serve?.logging?.datasetVar;
|
|
6156
|
+
if (other && !targets.some((t) => t.variable === other || other === "AXIOM_DATASET")) targets.push({
|
|
6157
|
+
id: idOf(other),
|
|
6158
|
+
label: `the service behind ${other}`,
|
|
6159
|
+
variable: other,
|
|
6160
|
+
name: resolveValue$2([other]),
|
|
6161
|
+
fix: "create it in Axiom (setup provisions only the CLI's dataset)"
|
|
6162
|
+
});
|
|
6163
|
+
return targets;
|
|
6164
|
+
}
|
|
6165
|
+
// src/commands/doctor-logs/doctor-logs.ts
|
|
6166
|
+
/**
|
|
6167
|
+
* `holocron doctor logs` — does each Axiom dataset the setup ships logs to exist, and does the token reach them?
|
|
6168
|
+
*
|
|
6169
|
+
* Read-only: it never creates a dataset, and prints names and numbers only, never a token or a secret value. One row for
|
|
6170
|
+
* the token (accepted by the provider), one per dataset (the CLI's, Sentinel's and any other `dev.serve.logging` names),
|
|
6171
|
+
* one for the organization, and an `info` row per existing dataset with its retention (ADR-0019: one setting for the whole
|
|
6172
|
+
* dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
|
|
6173
|
+
* a name, a token or a response that cannot be read is a skip with the reason.
|
|
6174
|
+
*/
|
|
6175
|
+
const row$4 = (id, title, status, detail, problems = []) => ({
|
|
6176
|
+
id,
|
|
6177
|
+
title,
|
|
6178
|
+
status,
|
|
6179
|
+
detail,
|
|
6180
|
+
problems
|
|
6181
|
+
});
|
|
6182
|
+
async function runDoctorLogs(input) {
|
|
6183
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
6184
|
+
const logger = input.logger ?? getLogger();
|
|
6185
|
+
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
6186
|
+
await loader.load();
|
|
6187
|
+
assertPluginsResolvable$1(loader, "doctor logs");
|
|
6188
|
+
const rows = [];
|
|
6189
|
+
if (!loader.has("logs")) {
|
|
6190
|
+
const failure = loader.loadFailures().find((f) => f.key === "logs");
|
|
6191
|
+
const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
|
|
6192
|
+
rows.push(row$4("logs", "logs", "skip", why));
|
|
6193
|
+
} else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
|
|
6194
|
+
printCheckRows(rows, print);
|
|
6195
|
+
const summary = summariseChecks(rows);
|
|
6196
|
+
printCheckSummary(summary, print);
|
|
6197
|
+
const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
|
|
6198
|
+
logger.info({
|
|
6199
|
+
...summary,
|
|
6200
|
+
status
|
|
6201
|
+
}, "doctor logs");
|
|
6202
|
+
return {
|
|
6203
|
+
status,
|
|
6204
|
+
rows,
|
|
6205
|
+
summary,
|
|
6206
|
+
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
6207
|
+
};
|
|
6208
|
+
}
|
|
6209
|
+
async function checkLogs(logs, targets) {
|
|
6210
|
+
const rows = [];
|
|
6211
|
+
const token = await checkToken(logs);
|
|
6212
|
+
rows.push(token.row);
|
|
6213
|
+
for (const target of targets) {
|
|
6214
|
+
const id = `logs:dataset:${target.id}`;
|
|
6215
|
+
const title = `dataset for ${target.label}`;
|
|
6216
|
+
if (!target.name) rows.push(row$4(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
|
|
6217
|
+
else if (!token.usable) rows.push(row$4(id, title, "skip", `${target.name}: not checked, the token is not usable`));
|
|
6218
|
+
else if (!logs.readDataset) rows.push(row$4(id, title, "skip", `${logs.providerName} cannot read a dataset`));
|
|
6219
|
+
else rows.push(...await checkDataset(logs, target, target.name, id, title));
|
|
6220
|
+
}
|
|
6221
|
+
const org = resolveValue$2(["AXIOM_ORG"], void 0, { prefix: PREFIX });
|
|
6222
|
+
rows.push(org ? row$4("logs:org", "organization", "ok", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$4("logs:org", "organization", "skip", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links and check-dispatched need it`));
|
|
6223
|
+
return rows;
|
|
6224
|
+
}
|
|
6225
|
+
/** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
|
|
6226
|
+
async function checkToken(logs) {
|
|
6227
|
+
const title = "token is accepted";
|
|
6228
|
+
if (!logs.checkToken) return {
|
|
6229
|
+
row: row$4("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
|
|
6230
|
+
usable: true
|
|
6231
|
+
};
|
|
6232
|
+
try {
|
|
6233
|
+
const result = await logs.checkToken();
|
|
6234
|
+
if (result.ok) return {
|
|
6235
|
+
row: row$4("logs:token", title, "ok", `${logs.providerName} accepts the token`),
|
|
6236
|
+
usable: true
|
|
6237
|
+
};
|
|
6238
|
+
const reason = result.reason ?? `${logs.providerName} refused the token`;
|
|
6239
|
+
return {
|
|
6240
|
+
row: row$4("logs:token", title, "fail", reason, [reason]),
|
|
6241
|
+
usable: false
|
|
6242
|
+
};
|
|
6243
|
+
} catch (err) {
|
|
6244
|
+
const noToken = missingTokenReason(err);
|
|
6245
|
+
const detail = noToken ?? `could not check the token: ${describeError(err)}`;
|
|
6246
|
+
return {
|
|
6247
|
+
row: row$4("logs:token", title, "skip", detail),
|
|
6248
|
+
usable: noToken === void 0
|
|
6249
|
+
};
|
|
6250
|
+
}
|
|
6251
|
+
}
|
|
6252
|
+
async function checkDataset(logs, target, name, id, title) {
|
|
6253
|
+
try {
|
|
6254
|
+
const found = await logs.readDataset(name);
|
|
6255
|
+
if (!found.exists) {
|
|
6256
|
+
const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
|
|
6257
|
+
return [row$4(id, title, "fail", `${name} does not exist`, [problem])];
|
|
6258
|
+
}
|
|
6259
|
+
const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
|
|
6260
|
+
return [row$4(id, title, "ok", `${name} exists`), row$4(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
|
|
6261
|
+
} catch (err) {
|
|
6262
|
+
const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
|
|
6263
|
+
return [row$4(id, title, "skip", detail)];
|
|
6264
|
+
}
|
|
6265
|
+
}
|
|
6266
|
+
// src/commands/doctor-logs/doctor-logs.command.ts
|
|
6267
|
+
const doctorLogsCommand = {
|
|
6268
|
+
command: "logs",
|
|
6269
|
+
describe: "Check the Axiom datasets the setup ships logs to exist and the token reaches them (read-only)",
|
|
6270
|
+
handler: async (argv) => {
|
|
6271
|
+
const tokens = tokenContext$1(argv.token);
|
|
6272
|
+
if (!tokens) return;
|
|
6273
|
+
const loaded = await loadConfig(argv.cwd);
|
|
6274
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
6275
|
+
if ((await runDoctorLogs({
|
|
6276
|
+
loaded,
|
|
6277
|
+
context: {
|
|
6278
|
+
repoRoot: argv.cwd,
|
|
6279
|
+
...tokens,
|
|
6280
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
6281
|
+
}
|
|
6282
|
+
})).status === "fail") process.exitCode = 1;
|
|
6283
|
+
}
|
|
6284
|
+
};
|
|
6121
6285
|
// src/commands/doctor-monitoring/doctor-monitoring.ts
|
|
6122
6286
|
/**
|
|
6123
6287
|
* `holocron doctor monitoring` — do the checks the `monitoring` provider declares exist in its account, as declared?
|
|
@@ -10659,6 +10823,19 @@ const DEEP_CHECKS = [
|
|
|
10659
10823
|
};
|
|
10660
10824
|
}
|
|
10661
10825
|
},
|
|
10826
|
+
{
|
|
10827
|
+
name: "logs",
|
|
10828
|
+
capability: "logs",
|
|
10829
|
+
command: doctorLogsCommand,
|
|
10830
|
+
async run(input) {
|
|
10831
|
+
const report = await runDoctorLogs(input);
|
|
10832
|
+
return {
|
|
10833
|
+
status: report.status,
|
|
10834
|
+
summary: report.summary,
|
|
10835
|
+
...report.reason ? { reason: report.reason } : {}
|
|
10836
|
+
};
|
|
10837
|
+
}
|
|
10838
|
+
},
|
|
10662
10839
|
{
|
|
10663
10840
|
name: "project",
|
|
10664
10841
|
capability: "projects",
|