@theholocron/cli 5.0.0-alpha.583 → 5.0.0-alpha.585

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
@@ -77,6 +77,14 @@ expiry); it is read through `resolveValue()` (so a 1Password Environment can hol
77
77
  environment for that run only, never written to an `.npmrc` and never printed. `npm whoami` runs first, so an expired
78
78
  token is reported as such (E401). With no token the command behaves as before (web login, direct publish).
79
79
 
80
+ **`publish approve`** approves what `--initial` staged: `holocron publish approve [--otp <code>] [--yes] [--dry-run]`
81
+ runs `npm stage list`, keeps the pending stages (any status but approved, rejected, published, cancelled or expired) of
82
+ this repository's packages (`--group`, `--exclude-group` and `--package` narrow them as for `publish package`), prints
83
+ one row each, asks once (`--yes` skips it; without a terminal it is required), then runs `npm stage approve <id>` for
84
+ each, with `--otp` when given and otherwise letting npm ask. It uses your own npm login, never `HOLOCRON_NPM_TOKEN`; a
85
+ failed approval is a row and the next still runs, with a non-zero exit. It never stages, publishes or logs in, and
86
+ `--dry-run` approves nothing.
87
+
80
88
  Each workflow's label ends with its real flag in parentheses when it has
81
89
  one, and a longer caveat ("use only for a package's very first publish")
82
90
  shows as helper text under the highlighted choice rather than bloating the
@@ -905,6 +913,7 @@ credential only affects that feature. Store them once in the OS keyring
905
913
  ```sh
906
914
  holocron new token github.read ghp_xxx # clone + CI run listing
907
915
  holocron new token github.issues ghp_xxx # issue management
916
+ holocron new token github.pulls ghp_xxx # open and change pull requests (an agent's; the admin token is the fallback)
908
917
  holocron new token github.sync ghp_xxx # sync-github workflow templates
909
918
  holocron new token github.release ghp_xxx # semantic-release
910
919
  holocron new token github.admin ghp_xxx # setup, secrets, environments
package/dist/cli.mjs CHANGED
@@ -71,6 +71,7 @@ const COMMAND_CONTEXTS = {
71
71
  "publish bump-versions": "global",
72
72
  "publish tag": "global",
73
73
  "publish package": "global",
74
+ "publish approve": "global",
74
75
  "install skills": "global",
75
76
  "remove skill": "global",
76
77
  "update skills": "global",
@@ -1642,7 +1643,7 @@ const providerEntry = {
1642
1643
  supportsDryRun: false
1643
1644
  };
1644
1645
  // src/commands/publish/publish.entry.ts
1645
- const env$11 = createEnvLookup();
1646
+ const env$12 = createEnvLookup();
1646
1647
  const PUBLISH_TAG_OPTION = {
1647
1648
  key: "tag",
1648
1649
  flag: "--tag",
@@ -1655,7 +1656,7 @@ const PUBLISH_OTP_OPTION = {
1655
1656
  type: "password",
1656
1657
  secret: true,
1657
1658
  askLast: true,
1658
- required: Boolean(env$11.get("HOLOCRON_NPM_ENFORCE_2FA")),
1659
+ required: Boolean(env$12.get("HOLOCRON_NPM_ENFORCE_2FA")),
1659
1660
  message: "One-time password (2FA), if npm requires it for this publish:"
1660
1661
  };
1661
1662
  const publishEntry = {
@@ -1719,6 +1720,20 @@ const publishEntry = {
1719
1720
  }
1720
1721
  ]
1721
1722
  };
1723
+ // src/commands/publish/publish-approve.entry.ts
1724
+ const publishApproveEntry = {
1725
+ name: "publish approve",
1726
+ description: "Approve the npm stages a first publish left pending",
1727
+ positionals: [],
1728
+ options: [PUBLISH_OTP_OPTION],
1729
+ skipOptions: [
1730
+ "group",
1731
+ "package",
1732
+ "exclude-group",
1733
+ "yes"
1734
+ ],
1735
+ supportsDryRun: true
1736
+ };
1722
1737
  // src/commands/reconcile-ci/reconcile-ci.entry.ts
1723
1738
  const reconcileCiEntry = {
1724
1739
  name: "reconcile ci",
@@ -2452,6 +2467,7 @@ const registry = createCommandRegistry([
2452
2467
  npmBumpVersionsEntry,
2453
2468
  moveTagEntry,
2454
2469
  publishEntry,
2470
+ publishApproveEntry,
2455
2471
  syncEntry,
2456
2472
  repoCleanupBranchesEntry,
2457
2473
  runCiEntry,
@@ -2780,7 +2796,7 @@ async function offerRealRun(input) {
2780
2796
  * traces, errors, structured context that routes to Axiom. It runs in
2781
2797
  * parallel to `print` (user-facing UX output) and does not replace it.
2782
2798
  */
2783
- const env$10 = createEnvLookup();
2799
+ const env$11 = createEnvLookup();
2784
2800
  const holocron = holocronEnv();
2785
2801
  /**
2786
2802
  * The CLI's Axiom dataset (`holocron`; each service has its own): the process environment (`HOLOCRON_AXIOM_DATASET`, then the unprefixed `AXIOM_DATASET`,
@@ -2808,7 +2824,7 @@ function resolveCliAxiom(opts, ctx) {
2808
2824
  if (fromEnv) return fromEnv;
2809
2825
  const dataset = resolveCliDataset(opts, contextForCommand(ctx.command ?? "") === "global");
2810
2826
  if (!dataset) return void 0;
2811
- const org = opts.org ?? env$10.get(`${PREFIX$1}_ORG`);
2827
+ const org = opts.org ?? env$11.get(`${PREFIX$1}_ORG`);
2812
2828
  const token = holocron.get("AXIOM_TOKEN") || (org ? keyring.get(`axiom.${org}`) : null) || keyring.get("axiom");
2813
2829
  return token ? {
2814
2830
  dataset,
@@ -2834,7 +2850,7 @@ const getRunId = logger.getRunId;
2834
2850
  logger.resetCliLogger;
2835
2851
  logger.resolveLogLevel;
2836
2852
  // src/observability/resolve-telemetry/resolve-telemetry.ts
2837
- const env$9 = holocronEnv();
2853
+ const env$10 = holocronEnv();
2838
2854
  /**
2839
2855
  * Holocron-specific credential resolution for the telemetry sinks — the env
2840
2856
  * chain plus Holocron's own shipped fallbacks. This is **CLI policy**, not part
@@ -2858,15 +2874,15 @@ const FALLBACK_POSTHOG_PROJECT_TOKEN = "phc_AC4vFCvYzwnzmG7Vg5nEc3PZKZztoPyfKp4L
2858
2874
  const DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com";
2859
2875
  /** Resolve the Sentry DSN. `""` → error telemetry disabled. */
2860
2876
  function resolveDsn() {
2861
- return env$9.get("SENTRY_DSN") ?? FALLBACK_DSN;
2877
+ return env$10.get("SENTRY_DSN") ?? FALLBACK_DSN;
2862
2878
  }
2863
2879
  /** Resolve the PostHog project key. `""` → usage analytics disabled. */
2864
2880
  function resolvePostHogKey() {
2865
- return env$9.get("POSTHOG_PROJECT_TOKEN") ?? FALLBACK_POSTHOG_PROJECT_TOKEN;
2881
+ return env$10.get("POSTHOG_PROJECT_TOKEN") ?? FALLBACK_POSTHOG_PROJECT_TOKEN;
2866
2882
  }
2867
2883
  /** Resolve the PostHog ingest host. */
2868
2884
  function resolvePostHogHost() {
2869
- return env$9.get("POSTHOG_HOST") ?? DEFAULT_POSTHOG_HOST;
2885
+ return env$10.get("POSTHOG_HOST") ?? DEFAULT_POSTHOG_HOST;
2870
2886
  }
2871
2887
  // src/observability/telemetry/telemetry.ts
2872
2888
  /**
@@ -4179,7 +4195,7 @@ function resolvedEnvironment(entry) {
4179
4195
  return entry.environment;
4180
4196
  }
4181
4197
  // src/commands/resolve-org/resolve-org.ts
4182
- const env$8 = createEnvLookup();
4198
+ const env$9 = createEnvLookup();
4183
4199
  /**
4184
4200
  * Resolves the active org in priority order:
4185
4201
  * 1. `--org` CLI flag
@@ -4187,7 +4203,7 @@ const env$8 = createEnvLookup();
4187
4203
  * 3. `org` from `holocron.config.ts`
4188
4204
  */
4189
4205
  function resolveOrg(argv, config) {
4190
- return argv.org ?? env$8.get("HOLOCRON_ORG") ?? config.org;
4206
+ return argv.org ?? env$9.get("HOLOCRON_ORG") ?? config.org;
4191
4207
  }
4192
4208
  // src/commands/apply-resolved-config/apply-resolved-config.ts
4193
4209
  /**
@@ -6800,7 +6816,7 @@ async function runClone(input) {
6800
6816
  };
6801
6817
  }
6802
6818
  // src/commands/clone/clone.command.ts
6803
- const env$7 = createEnvLookup();
6819
+ const env$8 = createEnvLookup();
6804
6820
  const resolveCloneToken = createFeatureResolver({
6805
6821
  envName: "HOLOCRON_READ_TOKEN",
6806
6822
  keyringKey: "github.read"
@@ -6838,7 +6854,7 @@ const cloneCommand = {
6838
6854
  } } : {},
6839
6855
  confirmOpen: async (openTarget, moreToCome) => {
6840
6856
  if (!process.stdin.isTTY) return;
6841
- if (moreToCome && env$7.get(DRY_RUN_PREVIEW_ENV_VAR) === "1") return;
6857
+ if (moreToCome && env$8.get(DRY_RUN_PREVIEW_ENV_VAR) === "1") return;
6842
6858
  if (await confirm({
6843
6859
  message: `Open ${openTarget}?`,
6844
6860
  default: false
@@ -6848,7 +6864,7 @@ const cloneCommand = {
6848
6864
  if (report.status === "fail") {
6849
6865
  if (report.message) reportError(`clone: ${report.message}`);
6850
6866
  process.exitCode = 1;
6851
- } else if (report.status === "dry-run" && report.cloned === 0 && env$7.get(DRY_RUN_PREVIEW_ENV_VAR) === "1") process.exitCode = DRY_RUN_NOOP_EXIT_CODE;
6867
+ } else if (report.status === "dry-run" && report.cloned === 0 && env$8.get(DRY_RUN_PREVIEW_ENV_VAR) === "1") process.exitCode = DRY_RUN_NOOP_EXIT_CODE;
6852
6868
  }
6853
6869
  };
6854
6870
  // src/commands/incident-write-failure/incident-write-failure.ts
@@ -11601,7 +11617,7 @@ const deployOnReleaseCommand = {
11601
11617
  }
11602
11618
  };
11603
11619
  // src/commands/deploy/deploy.command.ts
11604
- const env$6 = createEnvLookup();
11620
+ const env$7 = createEnvLookup();
11605
11621
  const deployCommand = {
11606
11622
  command: "deploy [branch]",
11607
11623
  describe: "Trigger a deployment via the configured `deployment` capability",
@@ -11632,7 +11648,7 @@ const deployCommand = {
11632
11648
  projectId: argv.projectId,
11633
11649
  dir: argv.files,
11634
11650
  ...argv.target ? { target: argv.target } : {},
11635
- ...env$6.get("HOLOCRON_PREVIEW_KEY") ? { previewKey: env$6.get("HOLOCRON_PREVIEW_KEY") } : {}
11651
+ ...env$7.get("HOLOCRON_PREVIEW_KEY") ? { previewKey: env$7.get("HOLOCRON_PREVIEW_KEY") } : {}
11636
11652
  })).status === "fail") process.exitCode = 1;
11637
11653
  return;
11638
11654
  }
@@ -11680,7 +11696,7 @@ async function runDevServe(input) {
11680
11696
  });
11681
11697
  }
11682
11698
  // src/commands/dev-serve/dev-serve.command.ts
11683
- const env$5 = holocronEnv();
11699
+ const env$6 = holocronEnv();
11684
11700
  const devServeCommand = {
11685
11701
  command: "serve",
11686
11702
  describe: "Serve the handler `dev.serve` names on PORT: the application `holocron dev` runs when it is configured, not usually run by hand",
@@ -11696,7 +11712,7 @@ const devServeCommand = {
11696
11712
  cwd: argv.cwd,
11697
11713
  environment: dev.environment ?? "",
11698
11714
  serve: dev.serve,
11699
- port: Number(env$5.get("PORT") ?? dev.port ?? 3e3)
11715
+ port: Number(env$6.get("PORT") ?? dev.port ?? 3e3)
11700
11716
  });
11701
11717
  } catch (err) {
11702
11718
  reportError(`dev serve: ${errorMessage(err)}`);
@@ -32400,7 +32416,7 @@ async function runSecretToFile(input, value, print, loader, logger = getLogger()
32400
32416
  *
32401
32417
  * Errors clearly when no value can be sourced.
32402
32418
  */
32403
- const env$4 = createEnvLookup();
32419
+ const env$5 = createEnvLookup();
32404
32420
  async function runSecretSet(input) {
32405
32421
  const print = input.print ?? ((line) => console.log(line));
32406
32422
  const logger = input.logger ?? getLogger();
@@ -32468,8 +32484,8 @@ function noValueMessage(name) {
32468
32484
  async function resolveValue(input) {
32469
32485
  if (input.value) return input.value;
32470
32486
  if (input.fromStdin) return (await (input.readStdin ?? defaultReadStdin)()).replace(/\r?\n$/, "");
32471
- if (input.fromEnv) return env$4.get(input.fromEnv);
32472
- return env$4.get(input.name);
32487
+ if (input.fromEnv) return env$5.get(input.fromEnv);
32488
+ return env$5.get(input.name);
32473
32489
  }
32474
32490
  async function defaultReadStdin() {
32475
32491
  const chunks = [];
@@ -32576,7 +32592,7 @@ const secretSetCommand = {
32576
32592
  * 9. Unless --no-verify: `pnpm install` in the new repo.
32577
32593
  * 10. Print next steps.
32578
32594
  */
32579
- const env$3 = createEnvLookup();
32595
+ const env$4 = createEnvLookup();
32580
32596
  var NewError = class extends Error {
32581
32597
  name = "NewError";
32582
32598
  };
@@ -32913,11 +32929,11 @@ async function runNew(input) {
32913
32929
  const setupEnv = {};
32914
32930
  const adminToken = input.token ?? keychainLookup("github.admin");
32915
32931
  if (adminToken) setupArgs.push("--token", adminToken);
32916
- if (!env$3.get("HOLOCRON_ORG_TOKEN")) {
32932
+ if (!env$4.get("HOLOCRON_ORG_TOKEN")) {
32917
32933
  const orgToken = keychainLookup("github.org");
32918
32934
  if (orgToken) setupEnv["HOLOCRON_ORG_TOKEN"] = orgToken;
32919
32935
  }
32920
- if (!env$3.get("HOLOCRON_DEPLOY_TOKEN")) {
32936
+ if (!env$4.get("HOLOCRON_DEPLOY_TOKEN")) {
32921
32937
  const deployToken = keychainLookup("github.deploy");
32922
32938
  if (deployToken) setupEnv["HOLOCRON_DEPLOY_TOKEN"] = deployToken;
32923
32939
  }
@@ -36531,6 +36547,232 @@ const npmBumpVersionsCommand = {
36531
36547
  })).status === "fail") process.exitCode = 1;
36532
36548
  }
36533
36549
  };
36550
+ // src/commands/publish/discover-public-package-entries.ts
36551
+ /**
36552
+ * Every public package (`!private && name`) with its version and a
36553
+ * `pnpm --filter`-ready path — {@link runSteadyPublish}'s `skipAlreadyPublished`
36554
+ * mode needs both to check `npm view <pkg>@<version>` and publish one
36555
+ * workspace at a time.
36556
+ */
36557
+ function discoverPublicPackageEntries(cwd, scope = {}) {
36558
+ return discoverManifests(cwd, scope).flatMap(({ manifest, dir }) => !manifest.private && manifest.name && manifest.version ? [{
36559
+ name: manifest.name,
36560
+ version: manifest.version,
36561
+ dir
36562
+ }] : []);
36563
+ }
36564
+ // src/commands/publish/npm-version-supports-stage.ts
36565
+ /** The first npm CLI that has `npm stage publish`. */
36566
+ const MIN_STAGE_NPM_VERSION = "11.15.0";
36567
+ /** True when the `npm --version` output names a release of 11.15.0 or later (a prerelease suffix is ignored). */
36568
+ function npmVersionSupportsStage(output) {
36569
+ const match = /^(\d+)\.(\d+)\.(\d+)/.exec(output.trim());
36570
+ if (!match) return false;
36571
+ const [major, minor] = [Number(match[1]), Number(match[2])];
36572
+ return major > 11 || major === 11 && minor >= 15;
36573
+ }
36574
+ // src/commands/publish/parse-stage-list.ts
36575
+ /**
36576
+ * The stages `npm stage list` prints, one block of `key: value` lines each (`id`, `package name`, `version`, `status`,
36577
+ * ...). A block with no id, name or version is dropped, so unfamiliar output reads as no pending stages.
36578
+ */
36579
+ function parseStageList(output) {
36580
+ const stages = [];
36581
+ let current;
36582
+ const flush = () => {
36583
+ if (current?.id && current.name && current.version) stages.push({
36584
+ id: current.id,
36585
+ name: current.name,
36586
+ version: current.version,
36587
+ status: current.status ?? ""
36588
+ });
36589
+ };
36590
+ for (const raw of output.split("\n")) {
36591
+ const line = raw.trim();
36592
+ const colon = line.indexOf(":");
36593
+ if (colon < 0) continue;
36594
+ const key = line.slice(0, colon).trim().toLowerCase();
36595
+ const value = line.slice(colon + 1).trim();
36596
+ if (key === "id") {
36597
+ flush();
36598
+ current = { id: value };
36599
+ } else if (current && key === "package name") current.name = value;
36600
+ else if (current && key === "version") current.version = value;
36601
+ else if (current && key === "status") current.status = value;
36602
+ }
36603
+ flush();
36604
+ return stages;
36605
+ }
36606
+ // src/commands/publish/redact-otp.ts
36607
+ /**
36608
+ * Replaces the literal `otp` value in a "would run: pnpm ..." dry-run
36609
+ * preview line with `***` — the real `args` passed to `exec()` still need
36610
+ * the raw OTP (npm's own `--otp` flag has no env-var alternative), but the
36611
+ * preview is printed straight to the terminal / captured as dry-run output
36612
+ * and must never echo a live 2FA code back out.
36613
+ */
36614
+ function redactOtp(args, otp) {
36615
+ if (!otp) return [...args];
36616
+ return args.map((arg) => arg === otp ? "***" : arg);
36617
+ }
36618
+ // src/commands/publish/scope-of.ts
36619
+ /** The {@link WorkspaceScope} a publish input asks for; unset options stay unset. */
36620
+ function scopeOf({ group, excludeGroups, onlyPackages }) {
36621
+ return {
36622
+ ...group === void 0 ? {} : { group },
36623
+ ...excludeGroups === void 0 ? {} : { excludeGroups },
36624
+ ...onlyPackages === void 0 ? {} : { onlyPackages }
36625
+ };
36626
+ }
36627
+ // src/commands/publish/approve-stages/default-approve-exec.ts
36628
+ /**
36629
+ * Approving needs the maintainer's own npm session and 2FA, never a token. So the child's environment drops
36630
+ * `HOLOCRON_NPM_TOKEN`, `NPM_TOKEN`, npm's own registry auth variable and `HOLOCRON_OTP` (the code, when given, is
36631
+ * an explicit `--otp` argument).
36632
+ */
36633
+ const defaultApproveExec = async (cmd, args, opts) => {
36634
+ const env = { ...process.env };
36635
+ for (const key of Object.keys(env)) if (key === "HOLOCRON_NPM_TOKEN" || key === "NPM_TOKEN" || key === "HOLOCRON_OTP" || key.toLowerCase().endsWith(":_authtoken")) delete env[key];
36636
+ const result = spawnSync(cmd, args, {
36637
+ cwd: opts.cwd,
36638
+ encoding: "utf8",
36639
+ stdio: opts.inherit ? "inherit" : [
36640
+ "inherit",
36641
+ "pipe",
36642
+ "pipe"
36643
+ ],
36644
+ env
36645
+ });
36646
+ return {
36647
+ exitCode: result.status ?? -1,
36648
+ stdout: result.stdout ?? "",
36649
+ stderr: result.stderr ?? ""
36650
+ };
36651
+ };
36652
+ // src/commands/publish/approve-stages/approve-stages.ts
36653
+ /** Statuses of a stage that is over, so there is nothing left to approve. Anything else is treated as pending. */
36654
+ const FINISHED = /* @__PURE__ */ new Set([
36655
+ "approved",
36656
+ "rejected",
36657
+ "published",
36658
+ "cancelled",
36659
+ "canceled",
36660
+ "expired"
36661
+ ]);
36662
+ /** True when `npm stage list` reports the stage as still waiting (an unfamiliar or empty status counts as waiting). */
36663
+ function isPendingStage(stage) {
36664
+ return !FINISHED.has(stage.status.trim().toLowerCase());
36665
+ }
36666
+ /**
36667
+ * `holocron publish approve`: approve, with `npm stage approve <id>`, the stages a first publish left pending for
36668
+ * this repository's packages. It uses the maintainer's own npm session (no token), and never stages, publishes or
36669
+ * logs in. One failed approval is a row and the next still runs.
36670
+ */
36671
+ async function approveStages(input = {}) {
36672
+ const print = input.print ?? ((line) => console.log(line));
36673
+ const logger = input.logger ?? getLogger();
36674
+ const cwd = input.cwd ?? process.cwd();
36675
+ const exec = input.exec ?? defaultApproveExec;
36676
+ const dryRun = input.dryRun ?? false;
36677
+ const { otp } = input;
36678
+ logger.info({ dryRun: dryRun || void 0 }, "publish approve: start");
36679
+ const stop = (message) => {
36680
+ print(statusRow$1("fail", [message]));
36681
+ logger.warn({ reason: message }, "publish approve: done");
36682
+ return {
36683
+ status: "fail",
36684
+ message,
36685
+ approved: [],
36686
+ failed: []
36687
+ };
36688
+ };
36689
+ print("");
36690
+ const version = await exec("npm", ["--version"], { cwd });
36691
+ if (version.exitCode !== 0 || !npmVersionSupportsStage(version.stdout)) return stop(`approving needs npm ${MIN_STAGE_NPM_VERSION} or later (found ${version.stdout.trim() || "none"}). Update npm, then re-run.`);
36692
+ const listed = await exec("npm", ["stage", "list"], { cwd });
36693
+ if (listed.exitCode !== 0) return stop(`npm stage list failed (it needs your own npm login: run npm login first): ${`${listed.stderr} ${listed.stdout}`.trim() || `exit ${listed.exitCode}`}`);
36694
+ const names = new Set((input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input))).map((e) => e.name));
36695
+ const pending = parseStageList(listed.stdout).filter((s) => names.has(s.name) && isPendingStage(s));
36696
+ if (pending.length === 0) {
36697
+ print(statusRow$1("ok", ["no pending stages for this repository's packages"]));
36698
+ logger.info({}, "publish approve: done");
36699
+ return {
36700
+ status: "ok",
36701
+ approved: [],
36702
+ failed: []
36703
+ };
36704
+ }
36705
+ const nameWidth = Math.max(...pending.map((s) => s.name.length));
36706
+ for (const s of pending) print(` ${pad$1(s.name, nameWidth)} v${s.version} ${s.id} ${s.status || "pending"}`);
36707
+ if (dryRun) {
36708
+ print("");
36709
+ for (const s of pending) print(style.dim(` would run: npm stage approve ${s.id}${otp ? " --otp ***" : ""}`));
36710
+ print(style.dim(` dry-run: ${pending.length} would be approved`));
36711
+ logger.info({ count: pending.length }, "publish approve: done");
36712
+ return {
36713
+ status: "dry-run",
36714
+ approved: [],
36715
+ failed: []
36716
+ };
36717
+ }
36718
+ if (!input.yes) {
36719
+ if (!input.confirm) throw new NonInteractiveError("pass --yes to approve the pending stages without a terminal");
36720
+ if (!await input.confirm(`Approve ${pending.length} pending stage(s)?`)) {
36721
+ print(statusRow$1("skip", ["nothing approved"]));
36722
+ return {
36723
+ status: "ok",
36724
+ approved: [],
36725
+ failed: []
36726
+ };
36727
+ }
36728
+ }
36729
+ const approved = [];
36730
+ const failed = [];
36731
+ for (const s of pending) {
36732
+ const args = [
36733
+ "stage",
36734
+ "approve",
36735
+ s.id,
36736
+ ...otp ? ["--otp", otp] : []
36737
+ ];
36738
+ const result = await exec("npm", args, {
36739
+ cwd,
36740
+ inherit: !otp
36741
+ });
36742
+ if (result.exitCode === 0) {
36743
+ approved.push(s.id);
36744
+ print(statusRow$1("ok", [pad$1(s.name, nameWidth), `approved (v${s.version})`]));
36745
+ continue;
36746
+ }
36747
+ failed.push(s.id);
36748
+ const detail = `${result.stderr} ${result.stdout}`.trim();
36749
+ const text = otp ? detail.split(otp).join("***") : detail;
36750
+ const shown = redactOtp(args, otp).join(" ");
36751
+ print(statusRow$1("fail", [
36752
+ pad$1(s.name, nameWidth),
36753
+ `not approved (npm ${shown} exited ${result.exitCode})`,
36754
+ text
36755
+ ]));
36756
+ }
36757
+ print("");
36758
+ const summary = `${approved.length} approved, ${failed.length} failed`;
36759
+ print(failed.length > 0 ? style.fail(` ${summary}`) : style.success(` ${summary}`));
36760
+ logger.info({
36761
+ approved: approved.length,
36762
+ failed: failed.length
36763
+ }, "publish approve: done");
36764
+ if (failed.length > 0) return {
36765
+ status: "fail",
36766
+ message: `${failed.length} stage(s) not approved`,
36767
+ approved,
36768
+ failed
36769
+ };
36770
+ return {
36771
+ status: "ok",
36772
+ approved,
36773
+ failed
36774
+ };
36775
+ }
36534
36776
  // src/commands/publish/resolve-otp.ts
36535
36777
  /**
36536
36778
  * `argvOtp` if given, else the `HOLOCRON_OTP` env var — the secret-delivery
@@ -36543,6 +36785,49 @@ const npmBumpVersionsCommand = {
36543
36785
  function resolveOtp(argvOtp, env) {
36544
36786
  return argvOtp ?? env.get("HOLOCRON_OTP");
36545
36787
  }
36788
+ // src/commands/publish/publish-approve.command.ts
36789
+ const env$3 = createEnvLookup();
36790
+ const publishApproveArgs = (y) => y.option("otp", {
36791
+ type: "string",
36792
+ describe: "One-time password from your authenticator, handed to every approval. Without it npm asks."
36793
+ }).option("yes", {
36794
+ type: "boolean",
36795
+ default: false,
36796
+ describe: "Approve without asking first (required without a terminal)"
36797
+ }).option("group", {
36798
+ type: "string",
36799
+ describe: "Only this version group's packages: a folder of the repo."
36800
+ }).option("package", {
36801
+ type: "string",
36802
+ array: true,
36803
+ describe: "Only this package (repeatable): its name or its folder."
36804
+ }).option("exclude-group", {
36805
+ type: "string",
36806
+ array: true,
36807
+ describe: "Everything except this version group (repeatable)."
36808
+ });
36809
+ const publishApproveCommand = {
36810
+ command: "approve",
36811
+ describe: "Approve the npm stages a first publish left pending",
36812
+ builder: publishApproveArgs,
36813
+ handler: async (argv) => {
36814
+ const otp = resolveOtp(argv.otp, env$3);
36815
+ const terminal = process.stdin.isTTY === true;
36816
+ if ((await approveStages({
36817
+ cwd: argv.cwd,
36818
+ dryRun: argv.dryRun,
36819
+ yes: argv.yes,
36820
+ ...argv.group ? { group: argv.group } : {},
36821
+ ...argv.excludeGroup?.length ? { excludeGroups: argv.excludeGroup } : {},
36822
+ ...argv.package?.length ? { onlyPackages: argv.package } : {},
36823
+ ...otp ? { otp } : {},
36824
+ ...terminal ? { confirm: (message) => confirm({
36825
+ message,
36826
+ default: false
36827
+ }) } : {}
36828
+ })).status === "fail") process.exitCode = 1;
36829
+ }
36830
+ };
36546
36831
  // src/commands/publish/default-exec.ts
36547
36832
  const defaultExec = async (cmd, args, opts) => {
36548
36833
  const { HOLOCRON_OTP: _omittedOtp, ...inherited } = process.env;
@@ -36578,20 +36863,6 @@ const defaultLogin = async (cwd) => {
36578
36863
  stdio: "inherit"
36579
36864
  }).status ?? -1 };
36580
36865
  };
36581
- // src/commands/publish/discover-public-package-entries.ts
36582
- /**
36583
- * Every public package (`!private && name`) with its version and a
36584
- * `pnpm --filter`-ready path — {@link runSteadyPublish}'s `skipAlreadyPublished`
36585
- * mode needs both to check `npm view <pkg>@<version>` and publish one
36586
- * workspace at a time.
36587
- */
36588
- function discoverPublicPackageEntries(cwd, scope = {}) {
36589
- return discoverManifests(cwd, scope).flatMap(({ manifest, dir }) => !manifest.private && manifest.name && manifest.version ? [{
36590
- name: manifest.name,
36591
- version: manifest.version,
36592
- dir
36593
- }] : []);
36594
- }
36595
36866
  // src/commands/publish/filter-new-packages.ts
36596
36867
  /** The version npm gives a staged new package's public placeholder until the stage is approved. */
36597
36868
  const STAGE_PLACEHOLDER_VERSION = "0.0.0-stage";
@@ -36650,16 +36921,6 @@ function nodeVersionSupportsStage(output) {
36650
36921
  const [major, minor] = [Number(match[1]), Number(match[2])];
36651
36922
  return major > 22 || major === 22 && minor >= 14;
36652
36923
  }
36653
- // src/commands/publish/npm-version-supports-stage.ts
36654
- /** The first npm CLI that has `npm stage publish`. */
36655
- const MIN_STAGE_NPM_VERSION = "11.15.0";
36656
- /** True when the `npm --version` output names a release of 11.15.0 or later (a prerelease suffix is ignored). */
36657
- function npmVersionSupportsStage(output) {
36658
- const match = /^(\d+)\.(\d+)\.(\d+)/.exec(output.trim());
36659
- if (!match) return false;
36660
- const [major, minor] = [Number(match[1]), Number(match[2])];
36661
- return major > 11 || major === 11 && minor >= 15;
36662
- }
36663
36924
  // src/commands/publish/print-approve-lines.ts
36664
36925
  /** One `npm stage approve <id>` line per staged package, and where to find the same stages on npmjs.com. */
36665
36926
  function printApproveLines(print, staged) {
@@ -36688,18 +36949,6 @@ function printNextSteps(print, env, packageNames, identity, workflowFile, npmTok
36688
36949
  print(" https://www.npmjs.com/settings/~/tokens");
36689
36950
  }
36690
36951
  }
36691
- // src/commands/publish/redact-otp.ts
36692
- /**
36693
- * Replaces the literal `otp` value in a "would run: pnpm ..." dry-run
36694
- * preview line with `***` — the real `args` passed to `exec()` still need
36695
- * the raw OTP (npm's own `--otp` flag has no env-var alternative), but the
36696
- * preview is printed straight to the terminal / captured as dry-run output
36697
- * and must never echo a live 2FA code back out.
36698
- */
36699
- function redactOtp(args, otp) {
36700
- if (!otp) return [...args];
36701
- return args.map((arg) => arg === otp ? "***" : arg);
36702
- }
36703
36952
  // src/commands/publish/redact-token.ts
36704
36953
  /** Replaces every occurrence of `token` in `text` with `***`, so an npm error never echoes the credential. */
36705
36954
  function redactToken(text, token) {
@@ -36734,15 +36983,6 @@ async function resolveRepoIdentity(cwd, exec) {
36734
36983
  repo: remote?.repo ?? "unknown"
36735
36984
  };
36736
36985
  }
36737
- // src/commands/publish/scope-of.ts
36738
- /** The {@link WorkspaceScope} a publish input asks for; unset options stay unset. */
36739
- function scopeOf({ group, excludeGroups, onlyPackages }) {
36740
- return {
36741
- ...group === void 0 ? {} : { group },
36742
- ...excludeGroups === void 0 ? {} : { excludeGroups },
36743
- ...onlyPackages === void 0 ? {} : { onlyPackages }
36744
- };
36745
- }
36746
36986
  // src/commands/publish/parse-stage-id.ts
36747
36987
  /**
36748
36988
  * The stage id `npm stage publish` prints, as in `+ @scope/name@0.0.1 (staged with id <uuid>)`.
@@ -36751,38 +36991,6 @@ function scopeOf({ group, excludeGroups, onlyPackages }) {
36751
36991
  function parseStageId(output) {
36752
36992
  return /staged with id ([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i.exec(output)?.[1];
36753
36993
  }
36754
- // src/commands/publish/parse-stage-list.ts
36755
- /**
36756
- * The stages `npm stage list` prints, one block of `key: value` lines each (`id`, `package name`, `version`, `status`,
36757
- * ...). A block with no id, name or version is dropped, so unfamiliar output reads as no pending stages.
36758
- */
36759
- function parseStageList(output) {
36760
- const stages = [];
36761
- let current;
36762
- const flush = () => {
36763
- if (current?.id && current.name && current.version) stages.push({
36764
- id: current.id,
36765
- name: current.name,
36766
- version: current.version,
36767
- status: current.status ?? ""
36768
- });
36769
- };
36770
- for (const raw of output.split("\n")) {
36771
- const line = raw.trim();
36772
- const colon = line.indexOf(":");
36773
- if (colon < 0) continue;
36774
- const key = line.slice(0, colon).trim().toLowerCase();
36775
- const value = line.slice(colon + 1).trim();
36776
- if (key === "id") {
36777
- flush();
36778
- current = { id: value };
36779
- } else if (current && key === "package name") current.name = value;
36780
- else if (current && key === "version") current.version = value;
36781
- else if (current && key === "status") current.status = value;
36782
- }
36783
- flush();
36784
- return stages;
36785
- }
36786
36994
  // src/commands/publish/stage-packages/stage-packages.ts
36787
36995
  /** The registry auth key npm reads from the environment, so the token never touches an `.npmrc`. */
36788
36996
  const NPM_AUTH_ENV_KEY = "npm_config_//registry.npmjs.org/:_authToken";
@@ -37748,7 +37956,7 @@ const publishPackageCommand = {
37748
37956
  const publishCommand = {
37749
37957
  command: "publish",
37750
37958
  describe: "Version and publish workspace packages",
37751
- builder: (y) => y.command(npmBumpVersionsCommand).command(moveTagCommand).command(publishPackageCommand).command(groupMenu("publish")),
37959
+ builder: (y) => y.command(npmBumpVersionsCommand).command(moveTagCommand).command(publishPackageCommand).command(publishApproveCommand).command(groupMenu("publish")),
37752
37960
  handler: () => {}
37753
37961
  };
37754
37962
  // src/commands/project/plan-pull-request-status/plan-pull-request-status.ts