@theholocron/cli 5.0.0-alpha.343 → 5.0.0-alpha.345

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
@@ -679,7 +679,7 @@ holocron auth list # show all stored providers
679
679
  holocron auth export # tokens as NAME=value lines in a private .credentials, to import into a credentials environment
680
680
  holocron auth export --only HOLOCRON_SENTRY_TOKEN # one token, to the clipboard
681
681
  holocron auth export --blank --vendor-names --file --only VERCEL_TOKEN --only HOLOCRON_RELEASE_TOKEN # the stored ones filled, the rest empty
682
- holocron github-app create --name "My App - dev" --webhook-url https://<tunnel>/api/webhook --manifest apps/sentinel/github-app.manifest.json # a GitHub App from a manifest; its id, key and webhook secret to a private .credentials
682
+ holocron github-app create --name "My App - dev" --webhook-url https://<tunnel>/api/webhook --manifest apps/sentinel/github-app.manifest.json # a GitHub App from a manifest (the flow is in @theholocron/dagobah); its id, key and webhook secret to a private .credentials
683
683
  holocron tunnel up --name sentinel-dev --hostname sentinel-dev.example.dev --port 3000 --run # a named tunnel with a stable hostname to a local port
684
684
  holocron project list # the org's project boards (also: create [template], close <number-or-name>, setup)
685
685
  holocron project move v4 v5 --dry-run # preview carrying the open items of one project board to another; without --dry-run it asks first (--yes skips)
@@ -814,8 +814,8 @@ the local override exists to exempt.
814
814
  `notifications sync-roles`, `project reconcile`, `doctor ci`, `doctor credentials`, `doctor dns`, `doctor environments`, `doctor monitoring`, `doctor notifications`, `doctor repo`, `doctor secrets`, `doctor tokens`, `doctor variables`
815
815
  - `src/commands/deep-checks/` — `DEEP_CHECKS`, the registry every `doctor <capability>` is
816
816
  listed in; the shared row renderer and `declaredVsActual` helper are in `@theholocron/kyber/ui`
817
- - `src/interactive-menu/` — the interactive fallback's Holocron data: `command-registry`
818
- (`COMMAND_REGISTRY`, each entry's `positionals`/`options`), `run-menu-entries`
817
+ - `src/interactive-menu/` — the interactive fallback's Holocron data: `command-catalog`
818
+ (`COMMAND_REGISTRY`, built with kyber's `createCommandRegistry`; each entry's `positionals`/`options`), `run-menu-entries`
819
819
  and `probe-menu-entries` (menu entries built at run time), and `menu.ts`,
820
820
  kyber's `createMenu` bound to the `holocron` bin and `HOLOCRON_` env prefix.
821
821
  The engine itself (the picker, argv and secret env, the dry-run preview, the spawn)
package/dist/cli.mjs CHANGED
@@ -22,13 +22,13 @@ import { Entry, findCredentials } from "@napi-rs/keyring";
22
22
  import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver, createKeyring, dotenvLine, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
23
23
  import { errorMessage } from "@theholocron/misc-utils";
24
24
  import { pathToFileURL } from "node:url";
25
- import { DRY_RUN_NOOP_EXIT_CODE, createMenu } from "@theholocron/kyber/menu";
25
+ import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
26
26
  import { promptForPositionals } from "@theholocron/kyber/prompts";
27
27
  import { Separator, checkbox, confirm, input, select } from "@inquirer/prompts";
28
28
  import { execFileSync, spawn, spawnSync } from "node:child_process";
29
29
  import { stringifyJson } from "@theholocron/json-utils";
30
30
  import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
31
- import { serveHandler, superviseProcesses } from "@theholocron/dagobah";
31
+ import { appManifestPage, buildAppManifest, convertAppManifest, serveAppManifest, serveHandler, superviseProcesses } from "@theholocron/dagobah";
32
32
  import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
33
33
  import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
34
34
  import { createServer } from "node:http";
@@ -1921,8 +1921,6 @@ const authExportEntry = {
1921
1921
  positionals: [],
1922
1922
  supportsDryRun: false
1923
1923
  };
1924
- // src/interactive-menu/command-registry/validators.ts
1925
- const numeric = (value) => /^\d+$/.test(value) ? true : "enter a number";
1926
1924
  // src/commands/cleanup-preview/cleanup-preview.entry.ts
1927
1925
  const cleanupPreviewEntry = {
1928
1926
  name: "deploy cleanup-preview",
@@ -2354,7 +2352,7 @@ const PUBLISH_OTP_OPTION = {
2354
2352
  required: Boolean(env$6.get("HOLOCRON_NPM_ENFORCE_2FA")),
2355
2353
  message: "One-time password (2FA), if npm requires it for this publish:"
2356
2354
  };
2357
- // src/interactive-menu/command-registry/command-registry.ts
2355
+ // src/interactive-menu/command-catalog/command-catalog.ts
2358
2356
  /**
2359
2357
  * The full command surface for the interactive menu. Each entry lives next to the command it describes
2360
2358
  * (`commands/<name>/<name>.entry.ts`) and is listed here in menu order; this module does not introspect yargs at runtime.
@@ -2365,7 +2363,7 @@ const PUBLISH_OTP_OPTION = {
2365
2363
  * `run lint commit-msg <file>` stays excluded entirely: it's invoked exclusively from `.husky/commit-msg "$1"`, never
2366
2364
  * typed by a human.
2367
2365
  */
2368
- const COMMAND_REGISTRY = [
2366
+ const registry = createCommandRegistry([
2369
2367
  cloneEntry,
2370
2368
  doctorEntry,
2371
2369
  doctorAllEntry,
@@ -2674,13 +2672,11 @@ const COMMAND_REGISTRY = [
2674
2672
  projectCloseEntry,
2675
2673
  projectSetupEntry,
2676
2674
  projectReconcileEntry
2677
- ];
2678
- /** Look up a {@link CommandEntry} by its full name — for Layer 3 call sites in `cli.ts`. */
2679
- function getEntry(name) {
2680
- const entry = COMMAND_REGISTRY.find((e) => e.name === name);
2681
- if (!entry) throw new Error(`interactive-menu: no COMMAND_REGISTRY entry named "${name}"`);
2682
- return entry;
2683
- }
2675
+ ], "interactive-menu");
2676
+ /** Every Holocron command, in menu order: what {@link launchMenu} lists and what a leaf handler's prompt reads. */
2677
+ const COMMAND_REGISTRY = registry.entries;
2678
+ /** Look up a command's menu entry by its full name — for Layer 3 call sites in `cli.ts`. */
2679
+ const getEntry = registry.getEntry;
2684
2680
  // src/interactive-menu/menu.ts
2685
2681
  /**
2686
2682
  * Kyber's menu engine bound to `holocron`: secret options travel as `HOLOCRON_<OPTION>` env vars and the
@@ -8312,7 +8308,7 @@ const FIELD_TYPES = [
8312
8308
  "iteration"
8313
8309
  ];
8314
8310
  const LAYOUTS = ["board", "table"];
8315
- function isRecord$1(value) {
8311
+ function isRecord(value) {
8316
8312
  return typeof value === "object" && value !== null && !Array.isArray(value);
8317
8313
  }
8318
8314
  function isText(value) {
@@ -8325,7 +8321,7 @@ function namedList(label, value, check) {
8325
8321
  const seen = /* @__PURE__ */ new Set();
8326
8322
  value.forEach((entry, i) => {
8327
8323
  const where = `${label}[${i}]`;
8328
- if (!isRecord$1(entry)) {
8324
+ if (!isRecord(entry)) {
8329
8325
  problems.push(`${where} must be an object`);
8330
8326
  return;
8331
8327
  }
@@ -8342,7 +8338,7 @@ function namedList(label, value, check) {
8342
8338
  * status, the fields and the views). Returns the file typed, or every problem found, so one run lists them all.
8343
8339
  */
8344
8340
  function validateTemplateFile(value) {
8345
- if (!isRecord$1(value)) return {
8341
+ if (!isRecord(value)) return {
8346
8342
  ok: false,
8347
8343
  problems: ["a template must be an object"]
8348
8344
  };
@@ -8361,7 +8357,7 @@ function validateTemplateFile(value) {
8361
8357
  if (value.views !== void 0) problems.push(...namedList("views", value.views, (v, where) => typeof v.layout === "string" && LAYOUTS.includes(v.layout) ? [] : [`${where} needs a layout: ${LAYOUTS.join(", ")}`]));
8362
8358
  if (value.extends === void 0) {
8363
8359
  if (!Array.isArray(value.statuses) || value.statuses.length === 0) problems.push("a template without extends must list its statuses");
8364
- else if (!value.statuses.some((s) => isRecord$1(s) && s.category === "done")) problems.push("statuses need one in the done category");
8360
+ else if (!value.statuses.some((s) => isRecord(s) && s.category === "done")) problems.push("statuses need one in the done category");
8365
8361
  if (value.fields === void 0) problems.push("a template without extends must list its fields (an empty list is fine)");
8366
8362
  if (!Array.isArray(value.views) || value.views.length === 0) problems.push("a template without extends must list its views");
8367
8363
  }
@@ -10359,142 +10355,6 @@ const doctorCommand = {
10359
10355
  })).summary.fail > 0) process.exitCode = 1;
10360
10356
  }
10361
10357
  };
10362
- // src/commands/app-manifest-page/app-manifest-page.ts
10363
- const ESCAPES = {
10364
- "&": "&amp;",
10365
- "<": "&lt;",
10366
- ">": "&gt;",
10367
- "\"": "&quot;",
10368
- "'": "&#39;"
10369
- };
10370
- const escapeHtml = (text) => text.replace(/[&<>"']/g, (c) => ESCAPES[c]);
10371
- /**
10372
- * The page the local server shows: a form that posts the manifest to GitHub on load (the manifest flow takes a form
10373
- * post, not a link), with a button for a browser that blocks the script.
10374
- */
10375
- function appManifestPage(action, manifest) {
10376
- return `<!doctype html>
10377
- <html lang="en">
10378
- <head><meta charset="utf-8"><title>Create ${escapeHtml(manifest.name)}</title></head>
10379
- <body>
10380
- <form id="form" method="post" action="${escapeHtml(action)}">
10381
- <input type="hidden" name="manifest" value="${escapeHtml(JSON.stringify(manifest))}">
10382
- <p>Sending the manifest to GitHub. If nothing happens, <button type="submit">continue</button>.</p>
10383
- </form>
10384
- <script>document.getElementById("form").submit();<\/script>
10385
- </body>
10386
- </html>
10387
- `;
10388
- }
10389
- // src/commands/build-app-manifest/build-app-manifest.ts
10390
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
10391
- /**
10392
- * The manifest to post to GitHub: the shared part read from a file, with this instance's name, webhook and redirect.
10393
- * Throws a message that names the problem when the file or the webhook URL is not usable, so nothing reaches GitHub.
10394
- */
10395
- function buildAppManifest(input) {
10396
- const { base } = input;
10397
- if (!isRecord(base)) throw new Error("the manifest file must hold a JSON object");
10398
- const permissions = base["default_permissions"];
10399
- if (!isRecord(permissions) || !Object.values(permissions).every((access) => typeof access === "string")) throw new Error("the manifest file needs a default_permissions object of permission name to access");
10400
- const events = base["default_events"];
10401
- if (!Array.isArray(events) || !events.every((event) => typeof event === "string")) throw new Error("the manifest file needs a default_events list of event names");
10402
- let webhook;
10403
- try {
10404
- webhook = new URL(input.webhookUrl);
10405
- } catch {
10406
- throw new Error(`the webhook URL is not a URL: ${input.webhookUrl}`);
10407
- }
10408
- if (webhook.protocol !== "https:") throw new Error("the webhook URL must be https: GitHub only delivers to one");
10409
- return {
10410
- name: input.name,
10411
- ...typeof base["description"] === "string" ? { description: base["description"] } : {},
10412
- ...typeof base["url"] === "string" ? { url: base["url"] } : {},
10413
- public: base["public"] === true,
10414
- redirect_url: input.redirectUrl,
10415
- hook_attributes: {
10416
- url: webhook.href,
10417
- active: true
10418
- },
10419
- default_permissions: permissions,
10420
- default_events: events
10421
- };
10422
- }
10423
- // src/commands/convert-app-manifest/convert-app-manifest.ts
10424
- /**
10425
- * Exchanges the one-time code from the manifest flow for the App's id, private key and webhook secret
10426
- * (`POST /app-manifests/{code}/conversions`, which takes no token). The code works once, and GitHub shows the key
10427
- * once. An error names the status, never the body: the body of a success is the secrets.
10428
- */
10429
- async function convertAppManifest(code, fetchImpl = fetch) {
10430
- const response = await fetchImpl(`https://api.github.com/app-manifests/${encodeURIComponent(code)}/conversions`, {
10431
- method: "POST",
10432
- headers: {
10433
- accept: "application/vnd.github+json",
10434
- "x-github-api-version": "2022-11-28"
10435
- }
10436
- });
10437
- if (!response.ok) throw new Error(`GitHub did not convert the manifest (HTTP ${response.status})`);
10438
- const { id, slug, html_url: htmlUrl, pem, webhook_secret: webhookSecret } = await response.json();
10439
- if (typeof id !== "number" || typeof slug !== "string" || typeof htmlUrl !== "string" || typeof pem !== "string" || typeof webhookSecret !== "string") throw new Error("GitHub's answer did not hold the App id, private key and webhook secret");
10440
- return {
10441
- id,
10442
- slug,
10443
- htmlUrl,
10444
- pem,
10445
- webhookSecret
10446
- };
10447
- }
10448
- // src/commands/serve-app-manifest/serve-app-manifest.ts
10449
- const LOOPBACK = "127.0.0.1";
10450
- const FIVE_MINUTES = 3e5;
10451
- /**
10452
- * A one-shot server on a random loopback port: `/` shows the page that posts the manifest to GitHub, `/callback` takes
10453
- * the one-time code GitHub redirects back with. The code is only accepted with the `state` it was started with, and a
10454
- * request that does not name this server's own address (a DNS-rebinding page) is refused.
10455
- */
10456
- async function serveAppManifest(input) {
10457
- let resolveCode;
10458
- let rejectCode;
10459
- const code = new Promise((resolve, reject) => {
10460
- resolveCode = resolve;
10461
- rejectCode = reject;
10462
- });
10463
- code.catch(() => {});
10464
- const server = createServer((req, res) => {
10465
- const reply = (status, type, body) => {
10466
- res.writeHead(status, {
10467
- "content-type": `${type}; charset=utf-8`,
10468
- "cache-control": "no-store"
10469
- });
10470
- res.end(body);
10471
- };
10472
- const { port } = server.address();
10473
- if (req.headers.host !== `${LOOPBACK}:${port}`) return reply(403, "text/plain", "forbidden");
10474
- const url = new URL(req.url, `http://${LOOPBACK}:${port}`);
10475
- if (url.pathname === "/") return reply(200, "text/html", input.page(`http://${LOOPBACK}:${port}/callback`));
10476
- if (url.pathname === "/callback") {
10477
- const got = url.searchParams.get("code");
10478
- if (url.searchParams.get("state") !== input.state || !got) return reply(400, "text/plain", "bad request");
10479
- reply(200, "text/plain", "Done. You can close this tab and go back to the terminal.");
10480
- resolveCode(got);
10481
- return;
10482
- }
10483
- reply(404, "text/plain", "not found");
10484
- });
10485
- await new Promise((resolve) => server.listen(0, LOOPBACK, resolve));
10486
- const timer = setTimeout(() => rejectCode(/* @__PURE__ */ new Error("timed out waiting for GitHub: the App was not created")), input.timeoutMs ?? FIVE_MINUTES);
10487
- const close = () => {
10488
- clearTimeout(timer);
10489
- server.close();
10490
- server.closeAllConnections();
10491
- };
10492
- return {
10493
- url: `http://${LOOPBACK}:${server.address().port}/`,
10494
- code,
10495
- close
10496
- };
10497
- }
10498
10358
  // src/commands/github-app-create/github-app-create.ts
10499
10359
  /**
10500
10360
  * `holocron github-app create` — create a GitHub App from a manifest (GitHub's manifest flow), and keep its
@@ -15868,7 +15728,7 @@ function withAutoPreviewDeployPaths(tasks, gitRoot) {
15868
15728
  }
15869
15729
  // src/commands/thin-caller-file/thin-caller-file.ts
15870
15730
  const { workflowHeader } = createHeader({
15871
- source: "cli/astromech/src/thin-callers.ts",
15731
+ source: "cli/astromech/src/generators/github-action-thin-callers/github-action-thin-callers.ts",
15872
15732
  tool: "holocron repo sync"
15873
15733
  });
15874
15734
  /**