@theholocron/cli 5.0.0-alpha.473 → 5.0.0-alpha.474

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 CHANGED
@@ -660,6 +660,7 @@ commands and the config are provider-neutral; Discord is the first provider.
660
660
  | `holocron doctor notifications [--built-only] [--deliver] [--post]` | Step by step: does the server match the layout, do the secrets exist, and does a person (not the bot) own it. A full run also leaves one `🧪 test:` post in the layout's `testChannel`; `--built-only` posts nothing; `--deliver` posts to every channel and removes each post; `--post [channel]` posts the result as the bot (the failures, or only the summary when none fail). It also reads the Checkly feed (webhook, alert channel, subscriptions), the Comlink relay (Worker, route, bindings, the tracker's integration and rule) and the Notifications workflow (the file, and the secrets it reads), posting nothing, so `--built-only` keeps those steps. The `bot-permissions` row compares what the bot's roles hold server-wide with the permissions it needs (`ServerInspection` `botPermissions`; the owner and Administrator hold all, channel overwrites are left to the forum row) and, when some are missing, fails naming them in plain words with the invite link that asks for them again (not a credential); it is skipped, with the reason, when the roles could not be read |
661
661
  | `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 |
662
662
  | `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 |
663
+ | `holocron doctor releases` | Did npm receive every release tag? One row per release line (each `release` task group, tags `<group>-v<version>`, and the repo-wide `v<version>`) and channel (`latest`, or a prerelease's first identifier such as `alpha`): the newest tag against what each package serves on that dist-tag. A package behind, or not on npm, fails the row, which names the tag and the `refs/notes/semantic-release-<tag>` note to delete and the two known causes (a sigstore 409, `ENEEDAUTH` fixed by `holocron publish package --sync-trust`). A tag under 30 minutes old is a skip. Reads git tags and npm's public registry; no provider or token. Read-only |
663
664
  | `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 |
664
665
  | `holocron doctor environments` | Do the deployment environments exist? The ones `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 |
665
666
  | `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 `reconcile project` 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. |
package/dist/cli.mjs CHANGED
@@ -14,8 +14,8 @@ import { appendFileSync, copyFileSync, existsSync, fstatSync, mkdirSync, mkdtemp
14
14
  import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
15
15
  import { Entry, findCredentials } from "@napi-rs/keyring";
16
16
  import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
17
- import { DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, HOLOCRON_REPO, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, checkPackageScripts, codecovFlagNames, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, formatJson, frozenReusablePaths, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, localizeActions, mergeScripts, packageLocation, readWorkspacePackages, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, workflowFile, workflowKey, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
18
- import { loadTasksConfig } from "@theholocron/astromech/config";
17
+ import { DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, HOLOCRON_REPO, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, checkPackageScripts, checkReleaseLines, codecovFlagNames, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, formatJson, frozenReusablePaths, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, localizeActions, mergeScripts, packageLocation, readWorkspacePackages, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, wedgeFix, workflowFile, workflowKey, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
18
+ import { loadTasksConfig, releaseGroups } from "@theholocron/astromech/config";
19
19
  import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
20
20
  import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
21
21
  import { ConfigError, ConfigError as ConfigError$1, createConfigSystem, lastWins, mergeByKey, shallowMerge, union } from "@theholocron/kyber/config";
@@ -117,6 +117,7 @@ const COMMAND_CONTEXTS = {
117
117
  "doctor tokens": "workspace",
118
118
  "doctor monitoring": "workspace",
119
119
  "doctor ci": "repo-aware",
120
+ "doctor releases": "repo-aware",
120
121
  probe: "workspace",
121
122
  provider: "workspace",
122
123
  deploy: "workspace",
@@ -444,6 +445,14 @@ const doctorProjectEntry = {
444
445
  skipOptions: ["all", "repo"],
445
446
  supportsDryRun: false
446
447
  };
448
+ // src/commands/doctor-releases/doctor-releases.entry.ts
449
+ const doctorReleasesEntry = {
450
+ name: "doctor releases",
451
+ description: "Check that npm received every release tag, and name the tag and note to delete when it did not (read-only)",
452
+ positionals: [],
453
+ skipOptions: ["all", "repo"],
454
+ supportsDryRun: false
455
+ };
447
456
  // src/commands/doctor-repo/doctor-repo.entry.ts
448
457
  const doctorRepoEntry = {
449
458
  name: "doctor repo",
@@ -1263,6 +1272,7 @@ const registry = createCommandRegistry([
1263
1272
  doctorSecretsEntry,
1264
1273
  doctorTokensEntry,
1265
1274
  doctorCiEntry,
1275
+ doctorReleasesEntry,
1266
1276
  notificationsSetupEntry,
1267
1277
  notificationsCreateServerEntry,
1268
1278
  notificationsLinkEntry,
@@ -11133,6 +11143,214 @@ const doctorProjectCommand = {
11133
11143
  })).status === "fail") process.exitCode = 1;
11134
11144
  }
11135
11145
  };
11146
+ // src/commands/publish/discover-manifests.ts
11147
+ /** `./plugins/x/`, `plugins/x` and `plugins/x/` are the same folder. */
11148
+ const normalizeDir = (dir) => dir.replace(/^\.\//, "").replace(/\/+$/, "");
11149
+ /**
11150
+ * Monorepo (the workspace declares public packages): every workspace
11151
+ * package. Single package (it declares none -- no `pnpm-workspace.yaml`, or one
11152
+ * listing only private members like a docs site): the root `package.json`.
11153
+ * Callers keep the public ones.
11154
+ *
11155
+ * With a `group` (a folder of the repo, `clients`), only that group's packages,
11156
+ * and never the root `package.json`: a group that has no packages has nothing to
11157
+ * publish, not a single-package repo.
11158
+ *
11159
+ * With `onlyPackages` (package names or their folders), only those packages: what is left after the group and
11160
+ * the exclusions is narrowed to them, and one that matches nothing is simply not there.
11161
+ */
11162
+ function discoverManifests(cwd, scope = {}) {
11163
+ const found = discoverAll(cwd, scope);
11164
+ const only = scope.onlyPackages;
11165
+ if (only === void 0 || only.length === 0) return found;
11166
+ const wanted = new Set(only.map(normalizeDir));
11167
+ return found.filter(({ manifest, dir }) => wanted.has(manifest.name ?? "") || wanted.has(normalizeDir(dir)));
11168
+ }
11169
+ function discoverAll(cwd, scope) {
11170
+ const workspace = discoverWorkspacePackages(cwd, scope);
11171
+ if (scope.group !== void 0) return workspace.map(({ manifest, relativeDir }) => ({
11172
+ manifest,
11173
+ dir: `./${relativeDir}`
11174
+ }));
11175
+ if (!workspace.some(({ manifest }) => !manifest.private)) {
11176
+ const manifest = readPackageJsonSync(cwd);
11177
+ return manifest ? [{
11178
+ manifest,
11179
+ dir: "."
11180
+ }] : [];
11181
+ }
11182
+ return workspace.map(({ manifest, relativeDir }) => ({
11183
+ manifest,
11184
+ dir: `./${relativeDir}`
11185
+ }));
11186
+ }
11187
+ // src/commands/publish/discover-public-packages.ts
11188
+ /** The names of `discoverPublicPackageEntries`' packages, without requiring a version. */
11189
+ function discoverPublicPackages(cwd, scope = {}) {
11190
+ return discoverManifests(cwd, scope).flatMap(({ manifest }) => !manifest.private && manifest.name ? [manifest.name] : []);
11191
+ }
11192
+ // src/commands/doctor-releases/real-releases-io.ts
11193
+ const REGISTRY = "https://registry.npmjs.org";
11194
+ /** Reads `git for-each-ref` output: one `<tag> <unix time>` per line. */
11195
+ function parseTagList(output) {
11196
+ return output.split("\n").flatMap((line) => {
11197
+ const [name, time] = line.trim().split(" ");
11198
+ if (!name) return [];
11199
+ const createdAt = Number(time);
11200
+ return [{
11201
+ name,
11202
+ ...Number.isFinite(createdAt) && time ? { createdAt } : {}
11203
+ }];
11204
+ });
11205
+ }
11206
+ const defaultDeps = {
11207
+ spawn: (command, args, options) => spawnSync(command, args, options),
11208
+ fetch: (url) => fetch(url),
11209
+ discover: discoverPublicPackages,
11210
+ nowMs: () => Date.now()
11211
+ };
11212
+ /** `doctor releases`' inputs from the real git checkout under `repoRoot`, the npm registry and the workspace. */
11213
+ function realReleasesIo(repoRoot, deps = defaultDeps) {
11214
+ return {
11215
+ tags: () => {
11216
+ const result = deps.spawn("git", [
11217
+ "for-each-ref",
11218
+ "--format=%(refname:short) %(creatordate:unix)",
11219
+ "refs/tags"
11220
+ ], {
11221
+ cwd: repoRoot,
11222
+ encoding: "utf8"
11223
+ });
11224
+ if (result.status !== 0) throw new Error(`git for-each-ref failed: ${result.stderr.trim()}`);
11225
+ return parseTagList(result.stdout);
11226
+ },
11227
+ packages: (scope) => [...deps.discover(repoRoot, scope)],
11228
+ distTags: async (name) => {
11229
+ const response = await deps.fetch(`${REGISTRY}/-/package/${name.replace("/", "%2f")}/dist-tags`);
11230
+ if (response.status === 404 || response.status === 401) return void 0;
11231
+ if (!response.ok) throw new Error(`npm answered ${response.status} for ${name}`);
11232
+ return await response.json();
11233
+ },
11234
+ now: () => Math.floor(deps.nowMs() / 1e3)
11235
+ };
11236
+ }
11237
+ // src/commands/doctor-releases/release-lines.ts
11238
+ /**
11239
+ * The lines a repo releases on, the way `release.config.ts` cuts them: one per version group named by the `release`
11240
+ * task (tags `<group>-v<version>`) and one for every public package outside them (tags `v<version>`). A line that
11241
+ * publishes no package, such as the `ci` group's private one, is left out: it has nothing on npm to compare.
11242
+ */
11243
+ function releaseLines(config, io) {
11244
+ const groups = releaseGroups(config);
11245
+ return [...groups.map((group) => ({
11246
+ id: group,
11247
+ tagPrefix: `${group}-v`,
11248
+ packages: io.packages({ group })
11249
+ })), {
11250
+ id: "repo",
11251
+ tagPrefix: "v",
11252
+ packages: io.packages({ excludeGroups: groups })
11253
+ }].filter((line) => line.packages.length > 0);
11254
+ }
11255
+ // src/commands/doctor-releases/doctor-releases.ts
11256
+ const DEFAULT_GRACE_SECONDS = 1800;
11257
+ const CONCURRENCY = 8;
11258
+ /** The dist-tags of every name, a few requests at a time. */
11259
+ async function readDistTags(io, names) {
11260
+ const found = /* @__PURE__ */ new Map();
11261
+ for (let i = 0; i < names.length; i += CONCURRENCY) {
11262
+ const batch = names.slice(i, i + CONCURRENCY);
11263
+ const tags = await Promise.all(batch.map((name) => io.distTags(name)));
11264
+ batch.forEach((name, index) => found.set(name, tags[index]));
11265
+ }
11266
+ return found;
11267
+ }
11268
+ function rowOf(check) {
11269
+ const id = `releases-${check.line}-${check.distTag}`;
11270
+ const title = `${check.tag} reached npm (${check.distTag})`;
11271
+ if (check.state === "published") return {
11272
+ id,
11273
+ title,
11274
+ status: "ok",
11275
+ detail: "npm serves it",
11276
+ problems: []
11277
+ };
11278
+ const behind = check.behind.map((p) => `${p.name} serves ${p.onNpm ?? `nothing on ${check.distTag}`}, tag is ${check.version}`);
11279
+ if (check.state === "pending") return {
11280
+ id,
11281
+ title,
11282
+ status: "skip",
11283
+ detail: `${check.behind.length} package(s) behind, but the tag is new: its release may still be publishing`,
11284
+ problems: []
11285
+ };
11286
+ return {
11287
+ id,
11288
+ title,
11289
+ status: "fail",
11290
+ detail: `${check.behind.length} package(s) behind: the tag was pushed and the publish failed`,
11291
+ problems: [...behind, ...wedgeFix(check.tag)]
11292
+ };
11293
+ }
11294
+ async function runDoctorReleases(input) {
11295
+ const print = input.print ?? ((line) => console.log(line));
11296
+ const logger = input.logger ?? getLogger();
11297
+ const io = input.io ?? realReleasesIo(input.context.repoRoot);
11298
+ const lines = releaseLines({ tasks: input.loaded.resolved.tasks ?? [] }, io);
11299
+ let rows;
11300
+ try {
11301
+ const tags = io.tags();
11302
+ const npm = await readDistTags(io, [...new Set(lines.flatMap((line) => line.packages))]);
11303
+ const checks = checkReleaseLines({
11304
+ lines,
11305
+ tags,
11306
+ npm,
11307
+ now: io.now(),
11308
+ graceSeconds: input.graceSeconds ?? DEFAULT_GRACE_SECONDS
11309
+ });
11310
+ rows = checks.length > 0 ? checks.map(rowOf) : [{
11311
+ id: "releases",
11312
+ title: "release tags",
11313
+ status: "skip",
11314
+ detail: "no release tags to check",
11315
+ problems: []
11316
+ }];
11317
+ } catch (err) {
11318
+ rows = [{
11319
+ id: "releases",
11320
+ title: "release tags",
11321
+ status: "skip",
11322
+ detail: `could not read tags or npm: ${errorMessage(err)}`,
11323
+ problems: []
11324
+ }];
11325
+ }
11326
+ printCheckRows(rows, print);
11327
+ const summary = summariseChecks(rows);
11328
+ printCheckSummary(summary, print);
11329
+ const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
11330
+ logger.info({
11331
+ ...summary,
11332
+ status
11333
+ }, "doctor releases");
11334
+ return {
11335
+ status,
11336
+ rows,
11337
+ summary,
11338
+ ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
11339
+ };
11340
+ }
11341
+ // src/commands/doctor-releases/doctor-releases.command.ts
11342
+ const doctorReleasesCommand = {
11343
+ command: "releases",
11344
+ describe: "Check that npm received every release tag, and name the tag and note to delete when it did not (read-only)",
11345
+ handler: async (argv) => {
11346
+ const loaded = await loadConfig(argv.cwd);
11347
+ applyResolvedConfig(argv, loaded.resolved);
11348
+ if ((await runDoctorReleases({
11349
+ loaded,
11350
+ context: { repoRoot: argv.cwd }
11351
+ })).status === "fail") process.exitCode = 1;
11352
+ }
11353
+ };
11136
11354
  // src/commands/coverage-expectations/coverage-expectations.ts
11137
11355
  /**
11138
11356
  * The flags and components `holocron sync` writes to `codecov.yml` for the workspace at `repoRoot`: the same
@@ -14644,6 +14862,19 @@ const DEEP_CHECKS = [
14644
14862
  };
14645
14863
  }
14646
14864
  },
14865
+ {
14866
+ name: "releases",
14867
+ capability: "source",
14868
+ command: doctorReleasesCommand,
14869
+ async run(input) {
14870
+ const report = await runDoctorReleases(input);
14871
+ return {
14872
+ status: report.status,
14873
+ summary: report.summary,
14874
+ ...report.reason ? { reason: report.reason } : {}
14875
+ };
14876
+ }
14877
+ },
14647
14878
  {
14648
14879
  name: "project",
14649
14880
  capability: "projects",
@@ -24783,47 +25014,6 @@ const defaultLogin = async (cwd) => {
24783
25014
  stdio: "inherit"
24784
25015
  }).status ?? -1 };
24785
25016
  };
24786
- // src/commands/publish/discover-manifests.ts
24787
- /** `./plugins/x/`, `plugins/x` and `plugins/x/` are the same folder. */
24788
- const normalizeDir = (dir) => dir.replace(/^\.\//, "").replace(/\/+$/, "");
24789
- /**
24790
- * Monorepo (the workspace declares public packages): every workspace
24791
- * package. Single package (it declares none -- no `pnpm-workspace.yaml`, or one
24792
- * listing only private members like a docs site): the root `package.json`.
24793
- * Callers keep the public ones.
24794
- *
24795
- * With a `group` (a folder of the repo, `clients`), only that group's packages,
24796
- * and never the root `package.json`: a group that has no packages has nothing to
24797
- * publish, not a single-package repo.
24798
- *
24799
- * With `onlyPackages` (package names or their folders), only those packages: what is left after the group and
24800
- * the exclusions is narrowed to them, and one that matches nothing is simply not there.
24801
- */
24802
- function discoverManifests(cwd, scope = {}) {
24803
- const found = discoverAll(cwd, scope);
24804
- const only = scope.onlyPackages;
24805
- if (only === void 0 || only.length === 0) return found;
24806
- const wanted = new Set(only.map(normalizeDir));
24807
- return found.filter(({ manifest, dir }) => wanted.has(manifest.name ?? "") || wanted.has(normalizeDir(dir)));
24808
- }
24809
- function discoverAll(cwd, scope) {
24810
- const workspace = discoverWorkspacePackages(cwd, scope);
24811
- if (scope.group !== void 0) return workspace.map(({ manifest, relativeDir }) => ({
24812
- manifest,
24813
- dir: `./${relativeDir}`
24814
- }));
24815
- if (!workspace.some(({ manifest }) => !manifest.private)) {
24816
- const manifest = readPackageJsonSync(cwd);
24817
- return manifest ? [{
24818
- manifest,
24819
- dir: "."
24820
- }] : [];
24821
- }
24822
- return workspace.map(({ manifest, relativeDir }) => ({
24823
- manifest,
24824
- dir: `./${relativeDir}`
24825
- }));
24826
- }
24827
25017
  // src/commands/publish/discover-public-package-entries.ts
24828
25018
  /**
24829
25019
  * Every public package (`!private && name`) with its version and a
@@ -25348,11 +25538,6 @@ async function runSteadyPublish(input = {}) {
25348
25538
  packageNames
25349
25539
  };
25350
25540
  }
25351
- // src/commands/publish/discover-public-packages.ts
25352
- /** The names of `discoverPublicPackageEntries`' packages, without requiring a version. */
25353
- function discoverPublicPackages(cwd, scope = {}) {
25354
- return discoverManifests(cwd, scope).flatMap(({ manifest }) => !manifest.private && manifest.name ? [manifest.name] : []);
25355
- }
25356
25541
  // src/commands/publish/is-eotp.ts
25357
25542
  function isEotp(parsed) {
25358
25543
  return typeof parsed === "object" && parsed !== null && "error" in parsed && parsed.error?.code === "EOTP";