Compare commits
No commits in common. "63e601992bb788d6aa50c38b13fd9ef012d25b05" and "bf50dd99a90c000643db71b71c08ff910f13dd2d" have entirely different histories.
63e601992b
...
bf50dd99a9
5 changed files with 19 additions and 54 deletions
|
|
@ -1,14 +1,5 @@
|
|||
# Changelog
|
||||
|
||||
# v0.8.9
|
||||
|
||||
### Improvements
|
||||
|
||||
- Release notes posted to Discord now use proper section headings, so Features, Improvements, and Fixes stand out at a glance instead of blending into the surrounding text.
|
||||
- Various bug fixes and improvements.
|
||||
|
||||
---
|
||||
|
||||
# v0.8.8
|
||||
|
||||
The minigames get anchored periods, close-time achievements, a public leaderboards hub and a game registry.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "polaris-task-force",
|
||||
"version": "0.8.9",
|
||||
"version": "0.8.8",
|
||||
"description": "Web app for the Arma 3 unit Polaris Task Force. Uses Next.js for client- and server-side rendering, with a Postgres database and some other neat libraries.",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ bot/
|
|||
|
||||
## Feature flow: changelogs
|
||||
|
||||
`/changelog` (guild-only, staff only) posts a `CHANGELOG.md` release entry to the releases channel (`DISCORD_CHANGELOG_CHANNEL_ID`, falling back to `DISCORD_ANNOUNCE_CHANNEL_ID`). `/changelog` targets the newest entry; `/changelog v0.4.0` targets a specific version (for catching up on missed posts); `/changelog v0.3.0..v0.5.0` targets a range (inclusive slice, output oldest-to-newest). Either range end is open (`v0.3.0..` to the latest, `..v0.5.0` from the oldest) and a reversed range is normalized. Rendering lives in `bot/lib/changelogRender.ts` (pure, no Discord/Payload deps): entries are split on `# vX.Y.Z` headers, `### ` sections become Discord markdown headings (`### `, the deepest level Discord renders), bullets become `•`, and entries over Discord's 4096-char limit are split across messages at section boundaries. The command reads `CHANGELOG.md` from the repo root relative to the file (works from the deploy server) and posts each version as its own amber embed, the first message of each version carrying the `Changelog vX.Y.Z` title and multi-message versions adding a page footer. Ranges spanning more than `WIDE_RANGE_THRESHOLD` (10) versions post an ephemeral warning but proceed. Idempotency ("don't repost") is intentionally out of scope for the manual command; the same rendering can be reused by a future automatic trigger.
|
||||
`/changelog` (guild-only, staff only) posts a `CHANGELOG.md` release entry to the releases channel (`DISCORD_CHANGELOG_CHANNEL_ID`, falling back to `DISCORD_ANNOUNCE_CHANNEL_ID`). `/changelog` targets the newest entry; `/changelog v0.4.0` targets a specific version (for catching up on missed posts); `/changelog v0.3.0..v0.5.0` targets a range (inclusive slice, output oldest-to-newest). Either range end is open (`v0.3.0..` to the latest, `..v0.5.0` from the oldest) and a reversed range is normalized. Rendering lives in `bot/lib/changelogRender.ts` (pure, no Discord/Payload deps): entries are split on `# vX.Y.Z` headers, `### ` sections become `**bold**`, bullets become `•`, and entries over Discord's 4096-char limit are split across messages at section boundaries. The command reads `CHANGELOG.md` from the repo root relative to the file (works from the deploy server) and posts each version as its own amber embed, the first message of each version carrying the `Changelog vX.Y.Z` title and multi-message versions adding a page footer. Ranges spanning more than `WIDE_RANGE_THRESHOLD` (10) versions post an ephemeral warning but proceed. Idempotency ("don't repost") is intentionally out of scope for the manual command; the same rendering can be reused by a future automatic trigger.
|
||||
|
||||
## Feature flow: attendance
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,11 @@
|
|||
* messages. No Discord or Payload dependencies, so the logic is trivially
|
||||
* testable in isolation.
|
||||
*
|
||||
* Discord renders `**bold**`, *italic*, `code`, [links](url) and :emoji:, plus
|
||||
* markdown headings and lists inside embed descriptions (its renderer stops at
|
||||
* `###`, and a heading needs a blank line before it, which the block join
|
||||
* supplies). Section headers therefore become real markdown headings and list
|
||||
* bullets become the "•" glyph. Entries longer than Discord's message limit are
|
||||
* split into multiple messages at section/bullet boundaries so a chunk never
|
||||
* lands mid-item.
|
||||
* Discord renders `**bold**`, *italic*, `code`, [links](url) and :emoji:, but
|
||||
* NOT markdown headings or list markers. Section headers therefore become bold
|
||||
* and list bullets become the "•" glyph. Entries longer than Discord's message
|
||||
* limit are split into multiple messages at section/bullet boundaries so a
|
||||
* chunk never lands mid-item.
|
||||
*/
|
||||
|
||||
/** Discord allows 4096 chars per message and per embed description; leave headroom. */
|
||||
|
|
@ -31,15 +29,6 @@ const HORIZONTAL_RULE = /^\s*-{3,}\s*$/;
|
|||
/** The fallback rendered as a list item, matching how Fixes footnotes look. */
|
||||
const FALLBACK_LINE = `- ${EMPTY_SECTION_FALLBACK}`;
|
||||
|
||||
/**
|
||||
* Discord's renderer supports headings only up to `###`; a section header is
|
||||
* rendered at that level (the version itself is the embed title). Change this
|
||||
* one constant to `## ` for a larger heading.
|
||||
*/
|
||||
const SECTION_HEADER_PREFIX = "### ";
|
||||
|
||||
const sectionHeader = (header: string): string => `${SECTION_HEADER_PREFIX}${header}`;
|
||||
|
||||
/** A parsed `# vX.Y.Z` entry: the version and the raw markdown body under it. */
|
||||
export interface ChangelogEntry {
|
||||
version: string;
|
||||
|
|
@ -99,13 +88,6 @@ function intoBlocks(rawBody: string): Block[] {
|
|||
if (HORIZONTAL_RULE.test(line)) continue;
|
||||
const section = line.match(SECTION_HEADER);
|
||||
if (section) {
|
||||
// A single-hash heading is the entry's own "# vX.Y.Z" title line, which
|
||||
// the embed title already carries. parseChangelog excludes it from the
|
||||
// body it hands over; drop it here too so a raw body renders the same.
|
||||
if (section[1] === "#") {
|
||||
current = null;
|
||||
continue;
|
||||
}
|
||||
current = { header: section[2].trim(), lines: [] };
|
||||
blocks.push(current);
|
||||
continue;
|
||||
|
|
@ -153,7 +135,7 @@ const formatLine = (raw: string): string => {
|
|||
|
||||
const blockToString = (block: Block): string => {
|
||||
const lines: string[] = [];
|
||||
if (block.header !== null) lines.push(sectionHeader(block.header));
|
||||
if (block.header !== null) lines.push(`**${block.header}**`);
|
||||
for (const line of block.lines) lines.push(formatLine(line));
|
||||
return lines.join("\n");
|
||||
};
|
||||
|
|
@ -194,7 +176,7 @@ export function splitForDiscord(rawBody: string): string[] {
|
|||
let current = "";
|
||||
for (const block of intoBlocks(rawBody)) {
|
||||
const blockLines: string[] = [];
|
||||
if (block.header !== null) blockLines.push(sectionHeader(block.header));
|
||||
if (block.header !== null) blockLines.push(`**${block.header}**`);
|
||||
for (const line of block.lines) blockLines.push(formatLine(line));
|
||||
if (blockLines.length === 0) continue;
|
||||
|
||||
|
|
@ -215,7 +197,7 @@ export function splitForDiscord(rawBody: string): string[] {
|
|||
continue;
|
||||
}
|
||||
|
||||
const headerPrefix = block.header !== null ? sectionHeader(block.header) : null;
|
||||
const headerPrefix = block.header !== null ? `**${block.header}**` : null;
|
||||
// Reserve room for the re-attached header + separator on continuation chunks.
|
||||
const headroom = headerPrefix ? headerPrefix.length + "\n\n".length : 0;
|
||||
const blockChunks = splitLinesToMessages(blockLines, MAX_MESSAGE_CHARS - headroom);
|
||||
|
|
|
|||
|
|
@ -131,13 +131,12 @@ describe("resolveChangelogRange", () => {
|
|||
});
|
||||
|
||||
describe("formatEntryDiscord", () => {
|
||||
it("turns section headers into markdown headings and bullets into the bullet glyph", () => {
|
||||
it("turns section headers bold and bullets into the bullet glyph", () => {
|
||||
const formatted = formatEntryDiscord(SAMPLE);
|
||||
expect(formatted).toContain("### Features");
|
||||
expect(formatted).toContain("### Fixes");
|
||||
expect(formatted).toContain("**Features**");
|
||||
expect(formatted).toContain("**Fixes**");
|
||||
expect(formatted).toContain("• **Feature one:** does a thing.");
|
||||
// The entry's own "# vX.Y.Z" version header stays out (the embed title has it).
|
||||
expect(formatted).not.toContain("# v0.4.0");
|
||||
expect(formatted).not.toContain("# ");
|
||||
});
|
||||
|
||||
it("preserves inline markdown", () => {
|
||||
|
|
@ -165,8 +164,8 @@ describe("splitForDiscord", () => {
|
|||
.flatMap((message) => message.split("\n"))
|
||||
.filter((line) => line.startsWith("• "));
|
||||
expect(bulletsInMessages).toHaveLength(300);
|
||||
// The first chunk leads with the section heading.
|
||||
expect(messages[0]).toContain("### Features");
|
||||
// The first chunk leads with the section header.
|
||||
expect(messages[0]).toContain("**Features**");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -190,14 +189,14 @@ describe("empty-section fallback", () => {
|
|||
const resolved = resolveChangelog(content, "0.8.3");
|
||||
expect(resolved.found).toBe(true);
|
||||
expect(resolved.messages).toHaveLength(1);
|
||||
expect(resolved.messages[0]).toContain("### Fixes");
|
||||
expect(resolved.messages[0]).toContain("**Fixes**");
|
||||
expect(resolved.messages[0]).toContain(EMPTY_SECTION_FALLBACK);
|
||||
expect(resolved.messages[0]).not.toContain("---");
|
||||
});
|
||||
|
||||
it("fills a section heading that has no items, leaving real sections alone", () => {
|
||||
const formatted = formatEntryDiscord("### Improvements\n\n### Fixes\n\n- A real fix.\n");
|
||||
expect(formatted).toContain("### Improvements");
|
||||
expect(formatted).toContain("**Improvements**");
|
||||
expect(formatted).toContain(`• ${EMPTY_SECTION_FALLBACK}`);
|
||||
expect(formatted).toContain("• A real fix.");
|
||||
});
|
||||
|
|
@ -215,13 +214,6 @@ describe("empty-section fallback", () => {
|
|||
expect(formatted).not.toContain(EMPTY_SECTION_FALLBACK);
|
||||
});
|
||||
|
||||
it("drops a raw body's own # version line (the embed title carries it)", () => {
|
||||
const formatted = formatEntryDiscord("# v9.9.9\n\nA summary.\n\n### Fixes\n\n- A fix.\n");
|
||||
expect(formatted).not.toContain("v9.9.9");
|
||||
expect(formatted).toContain("A summary.");
|
||||
expect(formatted).toContain("### Fixes");
|
||||
});
|
||||
|
||||
it("renders the shipped empty v0.8.3 entry from the real file", () => {
|
||||
const content = readFileSync(CHANGELOG_PATH, "utf8");
|
||||
const resolved = resolveChangelog(content, "0.8.3");
|
||||
|
|
@ -246,7 +238,7 @@ describe("real CHANGELOG.md", () => {
|
|||
const v040 = resolveChangelog(content, "0.4.0");
|
||||
expect(v040.found).toBe(true);
|
||||
expect(v040.messages.length).toBeGreaterThan(0);
|
||||
expect(v040.messages[0]).toContain("### Features");
|
||||
expect(v040.messages[0]).toContain("**Features**");
|
||||
expect(v040.messages[0]).toContain("• **Mission planning maps**:");
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue