Compare commits
No commits in common. "0c00726759a1fa0b885a9fb352746d514deb2226" and "0ef3da018ede1095a1f4b04450e1d8e44601c5bd" have entirely different histories.
0c00726759
...
0ef3da018e
4 changed files with 5 additions and 98 deletions
|
|
@ -1,14 +1,5 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
# v0.8.7
|
|
||||||
|
|
||||||
### Fixes
|
|
||||||
|
|
||||||
- Release notes posted to Discord no longer trail a stray separator line, and a release with no player-facing changes now reads "Various bug fixes and improvements" instead of showing an empty entry.
|
|
||||||
- Various bug fixes and improvements.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# v0.8.6
|
# v0.8.6
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "polaris-task-force",
|
"name": "polaris-task-force",
|
||||||
"version": "0.8.7",
|
"version": "0.8.6",
|
||||||
"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.",
|
"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",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
|
||||||
|
|
@ -13,22 +13,6 @@
|
||||||
/** Discord allows 4096 chars per message and per embed description; leave headroom. */
|
/** Discord allows 4096 chars per message and per embed description; leave headroom. */
|
||||||
const MAX_MESSAGE_CHARS = 4000;
|
const MAX_MESSAGE_CHARS = 4000;
|
||||||
|
|
||||||
/**
|
|
||||||
* Shown in place of an empty release entry or an empty section, so a post never
|
|
||||||
* renders as a bare heading (or a stray separator). Players read it as "there
|
|
||||||
* were other changes we did not detail".
|
|
||||||
*/
|
|
||||||
export const EMPTY_SECTION_FALLBACK = "Various bug fixes and improvements.";
|
|
||||||
|
|
||||||
/** Section the fallback goes under when an entire entry has no content. */
|
|
||||||
const FALLBACK_SECTION_HEADER = "Fixes";
|
|
||||||
|
|
||||||
/** The `---` separator CHANGELOG.md puts between entries: file formatting, never content. */
|
|
||||||
const HORIZONTAL_RULE = /^\s*-{3,}\s*$/;
|
|
||||||
|
|
||||||
/** The fallback rendered as a list item, matching how Fixes footnotes look. */
|
|
||||||
const FALLBACK_LINE = `- ${EMPTY_SECTION_FALLBACK}`;
|
|
||||||
|
|
||||||
/** A parsed `# vX.Y.Z` entry: the version and the raw markdown body under it. */
|
/** A parsed `# vX.Y.Z` entry: the version and the raw markdown body under it. */
|
||||||
export interface ChangelogEntry {
|
export interface ChangelogEntry {
|
||||||
version: string;
|
version: string;
|
||||||
|
|
@ -84,8 +68,6 @@ function intoBlocks(rawBody: string): Block[] {
|
||||||
const blocks: Block[] = [];
|
const blocks: Block[] = [];
|
||||||
let current: Block | null = null;
|
let current: Block | null = null;
|
||||||
for (const line of rawBody.split("\n")) {
|
for (const line of rawBody.split("\n")) {
|
||||||
// Entry separators are file formatting; they are not player-facing content.
|
|
||||||
if (HORIZONTAL_RULE.test(line)) continue;
|
|
||||||
const section = line.match(SECTION_HEADER);
|
const section = line.match(SECTION_HEADER);
|
||||||
if (section) {
|
if (section) {
|
||||||
current = { header: section[2].trim(), lines: [] };
|
current = { header: section[2].trim(), lines: [] };
|
||||||
|
|
@ -106,21 +88,10 @@ function intoBlocks(rawBody: string): Block[] {
|
||||||
while (start < end && /^\s*$/.test(block.lines[start])) start++;
|
while (start < end && /^\s*$/.test(block.lines[start])) start++;
|
||||||
while (end > start && /^\s*$/.test(block.lines[end - 1])) end--;
|
while (end > start && /^\s*$/.test(block.lines[end - 1])) end--;
|
||||||
const lines = block.lines.slice(start, end);
|
const lines = block.lines.slice(start, end);
|
||||||
|
// Drop a leading/trailing all-blank intro block; keep section blocks even
|
||||||
if (block.header === null) {
|
// if empty so their bold header still renders.
|
||||||
// Drop a leading/trailing all-blank intro block.
|
if (lines.length === 0 && block.header === null) continue;
|
||||||
if (lines.length === 0) continue;
|
result.push({ header: block.header, lines });
|
||||||
result.push({ header: null, lines });
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Keep every section, falling back to the generic line when it has no
|
|
||||||
// items, so a post never shows a heading with nothing under it.
|
|
||||||
result.push({ header: block.header, lines: lines.length > 0 ? lines : [FALLBACK_LINE] });
|
|
||||||
}
|
|
||||||
|
|
||||||
// An entry with no content at all still tells players something shipped.
|
|
||||||
if (result.length === 0) {
|
|
||||||
return [{ header: FALLBACK_SECTION_HEADER, lines: [FALLBACK_LINE] }];
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import path from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import {
|
import {
|
||||||
EMPTY_SECTION_FALLBACK,
|
|
||||||
compareVersions,
|
compareVersions,
|
||||||
formatEntryDiscord,
|
formatEntryDiscord,
|
||||||
parseChangelog,
|
parseChangelog,
|
||||||
|
|
@ -169,60 +168,6 @@ describe("splitForDiscord", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("empty-section fallback", () => {
|
|
||||||
it("renders a fully empty entry as a Fixes section carrying the generic line", () => {
|
|
||||||
const content = [
|
|
||||||
"# Changelog",
|
|
||||||
"",
|
|
||||||
"# v0.8.3",
|
|
||||||
"",
|
|
||||||
"---",
|
|
||||||
"",
|
|
||||||
"# v0.8.2",
|
|
||||||
"",
|
|
||||||
"### Fixes",
|
|
||||||
"",
|
|
||||||
"- A real fix.",
|
|
||||||
"",
|
|
||||||
].join("\n");
|
|
||||||
|
|
||||||
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(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(`• ${EMPTY_SECTION_FALLBACK}`);
|
|
||||||
expect(formatted).toContain("• A real fix.");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not invent content for entries that already have some", () => {
|
|
||||||
const formatted = formatEntryDiscord(SAMPLE);
|
|
||||||
expect(formatted).not.toContain(EMPTY_SECTION_FALLBACK);
|
|
||||||
// Entry separators never leak into the post.
|
|
||||||
expect(formatted).not.toContain("---");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("keeps a real summary paragraph even without sections", () => {
|
|
||||||
const formatted = formatEntryDiscord("Just a summary sentence.\n");
|
|
||||||
expect(formatted).toBe("Just a summary sentence.");
|
|
||||||
expect(formatted).not.toContain(EMPTY_SECTION_FALLBACK);
|
|
||||||
});
|
|
||||||
|
|
||||||
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");
|
|
||||||
expect(resolved.found).toBe(true);
|
|
||||||
expect(resolved.messages[0]).toContain(EMPTY_SECTION_FALLBACK);
|
|
||||||
expect(resolved.messages[0]).not.toContain("---");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("real CHANGELOG.md", () => {
|
describe("real CHANGELOG.md", () => {
|
||||||
it("parses and renders the shipped entries", () => {
|
it("parses and renders the shipped entries", () => {
|
||||||
const content = readFileSync(CHANGELOG_PATH, "utf8");
|
const content = readFileSync(CHANGELOG_PATH, "utf8");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue