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

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
@@ -144,6 +144,7 @@ const COMMAND_CONTEXTS = {
144
144
  "sync github": "workspace",
145
145
  "sync issues": "workspace",
146
146
  "sync incidents": "workspace",
147
+ "sync releases": "workspace",
147
148
  "sync ideas": "workspace",
148
149
  "sync tooling": "workspace",
149
150
  "sync requests": "workspace",
@@ -2202,6 +2203,30 @@ const syncReadmeEntry = {
2202
2203
  skipOptions: ["dry-run"],
2203
2204
  supportsDryRun: true
2204
2205
  };
2206
+ // src/commands/sync-releases/sync-releases.entry.ts
2207
+ const syncReleasesEntry = {
2208
+ name: "sync releases",
2209
+ description: "Announce a release in the releases channel, with a thread listing each package",
2210
+ positionals: [],
2211
+ options: [{
2212
+ key: "from",
2213
+ flag: "--from",
2214
+ type: "input",
2215
+ message: "The commit the release started from:"
2216
+ }, {
2217
+ key: "tag",
2218
+ flag: "--tag",
2219
+ type: "input",
2220
+ message: "The release's tag (v5.0.0-alpha.1):"
2221
+ }],
2222
+ skipOptions: [
2223
+ "to",
2224
+ "channel",
2225
+ "provider",
2226
+ "yes"
2227
+ ],
2228
+ supportsDryRun: true
2229
+ };
2205
2230
  // src/commands/sync-requests/sync-requests.entry.ts
2206
2231
  const syncRequestsEntry = {
2207
2232
  name: "sync requests",
@@ -2433,6 +2458,7 @@ const registry = createCommandRegistry([
2433
2458
  syncGithubEntry,
2434
2459
  syncIssuesEntry,
2435
2460
  syncIncidentsEntry,
2461
+ syncReleasesEntry,
2436
2462
  ideasSyncEntry,
2437
2463
  syncToolingEntry,
2438
2464
  syncRequestsEntry,
@@ -13361,7 +13387,7 @@ async function readShadowSamples(source, limit = 40) {
13361
13387
  }
13362
13388
  // src/commands/doctor-ci/shadow-row.ts
13363
13389
  const ID$7 = "shadow";
13364
- const TITLE$7 = "Sentinel's ci shadow agrees with the Actions aggregate";
13390
+ const TITLE$8 = "Sentinel's ci shadow agrees with the Actions aggregate";
13365
13391
  /**
13366
13392
  * The `shadow` row (SPEC-0099, phase 4): do `ci / Required checks (sentinel)` and `ci / Required checks` say the same on
13367
13393
  * the same commit? `samples` are the newest pull requests first. A pull request is **decided** when both posted and
@@ -13376,7 +13402,7 @@ function shadowRow$1(samples, target = 20) {
13376
13402
  const decided = samples.filter((sample) => sample.actions !== void 0 && sample.sentinel !== void 0 && sample.actions !== "pending" && sample.sentinel !== "pending");
13377
13403
  if (decided.length === 0) return {
13378
13404
  id: ID$7,
13379
- title: TITLE$7,
13405
+ title: TITLE$8,
13380
13406
  status: "skip",
13381
13407
  detail: "no pull request has a finished verdict from both the Actions aggregate and the shadow yet",
13382
13408
  problems: []
@@ -13384,7 +13410,7 @@ function shadowRow$1(samples, target = 20) {
13384
13410
  const disagreements = decided.filter((sample) => sample.actions !== sample.sentinel);
13385
13411
  if (disagreements.length > 0) return {
13386
13412
  id: ID$7,
13387
- title: TITLE$7,
13413
+ title: TITLE$8,
13388
13414
  status: "fail",
13389
13415
  detail: `${disagreements.length} of ${decided.length} decided pull requests disagree`,
13390
13416
  problems: disagreements.map((s) => `#${s.number}: Actions said ${s.actions}, the shadow said ${s.sentinel}`)
@@ -13392,13 +13418,13 @@ function shadowRow$1(samples, target = 20) {
13392
13418
  const consecutive = decided.length;
13393
13419
  return consecutive >= target ? {
13394
13420
  id: ID$7,
13395
- title: TITLE$7,
13421
+ title: TITLE$8,
13396
13422
  status: "ok",
13397
13423
  detail: `${consecutive} consecutive pull requests agree (target ${target})`,
13398
13424
  problems: []
13399
13425
  } : {
13400
13426
  id: ID$7,
13401
- title: TITLE$7,
13427
+ title: TITLE$8,
13402
13428
  status: "skip",
13403
13429
  detail: `${consecutive} of ${target} consecutive pull requests agree so far`,
13404
13430
  problems: []
@@ -14105,7 +14131,7 @@ function environmentProblems(declared, have) {
14105
14131
  * nothing named, nothing is declared; with no provider but some named, the row is a skip with the reason.
14106
14132
  */
14107
14133
  const ID$6 = "environments";
14108
- const TITLE$6 = "environments exist";
14134
+ const TITLE$7 = "environments exist";
14109
14135
  const UNDECLARED_ID = "environments-undeclared";
14110
14136
  const UNDECLARED_TITLE = "environments nothing declares";
14111
14137
  async function runDoctorEnvironments(input) {
@@ -14133,7 +14159,7 @@ async function runDoctorEnvironments(input) {
14133
14159
  async function checkEnvironments(loader, named, declared, manual) {
14134
14160
  const make = (status, detail, problems = []) => ({
14135
14161
  id: ID$6,
14136
- title: TITLE$6,
14162
+ title: TITLE$7,
14137
14163
  status,
14138
14164
  detail,
14139
14165
  problems
@@ -14510,7 +14536,7 @@ async function readWorkspaceMonitoring(context) {
14510
14536
  }
14511
14537
  // src/commands/doctor-monitoring/dashboard-rows/dashboard-rows.ts
14512
14538
  const ID$5 = "monitoring-dashboards";
14513
- const TITLE$5 = "monitoring dashboards match";
14539
+ const TITLE$6 = "monitoring dashboards match";
14514
14540
  /** The tags as comparable text: sorted and de-duplicated. */
14515
14541
  const tagsText = (tags) => [...new Set(tags)].sort().join(", ") || "none";
14516
14542
  /** What differs between a declared dashboard and the one the account holds. Privacy is always compared (default private). */
@@ -14542,7 +14568,7 @@ async function dashboardRows(monitoring) {
14542
14568
  detail,
14543
14569
  problems: []
14544
14570
  });
14545
- if (!monitoring.inspectDashboard) return [skip(ID$5, TITLE$5, "provider does not implement inspectDashboard")];
14571
+ if (!monitoring.inspectDashboard) return [skip(ID$5, TITLE$6, "provider does not implement inspectDashboard")];
14546
14572
  try {
14547
14573
  const names = new Set(declared.map((d) => d.name));
14548
14574
  const problems = [];
@@ -14554,13 +14580,13 @@ async function dashboardRows(monitoring) {
14554
14580
  }
14555
14581
  const rows = [problems.length > 0 ? {
14556
14582
  id: ID$5,
14557
- title: TITLE$5,
14583
+ title: TITLE$6,
14558
14584
  status: "fail",
14559
14585
  detail: `${problems.length} problem(s)`,
14560
14586
  problems
14561
14587
  } : {
14562
14588
  id: ID$5,
14563
- title: TITLE$5,
14589
+ title: TITLE$6,
14564
14590
  status: "ok",
14565
14591
  detail: `${declared.length} of ${declared.length} match`,
14566
14592
  problems: []
@@ -14569,10 +14595,10 @@ async function dashboardRows(monitoring) {
14569
14595
  return rows;
14570
14596
  } catch (err) {
14571
14597
  const noToken = missingTokenReason(err);
14572
- if (noToken !== void 0) return [skip(ID$5, TITLE$5, noToken)];
14598
+ if (noToken !== void 0) return [skip(ID$5, TITLE$6, noToken)];
14573
14599
  return [{
14574
14600
  id: ID$5,
14575
- title: TITLE$5,
14601
+ title: TITLE$6,
14576
14602
  status: "fail",
14577
14603
  detail: errorMessage(err),
14578
14604
  problems: []
@@ -14586,7 +14612,7 @@ async function dashboardRows(monitoring) {
14586
14612
  * config is an `info` row (shown as skipped). Names only: the ping URL is never read here.
14587
14613
  */
14588
14614
  const ID$4 = "monitoring-heartbeats";
14589
- const TITLE$4 = "monitoring heartbeats match";
14615
+ const TITLE$5 = "monitoring heartbeats match";
14590
14616
  const show = (b) => new Map([
14591
14617
  ["period", `${b.period} ${b.periodUnit}`],
14592
14618
  ["grace", `${b.grace} ${b.graceUnit}`],
@@ -14598,7 +14624,7 @@ async function heartbeatRows(monitoring) {
14598
14624
  if (declared.length === 0) return [];
14599
14625
  const skip = (detail) => ({
14600
14626
  id: ID$4,
14601
- title: TITLE$4,
14627
+ title: TITLE$5,
14602
14628
  status: "skip",
14603
14629
  detail,
14604
14630
  problems: []
@@ -14623,13 +14649,13 @@ async function heartbeatRows(monitoring) {
14623
14649
  }
14624
14650
  const rows = [problems.length > 0 ? {
14625
14651
  id: ID$4,
14626
- title: TITLE$4,
14652
+ title: TITLE$5,
14627
14653
  status: "fail",
14628
14654
  detail: `${problems.length} problem(s)`,
14629
14655
  problems
14630
14656
  } : {
14631
14657
  id: ID$4,
14632
- title: TITLE$4,
14658
+ title: TITLE$5,
14633
14659
  status: "ok",
14634
14660
  detail: `${declared.length} of ${declared.length} match`,
14635
14661
  problems: []
@@ -14649,7 +14675,7 @@ async function heartbeatRows(monitoring) {
14649
14675
  if (noToken !== void 0) return [skip(noToken)];
14650
14676
  return [{
14651
14677
  id: ID$4,
14652
- title: TITLE$4,
14678
+ title: TITLE$5,
14653
14679
  status: "fail",
14654
14680
  detail: errorMessage(err),
14655
14681
  problems: []
@@ -14754,7 +14780,7 @@ async function statusPageRows(monitoring) {
14754
14780
  }
14755
14781
  // src/commands/doctor-monitoring/undeclared-check-rows/undeclared-check-rows.ts
14756
14782
  const ID$3 = "monitoring-undeclared";
14757
- const TITLE$3 = "checks no config declares";
14783
+ const TITLE$4 = "checks no config declares";
14758
14784
  function undeclaredCheckRows({ monitoring, workspace, have }) {
14759
14785
  if (have === void 0) return [];
14760
14786
  const tags = new Set([
@@ -14765,7 +14791,7 @@ function undeclaredCheckRows({ monitoring, workspace, have }) {
14765
14791
  if (tags.size === 0) return [];
14766
14792
  const row = (status, detail) => [{
14767
14793
  id: ID$3,
14768
- title: TITLE$3,
14794
+ title: TITLE$4,
14769
14795
  status,
14770
14796
  detail,
14771
14797
  problems: []
@@ -14803,7 +14829,7 @@ function undeclaredCheckRows({ monitoring, workspace, have }) {
14803
14829
  * `doctor notifications`) and any check that a message really arrives.
14804
14830
  */
14805
14831
  const ID$2 = "monitoring-checks";
14806
- const TITLE$2 = "monitoring checks match";
14832
+ const TITLE$3 = "monitoring checks match";
14807
14833
  async function runDoctorMonitoring(input) {
14808
14834
  const print = input.print ?? ((line) => console.log(line));
14809
14835
  const logger = input.logger ?? getLogger();
@@ -14843,14 +14869,14 @@ async function runDoctorMonitoring(input) {
14843
14869
  async function checkRow(loader) {
14844
14870
  const skip = (detail) => ({ row: {
14845
14871
  id: ID$2,
14846
- title: TITLE$2,
14872
+ title: TITLE$3,
14847
14873
  status: "skip",
14848
14874
  detail,
14849
14875
  problems: []
14850
14876
  } });
14851
14877
  const none = () => ({ row: {
14852
14878
  id: ID$2,
14853
- title: TITLE$2,
14879
+ title: TITLE$3,
14854
14880
  status: "ok",
14855
14881
  detail: "none declared",
14856
14882
  problems: []
@@ -14868,7 +14894,7 @@ async function checkRow(loader) {
14868
14894
  if (problems.length > 0) return {
14869
14895
  row: {
14870
14896
  id: ID$2,
14871
- title: TITLE$2,
14897
+ title: TITLE$3,
14872
14898
  status: "fail",
14873
14899
  detail: `${problems.length} problem(s)`,
14874
14900
  problems
@@ -14879,7 +14905,7 @@ async function checkRow(loader) {
14879
14905
  return {
14880
14906
  row: {
14881
14907
  id: ID$2,
14882
- title: TITLE$2,
14908
+ title: TITLE$3,
14883
14909
  status: "ok",
14884
14910
  detail: `${n} of ${n} match`,
14885
14911
  problems: []
@@ -14891,7 +14917,7 @@ async function checkRow(loader) {
14891
14917
  if (noToken !== void 0) return skip(noToken);
14892
14918
  return { row: {
14893
14919
  id: ID$2,
14894
- title: TITLE$2,
14920
+ title: TITLE$3,
14895
14921
  status: "fail",
14896
14922
  detail: errorMessage(err),
14897
14923
  problems: []
@@ -15026,7 +15052,7 @@ function resultRow(id, title, problems, ok) {
15026
15052
  };
15027
15053
  }
15028
15054
  // src/commands/bot-permission-checks/bot-permission-checks.ts
15029
- const TITLE$1 = "bot holds the server-wide permissions it needs";
15055
+ const TITLE$2 = "bot holds the server-wide permissions it needs";
15030
15056
  /**
15031
15057
  * The step of `doctor notifications` for the bot's own role: the permissions the provider says it needs (read from
15032
15058
  * `inspect`, server-wide, before any channel overwrite) are all held. A failure names the missing ones and carries the
@@ -15035,13 +15061,13 @@ const TITLE$1 = "bot holds the server-wide permissions it needs";
15035
15061
  */
15036
15062
  function botPermissionChecks(input) {
15037
15063
  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)})`)];
15064
+ if (!found) return [skipRow$1("bot-permissions", TITLE$2, "not checked: could not read the server")];
15065
+ if (found.botPermissionsError) return [skipRow$1("bot-permissions", TITLE$2, `not checked: could not read the bot's roles (${sanitizeDetail(found.botPermissionsError)})`)];
15040
15066
  const { botPermissions } = found;
15041
15067
  if (!botPermissions) return [];
15042
15068
  const { missing, inviteUrl } = botPermissions;
15043
15069
  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")];
15070
+ return [resultRow("bot-permissions", TITLE$2, problems, "every permission it needs")];
15045
15071
  }
15046
15072
  // src/commands/notifications-reaction/layout-reactions/layout-reactions.ts
15047
15073
  /**
@@ -15196,7 +15222,7 @@ function tagEmojiProblem(tagName, emoji, pictured) {
15196
15222
  return `${noun} \`${emoji}\` has no picture: give the emoji an \`image\` in \`emojis\` or a reaction so \`setup\` can make it`;
15197
15223
  }
15198
15224
  // src/commands/emoji-checks/emoji-checks.ts
15199
- const TITLE = "server emoji the forums' reactions and tags name exist";
15225
+ const TITLE$1 = "server emoji the forums' reactions and tags name exist";
15200
15226
  /**
15201
15227
  * The step of `doctor notifications` for server emoji: each one a forum's `defaultReaction`, `starterReactions` or tag `emoji` names
15202
15228
  * (`: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 +15234,17 @@ function emojiChecks(input) {
15208
15234
  const wanted = layoutEmojis(input.layout);
15209
15235
  if (wanted.length === 0) return [];
15210
15236
  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)})`)];
15237
+ if (!found) return [skipRow$1("emoji", TITLE$1, "not checked: could not read the server")];
15238
+ if (found.emojisError) return [skipRow$1("emoji", TITLE$1, `not checked: could not read the server's emoji (${sanitizeDetail(found.emojisError)})`)];
15213
15239
  const have = new Set(found.emojis ?? []);
15214
15240
  const problems = wanted.filter((emoji) => !have.has(emoji.name)).map((emoji) => {
15215
15241
  const name = sanitizeDetail(emoji.name);
15216
15242
  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
15243
  });
15218
- return [resultRow("emoji", TITLE, problems, `${wanted.length} of ${wanted.length} on the server`)];
15244
+ return [resultRow("emoji", TITLE$1, problems, `${wanted.length} of ${wanted.length} on the server`)];
15219
15245
  }
15220
15246
  // src/commands/forum-feed-checks/forum-feed-checks.ts
15221
- const same$5 = (a, b) => a.toLowerCase() === b.toLowerCase();
15247
+ const same$6 = (a, b) => a.toLowerCase() === b.toLowerCase();
15222
15248
  const shown$6 = (s) => sanitizeDetail(s);
15223
15249
  /**
15224
15250
  * The steps of `doctor notifications` for a forum feed (`feeds.prs`, `feeds.incidents`): the forum is there (in its
@@ -15249,7 +15275,7 @@ function forumFeedChecks(input, spec) {
15249
15275
  const botProblems = [];
15250
15276
  for (const { cat, channel } of fed) {
15251
15277
  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));
15278
+ const have = found.channels.find((c) => same$6(c.name, channel.name) && c.category !== void 0 && same$6(c.category, cat));
15253
15279
  if (!have) {
15254
15280
  forumProblems.push(`#${name}: missing from ${shown$6(cat)}`);
15255
15281
  continue;
@@ -15258,7 +15284,7 @@ function forumFeedChecks(input, spec) {
15258
15284
  forumProblems.push(`#${name}: is a text channel, not a forum; delete it so \`setup\` can make it again`);
15259
15285
  continue;
15260
15286
  }
15261
- for (const tag of spec.tags) if (!have.tags?.some((t) => same$5(t.name, tag))) tagProblems.push(`#${name}: tag "${tag}" is missing`);
15287
+ for (const tag of spec.tags) if (!have.tags?.some((t) => same$6(t.name, tag))) tagProblems.push(`#${name}: tag "${tag}" is missing`);
15262
15288
  if (have.botThreadsError) botProblems.push(`#${name}: could not read the bot's permissions (${shown$6(have.botThreadsError)})`);
15263
15289
  else if (have.botThreads) {
15264
15290
  if (!have.botThreads.post) botProblems.push(`#${name}: the bot cannot start posts or reply in it`);
@@ -16488,7 +16514,7 @@ const CHANNEL_ID = "monitoring-alert-channel";
16488
16514
  const CHANNEL_TITLE = "monitoring alert channel posts through the feed webhook";
16489
16515
  const SUBSCRIPTIONS_ID = "monitoring-subscriptions";
16490
16516
  const SUBSCRIPTIONS_TITLE = "monitoring alert channel is subscribed to the checks routed to it";
16491
- const same$4 = (a, b) => a.toLowerCase() === b.toLowerCase();
16517
+ const same$5 = (a, b) => a.toLowerCase() === b.toLowerCase();
16492
16518
  const shown$4 = (s) => sanitizeDetail(s);
16493
16519
  const skipAll = (reason) => [
16494
16520
  skipRow$1(WEBHOOK_ID$1, WEBHOOK_TITLE$1, reason),
@@ -16516,14 +16542,14 @@ async function monitoringFeedChecks(input) {
16516
16542
  let channelSkip;
16517
16543
  for (const { channel, feed } of fed) {
16518
16544
  const names = monitoringFeed(channel.name, feed, monitoring);
16519
- const where = found.channels.find((c) => same$4(c.name, channel.name));
16545
+ const where = found.channels.find((c) => same$5(c.name, channel.name));
16520
16546
  const hookId = where?.webhookIds?.[names.webhook.toLowerCase()];
16521
- const named = where?.webhooks.some((w) => same$4(w, names.webhook)) ?? false;
16547
+ const named = where?.webhooks.some((w) => same$5(w, names.webhook)) ?? false;
16522
16548
  const label = `#${shown$4(channel.name)}`;
16523
16549
  if (!where) webhookProblems.push(`${label}: no channel to hold the feed webhook`);
16524
16550
  else if (where.webhooksError) webhookProblems.push(`${label}: could not list its webhooks (${shown$4(where.webhooksError)})`);
16525
16551
  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`);
16552
+ 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
16553
  if (channelSkip !== void 0) continue;
16528
16554
  if (!monitoring.inspectAlertChannel) {
16529
16555
  channelSkip = `the \`${monitoring.providerName}\` provider cannot read its alert channels`;
@@ -17253,7 +17279,7 @@ const BINDINGS_ID = "relay-bindings";
17253
17279
  const BINDINGS_TITLE = "relay Worker has its webhook and signing secret bound";
17254
17280
  const WEBHOOK_ID = "relay-feed-webhook";
17255
17281
  const WEBHOOK_TITLE = "error feed webhook exists and has a picture";
17256
- const same$3 = (a, b) => a.toLowerCase() === b.toLowerCase();
17282
+ const same$4 = (a, b) => a.toLowerCase() === b.toLowerCase();
17257
17283
  const shown$2 = (s) => sanitizeDetail(s);
17258
17284
  /** One unsigned `POST` to the Worker, and what the answer says about it. Reads nothing from the response. */
17259
17285
  async function answers(url, doFetch) {
@@ -17304,7 +17330,7 @@ async function relayChecks(input) {
17304
17330
  else {
17305
17331
  const bound = new Set(state.bindingNames.map((n) => n.toUpperCase()));
17306
17332
  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`));
17333
+ 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
17334
  }
17309
17335
  } catch (err) {
17310
17336
  const reason = missingTokenReason(err);
@@ -17331,15 +17357,38 @@ function webhookRow$1(input, source) {
17331
17357
  }
17332
17358
  /** The one rule both feeds follow: the channel exists, lists the webhook and, when a picture is wanted, the picture is on it. */
17333
17359
  function webhookProblems(input, id, title, channelName, name, avatar) {
17334
- const where = input.found.channels.find((c) => same$3(c.name, channelName));
17360
+ const where = input.found.channels.find((c) => same$4(c.name, channelName));
17335
17361
  const label = `#${shown$2(channelName)}`;
17336
17362
  const problems = [];
17337
17363
  if (!where) problems.push(`${label}: no channel to hold the feed webhook`);
17338
17364
  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`);
17365
+ else if (!where.webhooks.some((w) => same$4(w, name))) problems.push(`${label}: no webhook named ${shown$2(name)}`);
17366
+ else if (avatar.length > 0 && !where.webhookAvatars?.some((w) => same$4(w, name))) problems.push(`${label}: webhook ${shown$2(name)} has no picture`);
17341
17367
  return resultRow(id, title, problems, `${label}: ${shown$2(name)}`);
17342
17368
  }
17369
+ // src/commands/release-thread-checks/release-thread-checks.ts
17370
+ const same$3 = (a, b) => a.toLowerCase() === b.toLowerCase();
17371
+ const TITLE = "bot can create release threads in #releases";
17372
+ /**
17373
+ * The step of `doctor notifications` for release announcements (`sync releases`, SPEC-0119): when the layout has a
17374
+ * `releases` channel, the bot can create public threads there and send in them, read from `inspect` after the
17375
+ * channel's own overwrites (`botThreads.post`). Read-only. No row when the layout has no `releases` channel.
17376
+ */
17377
+ function releaseThreadChecks(input) {
17378
+ const { layout, found } = input;
17379
+ if (!(layout.categories ?? []).flatMap((cat) => (cat.channels ?? []).map((channel) => ({
17380
+ cat: cat.name,
17381
+ channel
17382
+ }))).find(({ channel }) => same$3(channel.name, "releases"))) return [];
17383
+ if (!found) return [skipRow$1("release-threads", TITLE, "not checked: could not read the server")];
17384
+ const have = found.channels.find((c) => same$3(c.name, "releases"));
17385
+ const problems = [];
17386
+ if (!have) problems.push("#releases: missing from the server");
17387
+ else if (have.botThreadsError) problems.push(`#releases: could not read the bot's permissions (${sanitizeDetail(have.botThreadsError)})`);
17388
+ else if (!have.botThreads) problems.push("#releases: the provider did not report the bot's permissions");
17389
+ else if (!have.botThreads.post) problems.push("#releases: the bot cannot create public threads there (needs Create Public Threads and Send Messages in Threads)");
17390
+ return [resultRow("release-threads", TITLE, problems, "the bot can create threads in #releases")];
17391
+ }
17343
17392
  // src/commands/sentry-relay-checks/sentry-relay-checks.ts
17344
17393
  const INTEGRATION_ID = "relay-integration";
17345
17394
  const INTEGRATION_TITLE = "error tracker integration posts to the relay";
@@ -17910,6 +17959,10 @@ async function runDoctorNotifications(input) {
17910
17959
  layout,
17911
17960
  found
17912
17961
  }));
17962
+ checks.push(...releaseThreadChecks({
17963
+ layout,
17964
+ found
17965
+ }));
17913
17966
  checks.push(...await notificationsWorkflowChecks({
17914
17967
  layout,
17915
17968
  source: loader.has("source") ? loader.get("source") : void 0,
@@ -36492,7 +36545,7 @@ function resolveOtp(argvOtp, env) {
36492
36545
  }
36493
36546
  // src/commands/publish/default-exec.ts
36494
36547
  const defaultExec = async (cmd, args, opts) => {
36495
- const { HOLOCRON_OTP: _omittedOtp, ...env } = process.env;
36548
+ const { HOLOCRON_OTP: _omittedOtp, ...inherited } = process.env;
36496
36549
  const result = spawnSync(cmd, args, {
36497
36550
  cwd: opts.cwd,
36498
36551
  encoding: "utf8",
@@ -36501,7 +36554,10 @@ const defaultExec = async (cmd, args, opts) => {
36501
36554
  "pipe",
36502
36555
  "pipe"
36503
36556
  ],
36504
- env
36557
+ env: {
36558
+ ...inherited,
36559
+ ...opts.env
36560
+ }
36505
36561
  });
36506
36562
  return {
36507
36563
  exitCode: result.status ?? -1,
@@ -36537,6 +36593,8 @@ function discoverPublicPackageEntries(cwd, scope = {}) {
36537
36593
  }] : []);
36538
36594
  }
36539
36595
  // src/commands/publish/filter-new-packages.ts
36596
+ /** The version npm gives a staged new package's public placeholder until the stage is approved. */
36597
+ const STAGE_PLACEHOLDER_VERSION = "0.0.0-stage";
36540
36598
  /**
36541
36599
  * Keeps only the entries that don't exist on npm yet — the actual
36542
36600
  * chicken-and-egg case `--initial` exists for (ADR: npm requires a package
@@ -36570,7 +36628,7 @@ async function filterNewPackages(entries, cwd, exec, print, nameWidth, dirWidth)
36570
36628
  "version"
36571
36629
  ], { cwd });
36572
36630
  const publishedVersion = view.exitCode === 0 ? view.stdout.trim() : "";
36573
- if (publishedVersion) {
36631
+ if (publishedVersion && publishedVersion !== STAGE_PLACEHOLDER_VERSION) {
36574
36632
  print(statusRow$1("skip", [
36575
36633
  pad$1(entry.name, nameWidth),
36576
36634
  pad$1(entry.dir, dirWidth),
@@ -36582,8 +36640,35 @@ async function filterNewPackages(entries, cwd, exec, print, nameWidth, dirWidth)
36582
36640
  }
36583
36641
  return results;
36584
36642
  }
36643
+ // src/commands/publish/node-version-supports-stage.ts
36644
+ /** The first Node that npm's `npm stage` supports. */
36645
+ const MIN_STAGE_NODE_VERSION = "22.14.0";
36646
+ /** True when the `node --version` output (`v22.14.0`) names 22.14.0 or later. */
36647
+ function nodeVersionSupportsStage(output) {
36648
+ const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(output.trim());
36649
+ if (!match) return false;
36650
+ const [major, minor] = [Number(match[1]), Number(match[2])];
36651
+ return major > 22 || major === 22 && minor >= 14;
36652
+ }
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
+ // src/commands/publish/print-approve-lines.ts
36664
+ /** One `npm stage approve <id>` line per staged package, and where to find the same stages on npmjs.com. */
36665
+ function printApproveLines(print, staged) {
36666
+ for (const s of staged) print(` npm stage approve ${s.id}`);
36667
+ print(" or on npmjs.com, the Staged Packages tab of each package (under its settings):");
36668
+ for (const s of staged) print(` https://www.npmjs.com/package/${s.name}/access`);
36669
+ }
36585
36670
  // src/commands/publish/print-next-steps.ts
36586
- function printNextSteps(print, env, packageNames, identity, workflowFile) {
36671
+ function printNextSteps(print, env, packageNames, identity, workflowFile, npmTokenUsed = false) {
36587
36672
  print("");
36588
36673
  print("→ next: configure Trusted Publisher for each package on npm:");
36589
36674
  print(" Publisher: GitHub Actions");
@@ -36596,9 +36681,10 @@ function printNextSteps(print, env, packageNames, identity, workflowFile) {
36596
36681
  print("");
36597
36682
  print("→ packages to be published:");
36598
36683
  for (const name of packageNames) print(` https://www.npmjs.com/package/${name}/access`);
36599
- if (env.get("NPM_TOKEN")) {
36684
+ if (npmTokenUsed || env.get("NPM_TOKEN") || env.get("HOLOCRON_NPM_TOKEN")) {
36600
36685
  print("");
36601
- print("→ cleanup: $NPM_TOKEN was used. Revoke it now (no API for self-revoke; UI-only):");
36686
+ print("→ cleanup: the npm token was used. It is short-lived (a short expiry); revoke it now if it has not run out");
36687
+ print(" (no API for self-revoke; UI-only):");
36602
36688
  print(" https://www.npmjs.com/settings/~/tokens");
36603
36689
  }
36604
36690
  }
@@ -36614,6 +36700,11 @@ function redactOtp(args, otp) {
36614
36700
  if (!otp) return [...args];
36615
36701
  return args.map((arg) => arg === otp ? "***" : arg);
36616
36702
  }
36703
+ // src/commands/publish/redact-token.ts
36704
+ /** Replaces every occurrence of `token` in `text` with `***`, so an npm error never echoes the credential. */
36705
+ function redactToken(text, token) {
36706
+ return token ? text.split(token).join("***") : text;
36707
+ }
36617
36708
  // src/commands/publish/release-workflow-file.ts
36618
36709
  /** The release caller's filename: the current name first, then the one a repo still on the older callers has. */
36619
36710
  const CANDIDATES = ["ci.release.yml", "delivery.publish.yml"];
@@ -36652,6 +36743,134 @@ function scopeOf({ group, excludeGroups, onlyPackages }) {
36652
36743
  ...onlyPackages === void 0 ? {} : { onlyPackages }
36653
36744
  };
36654
36745
  }
36746
+ // src/commands/publish/parse-stage-id.ts
36747
+ /**
36748
+ * The stage id `npm stage publish` prints, as in `+ @scope/name@0.0.1 (staged with id <uuid>)`.
36749
+ * `undefined` when the output carries none.
36750
+ */
36751
+ function parseStageId(output) {
36752
+ 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
+ }
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
+ // src/commands/publish/stage-packages/stage-packages.ts
36787
+ /** The registry auth key npm reads from the environment, so the token never touches an `.npmrc`. */
36788
+ const NPM_AUTH_ENV_KEY = "npm_config_//registry.npmjs.org/:_authToken";
36789
+ /**
36790
+ * Stages each package with `npm stage publish`: nothing becomes public until a maintainer approves it with 2FA. The
36791
+ * package is packed with `pnpm pack` first (npm would not rewrite `workspace:` ranges), and the tarball is staged. The
36792
+ * token is in the child environment for the stage calls only, and every message is redacted of it.
36793
+ */
36794
+ async function stagePackages(input) {
36795
+ const { exec, cwd, token } = input;
36796
+ const env = { [NPM_AUTH_ENV_KEY]: token };
36797
+ const staged = [];
36798
+ const listed = await exec("npm", ["stage", "list"], {
36799
+ cwd,
36800
+ env
36801
+ });
36802
+ const pending = listed.exitCode === 0 ? parseStageList(listed.stdout) : [];
36803
+ const scratch = mkdtempSync(join(tmpdir(), "holocron-stage-"));
36804
+ try {
36805
+ for (const entry of input.entries) {
36806
+ const dir = resolve(cwd, entry.dir);
36807
+ const label = `${entry.name}@${entry.version}`;
36808
+ const already = pending.find((p) => p.name === entry.name && p.version === entry.version);
36809
+ if (already) {
36810
+ input.print(` · ${label} is already staged (${already.id}); not uploading it again`);
36811
+ staged.push({
36812
+ name: entry.name,
36813
+ version: entry.version,
36814
+ id: already.id,
36815
+ resumed: true
36816
+ });
36817
+ continue;
36818
+ }
36819
+ const pack = await exec("pnpm", [
36820
+ "pack",
36821
+ "--pack-destination",
36822
+ scratch
36823
+ ], { cwd: dir });
36824
+ const tarball = pack.stdout.split("\n").map((l) => l.trim()).filter((l) => l.endsWith(".tgz")).pop();
36825
+ if (pack.exitCode !== 0 || !tarball) {
36826
+ const message = `pack failed for ${label}: ${redactToken(pack.stderr.trim() || pack.stdout.trim() || "no output", token)}`;
36827
+ input.print(` ✗ ${message}`);
36828
+ return {
36829
+ ok: false,
36830
+ staged,
36831
+ message
36832
+ };
36833
+ }
36834
+ const result = await exec("npm", [
36835
+ "stage",
36836
+ "publish",
36837
+ resolve(dir, tarball),
36838
+ "--access",
36839
+ "public",
36840
+ "--tag",
36841
+ input.tag
36842
+ ], {
36843
+ cwd: dir,
36844
+ env
36845
+ });
36846
+ const id = parseStageId(`${result.stdout}\n${result.stderr}`);
36847
+ if (result.exitCode !== 0 || !id) {
36848
+ const detail = redactToken(result.stderr.trim() || result.stdout.trim() || "no output", token);
36849
+ const message = result.exitCode === 0 ? `stage did not report an id for ${label}: ${detail}` : `stage failed for ${label} (exit ${result.exitCode}): ${detail}`;
36850
+ input.print(` ✗ ${message}`);
36851
+ return {
36852
+ ok: false,
36853
+ staged,
36854
+ message
36855
+ };
36856
+ }
36857
+ staged.push({
36858
+ name: entry.name,
36859
+ version: entry.version,
36860
+ id
36861
+ });
36862
+ }
36863
+ return {
36864
+ ok: true,
36865
+ staged
36866
+ };
36867
+ } finally {
36868
+ rmSync(scratch, {
36869
+ recursive: true,
36870
+ force: true
36871
+ });
36872
+ }
36873
+ }
36655
36874
  // src/commands/publish/workspace-filter-args.ts
36656
36875
  /**
36657
36876
  * `-r --filter=./clients/* --filter=./observability` -- one filter per
@@ -36727,20 +36946,62 @@ async function runPublish(input = {}) {
36727
36946
  const env = createEnvLookup(input.env);
36728
36947
  const exec = input.exec ?? defaultExec;
36729
36948
  const login = input.login ?? defaultLogin;
36949
+ const npmToken = resolveValue$2(["NPM_TOKEN"], input.env, { prefix: PREFIX$1 });
36950
+ const tokenEnv = npmToken ? { [NPM_AUTH_ENV_KEY]: npmToken } : void 0;
36730
36951
  logger.info({
36731
36952
  tag,
36732
- dryRun: dryRun || void 0
36953
+ dryRun: dryRun || void 0,
36954
+ staged: npmToken ? true : void 0
36733
36955
  }, "publish --initial: start");
36956
+ const names = () => (input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input))).map((e) => e.name);
36734
36957
  print("");
36735
36958
  print(style.dim(" → verifying npm auth (`npm whoami`)…"));
36736
- let whoami = await exec("npm", ["whoami"], { cwd });
36959
+ if (npmToken) {
36960
+ const version = await exec("npm", ["--version"], { cwd });
36961
+ if (version.exitCode !== 0 || !npmVersionSupportsStage(version.stdout)) {
36962
+ const message = `staging needs npm ${MIN_STAGE_NPM_VERSION} or later (found ${version.stdout.trim() || "none"}). Update npm, then re-run.`;
36963
+ print(` ✗ ${message}`);
36964
+ logger.warn({ reason: "npm too old for stage" }, "publish --initial: done");
36965
+ return {
36966
+ status: "fail",
36967
+ message,
36968
+ packageNames: names()
36969
+ };
36970
+ }
36971
+ const node = await exec("node", ["--version"], { cwd });
36972
+ if (node.exitCode !== 0 || !nodeVersionSupportsStage(node.stdout)) {
36973
+ const message = `staging needs Node ${MIN_STAGE_NODE_VERSION} or later (found ${node.stdout.trim() || "none"}). Switch Node, then re-run.`;
36974
+ print(` ✗ ${message}`);
36975
+ logger.warn({ reason: "node too old for stage" }, "publish --initial: done");
36976
+ return {
36977
+ status: "fail",
36978
+ message,
36979
+ packageNames: names()
36980
+ };
36981
+ }
36982
+ }
36983
+ let whoami = await exec("npm", ["whoami"], {
36984
+ cwd,
36985
+ ...tokenEnv ? { env: tokenEnv } : {}
36986
+ });
36987
+ if (npmToken && whoami.exitCode !== 0) {
36988
+ const detail = redactToken(`${whoami.stderr} ${whoami.stdout}`, npmToken);
36989
+ 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"}`;
36990
+ print(` ✗ ${message}`);
36991
+ logger.warn({ reason: "npm whoami failed with token" }, "publish --initial: done");
36992
+ return {
36993
+ status: "fail",
36994
+ message,
36995
+ packageNames: names()
36996
+ };
36997
+ }
36737
36998
  if (whoami.exitCode !== 0) {
36738
36999
  print(" not authenticated — running `npm login --auth-type=web`…");
36739
37000
  logger.info({}, "publish --initial: npm login");
36740
37001
  if ((await login(cwd)).exitCode !== 0) {
36741
37002
  const message = "npm login failed. Run `npm login --auth-type=web` (or `npm login`) manually, then re-run.";
36742
37003
  print(` ✗ ${message}`);
36743
- const packageNames = (input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input))).map((e) => e.name);
37004
+ const packageNames = names();
36744
37005
  logger.warn({ reason: "npm login failed" }, "publish --initial: done");
36745
37006
  return {
36746
37007
  status: "fail",
@@ -36752,7 +37013,7 @@ async function runPublish(input = {}) {
36752
37013
  if (whoami.exitCode !== 0) {
36753
37014
  const message = "npm login completed but `npm whoami` still fails — check your npm account.";
36754
37015
  print(` ✗ ${message}`);
36755
- const packageNames = (input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input))).map((e) => e.name);
37016
+ const packageNames = names();
36756
37017
  logger.warn({ reason: "npm whoami still fails after login" }, "publish --initial: done");
36757
37018
  return {
36758
37019
  status: "fail",
@@ -36811,10 +37072,10 @@ async function runPublish(input = {}) {
36811
37072
  ];
36812
37073
  if (dryRun) {
36813
37074
  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(" ")}`));
37075
+ 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})`));
37076
+ 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
37077
  printSummary(print, dryRun, packageNames.length, 0, skippedCount);
36817
- printNextSteps(print, env, packageNames, identity, releaseWorkflowFile(cwd));
37078
+ printNextSteps(print, env, packageNames, identity, releaseWorkflowFile(cwd), Boolean(npmToken));
36818
37079
  logger.info({
36819
37080
  tag,
36820
37081
  status: "dry-run",
@@ -36826,6 +37087,53 @@ async function runPublish(input = {}) {
36826
37087
  packageNames
36827
37088
  };
36828
37089
  }
37090
+ if (npmToken) {
37091
+ print("");
37092
+ print(` → staging ${packageNames.length} new package${packageNames.length === 1 ? "" : "s"} (nothing is published)…`);
37093
+ const result = await stagePackages({
37094
+ entries: newEntries,
37095
+ cwd,
37096
+ tag,
37097
+ token: npmToken,
37098
+ exec,
37099
+ print
37100
+ });
37101
+ if (!result.ok) {
37102
+ if (result.staged.length > 0) {
37103
+ print("");
37104
+ print("→ these were staged before the failure and are still pending (a rerun reports them, it does not stage them twice):");
37105
+ printApproveLines(print, result.staged);
37106
+ }
37107
+ printSummary(print, dryRun, 0, packageNames.length - result.staged.length, skippedCount);
37108
+ logger.warn({
37109
+ tag,
37110
+ reason: "stage failed"
37111
+ }, "publish --initial: done");
37112
+ return {
37113
+ status: "fail",
37114
+ message: result.message,
37115
+ packageNames,
37116
+ staged: result.staged
37117
+ };
37118
+ }
37119
+ for (const s of result.staged) print(statusRow$1("ok", [pad$1(s.name, nameWidth), `staged (v${s.version})`]));
37120
+ print("");
37121
+ print(style.dim(` ${result.staged.length} staged, 0 failed, ${skippedCount} skipped (nothing is public yet)`));
37122
+ print("");
37123
+ print("→ approve each staged package (asks for 2FA; add `--otp <code>` to give the code on the command line):");
37124
+ printApproveLines(print, result.staged);
37125
+ printNextSteps(print, env, packageNames, identity, releaseWorkflowFile(cwd), true);
37126
+ logger.info({
37127
+ tag,
37128
+ status: "ok",
37129
+ staged: result.staged.length
37130
+ }, "publish --initial: done");
37131
+ return {
37132
+ status: "ok",
37133
+ packageNames,
37134
+ staged: result.staged
37135
+ };
37136
+ }
36829
37137
  print("");
36830
37138
  print(` → publishing ${packageNames.length} new package${packageNames.length === 1 ? "" : "s"}…`);
36831
37139
  const publish = await exec("pnpm", publishArgs, { cwd });
@@ -40970,6 +41278,299 @@ const syncReadmeCommand = {
40970
41278
  }
40971
41279
  }
40972
41280
  };
41281
+ // src/commands/sync-releases/release-marker/release-marker.ts
41282
+ /**
41283
+ * The marker that ends a release's message: Discord's small-text line, so it is quiet to read, carrying the release id
41284
+ * between brackets. The closing bracket matters: a marker looked for as text must not match the next release's id
41285
+ * (`v5.0.0-alpha.1` is a prefix of `v5.0.0-alpha.10`).
41286
+ *
41287
+ * @param id - The release's id: its tag, or the two commits.
41288
+ */
41289
+ function releaseMarker(id) {
41290
+ return `-# release [${id}]`;
41291
+ }
41292
+ // src/commands/sync-releases/released-packages/released-packages.ts
41293
+ /** The file at `rev`, or `undefined` when the commit has no such file. */
41294
+ function showAt(cwd, rev, path) {
41295
+ try {
41296
+ return execFileSync("git", ["show", `${rev}:${path}`], {
41297
+ cwd,
41298
+ encoding: "utf8",
41299
+ stdio: [
41300
+ "ignore",
41301
+ "pipe",
41302
+ "ignore"
41303
+ ]
41304
+ });
41305
+ } catch {
41306
+ return;
41307
+ }
41308
+ }
41309
+ function versionAt(cwd, rev, dir) {
41310
+ const text = showAt(cwd, rev, dir === "." ? "package.json" : `${dir.replace(/^\.\//, "")}/package.json`);
41311
+ if (text === void 0) return {};
41312
+ try {
41313
+ const manifest = JSON.parse(text);
41314
+ return {
41315
+ version: manifest.version,
41316
+ private: manifest.private
41317
+ };
41318
+ } catch {
41319
+ return {};
41320
+ }
41321
+ }
41322
+ /** The dist-tag a version publishes under: its prerelease identifier (`5.0.0-alpha.3` is `alpha`), else `latest`. */
41323
+ function distTagOf(version) {
41324
+ const pre = version.split("-").slice(1).join("-");
41325
+ return pre ? pre.split(".")[0] : "latest";
41326
+ }
41327
+ /**
41328
+ * The public packages a release published: those whose `version` differs between `from` and `to`. Private packages
41329
+ * and apps (deployed, not versioned) are left out. The packages and their folders are the working tree's, read the
41330
+ * way `publish package` reads them, and each manifest is read from the two commits with git, so the working tree
41331
+ * needs no particular checkout. With no `from` (a first release) every public package counts.
41332
+ *
41333
+ * @param cwd - The repository root.
41334
+ * @param from - The commit the release started from; empty for none.
41335
+ * @param to - The release commit.
41336
+ * @throws When `to` (or a non-empty `from`) is not a commit of the repository.
41337
+ */
41338
+ function releasedPackages(cwd, from, to) {
41339
+ for (const rev of [from, to]) {
41340
+ if (!rev) continue;
41341
+ try {
41342
+ execFileSync("git", [
41343
+ "rev-parse",
41344
+ "--verify",
41345
+ "--quiet",
41346
+ `${rev}^{commit}`
41347
+ ], {
41348
+ cwd,
41349
+ stdio: [
41350
+ "ignore",
41351
+ "pipe",
41352
+ "ignore"
41353
+ ]
41354
+ });
41355
+ } catch {
41356
+ throw new Error(`\`${rev}\` is not a commit of this repository`);
41357
+ }
41358
+ }
41359
+ const released = [];
41360
+ for (const entry of discoverPublicPackageEntries(cwd)) {
41361
+ if (entry.dir.replace(/^\.\//, "").startsWith("apps/")) continue;
41362
+ const after = versionAt(cwd, to, entry.dir);
41363
+ if (!after.version || after.private) continue;
41364
+ if ((from ? versionAt(cwd, from, entry.dir).version : void 0) === after.version) continue;
41365
+ released.push({
41366
+ name: entry.name,
41367
+ version: after.version,
41368
+ distTag: distTagOf(after.version)
41369
+ });
41370
+ }
41371
+ return released.sort((a, b) => a.name.localeCompare(b.name));
41372
+ }
41373
+ // src/commands/sync-releases/render-release/render-release.ts
41374
+ /** Discord's limit on a thread's name. */
41375
+ const THREAD_NAME_LIMIT = 100;
41376
+ /**
41377
+ * The text of a release's announcement: a message with the headline, the link to the GitHub release (when a tag and
41378
+ * the repository are known) and the marker last, a thread name, and one line per package. Chunking the lines to the
41379
+ * provider's limit is the provider's job.
41380
+ */
41381
+ function renderRelease(input) {
41382
+ const { id, tag, repo, packages } = input;
41383
+ const count = packages.length;
41384
+ const tags = [...new Set(packages.map((p) => p.distTag))].join(", ");
41385
+ return {
41386
+ message: [
41387
+ `**${tag ?? id}** released: ${count} package${count === 1 ? "" : "s"} on ${tags}`,
41388
+ ...tag && repo ? [`https://github.com/${repo}/releases/tag/${tag}`] : [],
41389
+ releaseMarker(id)
41390
+ ].join("\n"),
41391
+ threadName: (tag ?? id).slice(0, THREAD_NAME_LIMIT),
41392
+ lines: packages.map((p) => `${p.name} ${p.version}`)
41393
+ };
41394
+ }
41395
+ // src/commands/sync-releases/run-sync-releases/run-sync-releases.ts
41396
+ /**
41397
+ * `holocron sync releases` -- announce a release in the `releases` channel (SPEC-0119 part 2, #2777).
41398
+ *
41399
+ * The public packages whose version differs between `--from` and `--to` are posted as one message, with a thread on it
41400
+ * holding one line per package. The message ends with a marker carrying the release id, so a rerun finds it, starts a
41401
+ * thread only when it has none, and posts only the lines the thread lacks: it never posts a second message. Nothing
41402
+ * published is a success that posts nothing. It writes, so it asks first; `--yes` skips the question and, without a
41403
+ * terminal, a run with neither `--yes` nor `--dry-run` refuses.
41404
+ */
41405
+ const DEFAULT_CHANNEL = "releases";
41406
+ const canThread = (p) => typeof p.sendWithId === "function" && typeof p.findMessage === "function" && typeof p.startThread === "function" && typeof p.postToThread === "function" && typeof p.readThread === "function";
41407
+ async function runSyncReleases(input) {
41408
+ const print = input.print ?? ((line) => console.log(line));
41409
+ const row = (status, ...parts) => print(statusRow$1(status, ["sync releases", ...parts]));
41410
+ const stop = (status, reason) => {
41411
+ row(status, reason);
41412
+ return {
41413
+ status,
41414
+ reason
41415
+ };
41416
+ };
41417
+ const channel = input.channel ?? DEFAULT_CHANNEL;
41418
+ const dryRun = Boolean(input.context.dryRun);
41419
+ let packages;
41420
+ try {
41421
+ packages = releasedPackages(input.context.repoRoot, input.from || void 0, input.to);
41422
+ } catch (err) {
41423
+ return stop("fail", errorMessage(err));
41424
+ }
41425
+ if (packages.length === 0) {
41426
+ row("ok", "no public package changed version, nothing to announce");
41427
+ return {
41428
+ status: "ok",
41429
+ packages
41430
+ };
41431
+ }
41432
+ const repo = input.context.repo ?? (input.context.org && input.loaded.resolved.name ? `${input.context.org}/${input.loaded.resolved.name}` : void 0);
41433
+ const id = input.tag || `${(input.from || "start").slice(0, 7)}..${input.to.slice(0, 7)}`;
41434
+ const rendered = renderRelease({
41435
+ id,
41436
+ ...input.tag ? { tag: input.tag } : {},
41437
+ ...repo ? { repo } : {},
41438
+ packages
41439
+ });
41440
+ const marker = releaseMarker(id);
41441
+ if (dryRun) {
41442
+ print(`Would post to #${channel}:`);
41443
+ for (const line of rendered.message.split("\n")) print(` ${line}`);
41444
+ print(`Would start the thread "${rendered.threadName}" with:`);
41445
+ for (const line of rendered.lines) print(` ${line}`);
41446
+ row("skip", `dry run, nothing posted; ${packages.length} package(s)`);
41447
+ return {
41448
+ status: "ok",
41449
+ packages
41450
+ };
41451
+ }
41452
+ /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
41453
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
41454
+ await loader.load();
41455
+ assertPluginsResolvable(loader, "sync releases");
41456
+ let notifications;
41457
+ try {
41458
+ notifications = pickProvider(notificationProviders(loader), input.provider, canThread, {
41459
+ infinitive: "start a thread on a message",
41460
+ gerund: "threading"
41461
+ });
41462
+ } catch (err) {
41463
+ return stop("fail", `the notifications provider cannot start a thread: ${errorMessage(err)}`);
41464
+ }
41465
+ const posted = {
41466
+ message: false,
41467
+ thread: false,
41468
+ lines: 0
41469
+ };
41470
+ try {
41471
+ let message = await notifications.findMessage(channel, marker);
41472
+ const existing = message?.threadId ? await notifications.readThread(message.threadId) : [];
41473
+ const have = new Set(existing.flatMap((text) => text.split("\n").map((l) => l.trim())));
41474
+ const missing = rendered.lines.filter((l) => !have.has(l));
41475
+ if (message?.threadId && missing.length === 0) {
41476
+ row("ok", id, "already announced, in step");
41477
+ return {
41478
+ status: "ok",
41479
+ packages,
41480
+ posted
41481
+ };
41482
+ }
41483
+ if (!input.yes) {
41484
+ 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`);
41485
+ if (!await (input.confirm ?? ((q) => confirm({
41486
+ message: q,
41487
+ default: false
41488
+ })))(`Announce ${id} (${packages.length} package(s)) in #${channel}?`)) {
41489
+ row("skip", "cancelled; nothing was changed");
41490
+ return {
41491
+ status: "cancelled",
41492
+ packages,
41493
+ posted
41494
+ };
41495
+ }
41496
+ }
41497
+ if (!message) {
41498
+ message = await notifications.sendWithId(channel, rendered.message);
41499
+ posted.message = true;
41500
+ row("ok", id, `posted to #${channel}`);
41501
+ }
41502
+ let threadId = message.threadId;
41503
+ if (!threadId) {
41504
+ threadId = (await notifications.startThread(message, rendered.threadName)).id;
41505
+ posted.thread = true;
41506
+ row("ok", id, `started the thread "${rendered.threadName}"`);
41507
+ }
41508
+ await notifications.postToThread(threadId, missing);
41509
+ posted.lines = missing.length;
41510
+ row("ok", id, `${missing.length} package line(s) posted`);
41511
+ return {
41512
+ status: "ok",
41513
+ packages,
41514
+ posted
41515
+ };
41516
+ } catch (err) {
41517
+ if (err instanceof NonInteractiveError) throw err;
41518
+ row("fail", id, describeError(err));
41519
+ return {
41520
+ status: "fail",
41521
+ packages,
41522
+ posted,
41523
+ reason: errorMessage(err)
41524
+ };
41525
+ }
41526
+ }
41527
+ // src/commands/sync-releases/sync-releases.command.ts
41528
+ const syncReleasesCommand = {
41529
+ command: "releases",
41530
+ describe: "Announce a release in the `releases` channel: one message, and a thread with a line per package that changed version",
41531
+ builder: (y) => y.option("from", {
41532
+ type: "string",
41533
+ describe: "The commit the release started from (the release job's `previous`); empty counts every package"
41534
+ }).option("to", {
41535
+ type: "string",
41536
+ default: "HEAD",
41537
+ describe: "The release commit"
41538
+ }).option("tag", {
41539
+ type: "string",
41540
+ describe: "The release's tag; names it and links its GitHub release"
41541
+ }).option("channel", {
41542
+ type: "string",
41543
+ default: "releases",
41544
+ describe: "The channel to post in"
41545
+ }).option("provider", {
41546
+ type: "string",
41547
+ describe: "The `notifications` provider to post through, when several are configured"
41548
+ }).option("yes", {
41549
+ type: "boolean",
41550
+ describe: "Post without asking (a workflow needs it)"
41551
+ }),
41552
+ handler: async (argv) => {
41553
+ const tokens = tokenContext(argv.token);
41554
+ if (!tokens) return;
41555
+ const loaded = await loadConfig(argv.cwd);
41556
+ applyResolvedConfig(argv, loaded.resolved);
41557
+ if ((await runSyncReleases({
41558
+ loaded,
41559
+ context: {
41560
+ repoRoot: argv.cwd,
41561
+ dryRun: argv.dryRun,
41562
+ ...tokens,
41563
+ org: resolveOrg(argv, loaded.resolved)
41564
+ },
41565
+ to: argv.to || "HEAD",
41566
+ ...argv.from ? { from: argv.from } : {},
41567
+ ...argv.tag ? { tag: argv.tag } : {},
41568
+ ...argv.channel ? { channel: argv.channel } : {},
41569
+ ...argv.provider ? { provider: argv.provider } : {},
41570
+ ...argv.yes ? { yes: true } : {}
41571
+ })).status === "fail") process.exitCode = 1;
41572
+ }
41573
+ };
40973
41574
  // src/commands/sync-requests/run-sync-requests/run-sync-requests.ts
40974
41575
  /**
40975
41576
  * `holocron sync requests` — keeps each `tooling` provider's own workspace and the repo's request files in step, both ways.
@@ -42239,7 +42840,7 @@ async function syncApp(argv) {
42239
42840
  const syncCommand = {
42240
42841
  command: "sync [steps..]",
42241
42842
  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),
42843
+ 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
42844
  handler: async (argv) => {
42244
42845
  if (argv.env !== void 0 || argv.steps?.[0] !== void 0) {
42245
42846
  if (await syncApp(argv)) return;