@theholocron/cli 5.0.0-alpha.497 → 5.0.0-alpha.499

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -699,7 +699,7 @@ Channels fed by the error tracker add `feeds: { errors: true }` and a layout `re
699
699
 
700
700
  `holocron list secrets [--scope repo|environment|organization] [--env <name>] [--json]` prints the names (never the values; GitHub does not return them) of the secrets at each scope, sorted, under a heading per scope. With no `--scope` it lists the repository, plus the organization (`--org`, `HOLOCRON_ORG` or the config's `org`) and the `--env` environment when they are known; `--scope` lists one. A scope that cannot be listed is reported under its heading and the rest are still listed; the exit code is 1 if any fails. `--json` prints `[{ scope, names, error? }]`. It is read-only, so `--dry-run` does not apply. Comparing the names with what the config expects is `doctor secrets`, which also covers the keys of the vault environments declared in `repo.secrets.sync`.
701
701
 
702
- A channel with `kind: "forum"` is a forum, with `tags` (each a `name`, an `emoji` and whether it is `moderated`); `setup` adds and corrects the tags but never removes one, and a text channel of the same name must be deleted first, since neither kind can become the other. A forum takes no `webhook` and none of the webhook feeds (`monitoring`, `errors`); its one feed is `feeds: { prs: true }`, the pull-request feed, where Sentinel keeps one post per pull request tagged with its state. The object form `feeds: { prs: { exclude: { repos?: ["owner/name"], authors?: ["login"] } } }` leaves some pull requests out. `feeds.prs` belongs to a forum (a text channel with it is refused) and the forum's `tags` must hold all eight states, `draft`, `conflicts`, `failing`, `changes requested`, `ready`, `waiting`, `merged` and `closed`, or `setup` refuses the layout. `setup` does nothing more for it; `doctor notifications` checks that the forum exists, has those tags and that the bot can start posts and manage threads in it (`ServerInspection` `botThreads`, filled in by the Discord provider after the forum's own permission overwrites). `defaultReaction` is the emoji Discord offers on every post (its Get Started step "Set a default reaction for posts"); Discord allows only one, so `starterReactions` lists more (`["👍", "👎", "❓"]` for approve, disapprove, question) that the bot adds to the first message of each post `sync specs` makes. Existing posts are left alone, a reaction the bot cannot add is skipped, and `doctor notifications` checks `defaultReaction`. A reaction is a Unicode emoji (`"✅"`) or one of the server's own emoji written between colons (`":git_merge:"`, 2 to 32 letters, digits and underscores); the object form `{ emoji: ":git_merge:", image: ".holocron/media/emoji/git_merge.png" }` also names the file `setup` makes the emoji from when the server has none (PNG, JPEG, GIF, WebP or AVIF, at most 256 KiB, under `.holocron/media/`; checked by its bytes before anything is written; an emoji that exists is never replaced or deleted; `--dry-run` only previews; the bot then needs Create Guild Expressions, which the invite link asks for only when the layout gives an emoji an `image`). The layout's own `emojis: [{ emoji: ":git_commit:", image }]` declares server emoji no reaction names; `setup` makes them with the others and `doctor notifications` expects them on the server. A word without colons (`git_merge`) is refused, not sent as text. `doctor notifications` has an `emoji` row that fails by name for each server emoji the server lacks, and its `channels` row compares the default reaction in the same spelling.
702
+ A channel with `kind: "forum"` is a forum, with `tags` (each a `name`, an `emoji` and whether it is `moderated`); `setup` adds and corrects the tags but never removes one, and a text channel of the same name must be deleted first, since neither kind can become the other. A forum takes no `webhook` and none of the webhook feeds (`monitoring`, `errors`); its one feed is `feeds: { prs: true }`, the pull-request feed, where Sentinel keeps one post per pull request tagged with its state. The object form `feeds: { prs: { exclude: { repos?: ["owner/name"], authors?: ["login"] } } }` leaves some pull requests out. `feeds.prs` belongs to a forum (a text channel with it is refused) and the forum's `tags` must hold all eight states, `draft`, `conflicts`, `failing`, `changes requested`, `ready`, `waiting`, `merged` and `closed`, or `setup` refuses the layout. `setup` does nothing more for it; `doctor notifications` checks that the forum exists, has those tags and that the bot can start posts and manage threads in it (`ServerInspection` `botThreads`, filled in by the Discord provider after the forum's own permission overwrites). `defaultReaction` is the emoji Discord offers on every post (its Get Started step "Set a default reaction for posts"); Discord allows only one, so `starterReactions` lists more (`["👍", "👎", "❓"]` for approve, disapprove, question) that the bot adds to the first message of each post `sync specs` makes. Existing posts are left alone, a reaction the bot cannot add is skipped, and `doctor notifications` checks `defaultReaction`. A reaction is a Unicode emoji (`"✅"`) or one of the server's own emoji written between colons (`":git_merge:"`, 2 to 32 letters, digits and underscores); the object form `{ emoji: ":git_merge:", image: ".holocron/media/emoji/git_merge.png" }` also names the file `setup` makes the emoji from when the server has none (PNG, JPEG, GIF, WebP or AVIF, at most 256 KiB, under `.holocron/media/`; checked by its bytes before anything is written; an emoji that exists is left alone unless its picture differs from the file (the Discord plugin compares it with the copy on Discord's CDN, and an emoji it cannot compare is left alone), when it is made again (new id; the old emoji and the reactions made with it are lost) after asking, or with `--yes`; `--dry-run` only previews; the bot then needs Create Guild Expressions, which the invite link asks for only when the layout gives an emoji an `image`). The layout's own `emojis: [{ emoji: ":git_commit:", image }]` declares server emoji no reaction names; `setup` makes them with the others and `doctor notifications` expects them on the server. A word without colons (`git_merge`) is refused, not sent as text. `doctor notifications` has an `emoji` row that fails by name for each server emoji the server lacks, and its `channels` row compares the default reaction in the same spelling.
703
703
 
704
704
  `holocron sync specs [--channel <forum>] [--files <paths...>] [--pr <number>] [--refresh] [--refresh-origin] [--refresh-titles] [--withdraw] [--notify]` keeps one forum post per ADR and spec in step with the files: it makes the post (titled with the document's own title, tagged with the file's status), writes its address into the file as `discussion.url`, and turns a gatekeeper's retag into an edit of the file's `status:` line in the working tree for a pull request. `--files` syncs only those files and `--pr` names a pull request on their posts, for a pull request that is still open. `--refresh-origin` is a one-off repair: it rewrites the `PR:` line of existing posts to the one the current rule names (the optional `prLine` of `DiscussionPatch`, and of `DiscussionPost`), and nothing else in them. `--refresh-titles` is the same kind of one-off repair for the title: it renames each existing post whose title differs from the current rule's (the optional `title` of `DiscussionPatch`, and of `DiscussionPost`) and changes nothing else; a rate limit stops it cleanly, reports how many documents are left, and the next run continues. The id that opens a post is a link to the file on the default branch (`repo.defaultBranch`, else `HEAD`) once the file is there, and plain text while `--pr` names an open pull request; the normal sync rewrites a post's id line (and only that line) whenever it is not the one the rule gives and no `--pr` is given, which covers a file that moved and a post made while its pull request was open, so it needs no extra request when every post is right and `--refresh` is no longer needed for it. `--refresh` runs the `PR:`, title and id-link repairs in one pass (the id link is the optional `idLine` of `DiscussionPatch`, and of `DiscussionPost`, which changes only the message's first line); `--refresh-origin` and `--refresh-titles` still do only their own. `--withdraw` (with `--files`, on the base branch) tags the posts of a pull request closed unmerged `withdrawn` and closes them; `withdrawn` is a tag only, never a file `status:`, and the next sync puts the file's own status back. It cannot be combined with `--refresh`, `--refresh-origin` or `--refresh-titles`. `--dry-run` previews it. The posts behind it are also usable for other keys, such as a pull request (`owner/repo#123`, the state a tag name): `DiscussionPatch.body` replaces the first message's text (the provider keeps its footer), and the optional `Notifications` methods `postDiscussionMessage(channel, key, content, { quiet })` (a closed post is unarchived, written to and closed again), `readDiscussionMessages(channel, key, limit)` (text, newest first, 50 by default) and `dedupeDiscussion(channel, key)` (keeps the oldest post of the key, deletes the rest, returns how many) append to, read and repair a post, and `duplicateDiscussions(channel)` lists the keys with more than one post without deleting: `holocron cleanup posts [channel] [--provider <name>] [--yes]` uses the two to clear duplicates that are already there (the forum with `feeds.prs` by default; `--dry-run` previews it). See the [`sync specs` page](https://docs.theholocron.dev/holocron/commands/sync-specs/).
705
705
 
package/dist/cli.mjs CHANGED
@@ -983,7 +983,11 @@ const notificationsSetupEntry = {
983
983
  name: "setup notifications",
984
984
  description: "Apply the server layout a notifications provider declares in holocron.config.ts",
985
985
  positionals: [],
986
- skipOptions: ["scope", "provider"],
986
+ skipOptions: [
987
+ "scope",
988
+ "provider",
989
+ "yes"
990
+ ],
987
991
  supportsDryRun: true
988
992
  };
989
993
  // src/commands/notifications-sync-roles/notifications-sync-roles.entry.ts
@@ -9488,6 +9492,33 @@ async function runNotificationsSetup(input$1) {
9488
9492
  } catch (err) {
9489
9493
  return refuse(describeError(err), logReason(err));
9490
9494
  }
9495
+ const emojiStates = /* @__PURE__ */ new Map();
9496
+ if (notifications.checkEmoji) for (const [name, image] of emojiImages) try {
9497
+ emojiStates.set(name, await notifications.checkEmoji({
9498
+ name,
9499
+ image
9500
+ }));
9501
+ } catch (err) {
9502
+ emojiStates.set(name, {
9503
+ state: "unknown",
9504
+ note: describeError(err)
9505
+ });
9506
+ }
9507
+ const changedEmoji = [...emojiStates].filter(([, check]) => check.state === "different").map(([name]) => name);
9508
+ if (changedEmoji.length > 0 && !dryRun && !input$1.yes) {
9509
+ const names = changedEmoji.map((name) => `:${name}:`).join(", ");
9510
+ if (!(input$1.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`the picture of ${names} differs from the layout's, so setup would make ${changedEmoji.length === 1 ? "it" : "them"} again and delete the old one; pass --yes to run it without asking, or --dry-run to preview`);
9511
+ if (!await (input$1.confirm ?? ((message) => confirm({
9512
+ message,
9513
+ default: false
9514
+ })))(`The picture of ${names} differs from the layout's. Replace ${changedEmoji.length === 1 ? "it" : "them"}? Each is made again from its image with a new id and the old one deleted, so reactions made with the old one disappear from existing posts.`)) {
9515
+ print(` ${style.skip("cancelled; nothing was written")}`);
9516
+ return {
9517
+ ...report,
9518
+ status: "cancelled"
9519
+ };
9520
+ }
9521
+ }
9491
9522
  let relayWebhook;
9492
9523
  const tally = {
9493
9524
  ok: 0,
@@ -9549,21 +9580,28 @@ async function runNotificationsSetup(input$1) {
9549
9580
  });
9550
9581
  if (emojiImages.size > 0) print(`\n${style.header("Emoji")}`);
9551
9582
  for (const [name, image] of emojiImages) await attempt(`emoji :${name}:`, async () => {
9583
+ const check = emojiStates.get(name);
9584
+ const replace = check?.state === "different";
9585
+ const note = check?.state === "unknown" ? ` (picture not compared: ${check.note ?? "unknown"})` : "";
9552
9586
  if (dryRun) {
9553
- print(` ${style.skip(`would ensure emoji :${name}: (made from its image only when the server has none)`)}`);
9587
+ print(` ${style.skip(replace ? `would replace emoji :${name}: (its picture differs; made again, a new id)` : `would ensure emoji :${name}: (made from its image only when the server has none)${note}`)}`);
9554
9588
  tally.skip++;
9555
9589
  return;
9556
9590
  }
9557
9591
  const result = await notifications.ensureEmoji({
9558
9592
  name,
9559
- image
9593
+ image,
9594
+ ...replace ? { replace: true } : {}
9560
9595
  });
9596
+ const replaced = !result.created && (result.updated?.length ?? 0) > 0;
9561
9597
  report.emojis = [...report.emojis ?? [], {
9562
9598
  name,
9563
- created: result.created
9599
+ created: result.created,
9600
+ ...replaced ? { replaced: true } : {}
9564
9601
  }];
9565
- print(` ${(result.created ? style.success : style.skip)(`${result.created ? "created" : "exists "} emoji :${name}: (id ${result.id})`)}`);
9566
- made(result.created);
9602
+ const verb = result.created ? "created" : replaced ? "replaced" : "exists ";
9603
+ print(` ${(result.created || replaced ? style.success : style.skip)(`${verb} emoji :${name}: (id ${result.id})${result.created || replaced ? "" : note}`)}`);
9604
+ made(result.created || replaced);
9567
9605
  });
9568
9606
  for (const category of layout.categories ?? []) {
9569
9607
  print(`\n${style.header(category.name)}`);
@@ -28451,6 +28489,9 @@ const notificationsSetupArgs = (y) => y.option("scope", {
28451
28489
  }).option("provider", {
28452
28490
  type: "string",
28453
28491
  describe: "Which notifications provider, when several can provision"
28492
+ }).option("yes", {
28493
+ type: "boolean",
28494
+ describe: "Replace server emoji whose picture changed without asking (required without a terminal when one is)"
28454
28495
  });
28455
28496
  // src/commands/notifications-setup/notifications-setup.command.ts
28456
28497
  const notificationsSetupCommand = {
@@ -28471,7 +28512,8 @@ const notificationsSetupCommand = {
28471
28512
  org: resolveOrg(argv, loaded.resolved)
28472
28513
  },
28473
28514
  ...argv.scope ? { scope: parseScope(argv.scope) } : {},
28474
- ...argv.provider ? { provider: argv.provider } : {}
28515
+ ...argv.provider ? { provider: argv.provider } : {},
28516
+ ...argv.yes ? { yes: true } : {}
28475
28517
  })).status === "fail") process.exitCode = 1;
28476
28518
  }
28477
28519
  };