@theholocron/cli 5.0.0-alpha.393 → 5.0.0-alpha.394

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
@@ -898,7 +898,7 @@ the local override exists to exempt.
898
898
  (`@theholocron/kyber/plugins`: dynamic-imports plugins, resolves capability config packages,
899
899
  builds the capability registry); Holocron's prefix, plugin options and the credentials / `.env`
900
900
  step are passed in
901
- - `src/cli.ts` — yargs entry, dispatches subcommands. `holocron run` / `ci` are
901
+ - `src/cli/cli.ts` — yargs entry, dispatches subcommands. `holocron run` / `ci` are
902
902
  delegated to [`@theholocron/astromech`](../astromech) (`createAstromech`).
903
903
  `holocron repo sync` / `holocron repo setup` write each repo's `.github/workflows/*.yml`
904
904
  thin callers from `astromech.thinCallers()`; `holocron sync github` pushes the
@@ -921,7 +921,7 @@ the local override exists to exempt.
921
921
  The engine itself (the picker, argv and secret env, the dry-run preview, the spawn)
922
922
  and the prompting pieces — `promptForPositionals`, `promptForOptions` — live in
923
923
  `@theholocron/kyber` (`/menu`, `/prompts`), which has no knowledge of commands.
924
- - `src/plugin/connection-probe/` — the `connectionProbe` a plugin offers, kyber's `connectionProbe` (`@theholocron/kyber/checks`)
924
+ - `src/plugin/probes/connection-probe/` — the `connectionProbe` a plugin offers, kyber's `connectionProbe` (`@theholocron/kyber/checks`)
925
925
  typed as the plugin system's `Probe` with `verify` returning `VerifyTokenResult`; `monitoring check` runs its checks
926
926
  with kyber's `runCheckAgainstUrl`.
927
927
  - `src/commands/move-tag/` — the `package move-tag` yargs command, the registry entry and `runMoveTag`, which adds the
package/dist/cli.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
- import { copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
4
3
  import { homedir, tmpdir } from "node:os";
5
4
  import path, { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
6
5
  import { PREFIX, createEnvLookup, firstEnv, holocronEnv } from "@theholocron/env-utils/lookup";
@@ -22,7 +21,9 @@ import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
22
21
  import { Entry, findCredentials } from "@napi-rs/keyring";
23
22
  import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver, createKeyring, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
24
23
  import { errorMessage } from "@theholocron/misc-utils";
25
- import { pathToFileURL } from "node:url";
24
+ import { runCheckAgainstUrl } from "@theholocron/kyber/checks";
25
+ import { fileURLToPath, pathToFileURL } from "node:url";
26
+ import { copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
26
27
  import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
27
28
  import { promptForPositionals } from "@theholocron/kyber/prompts";
28
29
  import { Separator, checkbox, confirm, input, select } from "@inquirer/prompts";
@@ -34,7 +35,6 @@ import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rena
34
35
  import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
35
36
  import { createGitHubClient, getApp, listAppInstallations } from "@theholocron/github-client";
36
37
  import { createServer } from "node:http";
37
- import { runCheckAgainstUrl } from "@theholocron/kyber/checks";
38
38
  import { moveMajorTag } from "@theholocron/kyber/git";
39
39
  import { ADR_DIR, ADR_STATUSES, CLOSED_STATUSES, SPEC_DIRS, SPEC_STATUSES, WITHDRAWN_STATE, assignSpecIds, checkSpecs, classifySpecPath, discussionBody, discussionIdLine, discussionPrLine, discussionTitle, evaluateDocsPresence, isAddedDocComment, isFeat, packageOf, parseFrontmatter, parseSkipDocs, reconcileSpecStatus, specSummary, specTitle, updateFrontmatter } from "@theholocron/astromech/repo-validation";
40
40
  import { loadConfigPath } from "@theholocron/datapad";
@@ -660,7 +660,7 @@ system$1.defineConfig;
660
660
  */
661
661
  const loadConfig = system$1.loadConfig;
662
662
  system$1.compose;
663
- // src/auth.ts
663
+ // src/auth/auth.ts
664
664
  /**
665
665
  * The CLI's credentials: the OS keyring every plugin's bootstrap token lives in, and the two token resolvers built on
666
666
  * it. Both are public, so a plugin's `src/auth.ts` is a one-line call.
@@ -1121,41 +1121,6 @@ function actionsOf(plugin) {
1121
1121
  ...plugin.doctor ? { doctor: plugin.doctor } : {}
1122
1122
  };
1123
1123
  }
1124
- // src/plugin/verify-vercel-project/verify-vercel-project.ts
1125
- /**
1126
- * `true` only when Vercel's API confirms `url` resolves to a deployment
1127
- * whose `projectId` matches `expectedProjectId` exactly. `false` for any
1128
- * other outcome — a non-matching project, a non-2xx response, a
1129
- * malformed body, or a transport failure — never throws, since every one
1130
- * of those outcomes means the same thing to a caller: don't attach the
1131
- * credential.
1132
- */
1133
- async function verifyVercelDeploymentProject(url, expectedProjectId, token, opts = {}) {
1134
- const doFetch = opts.fetch ?? fetch;
1135
- const baseUrl = opts.baseUrl ?? "https://api.vercel.com";
1136
- let host;
1137
- try {
1138
- host = new URL(url).host;
1139
- } catch {
1140
- return false;
1141
- }
1142
- const params = new URLSearchParams({ url: host });
1143
- if (opts.teamId) params.set("teamId", opts.teamId);
1144
- let response;
1145
- try {
1146
- response = await doFetch(`${baseUrl}/v13/deployments/get?${params}`, { headers: { Authorization: `Bearer ${token}` } });
1147
- } catch {
1148
- return false;
1149
- }
1150
- if (!response.ok) return false;
1151
- let body;
1152
- try {
1153
- body = await response.json();
1154
- } catch {
1155
- return false;
1156
- }
1157
- return (typeof body === "object" && body !== null && "projectId" in body ? body.projectId : void 0) === expectedProjectId;
1158
- }
1159
1124
  // src/commands/auth/auth.ts
1160
1125
  /**
1161
1126
  * `holocron auth <subcommand>` — manage bootstrap credentials in the
@@ -12106,22 +12071,42 @@ async function runMonitoringCheck(input) {
12106
12071
  ...input.runCheck ? { runCheck: input.runCheck } : {}
12107
12072
  });
12108
12073
  }
12109
- // src/commands/monitoring-run-resolved/monitoring-run-resolved.ts
12074
+ // src/commands/monitoring-run-resolved/verify-vercel-project/verify-vercel-project.ts
12110
12075
  /**
12111
- * `holocron monitoring run-resolved <url>` — runs an already-resolved
12112
- * check list (no `holocron.config.ts` loading at all) against `url`
12113
- * (holocron#1030/#1032 review).
12114
- *
12115
- * The trusted half of the `delivery.previewCheck` split, paired with
12116
- * `monitoring resolve-checks` (the untrusted half, which loads config).
12117
- * Safe to run with a credential present, since nothing here executes
12118
- * PR-authored code — but a credential is only ever attached after
12119
- * `verifyVercelDeploymentProject` confirms `url` actually belongs to
12120
- * `vercelProject`: a URL merely ending in `.vercel.app` proves nothing,
12121
- * since anyone can register their own Vercel project (sourcery review
12122
- * on holocron#1032). No `vercelProject` given at all → the credential
12123
- * is never attached, regardless of whether one is configured.
12076
+ * `true` only when Vercel's API confirms `url` resolves to a deployment
12077
+ * whose `projectId` matches `expectedProjectId` exactly. `false` for any
12078
+ * other outcome — a non-matching project, a non-2xx response, a
12079
+ * malformed body, or a transport failure — never throws, since every one
12080
+ * of those outcomes means the same thing to a caller: don't attach the
12081
+ * credential.
12124
12082
  */
12083
+ async function verifyVercelDeploymentProject(url, expectedProjectId, token, opts = {}) {
12084
+ const doFetch = opts.fetch ?? fetch;
12085
+ const baseUrl = opts.baseUrl ?? "https://api.vercel.com";
12086
+ let host;
12087
+ try {
12088
+ host = new URL(url).host;
12089
+ } catch {
12090
+ return false;
12091
+ }
12092
+ const params = new URLSearchParams({ url: host });
12093
+ if (opts.teamId) params.set("teamId", opts.teamId);
12094
+ let response;
12095
+ try {
12096
+ response = await doFetch(`${baseUrl}/v13/deployments/get?${params}`, { headers: { Authorization: `Bearer ${token}` } });
12097
+ } catch {
12098
+ return false;
12099
+ }
12100
+ if (!response.ok) return false;
12101
+ let body;
12102
+ try {
12103
+ body = await response.json();
12104
+ } catch {
12105
+ return false;
12106
+ }
12107
+ return (typeof body === "object" && body !== null && "projectId" in body ? body.projectId : void 0) === expectedProjectId;
12108
+ }
12109
+ // src/commands/monitoring-run-resolved/monitoring-run-resolved.ts
12125
12110
  /**
12126
12111
  * The shared gate every caller that might attach the Deployment
12127
12112
  * Protection bypass header goes through — `monitoring check`'s direct
@@ -15025,7 +15010,7 @@ function workspaceFilterArgs(cwd, scope = {}) {
15025
15010
  *
15026
15011
  * $ pnpm install --frozen-lockfile
15027
15012
  * $ pnpm build
15028
- * $ pnpm exec tsx cli/cli/src/cli.ts package publish --initial
15013
+ * $ pnpm exec tsx cli/cli/src/cli/cli.ts package publish --initial
15029
15014
  *
15030
15015
  * `npm login --auth-type=web` runs automatically the first time — no
15031
15016
  * separate manual step. `pnpm install` + `pnpm build` stay outside the
@@ -15179,7 +15164,7 @@ async function runPublish(input = {}) {
15179
15164
  if (publish.stdout.includes("EOTP") || publish.stderr.includes("EOTP")) {
15180
15165
  print("");
15181
15166
  print(" → hint: your npm account requires 2FA for writes. Re-run with `--otp <code>`:");
15182
- print(` pnpm exec tsx cli/cli/src/cli.ts package publish --initial --otp <6-digit-code>`);
15167
+ print(` pnpm exec tsx cli/cli/src/cli/cli.ts package publish --initial --otp <6-digit-code>`);
15183
15168
  }
15184
15169
  for (const entry of newEntries) print(statusRow("fail", [
15185
15170
  pad(entry.name, nameWidth),
@@ -16916,7 +16901,7 @@ function docsCoverageProbes(repoRoot, typedoc = runTypedoc(repoRoot), diff = rea
16916
16901
  * Workflow files that no task generates and that are not marked `# HAND-MAINTAINED`, so the check would take them for
16917
16902
  * stale generated files. Each is intentional.
16918
16903
  */
16919
- const UNMANAGED_WORKFLOWS = { "ci.sync-templates.yml": "its task is not in the config yet, on purpose (see astromech.config.ts)" };
16904
+ const UNMANAGED_WORKFLOWS = {};
16920
16905
  // src/commands/probe/generated/check-generated.ts
16921
16906
  const WORKFLOWS_DIR = ".github/workflows/";
16922
16907
  /** Where two texts first differ: the line number and both lines, cut to fit a terminal. */
@@ -24454,9 +24439,21 @@ const tunnelCommand = {
24454
24439
  builder: (y) => y.command(tunnelUpCommand).command(groupMenu$1("tunnel")),
24455
24440
  handler: () => {}
24456
24441
  };
24457
- // src/cli.ts
24442
+ // src/cli/own-package-json.ts
24443
+ /**
24444
+ * The `name` and `version` of the package that `moduleUrl` belongs to, from the nearest `package.json` above it.
24445
+ * That is the package root whether the CLI runs from source (`src/cli/cli.ts`, through tsx) or built (`dist/cli.mjs`),
24446
+ * which a fixed `../package.json` would not be: the entry sits one folder deeper in source than it does built.
24447
+ */
24448
+ function ownPackageJson(moduleUrl) {
24449
+ const from = dirname(fileURLToPath(moduleUrl));
24450
+ const root = findRootSync(from, "package.json");
24451
+ if (!root) throw new Error(`no package.json found above ${from}`);
24452
+ return JSON.parse(readFileSync(join(root, "package.json"), "utf-8"));
24453
+ }
24454
+ // src/cli/cli.ts
24458
24455
  const env = createEnvLookup();
24459
- const { name: CLI_PACKAGE_NAME, version: CLI_VERSION } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
24456
+ const { name: CLI_PACKAGE_NAME, version: CLI_VERSION } = ownPackageJson(import.meta.url);
24460
24457
  /**
24461
24458
  * Error class names whose `.message` is a complete, actionable sentence: printed on its own, with no usage dump and no
24462
24459
  * stack trace. Any other error is printed too, so a command that throws a plain `Error` is never silent.