@theholocron/cli 5.0.0-alpha.582 → 5.0.0-alpha.584

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/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",
@@ -144,6 +145,7 @@ const COMMAND_CONTEXTS = {
144
145
  "sync github": "workspace",
145
146
  "sync issues": "workspace",
146
147
  "sync incidents": "workspace",
148
+ "sync releases": "workspace",
147
149
  "sync ideas": "workspace",
148
150
  "sync tooling": "workspace",
149
151
  "sync requests": "workspace",
@@ -1641,7 +1643,7 @@ const providerEntry = {
1641
1643
  supportsDryRun: false
1642
1644
  };
1643
1645
  // src/commands/publish/publish.entry.ts
1644
- const env$11 = createEnvLookup();
1646
+ const env$12 = createEnvLookup();
1645
1647
  const PUBLISH_TAG_OPTION = {
1646
1648
  key: "tag",
1647
1649
  flag: "--tag",
@@ -1654,7 +1656,7 @@ const PUBLISH_OTP_OPTION = {
1654
1656
  type: "password",
1655
1657
  secret: true,
1656
1658
  askLast: true,
1657
- required: Boolean(env$11.get("HOLOCRON_NPM_ENFORCE_2FA")),
1659
+ required: Boolean(env$12.get("HOLOCRON_NPM_ENFORCE_2FA")),
1658
1660
  message: "One-time password (2FA), if npm requires it for this publish:"
1659
1661
  };
1660
1662
  const publishEntry = {
@@ -1718,6 +1720,20 @@ const publishEntry = {
1718
1720
  }
1719
1721
  ]
1720
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
+ };
1721
1737
  // src/commands/reconcile-ci/reconcile-ci.entry.ts
1722
1738
  const reconcileCiEntry = {
1723
1739
  name: "reconcile ci",
@@ -2202,6 +2218,30 @@ const syncReadmeEntry = {
2202
2218
  skipOptions: ["dry-run"],
2203
2219
  supportsDryRun: true
2204
2220
  };
2221
+ // src/commands/sync-releases/sync-releases.entry.ts
2222
+ const syncReleasesEntry = {
2223
+ name: "sync releases",
2224
+ description: "Announce a release in the releases channel, with a thread listing each package",
2225
+ positionals: [],
2226
+ options: [{
2227
+ key: "from",
2228
+ flag: "--from",
2229
+ type: "input",
2230
+ message: "The commit the release started from:"
2231
+ }, {
2232
+ key: "tag",
2233
+ flag: "--tag",
2234
+ type: "input",
2235
+ message: "The release's tag (v5.0.0-alpha.1):"
2236
+ }],
2237
+ skipOptions: [
2238
+ "to",
2239
+ "channel",
2240
+ "provider",
2241
+ "yes"
2242
+ ],
2243
+ supportsDryRun: true
2244
+ };
2205
2245
  // src/commands/sync-requests/sync-requests.entry.ts
2206
2246
  const syncRequestsEntry = {
2207
2247
  name: "sync requests",
@@ -2427,12 +2467,14 @@ const registry = createCommandRegistry([
2427
2467
  npmBumpVersionsEntry,
2428
2468
  moveTagEntry,
2429
2469
  publishEntry,
2470
+ publishApproveEntry,
2430
2471
  syncEntry,
2431
2472
  repoCleanupBranchesEntry,
2432
2473
  runCiEntry,
2433
2474
  syncGithubEntry,
2434
2475
  syncIssuesEntry,
2435
2476
  syncIncidentsEntry,
2477
+ syncReleasesEntry,
2436
2478
  ideasSyncEntry,
2437
2479
  syncToolingEntry,
2438
2480
  syncRequestsEntry,
@@ -2754,7 +2796,7 @@ async function offerRealRun(input) {
2754
2796
  * traces, errors, structured context that routes to Axiom. It runs in
2755
2797
  * parallel to `print` (user-facing UX output) and does not replace it.
2756
2798
  */
2757
- const env$10 = createEnvLookup();
2799
+ const env$11 = createEnvLookup();
2758
2800
  const holocron = holocronEnv();
2759
2801
  /**
2760
2802
  * The CLI's Axiom dataset (`holocron`; each service has its own): the process environment (`HOLOCRON_AXIOM_DATASET`, then the unprefixed `AXIOM_DATASET`,
@@ -2782,7 +2824,7 @@ function resolveCliAxiom(opts, ctx) {
2782
2824
  if (fromEnv) return fromEnv;
2783
2825
  const dataset = resolveCliDataset(opts, contextForCommand(ctx.command ?? "") === "global");
2784
2826
  if (!dataset) return void 0;
2785
- const org = opts.org ?? env$10.get(`${PREFIX$1}_ORG`);
2827
+ const org = opts.org ?? env$11.get(`${PREFIX$1}_ORG`);
2786
2828
  const token = holocron.get("AXIOM_TOKEN") || (org ? keyring.get(`axiom.${org}`) : null) || keyring.get("axiom");
2787
2829
  return token ? {
2788
2830
  dataset,
@@ -2808,7 +2850,7 @@ const getRunId = logger.getRunId;
2808
2850
  logger.resetCliLogger;
2809
2851
  logger.resolveLogLevel;
2810
2852
  // src/observability/resolve-telemetry/resolve-telemetry.ts
2811
- const env$9 = holocronEnv();
2853
+ const env$10 = holocronEnv();
2812
2854
  /**
2813
2855
  * Holocron-specific credential resolution for the telemetry sinks — the env
2814
2856
  * chain plus Holocron's own shipped fallbacks. This is **CLI policy**, not part
@@ -2832,15 +2874,15 @@ const FALLBACK_POSTHOG_PROJECT_TOKEN = "phc_AC4vFCvYzwnzmG7Vg5nEc3PZKZztoPyfKp4L
2832
2874
  const DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com";
2833
2875
  /** Resolve the Sentry DSN. `""` → error telemetry disabled. */
2834
2876
  function resolveDsn() {
2835
- return env$9.get("SENTRY_DSN") ?? FALLBACK_DSN;
2877
+ return env$10.get("SENTRY_DSN") ?? FALLBACK_DSN;
2836
2878
  }
2837
2879
  /** Resolve the PostHog project key. `""` → usage analytics disabled. */
2838
2880
  function resolvePostHogKey() {
2839
- return env$9.get("POSTHOG_PROJECT_TOKEN") ?? FALLBACK_POSTHOG_PROJECT_TOKEN;
2881
+ return env$10.get("POSTHOG_PROJECT_TOKEN") ?? FALLBACK_POSTHOG_PROJECT_TOKEN;
2840
2882
  }
2841
2883
  /** Resolve the PostHog ingest host. */
2842
2884
  function resolvePostHogHost() {
2843
- return env$9.get("POSTHOG_HOST") ?? DEFAULT_POSTHOG_HOST;
2885
+ return env$10.get("POSTHOG_HOST") ?? DEFAULT_POSTHOG_HOST;
2844
2886
  }
2845
2887
  // src/observability/telemetry/telemetry.ts
2846
2888
  /**
@@ -4153,7 +4195,7 @@ function resolvedEnvironment(entry) {
4153
4195
  return entry.environment;
4154
4196
  }
4155
4197
  // src/commands/resolve-org/resolve-org.ts
4156
- const env$8 = createEnvLookup();
4198
+ const env$9 = createEnvLookup();
4157
4199
  /**
4158
4200
  * Resolves the active org in priority order:
4159
4201
  * 1. `--org` CLI flag
@@ -4161,7 +4203,7 @@ const env$8 = createEnvLookup();
4161
4203
  * 3. `org` from `holocron.config.ts`
4162
4204
  */
4163
4205
  function resolveOrg(argv, config) {
4164
- return argv.org ?? env$8.get("HOLOCRON_ORG") ?? config.org;
4206
+ return argv.org ?? env$9.get("HOLOCRON_ORG") ?? config.org;
4165
4207
  }
4166
4208
  // src/commands/apply-resolved-config/apply-resolved-config.ts
4167
4209
  /**
@@ -6774,7 +6816,7 @@ async function runClone(input) {
6774
6816
  };
6775
6817
  }
6776
6818
  // src/commands/clone/clone.command.ts
6777
- const env$7 = createEnvLookup();
6819
+ const env$8 = createEnvLookup();
6778
6820
  const resolveCloneToken = createFeatureResolver({
6779
6821
  envName: "HOLOCRON_READ_TOKEN",
6780
6822
  keyringKey: "github.read"
@@ -6812,7 +6854,7 @@ const cloneCommand = {
6812
6854
  } } : {},
6813
6855
  confirmOpen: async (openTarget, moreToCome) => {
6814
6856
  if (!process.stdin.isTTY) return;
6815
- 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;
6816
6858
  if (await confirm({
6817
6859
  message: `Open ${openTarget}?`,
6818
6860
  default: false
@@ -6822,7 +6864,7 @@ const cloneCommand = {
6822
6864
  if (report.status === "fail") {
6823
6865
  if (report.message) reportError(`clone: ${report.message}`);
6824
6866
  process.exitCode = 1;
6825
- } 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;
6826
6868
  }
6827
6869
  };
6828
6870
  // src/commands/incident-write-failure/incident-write-failure.ts
@@ -11575,7 +11617,7 @@ const deployOnReleaseCommand = {
11575
11617
  }
11576
11618
  };
11577
11619
  // src/commands/deploy/deploy.command.ts
11578
- const env$6 = createEnvLookup();
11620
+ const env$7 = createEnvLookup();
11579
11621
  const deployCommand = {
11580
11622
  command: "deploy [branch]",
11581
11623
  describe: "Trigger a deployment via the configured `deployment` capability",
@@ -11606,7 +11648,7 @@ const deployCommand = {
11606
11648
  projectId: argv.projectId,
11607
11649
  dir: argv.files,
11608
11650
  ...argv.target ? { target: argv.target } : {},
11609
- ...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") } : {}
11610
11652
  })).status === "fail") process.exitCode = 1;
11611
11653
  return;
11612
11654
  }
@@ -11654,7 +11696,7 @@ async function runDevServe(input) {
11654
11696
  });
11655
11697
  }
11656
11698
  // src/commands/dev-serve/dev-serve.command.ts
11657
- const env$5 = holocronEnv();
11699
+ const env$6 = holocronEnv();
11658
11700
  const devServeCommand = {
11659
11701
  command: "serve",
11660
11702
  describe: "Serve the handler `dev.serve` names on PORT: the application `holocron dev` runs when it is configured, not usually run by hand",
@@ -11670,7 +11712,7 @@ const devServeCommand = {
11670
11712
  cwd: argv.cwd,
11671
11713
  environment: dev.environment ?? "",
11672
11714
  serve: dev.serve,
11673
- port: Number(env$5.get("PORT") ?? dev.port ?? 3e3)
11715
+ port: Number(env$6.get("PORT") ?? dev.port ?? 3e3)
11674
11716
  });
11675
11717
  } catch (err) {
11676
11718
  reportError(`dev serve: ${errorMessage(err)}`);
@@ -13361,7 +13403,7 @@ async function readShadowSamples(source, limit = 40) {
13361
13403
  }
13362
13404
  // src/commands/doctor-ci/shadow-row.ts
13363
13405
  const ID$7 = "shadow";
13364
- const TITLE$7 = "Sentinel's ci shadow agrees with the Actions aggregate";
13406
+ const TITLE$8 = "Sentinel's ci shadow agrees with the Actions aggregate";
13365
13407
  /**
13366
13408
  * The `shadow` row (SPEC-0099, phase 4): do `ci / Required checks (sentinel)` and `ci / Required checks` say the same on
13367
13409
  * the same commit? `samples` are the newest pull requests first. A pull request is **decided** when both posted and
@@ -13376,7 +13418,7 @@ function shadowRow$1(samples, target = 20) {
13376
13418
  const decided = samples.filter((sample) => sample.actions !== void 0 && sample.sentinel !== void 0 && sample.actions !== "pending" && sample.sentinel !== "pending");
13377
13419
  if (decided.length === 0) return {
13378
13420
  id: ID$7,
13379
- title: TITLE$7,
13421
+ title: TITLE$8,
13380
13422
  status: "skip",
13381
13423
  detail: "no pull request has a finished verdict from both the Actions aggregate and the shadow yet",
13382
13424
  problems: []
@@ -13384,7 +13426,7 @@ function shadowRow$1(samples, target = 20) {
13384
13426
  const disagreements = decided.filter((sample) => sample.actions !== sample.sentinel);
13385
13427
  if (disagreements.length > 0) return {
13386
13428
  id: ID$7,
13387
- title: TITLE$7,
13429
+ title: TITLE$8,
13388
13430
  status: "fail",
13389
13431
  detail: `${disagreements.length} of ${decided.length} decided pull requests disagree`,
13390
13432
  problems: disagreements.map((s) => `#${s.number}: Actions said ${s.actions}, the shadow said ${s.sentinel}`)
@@ -13392,13 +13434,13 @@ function shadowRow$1(samples, target = 20) {
13392
13434
  const consecutive = decided.length;
13393
13435
  return consecutive >= target ? {
13394
13436
  id: ID$7,
13395
- title: TITLE$7,
13437
+ title: TITLE$8,
13396
13438
  status: "ok",
13397
13439
  detail: `${consecutive} consecutive pull requests agree (target ${target})`,
13398
13440
  problems: []
13399
13441
  } : {
13400
13442
  id: ID$7,
13401
- title: TITLE$7,
13443
+ title: TITLE$8,
13402
13444
  status: "skip",
13403
13445
  detail: `${consecutive} of ${target} consecutive pull requests agree so far`,
13404
13446
  problems: []
@@ -14105,7 +14147,7 @@ function environmentProblems(declared, have) {
14105
14147
  * nothing named, nothing is declared; with no provider but some named, the row is a skip with the reason.
14106
14148
  */
14107
14149
  const ID$6 = "environments";
14108
- const TITLE$6 = "environments exist";
14150
+ const TITLE$7 = "environments exist";
14109
14151
  const UNDECLARED_ID = "environments-undeclared";
14110
14152
  const UNDECLARED_TITLE = "environments nothing declares";
14111
14153
  async function runDoctorEnvironments(input) {
@@ -14133,7 +14175,7 @@ async function runDoctorEnvironments(input) {
14133
14175
  async function checkEnvironments(loader, named, declared, manual) {
14134
14176
  const make = (status, detail, problems = []) => ({
14135
14177
  id: ID$6,
14136
- title: TITLE$6,
14178
+ title: TITLE$7,
14137
14179
  status,
14138
14180
  detail,
14139
14181
  problems
@@ -14510,7 +14552,7 @@ async function readWorkspaceMonitoring(context) {
14510
14552
  }
14511
14553
  // src/commands/doctor-monitoring/dashboard-rows/dashboard-rows.ts
14512
14554
  const ID$5 = "monitoring-dashboards";
14513
- const TITLE$5 = "monitoring dashboards match";
14555
+ const TITLE$6 = "monitoring dashboards match";
14514
14556
  /** The tags as comparable text: sorted and de-duplicated. */
14515
14557
  const tagsText = (tags) => [...new Set(tags)].sort().join(", ") || "none";
14516
14558
  /** What differs between a declared dashboard and the one the account holds. Privacy is always compared (default private). */
@@ -14542,7 +14584,7 @@ async function dashboardRows(monitoring) {
14542
14584
  detail,
14543
14585
  problems: []
14544
14586
  });
14545
- if (!monitoring.inspectDashboard) return [skip(ID$5, TITLE$5, "provider does not implement inspectDashboard")];
14587
+ if (!monitoring.inspectDashboard) return [skip(ID$5, TITLE$6, "provider does not implement inspectDashboard")];
14546
14588
  try {
14547
14589
  const names = new Set(declared.map((d) => d.name));
14548
14590
  const problems = [];
@@ -14554,13 +14596,13 @@ async function dashboardRows(monitoring) {
14554
14596
  }
14555
14597
  const rows = [problems.length > 0 ? {
14556
14598
  id: ID$5,
14557
- title: TITLE$5,
14599
+ title: TITLE$6,
14558
14600
  status: "fail",
14559
14601
  detail: `${problems.length} problem(s)`,
14560
14602
  problems
14561
14603
  } : {
14562
14604
  id: ID$5,
14563
- title: TITLE$5,
14605
+ title: TITLE$6,
14564
14606
  status: "ok",
14565
14607
  detail: `${declared.length} of ${declared.length} match`,
14566
14608
  problems: []
@@ -14569,10 +14611,10 @@ async function dashboardRows(monitoring) {
14569
14611
  return rows;
14570
14612
  } catch (err) {
14571
14613
  const noToken = missingTokenReason(err);
14572
- if (noToken !== void 0) return [skip(ID$5, TITLE$5, noToken)];
14614
+ if (noToken !== void 0) return [skip(ID$5, TITLE$6, noToken)];
14573
14615
  return [{
14574
14616
  id: ID$5,
14575
- title: TITLE$5,
14617
+ title: TITLE$6,
14576
14618
  status: "fail",
14577
14619
  detail: errorMessage(err),
14578
14620
  problems: []
@@ -14586,7 +14628,7 @@ async function dashboardRows(monitoring) {
14586
14628
  * config is an `info` row (shown as skipped). Names only: the ping URL is never read here.
14587
14629
  */
14588
14630
  const ID$4 = "monitoring-heartbeats";
14589
- const TITLE$4 = "monitoring heartbeats match";
14631
+ const TITLE$5 = "monitoring heartbeats match";
14590
14632
  const show = (b) => new Map([
14591
14633
  ["period", `${b.period} ${b.periodUnit}`],
14592
14634
  ["grace", `${b.grace} ${b.graceUnit}`],
@@ -14598,7 +14640,7 @@ async function heartbeatRows(monitoring) {
14598
14640
  if (declared.length === 0) return [];
14599
14641
  const skip = (detail) => ({
14600
14642
  id: ID$4,
14601
- title: TITLE$4,
14643
+ title: TITLE$5,
14602
14644
  status: "skip",
14603
14645
  detail,
14604
14646
  problems: []
@@ -14623,13 +14665,13 @@ async function heartbeatRows(monitoring) {
14623
14665
  }
14624
14666
  const rows = [problems.length > 0 ? {
14625
14667
  id: ID$4,
14626
- title: TITLE$4,
14668
+ title: TITLE$5,
14627
14669
  status: "fail",
14628
14670
  detail: `${problems.length} problem(s)`,
14629
14671
  problems
14630
14672
  } : {
14631
14673
  id: ID$4,
14632
- title: TITLE$4,
14674
+ title: TITLE$5,
14633
14675
  status: "ok",
14634
14676
  detail: `${declared.length} of ${declared.length} match`,
14635
14677
  problems: []
@@ -14649,7 +14691,7 @@ async function heartbeatRows(monitoring) {
14649
14691
  if (noToken !== void 0) return [skip(noToken)];
14650
14692
  return [{
14651
14693
  id: ID$4,
14652
- title: TITLE$4,
14694
+ title: TITLE$5,
14653
14695
  status: "fail",
14654
14696
  detail: errorMessage(err),
14655
14697
  problems: []
@@ -14754,7 +14796,7 @@ async function statusPageRows(monitoring) {
14754
14796
  }
14755
14797
  // src/commands/doctor-monitoring/undeclared-check-rows/undeclared-check-rows.ts
14756
14798
  const ID$3 = "monitoring-undeclared";
14757
- const TITLE$3 = "checks no config declares";
14799
+ const TITLE$4 = "checks no config declares";
14758
14800
  function undeclaredCheckRows({ monitoring, workspace, have }) {
14759
14801
  if (have === void 0) return [];
14760
14802
  const tags = new Set([
@@ -14765,7 +14807,7 @@ function undeclaredCheckRows({ monitoring, workspace, have }) {
14765
14807
  if (tags.size === 0) return [];
14766
14808
  const row = (status, detail) => [{
14767
14809
  id: ID$3,
14768
- title: TITLE$3,
14810
+ title: TITLE$4,
14769
14811
  status,
14770
14812
  detail,
14771
14813
  problems: []
@@ -14803,7 +14845,7 @@ function undeclaredCheckRows({ monitoring, workspace, have }) {
14803
14845
  * `doctor notifications`) and any check that a message really arrives.
14804
14846
  */
14805
14847
  const ID$2 = "monitoring-checks";
14806
- const TITLE$2 = "monitoring checks match";
14848
+ const TITLE$3 = "monitoring checks match";
14807
14849
  async function runDoctorMonitoring(input) {
14808
14850
  const print = input.print ?? ((line) => console.log(line));
14809
14851
  const logger = input.logger ?? getLogger();
@@ -14843,14 +14885,14 @@ async function runDoctorMonitoring(input) {
14843
14885
  async function checkRow(loader) {
14844
14886
  const skip = (detail) => ({ row: {
14845
14887
  id: ID$2,
14846
- title: TITLE$2,
14888
+ title: TITLE$3,
14847
14889
  status: "skip",
14848
14890
  detail,
14849
14891
  problems: []
14850
14892
  } });
14851
14893
  const none = () => ({ row: {
14852
14894
  id: ID$2,
14853
- title: TITLE$2,
14895
+ title: TITLE$3,
14854
14896
  status: "ok",
14855
14897
  detail: "none declared",
14856
14898
  problems: []
@@ -14868,7 +14910,7 @@ async function checkRow(loader) {
14868
14910
  if (problems.length > 0) return {
14869
14911
  row: {
14870
14912
  id: ID$2,
14871
- title: TITLE$2,
14913
+ title: TITLE$3,
14872
14914
  status: "fail",
14873
14915
  detail: `${problems.length} problem(s)`,
14874
14916
  problems
@@ -14879,7 +14921,7 @@ async function checkRow(loader) {
14879
14921
  return {
14880
14922
  row: {
14881
14923
  id: ID$2,
14882
- title: TITLE$2,
14924
+ title: TITLE$3,
14883
14925
  status: "ok",
14884
14926
  detail: `${n} of ${n} match`,
14885
14927
  problems: []
@@ -14891,7 +14933,7 @@ async function checkRow(loader) {
14891
14933
  if (noToken !== void 0) return skip(noToken);
14892
14934
  return { row: {
14893
14935
  id: ID$2,
14894
- title: TITLE$2,
14936
+ title: TITLE$3,
14895
14937
  status: "fail",
14896
14938
  detail: errorMessage(err),
14897
14939
  problems: []
@@ -15026,7 +15068,7 @@ function resultRow(id, title, problems, ok) {
15026
15068
  };
15027
15069
  }
15028
15070
  // src/commands/bot-permission-checks/bot-permission-checks.ts
15029
- const TITLE$1 = "bot holds the server-wide permissions it needs";
15071
+ const TITLE$2 = "bot holds the server-wide permissions it needs";
15030
15072
  /**
15031
15073
  * The step of `doctor notifications` for the bot's own role: the permissions the provider says it needs (read from
15032
15074
  * `inspect`, server-wide, before any channel overwrite) are all held. A failure names the missing ones and carries the
@@ -15035,13 +15077,13 @@ const TITLE$1 = "bot holds the server-wide permissions it needs";
15035
15077
  */
15036
15078
  function botPermissionChecks(input) {
15037
15079
  const { found } = input;
15038
- if (!found) return [skipRow$1("bot-permissions", TITLE$1, "not checked: could not read the server")];
15039
- if (found.botPermissionsError) return [skipRow$1("bot-permissions", TITLE$1, `not checked: could not read the bot's roles (${sanitizeDetail(found.botPermissionsError)})`)];
15080
+ if (!found) return [skipRow$1("bot-permissions", TITLE$2, "not checked: could not read the server")];
15081
+ if (found.botPermissionsError) return [skipRow$1("bot-permissions", TITLE$2, `not checked: could not read the bot's roles (${sanitizeDetail(found.botPermissionsError)})`)];
15040
15082
  const { botPermissions } = found;
15041
15083
  if (!botPermissions) return [];
15042
15084
  const { missing, inviteUrl } = botPermissions;
15043
15085
  const problems = missing.length === 0 ? [] : [`missing: ${missing.map((m) => sanitizeDetail(m)).join(", ")}`, ...inviteUrl ? [`invite the bot again with them (updates its role in place): ${inviteUrl}`] : []];
15044
- return [resultRow("bot-permissions", TITLE$1, problems, "every permission it needs")];
15086
+ return [resultRow("bot-permissions", TITLE$2, problems, "every permission it needs")];
15045
15087
  }
15046
15088
  // src/commands/notifications-reaction/layout-reactions/layout-reactions.ts
15047
15089
  /**
@@ -15196,7 +15238,7 @@ function tagEmojiProblem(tagName, emoji, pictured) {
15196
15238
  return `${noun} \`${emoji}\` has no picture: give the emoji an \`image\` in \`emojis\` or a reaction so \`setup\` can make it`;
15197
15239
  }
15198
15240
  // src/commands/emoji-checks/emoji-checks.ts
15199
- const TITLE = "server emoji the forums' reactions and tags name exist";
15241
+ const TITLE$1 = "server emoji the forums' reactions and tags name exist";
15200
15242
  /**
15201
15243
  * The step of `doctor notifications` for server emoji: each one a forum's `defaultReaction`, `starterReactions` or tag `emoji` names
15202
15244
  * (`:git_merge:`) is on the server. A missing one fails by name, and says how to get it: `setup` makes it when the layout
@@ -15208,17 +15250,17 @@ function emojiChecks(input) {
15208
15250
  const wanted = layoutEmojis(input.layout);
15209
15251
  if (wanted.length === 0) return [];
15210
15252
  const { found } = input;
15211
- if (!found) return [skipRow$1("emoji", TITLE, "not checked: could not read the server")];
15212
- if (found.emojisError) return [skipRow$1("emoji", TITLE, `not checked: could not read the server's emoji (${sanitizeDetail(found.emojisError)})`)];
15253
+ if (!found) return [skipRow$1("emoji", TITLE$1, "not checked: could not read the server")];
15254
+ if (found.emojisError) return [skipRow$1("emoji", TITLE$1, `not checked: could not read the server's emoji (${sanitizeDetail(found.emojisError)})`)];
15213
15255
  const have = new Set(found.emojis ?? []);
15214
15256
  const problems = wanted.filter((emoji) => !have.has(emoji.name)).map((emoji) => {
15215
15257
  const name = sanitizeDetail(emoji.name);
15216
15258
  return emoji.image ? `:${name}: is not on the server; \`setup notifications\` makes it from ${sanitizeDetail(emoji.image)}` : `:${name}: is not on the server; add it in the server's settings, or give the reaction an \`image\` for \`setup notifications\` to make it from`;
15217
15259
  });
15218
- return [resultRow("emoji", TITLE, problems, `${wanted.length} of ${wanted.length} on the server`)];
15260
+ return [resultRow("emoji", TITLE$1, problems, `${wanted.length} of ${wanted.length} on the server`)];
15219
15261
  }
15220
15262
  // src/commands/forum-feed-checks/forum-feed-checks.ts
15221
- const same$5 = (a, b) => a.toLowerCase() === b.toLowerCase();
15263
+ const same$6 = (a, b) => a.toLowerCase() === b.toLowerCase();
15222
15264
  const shown$6 = (s) => sanitizeDetail(s);
15223
15265
  /**
15224
15266
  * The steps of `doctor notifications` for a forum feed (`feeds.prs`, `feeds.incidents`): the forum is there (in its
@@ -15249,7 +15291,7 @@ function forumFeedChecks(input, spec) {
15249
15291
  const botProblems = [];
15250
15292
  for (const { cat, channel } of fed) {
15251
15293
  const name = shown$6(channel.name);
15252
- const have = found.channels.find((c) => same$5(c.name, channel.name) && c.category !== void 0 && same$5(c.category, cat));
15294
+ const have = found.channels.find((c) => same$6(c.name, channel.name) && c.category !== void 0 && same$6(c.category, cat));
15253
15295
  if (!have) {
15254
15296
  forumProblems.push(`#${name}: missing from ${shown$6(cat)}`);
15255
15297
  continue;
@@ -15258,7 +15300,7 @@ function forumFeedChecks(input, spec) {
15258
15300
  forumProblems.push(`#${name}: is a text channel, not a forum; delete it so \`setup\` can make it again`);
15259
15301
  continue;
15260
15302
  }
15261
- for (const tag of spec.tags) if (!have.tags?.some((t) => same$5(t.name, tag))) tagProblems.push(`#${name}: tag "${tag}" is missing`);
15303
+ for (const tag of spec.tags) if (!have.tags?.some((t) => same$6(t.name, tag))) tagProblems.push(`#${name}: tag "${tag}" is missing`);
15262
15304
  if (have.botThreadsError) botProblems.push(`#${name}: could not read the bot's permissions (${shown$6(have.botThreadsError)})`);
15263
15305
  else if (have.botThreads) {
15264
15306
  if (!have.botThreads.post) botProblems.push(`#${name}: the bot cannot start posts or reply in it`);
@@ -16488,7 +16530,7 @@ const CHANNEL_ID = "monitoring-alert-channel";
16488
16530
  const CHANNEL_TITLE = "monitoring alert channel posts through the feed webhook";
16489
16531
  const SUBSCRIPTIONS_ID = "monitoring-subscriptions";
16490
16532
  const SUBSCRIPTIONS_TITLE = "monitoring alert channel is subscribed to the checks routed to it";
16491
- const same$4 = (a, b) => a.toLowerCase() === b.toLowerCase();
16533
+ const same$5 = (a, b) => a.toLowerCase() === b.toLowerCase();
16492
16534
  const shown$4 = (s) => sanitizeDetail(s);
16493
16535
  const skipAll = (reason) => [
16494
16536
  skipRow$1(WEBHOOK_ID$1, WEBHOOK_TITLE$1, reason),
@@ -16516,14 +16558,14 @@ async function monitoringFeedChecks(input) {
16516
16558
  let channelSkip;
16517
16559
  for (const { channel, feed } of fed) {
16518
16560
  const names = monitoringFeed(channel.name, feed, monitoring);
16519
- const where = found.channels.find((c) => same$4(c.name, channel.name));
16561
+ const where = found.channels.find((c) => same$5(c.name, channel.name));
16520
16562
  const hookId = where?.webhookIds?.[names.webhook.toLowerCase()];
16521
- const named = where?.webhooks.some((w) => same$4(w, names.webhook)) ?? false;
16563
+ const named = where?.webhooks.some((w) => same$5(w, names.webhook)) ?? false;
16522
16564
  const label = `#${shown$4(channel.name)}`;
16523
16565
  if (!where) webhookProblems.push(`${label}: no channel to hold the feed webhook`);
16524
16566
  else if (where.webhooksError) webhookProblems.push(`${label}: could not list its webhooks (${shown$4(where.webhooksError)})`);
16525
16567
  else if (!named) webhookProblems.push(`${label}: no webhook named ${shown$4(names.webhook)}`);
16526
- else if (feedAvatarOf(layout, feed, monitoring).length > 0 && !where.webhookAvatars?.some((w) => same$4(w, names.webhook))) webhookProblems.push(`${label}: webhook ${shown$4(names.webhook)} has no picture`);
16568
+ else if (feedAvatarOf(layout, feed, monitoring).length > 0 && !where.webhookAvatars?.some((w) => same$5(w, names.webhook))) webhookProblems.push(`${label}: webhook ${shown$4(names.webhook)} has no picture`);
16527
16569
  if (channelSkip !== void 0) continue;
16528
16570
  if (!monitoring.inspectAlertChannel) {
16529
16571
  channelSkip = `the \`${monitoring.providerName}\` provider cannot read its alert channels`;
@@ -17253,7 +17295,7 @@ const BINDINGS_ID = "relay-bindings";
17253
17295
  const BINDINGS_TITLE = "relay Worker has its webhook and signing secret bound";
17254
17296
  const WEBHOOK_ID = "relay-feed-webhook";
17255
17297
  const WEBHOOK_TITLE = "error feed webhook exists and has a picture";
17256
- const same$3 = (a, b) => a.toLowerCase() === b.toLowerCase();
17298
+ const same$4 = (a, b) => a.toLowerCase() === b.toLowerCase();
17257
17299
  const shown$2 = (s) => sanitizeDetail(s);
17258
17300
  /** One unsigned `POST` to the Worker, and what the answer says about it. Reads nothing from the response. */
17259
17301
  async function answers(url, doFetch) {
@@ -17304,7 +17346,7 @@ async function relayChecks(input) {
17304
17346
  else {
17305
17347
  const bound = new Set(state.bindingNames.map((n) => n.toUpperCase()));
17306
17348
  const wanted = ids.flatMap((id) => [relayWebhookBinding(id), relaySecretBinding(id)]);
17307
- rows.push(resultRow(WORKER_ID, WORKER_TITLE, state.routes.some((r) => same$3(r, route)) ? [] : [`${shown$2(script)} has no route ${shown$2(route)}`], `${shown$2(script)} serves ${shown$2(route)}`), resultRow(BINDINGS_ID, BINDINGS_TITLE, wanted.filter((n) => !bound.has(n)).map((n) => `${n}: not bound`), `${wanted.length} of ${wanted.length} bound`));
17349
+ rows.push(resultRow(WORKER_ID, WORKER_TITLE, state.routes.some((r) => same$4(r, route)) ? [] : [`${shown$2(script)} has no route ${shown$2(route)}`], `${shown$2(script)} serves ${shown$2(route)}`), resultRow(BINDINGS_ID, BINDINGS_TITLE, wanted.filter((n) => !bound.has(n)).map((n) => `${n}: not bound`), `${wanted.length} of ${wanted.length} bound`));
17308
17350
  }
17309
17351
  } catch (err) {
17310
17352
  const reason = missingTokenReason(err);
@@ -17331,15 +17373,38 @@ function webhookRow$1(input, source) {
17331
17373
  }
17332
17374
  /** The one rule both feeds follow: the channel exists, lists the webhook and, when a picture is wanted, the picture is on it. */
17333
17375
  function webhookProblems(input, id, title, channelName, name, avatar) {
17334
- const where = input.found.channels.find((c) => same$3(c.name, channelName));
17376
+ const where = input.found.channels.find((c) => same$4(c.name, channelName));
17335
17377
  const label = `#${shown$2(channelName)}`;
17336
17378
  const problems = [];
17337
17379
  if (!where) problems.push(`${label}: no channel to hold the feed webhook`);
17338
17380
  else if (where.webhooksError) problems.push(`${label}: could not list its webhooks (${shown$2(where.webhooksError)})`);
17339
- else if (!where.webhooks.some((w) => same$3(w, name))) problems.push(`${label}: no webhook named ${shown$2(name)}`);
17340
- else if (avatar.length > 0 && !where.webhookAvatars?.some((w) => same$3(w, name))) problems.push(`${label}: webhook ${shown$2(name)} has no picture`);
17381
+ else if (!where.webhooks.some((w) => same$4(w, name))) problems.push(`${label}: no webhook named ${shown$2(name)}`);
17382
+ else if (avatar.length > 0 && !where.webhookAvatars?.some((w) => same$4(w, name))) problems.push(`${label}: webhook ${shown$2(name)} has no picture`);
17341
17383
  return resultRow(id, title, problems, `${label}: ${shown$2(name)}`);
17342
17384
  }
17385
+ // src/commands/release-thread-checks/release-thread-checks.ts
17386
+ const same$3 = (a, b) => a.toLowerCase() === b.toLowerCase();
17387
+ const TITLE = "bot can create release threads in #releases";
17388
+ /**
17389
+ * The step of `doctor notifications` for release announcements (`sync releases`, SPEC-0119): when the layout has a
17390
+ * `releases` channel, the bot can create public threads there and send in them, read from `inspect` after the
17391
+ * channel's own overwrites (`botThreads.post`). Read-only. No row when the layout has no `releases` channel.
17392
+ */
17393
+ function releaseThreadChecks(input) {
17394
+ const { layout, found } = input;
17395
+ if (!(layout.categories ?? []).flatMap((cat) => (cat.channels ?? []).map((channel) => ({
17396
+ cat: cat.name,
17397
+ channel
17398
+ }))).find(({ channel }) => same$3(channel.name, "releases"))) return [];
17399
+ if (!found) return [skipRow$1("release-threads", TITLE, "not checked: could not read the server")];
17400
+ const have = found.channels.find((c) => same$3(c.name, "releases"));
17401
+ const problems = [];
17402
+ if (!have) problems.push("#releases: missing from the server");
17403
+ else if (have.botThreadsError) problems.push(`#releases: could not read the bot's permissions (${sanitizeDetail(have.botThreadsError)})`);
17404
+ else if (!have.botThreads) problems.push("#releases: the provider did not report the bot's permissions");
17405
+ else if (!have.botThreads.post) problems.push("#releases: the bot cannot create public threads there (needs Create Public Threads and Send Messages in Threads)");
17406
+ return [resultRow("release-threads", TITLE, problems, "the bot can create threads in #releases")];
17407
+ }
17343
17408
  // src/commands/sentry-relay-checks/sentry-relay-checks.ts
17344
17409
  const INTEGRATION_ID = "relay-integration";
17345
17410
  const INTEGRATION_TITLE = "error tracker integration posts to the relay";
@@ -17910,6 +17975,10 @@ async function runDoctorNotifications(input) {
17910
17975
  layout,
17911
17976
  found
17912
17977
  }));
17978
+ checks.push(...releaseThreadChecks({
17979
+ layout,
17980
+ found
17981
+ }));
17913
17982
  checks.push(...await notificationsWorkflowChecks({
17914
17983
  layout,
17915
17984
  source: loader.has("source") ? loader.get("source") : void 0,
@@ -32347,7 +32416,7 @@ async function runSecretToFile(input, value, print, loader, logger = getLogger()
32347
32416
  *
32348
32417
  * Errors clearly when no value can be sourced.
32349
32418
  */
32350
- const env$4 = createEnvLookup();
32419
+ const env$5 = createEnvLookup();
32351
32420
  async function runSecretSet(input) {
32352
32421
  const print = input.print ?? ((line) => console.log(line));
32353
32422
  const logger = input.logger ?? getLogger();
@@ -32415,8 +32484,8 @@ function noValueMessage(name) {
32415
32484
  async function resolveValue(input) {
32416
32485
  if (input.value) return input.value;
32417
32486
  if (input.fromStdin) return (await (input.readStdin ?? defaultReadStdin)()).replace(/\r?\n$/, "");
32418
- if (input.fromEnv) return env$4.get(input.fromEnv);
32419
- return env$4.get(input.name);
32487
+ if (input.fromEnv) return env$5.get(input.fromEnv);
32488
+ return env$5.get(input.name);
32420
32489
  }
32421
32490
  async function defaultReadStdin() {
32422
32491
  const chunks = [];
@@ -32523,7 +32592,7 @@ const secretSetCommand = {
32523
32592
  * 9. Unless --no-verify: `pnpm install` in the new repo.
32524
32593
  * 10. Print next steps.
32525
32594
  */
32526
- const env$3 = createEnvLookup();
32595
+ const env$4 = createEnvLookup();
32527
32596
  var NewError = class extends Error {
32528
32597
  name = "NewError";
32529
32598
  };
@@ -32860,11 +32929,11 @@ async function runNew(input) {
32860
32929
  const setupEnv = {};
32861
32930
  const adminToken = input.token ?? keychainLookup("github.admin");
32862
32931
  if (adminToken) setupArgs.push("--token", adminToken);
32863
- if (!env$3.get("HOLOCRON_ORG_TOKEN")) {
32932
+ if (!env$4.get("HOLOCRON_ORG_TOKEN")) {
32864
32933
  const orgToken = keychainLookup("github.org");
32865
32934
  if (orgToken) setupEnv["HOLOCRON_ORG_TOKEN"] = orgToken;
32866
32935
  }
32867
- if (!env$3.get("HOLOCRON_DEPLOY_TOKEN")) {
32936
+ if (!env$4.get("HOLOCRON_DEPLOY_TOKEN")) {
32868
32937
  const deployToken = keychainLookup("github.deploy");
32869
32938
  if (deployToken) setupEnv["HOLOCRON_DEPLOY_TOKEN"] = deployToken;
32870
32939
  }
@@ -36478,6 +36547,232 @@ const npmBumpVersionsCommand = {
36478
36547
  })).status === "fail") process.exitCode = 1;
36479
36548
  }
36480
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
+ }
36481
36776
  // src/commands/publish/resolve-otp.ts
36482
36777
  /**
36483
36778
  * `argvOtp` if given, else the `HOLOCRON_OTP` env var — the secret-delivery
@@ -36490,9 +36785,52 @@ const npmBumpVersionsCommand = {
36490
36785
  function resolveOtp(argvOtp, env) {
36491
36786
  return argvOtp ?? env.get("HOLOCRON_OTP");
36492
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
+ };
36493
36831
  // src/commands/publish/default-exec.ts
36494
36832
  const defaultExec = async (cmd, args, opts) => {
36495
- const { HOLOCRON_OTP: _omittedOtp, ...env } = process.env;
36833
+ const { HOLOCRON_OTP: _omittedOtp, ...inherited } = process.env;
36496
36834
  const result = spawnSync(cmd, args, {
36497
36835
  cwd: opts.cwd,
36498
36836
  encoding: "utf8",
@@ -36501,7 +36839,10 @@ const defaultExec = async (cmd, args, opts) => {
36501
36839
  "pipe",
36502
36840
  "pipe"
36503
36841
  ],
36504
- env
36842
+ env: {
36843
+ ...inherited,
36844
+ ...opts.env
36845
+ }
36505
36846
  });
36506
36847
  return {
36507
36848
  exitCode: result.status ?? -1,
@@ -36522,21 +36863,9 @@ const defaultLogin = async (cwd) => {
36522
36863
  stdio: "inherit"
36523
36864
  }).status ?? -1 };
36524
36865
  };
36525
- // src/commands/publish/discover-public-package-entries.ts
36526
- /**
36527
- * Every public package (`!private && name`) with its version and a
36528
- * `pnpm --filter`-ready path — {@link runSteadyPublish}'s `skipAlreadyPublished`
36529
- * mode needs both to check `npm view <pkg>@<version>` and publish one
36530
- * workspace at a time.
36531
- */
36532
- function discoverPublicPackageEntries(cwd, scope = {}) {
36533
- return discoverManifests(cwd, scope).flatMap(({ manifest, dir }) => !manifest.private && manifest.name && manifest.version ? [{
36534
- name: manifest.name,
36535
- version: manifest.version,
36536
- dir
36537
- }] : []);
36538
- }
36539
36866
  // src/commands/publish/filter-new-packages.ts
36867
+ /** The version npm gives a staged new package's public placeholder until the stage is approved. */
36868
+ const STAGE_PLACEHOLDER_VERSION = "0.0.0-stage";
36540
36869
  /**
36541
36870
  * Keeps only the entries that don't exist on npm yet — the actual
36542
36871
  * chicken-and-egg case `--initial` exists for (ADR: npm requires a package
@@ -36570,7 +36899,7 @@ async function filterNewPackages(entries, cwd, exec, print, nameWidth, dirWidth)
36570
36899
  "version"
36571
36900
  ], { cwd });
36572
36901
  const publishedVersion = view.exitCode === 0 ? view.stdout.trim() : "";
36573
- if (publishedVersion) {
36902
+ if (publishedVersion && publishedVersion !== STAGE_PLACEHOLDER_VERSION) {
36574
36903
  print(statusRow$1("skip", [
36575
36904
  pad$1(entry.name, nameWidth),
36576
36905
  pad$1(entry.dir, dirWidth),
@@ -36582,8 +36911,25 @@ async function filterNewPackages(entries, cwd, exec, print, nameWidth, dirWidth)
36582
36911
  }
36583
36912
  return results;
36584
36913
  }
36914
+ // src/commands/publish/node-version-supports-stage.ts
36915
+ /** The first Node that npm's `npm stage` supports. */
36916
+ const MIN_STAGE_NODE_VERSION = "22.14.0";
36917
+ /** True when the `node --version` output (`v22.14.0`) names 22.14.0 or later. */
36918
+ function nodeVersionSupportsStage(output) {
36919
+ const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(output.trim());
36920
+ if (!match) return false;
36921
+ const [major, minor] = [Number(match[1]), Number(match[2])];
36922
+ return major > 22 || major === 22 && minor >= 14;
36923
+ }
36924
+ // src/commands/publish/print-approve-lines.ts
36925
+ /** One `npm stage approve <id>` line per staged package, and where to find the same stages on npmjs.com. */
36926
+ function printApproveLines(print, staged) {
36927
+ for (const s of staged) print(` npm stage approve ${s.id}`);
36928
+ print(" or on npmjs.com, the Staged Packages tab of each package (under its settings):");
36929
+ for (const s of staged) print(` https://www.npmjs.com/package/${s.name}/access`);
36930
+ }
36585
36931
  // src/commands/publish/print-next-steps.ts
36586
- function printNextSteps(print, env, packageNames, identity, workflowFile) {
36932
+ function printNextSteps(print, env, packageNames, identity, workflowFile, npmTokenUsed = false) {
36587
36933
  print("");
36588
36934
  print("→ next: configure Trusted Publisher for each package on npm:");
36589
36935
  print(" Publisher: GitHub Actions");
@@ -36596,23 +36942,17 @@ function printNextSteps(print, env, packageNames, identity, workflowFile) {
36596
36942
  print("");
36597
36943
  print("→ packages to be published:");
36598
36944
  for (const name of packageNames) print(` https://www.npmjs.com/package/${name}/access`);
36599
- if (env.get("NPM_TOKEN")) {
36945
+ if (npmTokenUsed || env.get("NPM_TOKEN") || env.get("HOLOCRON_NPM_TOKEN")) {
36600
36946
  print("");
36601
- print("→ cleanup: $NPM_TOKEN was used. Revoke it now (no API for self-revoke; UI-only):");
36947
+ print("→ cleanup: the npm token was used. It is short-lived (a short expiry); revoke it now if it has not run out");
36948
+ print(" (no API for self-revoke; UI-only):");
36602
36949
  print(" https://www.npmjs.com/settings/~/tokens");
36603
36950
  }
36604
36951
  }
36605
- // src/commands/publish/redact-otp.ts
36606
- /**
36607
- * Replaces the literal `otp` value in a "would run: pnpm ..." dry-run
36608
- * preview line with `***` — the real `args` passed to `exec()` still need
36609
- * the raw OTP (npm's own `--otp` flag has no env-var alternative), but the
36610
- * preview is printed straight to the terminal / captured as dry-run output
36611
- * and must never echo a live 2FA code back out.
36612
- */
36613
- function redactOtp(args, otp) {
36614
- if (!otp) return [...args];
36615
- return args.map((arg) => arg === otp ? "***" : arg);
36952
+ // src/commands/publish/redact-token.ts
36953
+ /** Replaces every occurrence of `token` in `text` with `***`, so an npm error never echoes the credential. */
36954
+ function redactToken(text, token) {
36955
+ return token ? text.split(token).join("***") : text;
36616
36956
  }
36617
36957
  // src/commands/publish/release-workflow-file.ts
36618
36958
  /** The release caller's filename: the current name first, then the one a repo still on the older callers has. */
@@ -36643,14 +36983,101 @@ async function resolveRepoIdentity(cwd, exec) {
36643
36983
  repo: remote?.repo ?? "unknown"
36644
36984
  };
36645
36985
  }
36646
- // src/commands/publish/scope-of.ts
36647
- /** The {@link WorkspaceScope} a publish input asks for; unset options stay unset. */
36648
- function scopeOf({ group, excludeGroups, onlyPackages }) {
36649
- return {
36650
- ...group === void 0 ? {} : { group },
36651
- ...excludeGroups === void 0 ? {} : { excludeGroups },
36652
- ...onlyPackages === void 0 ? {} : { onlyPackages }
36653
- };
36986
+ // src/commands/publish/parse-stage-id.ts
36987
+ /**
36988
+ * The stage id `npm stage publish` prints, as in `+ @scope/name@0.0.1 (staged with id <uuid>)`.
36989
+ * `undefined` when the output carries none.
36990
+ */
36991
+ function parseStageId(output) {
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];
36993
+ }
36994
+ // src/commands/publish/stage-packages/stage-packages.ts
36995
+ /** The registry auth key npm reads from the environment, so the token never touches an `.npmrc`. */
36996
+ const NPM_AUTH_ENV_KEY = "npm_config_//registry.npmjs.org/:_authToken";
36997
+ /**
36998
+ * Stages each package with `npm stage publish`: nothing becomes public until a maintainer approves it with 2FA. The
36999
+ * package is packed with `pnpm pack` first (npm would not rewrite `workspace:` ranges), and the tarball is staged. The
37000
+ * token is in the child environment for the stage calls only, and every message is redacted of it.
37001
+ */
37002
+ async function stagePackages(input) {
37003
+ const { exec, cwd, token } = input;
37004
+ const env = { [NPM_AUTH_ENV_KEY]: token };
37005
+ const staged = [];
37006
+ const listed = await exec("npm", ["stage", "list"], {
37007
+ cwd,
37008
+ env
37009
+ });
37010
+ const pending = listed.exitCode === 0 ? parseStageList(listed.stdout) : [];
37011
+ const scratch = mkdtempSync(join(tmpdir(), "holocron-stage-"));
37012
+ try {
37013
+ for (const entry of input.entries) {
37014
+ const dir = resolve(cwd, entry.dir);
37015
+ const label = `${entry.name}@${entry.version}`;
37016
+ const already = pending.find((p) => p.name === entry.name && p.version === entry.version);
37017
+ if (already) {
37018
+ input.print(` · ${label} is already staged (${already.id}); not uploading it again`);
37019
+ staged.push({
37020
+ name: entry.name,
37021
+ version: entry.version,
37022
+ id: already.id,
37023
+ resumed: true
37024
+ });
37025
+ continue;
37026
+ }
37027
+ const pack = await exec("pnpm", [
37028
+ "pack",
37029
+ "--pack-destination",
37030
+ scratch
37031
+ ], { cwd: dir });
37032
+ const tarball = pack.stdout.split("\n").map((l) => l.trim()).filter((l) => l.endsWith(".tgz")).pop();
37033
+ if (pack.exitCode !== 0 || !tarball) {
37034
+ const message = `pack failed for ${label}: ${redactToken(pack.stderr.trim() || pack.stdout.trim() || "no output", token)}`;
37035
+ input.print(` ✗ ${message}`);
37036
+ return {
37037
+ ok: false,
37038
+ staged,
37039
+ message
37040
+ };
37041
+ }
37042
+ const result = await exec("npm", [
37043
+ "stage",
37044
+ "publish",
37045
+ resolve(dir, tarball),
37046
+ "--access",
37047
+ "public",
37048
+ "--tag",
37049
+ input.tag
37050
+ ], {
37051
+ cwd: dir,
37052
+ env
37053
+ });
37054
+ const id = parseStageId(`${result.stdout}\n${result.stderr}`);
37055
+ if (result.exitCode !== 0 || !id) {
37056
+ const detail = redactToken(result.stderr.trim() || result.stdout.trim() || "no output", token);
37057
+ const message = result.exitCode === 0 ? `stage did not report an id for ${label}: ${detail}` : `stage failed for ${label} (exit ${result.exitCode}): ${detail}`;
37058
+ input.print(` ✗ ${message}`);
37059
+ return {
37060
+ ok: false,
37061
+ staged,
37062
+ message
37063
+ };
37064
+ }
37065
+ staged.push({
37066
+ name: entry.name,
37067
+ version: entry.version,
37068
+ id
37069
+ });
37070
+ }
37071
+ return {
37072
+ ok: true,
37073
+ staged
37074
+ };
37075
+ } finally {
37076
+ rmSync(scratch, {
37077
+ recursive: true,
37078
+ force: true
37079
+ });
37080
+ }
36654
37081
  }
36655
37082
  // src/commands/publish/workspace-filter-args.ts
36656
37083
  /**
@@ -36727,20 +37154,62 @@ async function runPublish(input = {}) {
36727
37154
  const env = createEnvLookup(input.env);
36728
37155
  const exec = input.exec ?? defaultExec;
36729
37156
  const login = input.login ?? defaultLogin;
37157
+ const npmToken = resolveValue$2(["NPM_TOKEN"], input.env, { prefix: PREFIX$1 });
37158
+ const tokenEnv = npmToken ? { [NPM_AUTH_ENV_KEY]: npmToken } : void 0;
36730
37159
  logger.info({
36731
37160
  tag,
36732
- dryRun: dryRun || void 0
37161
+ dryRun: dryRun || void 0,
37162
+ staged: npmToken ? true : void 0
36733
37163
  }, "publish --initial: start");
37164
+ const names = () => (input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input))).map((e) => e.name);
36734
37165
  print("");
36735
37166
  print(style.dim(" → verifying npm auth (`npm whoami`)…"));
36736
- let whoami = await exec("npm", ["whoami"], { cwd });
37167
+ if (npmToken) {
37168
+ const version = await exec("npm", ["--version"], { cwd });
37169
+ if (version.exitCode !== 0 || !npmVersionSupportsStage(version.stdout)) {
37170
+ const message = `staging needs npm ${MIN_STAGE_NPM_VERSION} or later (found ${version.stdout.trim() || "none"}). Update npm, then re-run.`;
37171
+ print(` ✗ ${message}`);
37172
+ logger.warn({ reason: "npm too old for stage" }, "publish --initial: done");
37173
+ return {
37174
+ status: "fail",
37175
+ message,
37176
+ packageNames: names()
37177
+ };
37178
+ }
37179
+ const node = await exec("node", ["--version"], { cwd });
37180
+ if (node.exitCode !== 0 || !nodeVersionSupportsStage(node.stdout)) {
37181
+ const message = `staging needs Node ${MIN_STAGE_NODE_VERSION} or later (found ${node.stdout.trim() || "none"}). Switch Node, then re-run.`;
37182
+ print(` ✗ ${message}`);
37183
+ logger.warn({ reason: "node too old for stage" }, "publish --initial: done");
37184
+ return {
37185
+ status: "fail",
37186
+ message,
37187
+ packageNames: names()
37188
+ };
37189
+ }
37190
+ }
37191
+ let whoami = await exec("npm", ["whoami"], {
37192
+ cwd,
37193
+ ...tokenEnv ? { env: tokenEnv } : {}
37194
+ });
37195
+ if (npmToken && whoami.exitCode !== 0) {
37196
+ const detail = redactToken(`${whoami.stderr} ${whoami.stdout}`, npmToken);
37197
+ const message = /E401/.test(detail) ? "npm rejected HOLOCRON_NPM_TOKEN (E401): it is expired or revoked. Make a new stage-only token at https://www.npmjs.com/settings/~/tokens." : `npm whoami failed with HOLOCRON_NPM_TOKEN: ${detail.trim() || "no output"}`;
37198
+ print(` ✗ ${message}`);
37199
+ logger.warn({ reason: "npm whoami failed with token" }, "publish --initial: done");
37200
+ return {
37201
+ status: "fail",
37202
+ message,
37203
+ packageNames: names()
37204
+ };
37205
+ }
36737
37206
  if (whoami.exitCode !== 0) {
36738
37207
  print(" not authenticated — running `npm login --auth-type=web`…");
36739
37208
  logger.info({}, "publish --initial: npm login");
36740
37209
  if ((await login(cwd)).exitCode !== 0) {
36741
37210
  const message = "npm login failed. Run `npm login --auth-type=web` (or `npm login`) manually, then re-run.";
36742
37211
  print(` ✗ ${message}`);
36743
- const packageNames = (input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input))).map((e) => e.name);
37212
+ const packageNames = names();
36744
37213
  logger.warn({ reason: "npm login failed" }, "publish --initial: done");
36745
37214
  return {
36746
37215
  status: "fail",
@@ -36752,7 +37221,7 @@ async function runPublish(input = {}) {
36752
37221
  if (whoami.exitCode !== 0) {
36753
37222
  const message = "npm login completed but `npm whoami` still fails — check your npm account.";
36754
37223
  print(` ✗ ${message}`);
36755
- const packageNames = (input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input))).map((e) => e.name);
37224
+ const packageNames = names();
36756
37225
  logger.warn({ reason: "npm whoami still fails after login" }, "publish --initial: done");
36757
37226
  return {
36758
37227
  status: "fail",
@@ -36811,10 +37280,10 @@ async function runPublish(input = {}) {
36811
37280
  ];
36812
37281
  if (dryRun) {
36813
37282
  print("");
36814
- for (const entry of newEntries) print(style.dim(` ${pad$1(entry.name, nameWidth)} ${pad$1(entry.dir, dirWidth)} would publish (v${entry.version})`));
36815
- print(style.dim(` would run: pnpm ${redactOtp(publishArgs, otp).join(" ")}`));
37283
+ for (const entry of newEntries) print(style.dim(` ${pad$1(entry.name, nameWidth)} ${pad$1(entry.dir, dirWidth)} would ${npmToken ? "stage" : "publish"} (v${entry.version})`));
37284
+ print(style.dim(npmToken ? ` would run, per package: pnpm pack, then npm stage publish <tarball> --access public --tag ${tag} (token from the environment, not shown)` : ` would run: pnpm ${redactOtp(publishArgs, otp).join(" ")}`));
36816
37285
  printSummary(print, dryRun, packageNames.length, 0, skippedCount);
36817
- printNextSteps(print, env, packageNames, identity, releaseWorkflowFile(cwd));
37286
+ printNextSteps(print, env, packageNames, identity, releaseWorkflowFile(cwd), Boolean(npmToken));
36818
37287
  logger.info({
36819
37288
  tag,
36820
37289
  status: "dry-run",
@@ -36826,6 +37295,53 @@ async function runPublish(input = {}) {
36826
37295
  packageNames
36827
37296
  };
36828
37297
  }
37298
+ if (npmToken) {
37299
+ print("");
37300
+ print(` → staging ${packageNames.length} new package${packageNames.length === 1 ? "" : "s"} (nothing is published)…`);
37301
+ const result = await stagePackages({
37302
+ entries: newEntries,
37303
+ cwd,
37304
+ tag,
37305
+ token: npmToken,
37306
+ exec,
37307
+ print
37308
+ });
37309
+ if (!result.ok) {
37310
+ if (result.staged.length > 0) {
37311
+ print("");
37312
+ print("→ these were staged before the failure and are still pending (a rerun reports them, it does not stage them twice):");
37313
+ printApproveLines(print, result.staged);
37314
+ }
37315
+ printSummary(print, dryRun, 0, packageNames.length - result.staged.length, skippedCount);
37316
+ logger.warn({
37317
+ tag,
37318
+ reason: "stage failed"
37319
+ }, "publish --initial: done");
37320
+ return {
37321
+ status: "fail",
37322
+ message: result.message,
37323
+ packageNames,
37324
+ staged: result.staged
37325
+ };
37326
+ }
37327
+ for (const s of result.staged) print(statusRow$1("ok", [pad$1(s.name, nameWidth), `staged (v${s.version})`]));
37328
+ print("");
37329
+ print(style.dim(` ${result.staged.length} staged, 0 failed, ${skippedCount} skipped (nothing is public yet)`));
37330
+ print("");
37331
+ print("→ approve each staged package (asks for 2FA; add `--otp <code>` to give the code on the command line):");
37332
+ printApproveLines(print, result.staged);
37333
+ printNextSteps(print, env, packageNames, identity, releaseWorkflowFile(cwd), true);
37334
+ logger.info({
37335
+ tag,
37336
+ status: "ok",
37337
+ staged: result.staged.length
37338
+ }, "publish --initial: done");
37339
+ return {
37340
+ status: "ok",
37341
+ packageNames,
37342
+ staged: result.staged
37343
+ };
37344
+ }
36829
37345
  print("");
36830
37346
  print(` → publishing ${packageNames.length} new package${packageNames.length === 1 ? "" : "s"}…`);
36831
37347
  const publish = await exec("pnpm", publishArgs, { cwd });
@@ -37440,7 +37956,7 @@ const publishPackageCommand = {
37440
37956
  const publishCommand = {
37441
37957
  command: "publish",
37442
37958
  describe: "Version and publish workspace packages",
37443
- 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")),
37444
37960
  handler: () => {}
37445
37961
  };
37446
37962
  // src/commands/project/plan-pull-request-status/plan-pull-request-status.ts
@@ -40970,6 +41486,299 @@ const syncReadmeCommand = {
40970
41486
  }
40971
41487
  }
40972
41488
  };
41489
+ // src/commands/sync-releases/release-marker/release-marker.ts
41490
+ /**
41491
+ * The marker that ends a release's message: Discord's small-text line, so it is quiet to read, carrying the release id
41492
+ * between brackets. The closing bracket matters: a marker looked for as text must not match the next release's id
41493
+ * (`v5.0.0-alpha.1` is a prefix of `v5.0.0-alpha.10`).
41494
+ *
41495
+ * @param id - The release's id: its tag, or the two commits.
41496
+ */
41497
+ function releaseMarker(id) {
41498
+ return `-# release [${id}]`;
41499
+ }
41500
+ // src/commands/sync-releases/released-packages/released-packages.ts
41501
+ /** The file at `rev`, or `undefined` when the commit has no such file. */
41502
+ function showAt(cwd, rev, path) {
41503
+ try {
41504
+ return execFileSync("git", ["show", `${rev}:${path}`], {
41505
+ cwd,
41506
+ encoding: "utf8",
41507
+ stdio: [
41508
+ "ignore",
41509
+ "pipe",
41510
+ "ignore"
41511
+ ]
41512
+ });
41513
+ } catch {
41514
+ return;
41515
+ }
41516
+ }
41517
+ function versionAt(cwd, rev, dir) {
41518
+ const text = showAt(cwd, rev, dir === "." ? "package.json" : `${dir.replace(/^\.\//, "")}/package.json`);
41519
+ if (text === void 0) return {};
41520
+ try {
41521
+ const manifest = JSON.parse(text);
41522
+ return {
41523
+ version: manifest.version,
41524
+ private: manifest.private
41525
+ };
41526
+ } catch {
41527
+ return {};
41528
+ }
41529
+ }
41530
+ /** The dist-tag a version publishes under: its prerelease identifier (`5.0.0-alpha.3` is `alpha`), else `latest`. */
41531
+ function distTagOf(version) {
41532
+ const pre = version.split("-").slice(1).join("-");
41533
+ return pre ? pre.split(".")[0] : "latest";
41534
+ }
41535
+ /**
41536
+ * The public packages a release published: those whose `version` differs between `from` and `to`. Private packages
41537
+ * and apps (deployed, not versioned) are left out. The packages and their folders are the working tree's, read the
41538
+ * way `publish package` reads them, and each manifest is read from the two commits with git, so the working tree
41539
+ * needs no particular checkout. With no `from` (a first release) every public package counts.
41540
+ *
41541
+ * @param cwd - The repository root.
41542
+ * @param from - The commit the release started from; empty for none.
41543
+ * @param to - The release commit.
41544
+ * @throws When `to` (or a non-empty `from`) is not a commit of the repository.
41545
+ */
41546
+ function releasedPackages(cwd, from, to) {
41547
+ for (const rev of [from, to]) {
41548
+ if (!rev) continue;
41549
+ try {
41550
+ execFileSync("git", [
41551
+ "rev-parse",
41552
+ "--verify",
41553
+ "--quiet",
41554
+ `${rev}^{commit}`
41555
+ ], {
41556
+ cwd,
41557
+ stdio: [
41558
+ "ignore",
41559
+ "pipe",
41560
+ "ignore"
41561
+ ]
41562
+ });
41563
+ } catch {
41564
+ throw new Error(`\`${rev}\` is not a commit of this repository`);
41565
+ }
41566
+ }
41567
+ const released = [];
41568
+ for (const entry of discoverPublicPackageEntries(cwd)) {
41569
+ if (entry.dir.replace(/^\.\//, "").startsWith("apps/")) continue;
41570
+ const after = versionAt(cwd, to, entry.dir);
41571
+ if (!after.version || after.private) continue;
41572
+ if ((from ? versionAt(cwd, from, entry.dir).version : void 0) === after.version) continue;
41573
+ released.push({
41574
+ name: entry.name,
41575
+ version: after.version,
41576
+ distTag: distTagOf(after.version)
41577
+ });
41578
+ }
41579
+ return released.sort((a, b) => a.name.localeCompare(b.name));
41580
+ }
41581
+ // src/commands/sync-releases/render-release/render-release.ts
41582
+ /** Discord's limit on a thread's name. */
41583
+ const THREAD_NAME_LIMIT = 100;
41584
+ /**
41585
+ * The text of a release's announcement: a message with the headline, the link to the GitHub release (when a tag and
41586
+ * the repository are known) and the marker last, a thread name, and one line per package. Chunking the lines to the
41587
+ * provider's limit is the provider's job.
41588
+ */
41589
+ function renderRelease(input) {
41590
+ const { id, tag, repo, packages } = input;
41591
+ const count = packages.length;
41592
+ const tags = [...new Set(packages.map((p) => p.distTag))].join(", ");
41593
+ return {
41594
+ message: [
41595
+ `**${tag ?? id}** released: ${count} package${count === 1 ? "" : "s"} on ${tags}`,
41596
+ ...tag && repo ? [`https://github.com/${repo}/releases/tag/${tag}`] : [],
41597
+ releaseMarker(id)
41598
+ ].join("\n"),
41599
+ threadName: (tag ?? id).slice(0, THREAD_NAME_LIMIT),
41600
+ lines: packages.map((p) => `${p.name} ${p.version}`)
41601
+ };
41602
+ }
41603
+ // src/commands/sync-releases/run-sync-releases/run-sync-releases.ts
41604
+ /**
41605
+ * `holocron sync releases` -- announce a release in the `releases` channel (SPEC-0119 part 2, #2777).
41606
+ *
41607
+ * The public packages whose version differs between `--from` and `--to` are posted as one message, with a thread on it
41608
+ * holding one line per package. The message ends with a marker carrying the release id, so a rerun finds it, starts a
41609
+ * thread only when it has none, and posts only the lines the thread lacks: it never posts a second message. Nothing
41610
+ * published is a success that posts nothing. It writes, so it asks first; `--yes` skips the question and, without a
41611
+ * terminal, a run with neither `--yes` nor `--dry-run` refuses.
41612
+ */
41613
+ const DEFAULT_CHANNEL = "releases";
41614
+ const canThread = (p) => typeof p.sendWithId === "function" && typeof p.findMessage === "function" && typeof p.startThread === "function" && typeof p.postToThread === "function" && typeof p.readThread === "function";
41615
+ async function runSyncReleases(input) {
41616
+ const print = input.print ?? ((line) => console.log(line));
41617
+ const row = (status, ...parts) => print(statusRow$1(status, ["sync releases", ...parts]));
41618
+ const stop = (status, reason) => {
41619
+ row(status, reason);
41620
+ return {
41621
+ status,
41622
+ reason
41623
+ };
41624
+ };
41625
+ const channel = input.channel ?? DEFAULT_CHANNEL;
41626
+ const dryRun = Boolean(input.context.dryRun);
41627
+ let packages;
41628
+ try {
41629
+ packages = releasedPackages(input.context.repoRoot, input.from || void 0, input.to);
41630
+ } catch (err) {
41631
+ return stop("fail", errorMessage(err));
41632
+ }
41633
+ if (packages.length === 0) {
41634
+ row("ok", "no public package changed version, nothing to announce");
41635
+ return {
41636
+ status: "ok",
41637
+ packages
41638
+ };
41639
+ }
41640
+ const repo = input.context.repo ?? (input.context.org && input.loaded.resolved.name ? `${input.context.org}/${input.loaded.resolved.name}` : void 0);
41641
+ const id = input.tag || `${(input.from || "start").slice(0, 7)}..${input.to.slice(0, 7)}`;
41642
+ const rendered = renderRelease({
41643
+ id,
41644
+ ...input.tag ? { tag: input.tag } : {},
41645
+ ...repo ? { repo } : {},
41646
+ packages
41647
+ });
41648
+ const marker = releaseMarker(id);
41649
+ if (dryRun) {
41650
+ print(`Would post to #${channel}:`);
41651
+ for (const line of rendered.message.split("\n")) print(` ${line}`);
41652
+ print(`Would start the thread "${rendered.threadName}" with:`);
41653
+ for (const line of rendered.lines) print(` ${line}`);
41654
+ row("skip", `dry run, nothing posted; ${packages.length} package(s)`);
41655
+ return {
41656
+ status: "ok",
41657
+ packages
41658
+ };
41659
+ }
41660
+ /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
41661
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
41662
+ await loader.load();
41663
+ assertPluginsResolvable(loader, "sync releases");
41664
+ let notifications;
41665
+ try {
41666
+ notifications = pickProvider(notificationProviders(loader), input.provider, canThread, {
41667
+ infinitive: "start a thread on a message",
41668
+ gerund: "threading"
41669
+ });
41670
+ } catch (err) {
41671
+ return stop("fail", `the notifications provider cannot start a thread: ${errorMessage(err)}`);
41672
+ }
41673
+ const posted = {
41674
+ message: false,
41675
+ thread: false,
41676
+ lines: 0
41677
+ };
41678
+ try {
41679
+ let message = await notifications.findMessage(channel, marker);
41680
+ const existing = message?.threadId ? await notifications.readThread(message.threadId) : [];
41681
+ const have = new Set(existing.flatMap((text) => text.split("\n").map((l) => l.trim())));
41682
+ const missing = rendered.lines.filter((l) => !have.has(l));
41683
+ if (message?.threadId && missing.length === 0) {
41684
+ row("ok", id, "already announced, in step");
41685
+ return {
41686
+ status: "ok",
41687
+ packages,
41688
+ posted
41689
+ };
41690
+ }
41691
+ if (!input.yes) {
41692
+ if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`sync releases\` posts to #${channel}; pass --yes to run it without asking, or --dry-run to look`);
41693
+ if (!await (input.confirm ?? ((q) => confirm({
41694
+ message: q,
41695
+ default: false
41696
+ })))(`Announce ${id} (${packages.length} package(s)) in #${channel}?`)) {
41697
+ row("skip", "cancelled; nothing was changed");
41698
+ return {
41699
+ status: "cancelled",
41700
+ packages,
41701
+ posted
41702
+ };
41703
+ }
41704
+ }
41705
+ if (!message) {
41706
+ message = await notifications.sendWithId(channel, rendered.message);
41707
+ posted.message = true;
41708
+ row("ok", id, `posted to #${channel}`);
41709
+ }
41710
+ let threadId = message.threadId;
41711
+ if (!threadId) {
41712
+ threadId = (await notifications.startThread(message, rendered.threadName)).id;
41713
+ posted.thread = true;
41714
+ row("ok", id, `started the thread "${rendered.threadName}"`);
41715
+ }
41716
+ await notifications.postToThread(threadId, missing);
41717
+ posted.lines = missing.length;
41718
+ row("ok", id, `${missing.length} package line(s) posted`);
41719
+ return {
41720
+ status: "ok",
41721
+ packages,
41722
+ posted
41723
+ };
41724
+ } catch (err) {
41725
+ if (err instanceof NonInteractiveError) throw err;
41726
+ row("fail", id, describeError(err));
41727
+ return {
41728
+ status: "fail",
41729
+ packages,
41730
+ posted,
41731
+ reason: errorMessage(err)
41732
+ };
41733
+ }
41734
+ }
41735
+ // src/commands/sync-releases/sync-releases.command.ts
41736
+ const syncReleasesCommand = {
41737
+ command: "releases",
41738
+ describe: "Announce a release in the `releases` channel: one message, and a thread with a line per package that changed version",
41739
+ builder: (y) => y.option("from", {
41740
+ type: "string",
41741
+ describe: "The commit the release started from (the release job's `previous`); empty counts every package"
41742
+ }).option("to", {
41743
+ type: "string",
41744
+ default: "HEAD",
41745
+ describe: "The release commit"
41746
+ }).option("tag", {
41747
+ type: "string",
41748
+ describe: "The release's tag; names it and links its GitHub release"
41749
+ }).option("channel", {
41750
+ type: "string",
41751
+ default: "releases",
41752
+ describe: "The channel to post in"
41753
+ }).option("provider", {
41754
+ type: "string",
41755
+ describe: "The `notifications` provider to post through, when several are configured"
41756
+ }).option("yes", {
41757
+ type: "boolean",
41758
+ describe: "Post without asking (a workflow needs it)"
41759
+ }),
41760
+ handler: async (argv) => {
41761
+ const tokens = tokenContext(argv.token);
41762
+ if (!tokens) return;
41763
+ const loaded = await loadConfig(argv.cwd);
41764
+ applyResolvedConfig(argv, loaded.resolved);
41765
+ if ((await runSyncReleases({
41766
+ loaded,
41767
+ context: {
41768
+ repoRoot: argv.cwd,
41769
+ dryRun: argv.dryRun,
41770
+ ...tokens,
41771
+ org: resolveOrg(argv, loaded.resolved)
41772
+ },
41773
+ to: argv.to || "HEAD",
41774
+ ...argv.from ? { from: argv.from } : {},
41775
+ ...argv.tag ? { tag: argv.tag } : {},
41776
+ ...argv.channel ? { channel: argv.channel } : {},
41777
+ ...argv.provider ? { provider: argv.provider } : {},
41778
+ ...argv.yes ? { yes: true } : {}
41779
+ })).status === "fail") process.exitCode = 1;
41780
+ }
41781
+ };
40973
41782
  // src/commands/sync-requests/run-sync-requests/run-sync-requests.ts
40974
41783
  /**
40975
41784
  * `holocron sync requests` — keeps each `tooling` provider's own workspace and the repo's request files in step, both ways.
@@ -42239,7 +43048,7 @@ async function syncApp(argv) {
42239
43048
  const syncCommand = {
42240
43049
  command: "sync [steps..]",
42241
43050
  describe: "Sync state from config to the provider and local files (labels, properties, teams, topics, keywords, description, homepage, readme, workflows, scripts, wiki)",
42242
- builder: (y) => syncArgs(y).command(syncGithubCommand).command(syncIssuesCommand).command(syncIncidentsCommand).command(syncReadmeCommand).command(ideasSyncCommand).command(syncToolingCommand).command(syncRequestsCommand).command(specsSyncCommand).command(secretsSyncCommand).command(notificationsSyncRolesCommand),
43051
+ builder: (y) => syncArgs(y).command(syncGithubCommand).command(syncIssuesCommand).command(syncIncidentsCommand).command(syncReleasesCommand).command(syncReadmeCommand).command(ideasSyncCommand).command(syncToolingCommand).command(syncRequestsCommand).command(specsSyncCommand).command(secretsSyncCommand).command(notificationsSyncRolesCommand),
42243
43052
  handler: async (argv) => {
42244
43053
  if (argv.env !== void 0 || argv.steps?.[0] !== void 0) {
42245
43054
  if (await syncApp(argv)) return;