From 150a679687b4ce3e016eebab32e98e09ae41ddc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:06:46 +0100 Subject: [PATCH 1/5] test: docs guards for lists, screenshots, descriptions, release names and README links - build/docs-files.js defines the docs files once (site pages, READMEs, current-state docs); the growth guard and the llms.txt test use it - tests/js/docs-pages.test.js: a blank line before every list, a description on every page, no release of pivotkit or a module named outside an explicit list of places - tests/js/screenshots.test.js: every screenshot shown, light/dark pairs, alt text, the theme fragment on the site; the three single demo.md screenshots are listed until #213 retakes them - build/check-readme-links.js checks README links against the built site in docs.yml - getting-started.md: step 2 of the update list rendered as text; a blank line fixes it Refs #217 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/docs.yml | 3 + build/check-readme-links.js | 71 ++++++++++++++ build/docs-files.js | 60 ++++++++++++ build/growth.js | 20 +--- docs/getting-started.md | 1 + tests/js/ci.test.js | 12 +++ tests/js/docs-pages.test.js | 168 +++++++++++++++++++++++++++++++++ tests/js/llms-sections.test.js | 17 +--- tests/js/readme-links.test.js | 36 +++++++ tests/js/screenshots.test.js | 98 +++++++++++++++++++ 10 files changed, 457 insertions(+), 29 deletions(-) create mode 100644 build/check-readme-links.js create mode 100644 build/docs-files.js create mode 100644 tests/js/docs-pages.test.js create mode 100644 tests/js/readme-links.test.js create mode 100644 tests/js/screenshots.test.js diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 09fb3c6..1e4bae0 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -34,6 +34,9 @@ jobs: run: ./docs/site/Build-Site.ps1 # the shared design and the pinned Zensical version (eizedev/brand, docs-site/); the site lands in site/ - uses: eizedev/brand/docs-site@8d8d554bf72868842330a40a61e843ec631edcf5 # v1.0.0 + # every link from a README into the site names a page and anchor of this build + - name: README links + run: node build/check-readme-links.js site - uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 with: path: site diff --git a/build/check-readme-links.js b/build/check-readme-links.js new file mode 100644 index 0000000..e3646d4 --- /dev/null +++ b/build/check-readme-links.js @@ -0,0 +1,71 @@ +// Checks that every link to the documentation site in the READMEs (the root's and each module's) points +// at a page and heading anchor that exist in a built site. A published module carries its README, so +// these paths and anchors are a contract: a page or heading they name keeps its address. A link counts +// in Markdown, [text](url), and in HTML, href="url". The docs workflow runs it after the site build; +// it uses Node's own modules only, as that job runs no `npm ci`. +// +// node build/check-readme-links.js site # the directory `zensical build` wrote +// +// eizedev/pivotkit checks its READMEs the same way (scripts/check-readme-links.js). +import { existsSync, readFileSync } from "node:fs"; +import { join } from "node:path"; +import { fileURLToPath } from "node:url"; +import { readmes, root } from "./docs-files.js"; + +/** The site's address from `site_url` in zensical.toml, without a trailing slash. */ +export function siteUrl(dir = root) { + const url = /^site_url\s*=\s*"([^"]+)"/m.exec(readFileSync(join(dir, "zensical.toml"), "utf8"))?.[1]; + if (!url) throw new Error("check-readme-links: zensical.toml has no site_url"); + return url.replace(/\/$/, ""); +} + +/** + * The links to `site` in a README's text, each once. + * @param {string} text + * @param {string} site the site's address, without a trailing slash + * @returns {string[]} + */ +export function siteLinks(text, site) { + const escaped = site.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + // the site's address, then a path or an anchor: never a longer host name that starts the same + const pattern = new RegExp(`\\]\\((${escaped}(?:[/#][^)\\s]*)?)\\)|href="(${escaped}(?:[/#][^"\\s]*)?)"`, "g"); + return [...new Set([...text.matchAll(pattern)].map((m) => m[1] ?? m[2]))]; +} + +/** + * What is wrong with a link to the site, read from the built site, or null. + * @param {string} url + * @param {string} site + * @param {string} siteDir the built site + * @returns {string | null} + */ +export function linkProblem(url, site, siteDir) { + const [path, anchor] = url.slice(site.length).split("#"); + const file = join(siteDir, path === "" || path.endsWith("/") ? join(path, "index.html") : path); + if (!existsSync(file)) return `no page for ${url}`; + if (anchor && !readFileSync(file, "utf8").includes(`id="${anchor}"`)) return `no anchor for ${url}`; + return null; +} + +if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) { + const siteDir = process.argv[2]; + if (!siteDir || !existsSync(join(siteDir, "index.html"))) { + console.error("usage: node build/check-readme-links.js "); + process.exit(2); + } + const site = siteUrl(); + let checked = 0; + const problems = []; + for (const readme of readmes()) { + for (const url of siteLinks(readFileSync(join(root, readme), "utf8"), site)) { + checked++; + const problem = linkProblem(url, site, siteDir); + if (problem) problems.push(`${readme}: ${problem}`); + } + } + console.log(`${checked} links to ${site} checked`); + if (problems.length) { + console.error(problems.join("\n")); + process.exit(1); + } +} diff --git a/build/docs-files.js b/build/docs-files.js new file mode 100644 index 0000000..eb06a73 --- /dev/null +++ b/build/docs-files.js @@ -0,0 +1,60 @@ +// The Markdown files of the documentation, defined once for the growth guards (build/growth.js), the +// docs checks in tests/js/ and the README link check (build/check-readme-links.js): the pages of the +// site, the READMEs, and the files a reader takes as the current state. No imports beyond Node's own: +// the docs workflow runs the link check without `npm ci`. +import { existsSync, readdirSync } from "node:fs"; +import { join, relative, sep } from "node:path"; +import { fileURLToPath } from "node:url"; + +/** The repository's root directory. */ +export const root = fileURLToPath(new URL("../", import.meta.url)); + +/** A path relative to `base`, with forward slashes. */ +const posix = (base, path) => relative(base, path).split(sep).join("/"); + +/** + * The pages of the docs site, relative to docs/ ("pivot/views.md"), sorted. docs/site/ builds the site + * (exclude_docs in zensical.toml) and holds no pages. + * @param {string} [dir] the repository + * @returns {string[]} + */ +export function sitePages(dir = root) { + const docs = join(dir, "docs"); + return readdirSync(docs, { recursive: true, withFileTypes: true }) + .filter((entry) => entry.isFile() && entry.name.endsWith(".md")) + .map((entry) => posix(docs, join(entry.parentPath, entry.name))) + .filter((page) => !page.startsWith("site/")) + .sort(); +} + +/** + * The READMEs a reader of the repository or a module sees: the root's and each module's, as + * repository paths. + * @param {string} [dir] the repository + * @returns {string[]} + */ +export function readmes(dir = root) { + const modules = readdirSync(join(dir, "modules"), { withFileTypes: true }) + .filter((entry) => entry.isDirectory()) + .map((entry) => `modules/${entry.name}/README.md`) + .sort(); + return ["README.md", ...modules].filter((path) => existsSync(join(dir, path))); +} + +/** The guides at the root that describe the repository as it is now. */ +const GUIDES = ["CONTRIBUTING.md", "PRODUCT.md", "RELEASING.md", "SECURITY.md", "ACCESSIBILITY.md", "AGENTS.md"]; + +/** + * The Markdown a reader takes as the current state, as repository paths: the READMEs, the root's + * guides and the site's pages outside docs/decisions/. Changelogs and decision records keep history, + * so they are not here. + * @param {string} [dir] the repository + * @returns {string[]} + */ +export function currentStateDocs(dir = root) { + return [ + ...readmes(dir), + ...GUIDES.filter((path) => existsSync(join(dir, path))), + ...sitePages(dir).filter((page) => !page.startsWith("decisions/")).map((page) => `docs/${page}`), + ]; +} diff --git a/build/growth.js b/build/growth.js index 1f2c4d6..fd3f5e1 100644 --- a/build/growth.js +++ b/build/growth.js @@ -16,9 +16,10 @@ // entry by itself. Raising one is --accept-growth, and the pull request says why. // eizedev/pivotkit has the same guards in scripts/growth.js; both work alike. import { spawnSync } from "node:child_process"; -import { existsSync, readFileSync, readdirSync, writeFileSync } from "node:fs"; +import { existsSync, readFileSync, writeFileSync } from "node:fs"; import { basename, join, relative, sep } from "node:path"; import { fileURLToPath } from "node:url"; +import { readmes, sitePages } from "./docs-files.js"; import { LANGUAGE_OPTIONS, SOURCES } from "./javascript-sources.js"; const root = fileURLToPath(new URL("../", import.meta.url)); @@ -167,24 +168,13 @@ export function docsKind(page) { const lineCount = (text) => text.split("\n").length - (text.endsWith("\n") ? 1 : 0); /** - * Lines of every docs page (docs/**\/*.md without docs/site/, which builds the site) and every README - * (the repository's and each module's), as repository path -> lines. + * Lines of every docs page and every README (build/docs-files.js), as repository path -> lines. * @param {string} [dir] the repository * @returns {Record} */ export function docsPages(dir = root) { - const pages = {}; - const add = (path) => { - if (existsSync(join(dir, path))) pages[path] = lineCount(readFileSync(join(dir, path), "utf8")); - }; - for (const entry of readdirSync(join(dir, "docs"), { recursive: true, withFileTypes: true })) { - if (!entry.isFile() || !entry.name.endsWith(".md")) continue; - const path = posix(join(entry.parentPath, entry.name), dir); - if (!path.startsWith("docs/site/")) add(path); - } - add("README.md"); - for (const module of readdirSync(join(dir, "modules"), { withFileTypes: true })) if (module.isDirectory()) add(`modules/${module.name}/README.md`); - return pages; + const paths = [...sitePages(dir).map((page) => `docs/${page}`), ...readmes(dir)]; + return Object.fromEntries(paths.map((path) => [path, lineCount(readFileSync(join(dir, path), "utf8"))])); } /** diff --git a/docs/getting-started.md b/docs/getting-started.md index 6478307..7f8f601 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -30,6 +30,7 @@ when a page uses it. `Install-PSResource` puts the new version in a folder of its own, next to the old one. From a release zip, copy the new `` folder next to the old one in `Modules//`. + 2. Restart PSU. PowerShell imports the newest version it finds in the folder, but a process that has already imported the module keeps that version. 3. Readers reload their open pages. The bundle's file name holds a hash of its content, so a reload diff --git a/tests/js/ci.test.js b/tests/js/ci.test.js index 9cd56ca..3384132 100644 --- a/tests/js/ci.test.js +++ b/tests/js/ci.test.js @@ -147,3 +147,15 @@ test("the release needs the tagged commit on main and a green CI run of it, befo assert.equal(prepare.if, undefined, "prepare runs only under a condition"); assert.deepEqual(prepare.permissions, { contents: "read", actions: "read" }, "prepare needs actions: read for the gate, and nothing more"); }); + +// The READMEs travel with each module: their links into the site are checked against the site the +// docs workflow just built, before it is published +test("the docs workflow checks the README links against the built site, after building it", () => { + const steps = jobOf("docs.yml", "build").steps; + const build = steps.findIndex((step) => String(step.uses ?? "").startsWith("eizedev/brand/docs-site@")); + const check = stepRunning(steps, "node build/check-readme-links.js site"); + assert.ok(build !== -1, "docs.yml builds no site with eizedev/brand/docs-site"); + assert.ok(check > build, "docs.yml checks no README links against the built site after building it"); + const upload = steps.findIndex((step) => String(step.uses ?? "").startsWith("actions/upload-pages-artifact@")); + assert.ok(check < upload, "docs.yml uploads the site before checking the README links"); +}); diff --git a/tests/js/docs-pages.test.js b/tests/js/docs-pages.test.js new file mode 100644 index 0000000..ab49b9e --- /dev/null +++ b/tests/js/docs-pages.test.js @@ -0,0 +1,168 @@ +// Checks every docs page and README must pass, beyond what the site build checks: a list starts after a +// blank line, every page has a description, and the current-state docs name no release of pivotkit or +// of a module. eizedev/pivotkit has the same checks (tests/docs-lists.test.js, tests/ci.test.js). +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { currentStateDocs, root, sitePages } from "../../build/docs-files.js"; + +const read = (path) => readFileSync(join(root, path), "utf8"); + +// A list needs a blank line before it. Python-Markdown (Zensical) lets no list interrupt a paragraph: +// a "- " or "1. " line right after a paragraph that is not a list item, such as an indented paragraph +// inside an item, becomes part of that paragraph's text. The strict build does not warn. A line right +// after a table becomes another table row. Inside a blockquote, the check reads the lines without +// their "> ". It does not follow a blockquote's lazy lines that have no "> ". +const LIST_ITEM = /^\s*(?:[-*+]|\d+\.)\s+\S/; +const FENCE = /^\s*(`{3,}|~{3,})/; +// Lines that are a block of their own, so the next line starts a new block: a heading, an +// admonition's or a content tab's title, an HTML line or a rule. +const OWN_BLOCK = /^\s*(?:#|!!!|\?\?\?|===|<|(?:-{3,}|\*{3,}|_{3,})\s*$)/; +const QUOTE = /^\s*(?:>\s?)+/; + +/** + * The list items of a Markdown text that follow a paragraph or a table row without a blank line, as + * 1-based line numbers. Code fences and front matter are skipped. + * @param {string} text + * @returns {number[]} + */ +function swallowedListItems(text) { + const found = []; + let fence = null; + /** The first line of the paragraph the previous line belongs to, or null after a block's end. */ + let paragraphStart = null; + const lines = text.split("\n"); + const bodyStart = lines[0] === "---" ? lines.indexOf("---", 1) + 1 : 0; + lines.forEach((source, index) => { + if (index < bodyStart) return; + const line = source.replace(QUOTE, ""); + const marker = line.match(FENCE)?.[1]; + if (fence) { + if (marker && marker[0] === fence[0] && marker.length >= fence.length) fence = null; + return; + } + if (marker) { + fence = marker; + paragraphStart = null; + return; + } + if (!line.trim() || OWN_BLOCK.test(line)) { + paragraphStart = null; + return; + } + if (LIST_ITEM.test(line)) { + if (paragraphStart !== null && !LIST_ITEM.test(paragraphStart)) found.push(index + 1); + paragraphStart = line; + return; + } + paragraphStart ??= line; + }); + return found; +} + +/** Each case: a Markdown text and the line numbers swallowedListItems reports. */ +const LIST_CASES = [ + { name: "a list right after a paragraph", lines: ["Intro:", "- item"], found: [2] }, + { name: "a numbered list right after a paragraph", lines: ["Intro:", "1. item"], found: [2] }, + { name: "a list after a blank line", lines: ["Intro:", "", "- item", "1. item"], found: [] }, + { name: "an item with a wrapped line and a nested list", lines: ["- item", " wrapped", " - nested"], found: [] }, + { name: "an item after an indented paragraph in the item above", lines: ["- item", "", " Indented paragraph", "- next item"], found: [4] }, + { name: "a list right after a heading", lines: ["## Heading", "- item"], found: [] }, + { name: "a list in a code fence", lines: ["Text", "```", "text", "- in code", "```"], found: [] }, + { name: "a list in an admonition", lines: ["!!! note", " - item", " 1. numbered"], found: [] }, + { name: "a list in a fold", lines: ['
', "More", "- item"], found: [] }, + { name: "a list after a table", lines: ["| a | b |", "| --- | --- |", "| 1 | 2 |", "", "- item"], found: [] }, + // Python-Markdown takes the line as another table row. + { name: "a list right after a table", lines: ["| a | b |", "| --- | --- |", "- item"], found: [3] }, + { name: "a list right after a paragraph in a blockquote", lines: ["> Intro:", "> - item"], found: [2] }, + { name: "a list in a blockquote after a blank line", lines: ["> Intro:", ">", "> - item"], found: [] }, + { name: "front matter", lines: ["---", "title: Page", "hide:", " - toc", "---"], found: [] }, + // Flagged on purpose: the page shows it as text, but the source reads like a list. Rewrap the line. + { name: "a wrapped line that starts with a number and a dot", lines: ["Since version", "2. it works"], found: [2] }, +]; + +for (const { name, lines, found } of LIST_CASES) { + test(`swallowedListItems: ${name}`, () => { + assert.deepEqual(swallowedListItems(lines.join("\n")), found); + }); +} + +test("every list in the docs starts after a blank line", () => { + const pages = sitePages(); + assert.ok(pages.includes("index.md") && pages.includes("pivot/reference.md"), "the page list misses known pages"); + const problems = pages.flatMap((page) => swallowedListItems(read(`docs/${page}`)).map((line) => `docs/${page}:${line}`)); + assert.deepEqual(problems, [], "add a blank line before these list items"); +}); + +/** + * The description in a page's front matter, or undefined. + * @param {string} text + */ +function descriptionOf(text) { + const front = /^---\n([\s\S]*?)\n---\n/.exec(text)?.[1]; + return front && /^description:[ \t]*(\S.*)$/m.exec(front)?.[1]; +} + +test("descriptionOf reads the description of the front matter only", () => { + assert.equal(descriptionOf("---\ntitle: T\ndescription: What the page covers.\n---\n\n# T\n"), "What the page covers."); + assert.equal(descriptionOf("---\ndescription:\n---\n"), undefined); + assert.equal(descriptionOf("# T\n\ndescription: not front matter\n"), undefined); +}); + +// The description goes into the page's meta and Open Graph tags (overrides/main.html) and llms.txt; +// without one, search engines and link previews show the site's description for every page. +test("every page of the site has a description in its front matter", () => { + assert.deepEqual(sitePages().filter((page) => !descriptionOf(read(`docs/${page}`))), []); +}); + +// A release named as a fact of the present ("pivotkit 0.8 does not know it") is wrong for the next +// reader, and a release leaves it behind. The docs say what a feature needs as one minimum +// ("pivotkit-server 0.4.0 or later") and otherwise describe what an older version does, without its +// number. The pattern names pivotkit and its packages, the modules by their full name, "Pivot" and +// " module"; "ECharts 6.1" or "Perspective 5.7" name a bundled library, not a module. +const RELEASE_NAME = /\b(?:pivotkit(?:-[a-z]+)?|PowerShellUniversal\.Component\.[A-Za-z.]*[A-Za-z]|Pivot|(?:ECharts|Perspective|Pivot) module)[ @]\(?v?\d+\.\d+(?:\.\d+)?(?!\.?\d)(?!\)?\s+or\s+(?:later|newer))/g; + +/** + * Where a current-state page may name releases: the whole file, or one section of it (its "## " + * heading). Changelogs, decision records and the reference generated from the commands' help are + * not current-state pages (build/docs-files.js). + */ +const RELEASE_NAMES_ALLOWED = [ + { file: "docs/versioning.md" }, + // the versions the modules were tested with + { file: "docs/index.md", section: "Requirements" }, +]; + +/** + * The release names in a text, without the allowed sections. + * @param {string} text + * @param {string[]} [sections] the "## " headings whose sections may name releases + * @returns {string[]} + */ +function releaseNames(text, sections = []) { + const kept = text.split(/^(?=## )/m).filter((part) => !sections.some((s) => part.startsWith(`## ${s}\n`))); + return kept.flatMap((part) => [...part.matchAll(RELEASE_NAME)].map((m) => m[0])); +} + +test("releaseNames finds a release named as a fact and leaves minimums and allowed sections alone", () => { + assert.deepEqual(releaseNames("pivotkit 0.8 does not know it. Pivot 0.10.0 changed it."), ["pivotkit 0.8", "Pivot 0.10.0"]); + assert.deepEqual(releaseNames("Tag pivotkit-server@0.4.0 or PowerShellUniversal.Component.Pivot.Demo 0.3."), ["pivotkit-server@0.4.0", "PowerShellUniversal.Component.Pivot.Demo 0.3"]); + assert.deepEqual(releaseNames("needs pivotkit-server 0.4.0 or\nlater; a pivotkit-server (0.3.0 or later)"), []); + assert.deepEqual(releaseNames("Apache ECharts 6.1 and Perspective 5.7, the ECharts module 0.3"), ["ECharts module 0.3"]); + assert.deepEqual(releaseNames("## Requirements\n\nTested with pivotkit-cli 0.6.0.\n\n## Next\n\npivotkit 0.9\n", ["Requirements"]), ["pivotkit 0.9"]); +}); + +test("current-state docs name no release of pivotkit or a module outside the allowed places", () => { + const docs = currentStateDocs(); + for (const { file, section } of RELEASE_NAMES_ALLOWED) { + assert.ok(docs.includes(file), `${file} is no current-state page: update RELEASE_NAMES_ALLOWED`); + if (section) assert.ok(read(file).includes(`\n## ${section}\n`), `${file} has no section "## ${section}": update RELEASE_NAMES_ALLOWED`); + } + const problems = docs.flatMap((file) => { + const allowed = RELEASE_NAMES_ALLOWED.filter((a) => a.file === file); + if (allowed.some((a) => !a.section)) return []; + return releaseNames(read(file), allowed.map((a) => a.section)).map((name) => `${file}: ${name}`); + }); + assert.deepEqual(problems, [], "say what the feature needs as a minimum (\"0.4.0 or later\") or what an older version does, without its number"); +}); diff --git a/tests/js/llms-sections.test.js b/tests/js/llms-sections.test.js index 1f3167c..c6b6cd5 100644 --- a/tests/js/llms-sections.test.js +++ b/tests/js/llms-sections.test.js @@ -2,12 +2,10 @@ // section names: a new page that no section matches would be missing from both without a warning. import { test } from "node:test"; import assert from "node:assert/strict"; -import { readFileSync, readdirSync } from "node:fs"; -import { join, relative, sep } from "node:path"; -import { fileURLToPath } from "node:url"; +import { readFileSync } from "node:fs"; +import { sitePages } from "../../build/docs-files.js"; const root = new URL("../../", import.meta.url); -const docs = fileURLToPath(new URL("docs/", root)); /** The patterns of the llmstxt sections, in the order they are written; each section is a one-line array. */ function sectionPatterns() { @@ -23,22 +21,13 @@ function sectionPatterns() { }); } -/** The Markdown pages of the site; docs/site/ is the site's build tooling (exclude_docs), not pages. */ -function pages(dir = docs) { - return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => { - const path = join(dir, entry.name); - if (entry.isDirectory()) return dir === docs && entry.name === "site" ? [] : pages(path); - return entry.name.endsWith(".md") ? [relative(docs, path).split(sep).join("/")] : []; - }); -} - // fnmatch as the plugin uses it: "*" matches any characters, "/" included const matcher = (pattern) => new RegExp(`^${pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`); test("every page of the site is in exactly one llms.txt section", () => { const patterns = sectionPatterns().map((p) => ({ p, re: matcher(p) })); assert.ok(patterns.length > 0, "no section patterns found"); - const all = pages(); + const all = sitePages(); assert.ok(all.includes("index.md") && all.includes("pivot/reference.md"), "the page list misses known pages"); for (const page of all) { const hits = patterns.filter(({ re }) => re.test(page)).map(({ p }) => p); diff --git a/tests/js/readme-links.test.js b/tests/js/readme-links.test.js new file mode 100644 index 0000000..e8dfcd1 --- /dev/null +++ b/tests/js/readme-links.test.js @@ -0,0 +1,36 @@ +// build/check-readme-links.js: which links of a README it reads and how it checks them against a built +// site. The docs workflow runs it on the real site (.github/workflows/docs.yml). +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { linkProblem, siteLinks, siteUrl } from "../../build/check-readme-links.js"; + +const SITE = "https://docs.example.org"; + +test("siteLinks reads Markdown and HTML links to the site, each once, and no other host", () => { + const text = [ + `[a](${SITE}/pivot/) and [b](${SITE}/#requirements) and [a again](${SITE}/pivot/)`, + `c and [root](${SITE})`, + `[other](https://docs.example.org.evil/x) [plain](https://example.org/)`, + ].join("\n"); + assert.deepEqual(siteLinks(text, SITE), [`${SITE}/pivot/`, `${SITE}/#requirements`, `${SITE}/echarts/data/#tables`, `${SITE}`]); +}); + +test("linkProblem finds a missing page and a missing anchor in a built site", (t) => { + const dir = mkdtempSync(join(tmpdir(), "readme-links-")); + t.after(() => rmSync(dir, { recursive: true, force: true })); + mkdirSync(join(dir, "pivot")); + writeFileSync(join(dir, "index.html"), '

Requirements

'); + writeFileSync(join(dir, "pivot/index.html"), "

Pivot

"); + assert.equal(linkProblem(`${SITE}/#requirements`, SITE, dir), null); + assert.equal(linkProblem(SITE, SITE, dir), null); + assert.equal(linkProblem(`${SITE}/pivot/`, SITE, dir), null); + assert.equal(linkProblem(`${SITE}/pivot/#views`, SITE, dir), `no anchor for ${SITE}/pivot/#views`); + assert.equal(linkProblem(`${SITE}/echarts/`, SITE, dir), `no page for ${SITE}/echarts/`); +}); + +test("siteUrl is the site_url of zensical.toml without its trailing slash", () => { + assert.match(siteUrl(), /^https:\/\/[^/]+$/); +}); diff --git a/tests/js/screenshots.test.js b/tests/js/screenshots.test.js new file mode 100644 index 0000000..abed6ff --- /dev/null +++ b/tests/js/screenshots.test.js @@ -0,0 +1,98 @@ +// The screenshots of the docs and the READMEs: every one is shown somewhere, comes as a light and a dark +// one, and is shown with alt text. On the site each one carries the fragment that shows it in its theme +// only (#only-light, #only-dark); a README shows a pair as a whose holds the dark one. +// eizedev/pivotkit has the same checks (tests/screenshots.test.js). +// +// The screenshots live in two places: docs/assets/ (the pages and the READMEs show them from there) and +// assets/screenshot-* (the README's quick start and the showcase app; docs/site/Build-Site.ps1 copies +// them into docs/assets/images/ for the site, which is build output and not committed). +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { existsSync, readFileSync, readdirSync } from "node:fs"; +import { dirname, join, relative, sep } from "node:path"; +import { readmes, root, sitePages } from "../../build/docs-files.js"; + +const IMAGE = /\.(png|webp|jpe?g|gif|svg|avif)$/i; +const posix = (path) => relative(root, path).split(sep).join("/"); + +/** Every screenshot of the repository, as repository paths. */ +const files = [ + // docs/assets/ also holds examples.css, and after a site build site.css, charts/ and images/ + ...readdirSync(join(root, "docs/assets"), { withFileTypes: true }).filter((e) => e.isFile() && IMAGE.test(e.name)).map((e) => `docs/assets/${e.name}`), + ...readdirSync(join(root, "assets")).filter((name) => name.startsWith("screenshot-")).map((name) => `assets/${name}`), +]; + +// Single screenshots of the ECharts showcase app (docs/demo.md). Their partners need new screenshots +// from the app on a PowerShell Universal instance: #213. The site shows them without a theme fragment, +// so they stay visible in both themes. Remove an entry when its partner is there; the test fails until then. +const SINGLES = new Set(["assets/screenshot-data-platform-dark.png", "assets/screenshot-ticket-report-dark.png", "assets/screenshot-service-review-light.png"]); + +/** + * The repository path an image address of `page` points to, or null for an image elsewhere (a badge). + * A page's assets/images/ is the copy of the root's assets/ that Build-Site.ps1 makes. + * @param {string} page repository path + * @param {string} src + */ +function resolve(page, src) { + if (/^[a-z]+:/i.test(src)) return null; + const path = posix(join(root, dirname(page), src.split("#")[0])); + return path.startsWith("docs/assets/images/") ? `assets/${path.slice("docs/assets/images/".length)}` : path; +} + +/** The Markdown images of a text: { src, alt, fragment }. */ +const markdownImages = (text) => [...text.matchAll(/!\[([^\]]*)\]\(([^)\s#]+)(#[\w-]+)?\)/g)].map((m) => ({ alt: m[1], src: m[2], fragment: m[3] ?? "" })); + +/** The elements of a text: { dark, light, alt } from its srcset and its . */ +const pictures = (text) => + [...text.matchAll(/([\s\S]*?)<\/picture>/g)].map((m) => ({ + dark: /]*src="([^"]+)"/.exec(m[1])?.[1] ?? "", + alt: /]*alt="([^"]*)"/.exec(m[1])?.[1] ?? "", + })); + +const pages = sitePages().map((page) => `docs/${page}`); +/** Every screenshot shown: { file, page, alt, fragment, picture }. */ +const shown = [...pages, ...readmes()].flatMap((page) => { + const text = readFileSync(join(root, page), "utf8"); + const images = markdownImages(text).map((image) => ({ ...image, file: resolve(page, image.src), page })); + const fromPictures = pictures(text).flatMap(({ dark, light, alt }) => [ + { file: resolve(page, dark), page, alt, fragment: "", picture: "dark" }, + { file: resolve(page, light), page, alt, fragment: "", picture: "light" }, + ]); + return [...images, ...fromPictures].filter((s) => s.file && /^(docs\/)?assets\//.test(s.file) && IMAGE.test(s.file)); +}); + +/** "light" or "dark" from a screenshot's name, or undefined. */ +const themeOf = (file) => /-(light|dark)\.\w+$/.exec(file)?.[1]; + +test("the screenshot list and the shown screenshots are found", () => { + assert.ok(files.includes("docs/assets/pivot-weather-light.png") && files.includes("assets/screenshot-quickstart-dark.png"), "known screenshots missing"); + assert.ok(shown.some((s) => s.page === "README.md" && s.picture) && shown.some((s) => s.page === "docs/index.md"), "known shown screenshots missing"); +}); + +test("every screenshot is shown on a page or in a README", () => { + const used = new Set(shown.map((s) => s.file)); + assert.deepEqual(files.filter((f) => !used.has(f)), [], "show these screenshots or delete them"); +}); + +test("every screenshot comes as a light and a dark one, apart from the listed singles", () => { + const pairs = new Map(); + for (const f of files) { + assert.ok(themeOf(f), `${f}: name it -light or -dark`); + const name = f.replace(/-(light|dark)(\.\w+)$/, "$2"); + pairs.set(name, [...(pairs.get(name) ?? []), f]); + } + const unpaired = [...pairs.values()].filter((group) => group.length !== 2).flat(); + assert.deepEqual(unpaired.filter((f) => !SINGLES.has(f)), [], "add the other theme's screenshot"); + assert.deepEqual([...SINGLES].filter((f) => !unpaired.includes(f)), [], "these singles have a partner or are gone: remove them from SINGLES"); +}); + +test("a shown screenshot exists and has alt text; on the site it carries the fragment of its theme", () => { + const wrong = shown.filter((s) => { + if (!existsSync(join(root, s.file)) || s.alt.trim() === "") return true; + if (s.picture) return themeOf(s.file) !== s.picture; + if (!s.page.startsWith("docs/")) return false; + return s.fragment !== (SINGLES.has(s.file) ? "" : `#only-${themeOf(s.file)}`); + }); + assert.deepEqual(wrong.map((s) => `${s.page}: ${s.file}${s.fragment}${s.picture ? ` ( ${s.picture})` : ""}`), []); +}); From a8eab96c236cc9085fcb045d1ca58629c69c4715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:11:58 +0100 Subject: [PATCH 2/5] test: release names in backticks and screenshots in the docs guards Refs #217 Co-Authored-By: Claude Opus 5.5 --- tests/js/docs-pages.test.js | 9 +++++---- tests/js/screenshots.test.js | 12 ++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/js/docs-pages.test.js b/tests/js/docs-pages.test.js index ab49b9e..ed04b12 100644 --- a/tests/js/docs-pages.test.js +++ b/tests/js/docs-pages.test.js @@ -1,6 +1,6 @@ -// Checks every docs page and README must pass, beyond what the site build checks: a list starts after a -// blank line, every page has a description, and the current-state docs name no release of pivotkit or -// of a module. eizedev/pivotkit has the same checks (tests/docs-lists.test.js, tests/ci.test.js). +// Checks beyond what the site build checks: on every page of the site, a list starts after a blank line +// and the front matter has a description; the current-state docs (READMEs, guides and pages outside +// docs/decisions/) name no release of pivotkit or of a module. eizedev/pivotkit has the same checks (tests/docs-lists.test.js, tests/ci.test.js). import { test } from "node:test"; import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; @@ -121,7 +121,7 @@ test("every page of the site has a description in its front matter", () => { // ("pivotkit-server 0.4.0 or later") and otherwise describe what an older version does, without its // number. The pattern names pivotkit and its packages, the modules by their full name, "Pivot" and // " module"; "ECharts 6.1" or "Perspective 5.7" name a bundled library, not a module. -const RELEASE_NAME = /\b(?:pivotkit(?:-[a-z]+)?|PowerShellUniversal\.Component\.[A-Za-z.]*[A-Za-z]|Pivot|(?:ECharts|Perspective|Pivot) module)[ @]\(?v?\d+\.\d+(?:\.\d+)?(?!\.?\d)(?!\)?\s+or\s+(?:later|newer))/g; +const RELEASE_NAME = /\b(?:pivotkit(?:-[a-z]+)?|PowerShellUniversal\.Component\.[A-Za-z.]*[A-Za-z]|Pivot|(?:ECharts|Perspective|Pivot) module)`?[ @]\(?v?\d+\.\d+(?:\.\d+)?(?!\.?\d)(?!\)?\s+or\s+(?:later|newer))/g; /** * Where a current-state page may name releases: the whole file, or one section of it (its "## " @@ -148,6 +148,7 @@ function releaseNames(text, sections = []) { test("releaseNames finds a release named as a fact and leaves minimums and allowed sections alone", () => { assert.deepEqual(releaseNames("pivotkit 0.8 does not know it. Pivot 0.10.0 changed it."), ["pivotkit 0.8", "Pivot 0.10.0"]); assert.deepEqual(releaseNames("Tag pivotkit-server@0.4.0 or PowerShellUniversal.Component.Pivot.Demo 0.3."), ["pivotkit-server@0.4.0", "PowerShellUniversal.Component.Pivot.Demo 0.3"]); + assert.deepEqual(releaseNames("Since `pivotkit-cli` 0.8 it works."), ["pivotkit-cli` 0.8"]); assert.deepEqual(releaseNames("needs pivotkit-server 0.4.0 or\nlater; a pivotkit-server (0.3.0 or later)"), []); assert.deepEqual(releaseNames("Apache ECharts 6.1 and Perspective 5.7, the ECharts module 0.3"), ["ECharts module 0.3"]); assert.deepEqual(releaseNames("## Requirements\n\nTested with pivotkit-cli 0.6.0.\n\n## Next\n\npivotkit 0.9\n", ["Requirements"]), ["pivotkit 0.9"]); diff --git a/tests/js/screenshots.test.js b/tests/js/screenshots.test.js index abed6ff..9166f25 100644 --- a/tests/js/screenshots.test.js +++ b/tests/js/screenshots.test.js @@ -1,7 +1,8 @@ // The screenshots of the docs and the READMEs: every one is shown somewhere, comes as a light and a dark // one, and is shown with alt text. On the site each one carries the fragment that shows it in its theme // only (#only-light, #only-dark); a README shows a pair as a whose holds the dark one. -// eizedev/pivotkit has the same checks (tests/screenshots.test.js). +// Images count as Markdown images, ![alt](src), and ; reference-style images are not +// read (the docs use none). eizedev/pivotkit has the same checks (tests/screenshots.test.js). // // The screenshots live in two places: docs/assets/ (the pages and the READMEs show them from there) and // assets/screenshot-* (the README's quick start and the showcase app; docs/site/Build-Site.ps1 copies @@ -42,6 +43,13 @@ function resolve(page, src) { /** The Markdown images of a text: { src, alt, fragment }. */ const markdownImages = (text) => [...text.matchAll(/!\[([^\]]*)\]\(([^)\s#]+)(#[\w-]+)?\)/g)].map((m) => ({ alt: m[1], src: m[2], fragment: m[3] ?? "" })); +/** The elements outside a : { src, alt, fragment }. */ +const htmlImages = (text) => + [...text.replace(/[\s\S]*?<\/picture>/g, "").matchAll(/]*>/g)].map(([tag]) => { + const [src, fragment = ""] = (/src="([^"]+)"/.exec(tag)?.[1] ?? "").split(/(?=#)/); + return { src, alt: /alt="([^"]*)"/.exec(tag)?.[1] ?? "", fragment }; + }); + /** The elements of a text: { dark, light, alt } from its srcset and its . */ const pictures = (text) => [...text.matchAll(/([\s\S]*?)<\/picture>/g)].map((m) => ({ @@ -54,7 +62,7 @@ const pages = sitePages().map((page) => `docs/${page}`); /** Every screenshot shown: { file, page, alt, fragment, picture }. */ const shown = [...pages, ...readmes()].flatMap((page) => { const text = readFileSync(join(root, page), "utf8"); - const images = markdownImages(text).map((image) => ({ ...image, file: resolve(page, image.src), page })); + const images = [...markdownImages(text), ...htmlImages(text)].map((image) => ({ ...image, file: resolve(page, image.src), page })); const fromPictures = pictures(text).flatMap(({ dark, light, alt }) => [ { file: resolve(page, dark), page, alt, fragment: "", picture: "dark" }, { file: resolve(page, light), page, alt, fragment: "", picture: "light" }, From 492164d8795de1384c51638688011d4830ac9f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:12:57 +0100 Subject: [PATCH 3/5] docs: release checklist and an upgrading page - docs/development/release.md is the one release checklist: the release pull request with the upgrading page, CI, tag, approval, GitHub release and announcement, and the walk through the docs and entry pages in light and dark before a release is complete; RELEASING.md links it - docs/upgrading.md: how to update a module, and the breaks of each module's newest minor release and the next release, checked against the changelogs by tests/js/upgrading.test.js - getting-started.md keeps its #update anchor, which published READMEs link, and points there Refs #217 Co-Authored-By: Claude Opus 5.5 --- CONTRIBUTING.md | 2 +- RELEASING.md | 4 ++ docs/development/release.md | 67 +++++++++++++++++++++------ docs/getting-started.md | 29 +----------- docs/upgrading.md | 91 +++++++++++++++++++++++++++++++++++++ tests/js/docs-pages.test.js | 2 + tests/js/upgrading.test.js | 61 +++++++++++++++++++++++++ zensical.toml | 3 +- 8 files changed, 215 insertions(+), 44 deletions(-) create mode 100644 RELEASING.md create mode 100644 docs/upgrading.md create mode 100644 tests/js/upgrading.test.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2fd148c..d1bf3ba 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,5 +77,5 @@ Name it `PowerShellUniversal.Component.`, with `New-UD` and the type ## Releasing a module -Maintainers release each module on its own. The steps and the one-time setup are in +Maintainers release each module on its own. The checklist and the one-time setup are in [Releases](docs/development/release.md). diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..b5aa9e4 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,4 @@ +# Releasing + +Only maintainers release. The checklist for a module release and the one-time setup are on the +docs site, in one place: [Releases](docs/development/release.md). diff --git a/docs/development/release.md b/docs/development/release.md index 50c224b..bfd5074 100644 --- a/docs/development/release.md +++ b/docs/development/release.md @@ -1,27 +1,64 @@ --- -description: "How a module is released: CHANGELOG and ModuleVersion, the tag -v, the release workflow that publishes to the PowerShell Gallery, and the one-time setup." +description: "The maintainers' checklist for a module release: the release pull request, the tag, the approval for the PowerShell Gallery, the GitHub release and the checks before a release is complete; and the one-time setup." --- # Releases -Each module has its own SemVer `ModuleVersion` and `CHANGELOG.md` and is released on its own, from a -tag `-v` on `main`. +Only maintainers release. This page is their checklist. Each module has its own SemVer +`ModuleVersion` and `CHANGELOG.md` and is released on its own, from a tag `-v` on +`main`. A module that requires another one (a showcase app requires its component module) is +released after it: the gallery checks that the required version is there. -1. In the module's `CHANGELOG.md`, move the entries from `[Unreleased]` to `## [x.y.z] - YYYY-MM-DD`; - set `ModuleVersion` in the manifest to `x.y.z`. Merge that pull request. -2. Tag after CI has passed for that commit on `main`: the release needs its green CI run and fails - otherwise; re-run it once CI is green. Tag the merge commit: - `git tag -vx.y.z && git push origin -vx.y.z`. A tag on a commit that is not on - `main` stops the workflow before anything is built. -3. The workflow `release.yml` tests, builds and checks the module, then waits for approval in the - environment `psgallery`; after it, it publishes to the PowerShell Gallery and creates the GitHub - release with the zip, the CHANGELOG section and a link to the version's page in the gallery. For a - component module (not a demo, not a prerelease) it also starts a discussion in Announcements. +## Each release + +### 1. The release pull request + +- In the module's `CHANGELOG.md`, move the entries from `[Unreleased]` to `## [x.y.z] - YYYY-MM-DD`. + Pick the version by [Versioning](../versioning.md). +- Set `ModuleVersion` in the module's manifest to `x.y.z`. +- On [Upgrading](../upgrading.md), move the module's entries from "In the next release" to its own + section for the new minor version, replacing the section of the one before. Its breaks stay in + the `CHANGELOG.md`. `tests/js/upgrading.test.js` checks that the page and the changelogs agree. +- Merge the pull request. + +### 2. Tag + +Wait until CI has passed for the merge commit on `main`. The release needs that green CI run and +fails otherwise; re-run it once CI is green. Then tag the merge commit: + +```bash +git tag -vx.y.z && git push origin -vx.y.z +``` + +A tag on a commit that is not on `main` stops the workflow before anything is built. + +### 3. Approve the publication + +`release.yml` tests, builds and checks the module, then waits for approval in the environment +`psgallery`. Approve it there. It then publishes the module to the PowerShell Gallery. + +### 4. GitHub release and announcement + +After the gallery, the workflow creates the GitHub release with the zip, the CHANGELOG section and a +link to the version's page in the gallery. For a component module (not a showcase app, not a +prerelease) it also starts a discussion in Announcements. Check that both are there. + +### 5. Before the release is complete + +- **Walk through the docs with the built module.** Install the released version from the gallery on + a PSU instance and follow [Getting started](../getting-started.md) and the module's overview page + as written. Fix what does not run. +- **Look at the entry pages in light and dark**: the README, the docs start page and the module + overview, of this repository and of [pivotkit](https://github.com/eizedev/pivotkit), whose docs the + pivot pages hand readers over to. Each image must show, in the theme it was made for. + +## Trial run "Run workflow" on `release.yml` with a tag name checks a release without publishing anything. That trial run checks main membership and the CI run of the ref you choose to run it on, not of the tag -you type. A module that requires another one (a demo requires its component module) is released after -it: the gallery checks that the required version is there. +you type. + +## One-time setup Once per repository: Settings > Environments > `psgallery` with the maintainers as required reviewers and deployment tags `*-v*`; in that environment (never as a repository secret) the secret diff --git a/docs/getting-started.md b/docs/getting-started.md index 7f8f601..a74382c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,5 +1,5 @@ --- -description: "Install, update and first steps with the PowerShell Universal component modules: a first chart, your own data from SQL, REST or PowerShell objects, and the showcase apps." +description: "Install and first steps with the PowerShell Universal component modules: a first chart, your own data from SQL, REST or PowerShell objects, and the showcase apps." --- # Getting started @@ -22,32 +22,7 @@ when a page uses it. ## Update -1. Install the new version of each module you use, the way you installed it: - - ```powershell - Install-PSResource -Name PowerShellUniversal.Component.Pivot # repeat for each module - ``` - - `Install-PSResource` puts the new version in a folder of its own, next to the old one. From a release - zip, copy the new `` folder next to the old one in `Modules//`. - -2. Restart PSU. PowerShell imports the newest version it finds in the folder, but a process that has - already imported the module keeps that version. -3. Readers reload their open pages. The bundle's file name holds a hash of its content, so a reload - fetches the new code. -4. Remove the old version folder once nothing uses it. Installing a new version does not remove it. - -What to check: - -- **Every module carries its own copy of the code the modules share.** A fix in that code reaches a - module only with that module's own release. Update every module you use, and read each module's - `CHANGELOG.md`. -- **Readers' views (Pivot)** live outside the module folder: in the reader's browser, in - `pivot-views` next to the repository (`New-UDPivotFileTemplateStore`), or in your own storage - (`New-UDPivotTemplateStore`). A release refuses view files of a newer format than it reads, so - check before you go back to an older one: [View files](pivot/templates.md#view-files). -- **A published folder for the pivot schema** names the old version folder: - [Your own copy of the schema](pivot/schema.md#your-own-copy-of-the-schema). +How to update a module and what to change for its newest release: [Upgrading](upgrading.md). ## A first chart diff --git a/docs/upgrading.md b/docs/upgrading.md new file mode 100644 index 0000000..7953457 --- /dev/null +++ b/docs/upgrading.md @@ -0,0 +1,91 @@ +--- +title: Upgrading +description: How to update a module on the PowerShell Universal server, and what to change in your apps for the newest release of each module. +--- + +# Upgrading + +For everyone who runs the modules on a PSU server. The first part says how to update. The second +lists the changes of each module's newest release that need your action, and those of the next +release once `main` has any. Every other change is in the module's `CHANGELOG.md`. +[Versioning](versioning.md) says which releases may break things. + +## Update a module { #update } + +Read [what changed](#changes) first. + +1. Install the new version of each module you use, the way you installed it: + + ```powershell + Update-PSResource -Name PowerShellUniversal.Component.Pivot # the newest version + Install-PSResource -Name PowerShellUniversal.Component.Pivot -Version # a version you name + ``` + + Both put the new version in a folder of its own, next to the old one. From a release zip, copy + the new `` folder next to the old one in `Modules//`. + +2. Restart PSU. PowerShell imports the newest version it finds in the folder, but a process that has + already imported the module keeps that version. +3. Readers reload their open pages. The bundle's file name holds a hash of its content, so a reload + fetches the new code. +4. Remove the old version folder once nothing uses it. Installing a new version does not remove it. + +What to check: + +- **Every module carries its own copy of the code the modules share.** A fix in that code reaches a + module only with that module's own release. Update every module you use. +- **Readers' views (Pivot)** live outside the module folder: in the reader's browser, in + `pivot-views` next to the repository (`New-UDPivotFileTemplateStore`), or in your own storage + (`New-UDPivotTemplateStore`). A release refuses view files of a newer format than it reads, so + check before you go back to an older one: [View files](pivot/templates.md#view-files). +- **A published folder for the pivot schema** names the old version folder: + [Your own copy of the schema](pivot/schema.md#your-own-copy-of-the-schema). +- **A showcase app** requires a minimum version of its component module. Update the component + module first. + +## What changed { #changes } + +Each entry names who is affected and what to do. Releases not listed here need no action. + +### In the next release { #next } + +ECharts module: + +- **The chart's own texts follow `-Locale`**, or the browser's language without it: the toolbox, "Total" + in a stack's tooltip, the box plot's statistics and its "Outliers" series, the histogram's "Count" + axis, the candlestick's "Price" and "Volume" series, and "No data". + - Who is affected: an app with a `-ColorMap` entry or a click handler that names "Outliers", + "Volume" or "Price". + - What to do: set `-Locale` on that chart and name the series in that language, or set + `-Locale en-US` to keep the English names. + +### ECharts 0.3 { #echarts } + +- **A tooltip of a bar, line, area or step chart shows the element under the pointer**, with the + stack's total for a stacked segment, instead of every series at that position. + - Who is affected: readers who compare the series of a position in the tooltip. + - What to do: `-TooltipMode Axis` lists every series at the position. + +### Pivot 0.10 { #pivot } + +- **A reader's CSV or Excel file with numbers such as `1,234` or `1.500`** is read in the notation of + the report's locale, with a note that says so. + - Who is affected: readers of a report with `-AllowImport` who load such files. + - What to do: check such a column after the update. +- **`-Labels` has no key `settingsShort`.** + - Who is affected: an app that sets it. + - What to do: remove the key. +- **A shared view of a template store takes no origin from the request's headers** for a + `-SchemaUrl` path. It takes the origin of an https `PSU_COMPONENT_PIVOT_SCHEMA_URL`, else + pivotkit's schema address. + - Who is affected: an app that publishes shared views with a `-SchemaUrl` path and no https default. + - What to do: to keep your own address in them, set `PSU_COMPONENT_PIVOT_SCHEMA_URL` to it. + +### Older releases { #older } + +The breaks of every release, marked **Breaking:**, are in each module's `CHANGELOG.md`: +[ECharts](https://github.com/eizedev/powershell-universal-components/blob/HEAD/modules/PowerShellUniversal.Component.ECharts/CHANGELOG.md), +[Perspective](https://github.com/eizedev/powershell-universal-components/blob/HEAD/modules/PowerShellUniversal.Component.Perspective/CHANGELOG.md), +[Pivot](https://github.com/eizedev/powershell-universal-components/blob/HEAD/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md), +[ECharts showcase app](https://github.com/eizedev/powershell-universal-components/blob/HEAD/modules/PowerShellUniversal.Component.ECharts.Demo/CHANGELOG.md), +[Pivot showcase app](https://github.com/eizedev/powershell-universal-components/blob/HEAD/modules/PowerShellUniversal.Component.Pivot.Demo/CHANGELOG.md). diff --git a/tests/js/docs-pages.test.js b/tests/js/docs-pages.test.js index ed04b12..1ed5382 100644 --- a/tests/js/docs-pages.test.js +++ b/tests/js/docs-pages.test.js @@ -130,6 +130,8 @@ const RELEASE_NAME = /\b(?:pivotkit(?:-[a-z]+)?|PowerShellUniversal\.Component\. */ const RELEASE_NAMES_ALLOWED = [ { file: "docs/versioning.md" }, + // the breaks of each module's newest release, by release + { file: "docs/upgrading.md" }, // the versions the modules were tested with { file: "docs/index.md", section: "Requirements" }, ]; diff --git a/tests/js/upgrading.test.js b/tests/js/upgrading.test.js new file mode 100644 index 0000000..c8fbf83 --- /dev/null +++ b/tests/js/upgrading.test.js @@ -0,0 +1,61 @@ +// docs/upgrading.md lists the breaks of each module's newest minor release and of the next release, as +// the CHANGELOGs mark them (**Breaking:**). The release pull request updates the page with the +// CHANGELOG (docs/development/release.md); this test fails until both agree in the number of breaks. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync, readdirSync } from "node:fs"; + +const root = new URL("../../", import.meta.url); +const PREFIX = "PowerShellUniversal.Component."; +const read = (path) => readFileSync(new URL(path, root), "utf8"); + +/** + * The sections of a CHANGELOG by release ("Unreleased", "0.10.1"), newest first, with the number of + * entries marked **Breaking:** in each. + * @param {string} text + * @returns {{ release: string, breaks: number }[]} + */ +function changelogReleases(text) { + return text.split(/^(?=## \[)/m).slice(1).map((part) => ({ + release: /^## \[([^\]]+)\]/.exec(part)[1], + breaks: (part.match(/^- \*\*Breaking:\*\*/gm) ?? []).length, + })); +} + +/** + * The "### " sections of the upgrading page by heading, with their top-level list items. + * @param {string} text + * @returns {Map} + */ +function upgradingSections(text) { + const changes = text.slice(text.indexOf("\n## What changed")); + return new Map(changes.split(/^(?=### )/m).slice(1).map((part) => [ + /^### (.+?)(?: \{ #[\w-]+ \})?$/m.exec(part)[1], + (part.match(/^- /gm) ?? []).length, + ])); +} + +test("changelogReleases and upgradingSections read releases, headings and breaks", () => { + const log = "# Changelog\n\n## [Unreleased]\n\n- **Breaking:** a\n - Who\n\n## [0.2.0] - 2026-01-01\n\n- **Breaking:** b\n- c\n"; + assert.deepEqual(changelogReleases(log), [{ release: "Unreleased", breaks: 1 }, { release: "0.2.0", breaks: 1 }]); + const page = "# U\n\n## What changed { #changes }\n\n### In the next release { #next }\n\n- **a**\n - Who\n\n### Pivot 0.2 { #pivot }\n\n- **b**\n"; + assert.deepEqual([...upgradingSections(page)], [["In the next release", 1], ["Pivot 0.2", 1]]); +}); + +test("the upgrading page lists the breaks of each module's newest minor release and of the next release", () => { + const expected = new Map(); + let next = 0; + for (const folder of readdirSync(new URL("modules/", root)).filter((name) => name.startsWith(PREFIX)).sort()) { + const releases = changelogReleases(read(`modules/${folder}/CHANGELOG.md`)); + next += releases.find((r) => r.release === "Unreleased")?.breaks ?? 0; + const newest = releases.find((r) => r.release !== "Unreleased"); + if (!newest) continue; + const minor = newest.release.split(".").slice(0, 2).join("."); + const breaks = releases.filter((r) => r.release.startsWith(`${minor}.`)).reduce((sum, r) => sum + r.breaks, 0); + if (breaks) expected.set(`${folder.slice(PREFIX.length)} ${minor}`, breaks); + } + if (next) expected.set("In the next release", next); + const sections = upgradingSections(read("docs/upgrading.md")); + sections.delete("Older releases"); + assert.deepEqual(Object.fromEntries(sections), Object.fromEntries(expected), "docs/upgrading.md: one section per module whose newest minor release has breaks, one item per break; release PR: docs/development/release.md"); +}); diff --git a/zensical.toml b/zensical.toml index 108a140..b56484c 100644 --- a/zensical.toml +++ b/zensical.toml @@ -18,6 +18,7 @@ nav = [ { "Overview" = "index.md" }, { "Getting started" = "getting-started.md" }, { "Versioning" = "versioning.md" }, + { "Upgrading" = "upgrading.md" }, { "ECharts" = [ { "Overview" = "echarts/index.md" }, { "Showcase app (demo)" = "demo.md" }, @@ -116,7 +117,7 @@ PowerShell objects. Not affiliated with Devolutions. llms-full.txt holds every p """ [project.plugins.llmstxt.sections] -"Start" = ["index.md", "getting-started.md", "versioning.md"] +"Start" = ["index.md", "getting-started.md", "versioning.md", "upgrading.md"] "ECharts module" = ["echarts/*.md", "demo.md"] "Perspective module" = ["perspective/*.md"] "Pivot module" = ["pivot/*.md"] From 554497118e5db99e858a6b7b813ca9126de2f523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:15:27 +0100 Subject: [PATCH 4/5] chore: raise the docs total for the upgrading page Refs #217 Co-Authored-By: Claude Opus 5.5 --- build/growth-baseline.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/growth-baseline.json b/build/growth-baseline.json index 7e32c25..4de323c 100644 --- a/build/growth-baseline.json +++ b/build/growth-baseline.json @@ -3,7 +3,7 @@ "pages": { "README.md": [108] }, - "totalLines": 4908 + "totalLines": 5012 }, "javascript": { "complexity": { From ad2e581df03eaa5e485c60c6300217cd6c3d25c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:21:29 +0100 Subject: [PATCH 5/5] docs: release walk-through before the tag, upgrading page and test after review Refs #217 Co-Authored-By: Claude Opus 5.5 --- docs/development/release.md | 41 +++++++++++++++++++++++-------------- docs/upgrading.md | 11 +++++----- tests/js/upgrading.test.js | 16 +++++++++++---- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/docs/development/release.md b/docs/development/release.md index bfd5074..4513749 100644 --- a/docs/development/release.md +++ b/docs/development/release.md @@ -1,5 +1,5 @@ --- -description: "The maintainers' checklist for a module release: the release pull request, the tag, the approval for the PowerShell Gallery, the GitHub release and the checks before a release is complete; and the one-time setup." +description: "The maintainers' checklist for a module release: the release pull request, a walk through the docs, the tag, the approval for the PowerShell Gallery, the GitHub release and the checks before a release is complete; and the one-time setup." --- # Releases @@ -14,14 +14,27 @@ released after it: the gallery checks that the required version is there. ### 1. The release pull request - In the module's `CHANGELOG.md`, move the entries from `[Unreleased]` to `## [x.y.z] - YYYY-MM-DD`. - Pick the version by [Versioning](../versioning.md). -- Set `ModuleVersion` in the module's manifest to `x.y.z`. -- On [Upgrading](../upgrading.md), move the module's entries from "In the next release" to its own - section for the new minor version, replacing the section of the one before. Its breaks stay in - the `CHANGELOG.md`. `tests/js/upgrading.test.js` checks that the page and the changelogs agree. + Pick the version by [Versioning](../versioning.md). A prerelease (`x.y.z-rc1`) also sets + `Prerelease` in the manifest's `PSData`. +- Set `ModuleVersion` in the module's manifest to `x.y.z`. The release stops when the tag, the + manifest or the CHANGELOG section disagree. +- For a showcase app that uses something new of its component module, raise the minimum version in + its `RequiredModules`, and release the component module first. +- Update [Upgrading](../upgrading.md). `tests/js/upgrading.test.js` checks it against the changelogs: + - A new minor version with breaks: move the module's entries from "In the next release" into a + section of their own for that version, in place of the module's section for the minor before. + - A new minor version without breaks: remove the module's section for the minor before. + - A patch release: nothing moves. - Merge the pull request. -### 2. Tag +### 2. Walk through the docs with the built module + +Build the module from the merge commit (`./build/Build-Module.ps1`, or the zip of a +[trial run](#trial-run)) and install it on a PSU instance. Follow +[Getting started](../getting-started.md) and the module's overview page as written. Fix what does not +run before you tag: a published version cannot be changed. + +### 3. Tag Wait until CI has passed for the merge commit on `main`. The release needs that green CI run and fails otherwise; re-run it once CI is green. Then tag the merge commit: @@ -32,25 +45,23 @@ git tag -vx.y.z && git push origin -vx.y.z A tag on a commit that is not on `main` stops the workflow before anything is built. -### 3. Approve the publication +### 4. Approve the publication `release.yml` tests, builds and checks the module, then waits for approval in the environment `psgallery`. Approve it there. It then publishes the module to the PowerShell Gallery. -### 4. GitHub release and announcement - After the gallery, the workflow creates the GitHub release with the zip, the CHANGELOG section and a link to the version's page in the gallery. For a component module (not a showcase app, not a -prerelease) it also starts a discussion in Announcements. Check that both are there. +prerelease) it also starts a discussion in Announcements. When a step fails, re-run the failed jobs: +each step skips what already exists. ### 5. Before the release is complete -- **Walk through the docs with the built module.** Install the released version from the gallery on - a PSU instance and follow [Getting started](../getting-started.md) and the module's overview page - as written. Fix what does not run. +- Check that the version is in the gallery and that the GitHub release and its announcement are there. - **Look at the entry pages in light and dark**: the README, the docs start page and the module overview, of this repository and of [pivotkit](https://github.com/eizedev/pivotkit), whose docs the - pivot pages hand readers over to. Each image must show, in the theme it was made for. + pivot pages hand readers over to. Each image must show, in the theme it was made for. A problem + here is fixed in the docs, or with a patch release. ## Trial run diff --git a/docs/upgrading.md b/docs/upgrading.md index 7953457..714bbe3 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -17,11 +17,11 @@ Read [what changed](#changes) first. 1. Install the new version of each module you use, the way you installed it: ```powershell - Update-PSResource -Name PowerShellUniversal.Component.Pivot # the newest version - Install-PSResource -Name PowerShellUniversal.Component.Pivot -Version # a version you name + Update-PSResource -Name PowerShellUniversal.Component.Pivot # repeat for each module ``` - Both put the new version in a folder of its own, next to the old one. From a release zip, copy + `Update-PSResource` puts the newest version in a folder of its own, next to the old one. To take + a version you name instead, see [Versioning](versioning.md#before-100). From a release zip, copy the new `` folder next to the old one in `Modules//`. 2. Restart PSU. PowerShell imports the newest version it finds in the folder, but a process that has @@ -45,7 +45,8 @@ What to check: ## What changed { #changes } -Each entry names who is affected and what to do. Releases not listed here need no action. +The breaks of each module's newest minor release and of the next release. Each entry names who is +affected and what to do. Older breaks are in the changelogs, [below](#older). ### In the next release { #next } @@ -77,7 +78,7 @@ ECharts module: - What to do: remove the key. - **A shared view of a template store takes no origin from the request's headers** for a `-SchemaUrl` path. It takes the origin of an https `PSU_COMPONENT_PIVOT_SCHEMA_URL`, else - pivotkit's schema address. + pivotkit's schema address. A view a reader saves for themselves keeps the origin of the request. - Who is affected: an app that publishes shared views with a `-SchemaUrl` path and no https default. - What to do: to keep your own address in them, set `PSU_COMPONENT_PIVOT_SCHEMA_URL` to it. diff --git a/tests/js/upgrading.test.js b/tests/js/upgrading.test.js index c8fbf83..cb10362 100644 --- a/tests/js/upgrading.test.js +++ b/tests/js/upgrading.test.js @@ -1,6 +1,7 @@ // docs/upgrading.md lists the breaks of each module's newest minor release and of the next release, as -// the CHANGELOGs mark them (**Breaking:**). The release pull request updates the page with the -// CHANGELOG (docs/development/release.md); this test fails until both agree in the number of breaks. +// the CHANGELOGs mark them (**Breaking:**, newest release first). The release pull request updates the +// page with the CHANGELOG (docs/development/release.md); this test fails until both agree in the +// number of breaks. It counts, so a reworded entry is the reviewer's to catch. import { test } from "node:test"; import assert from "node:assert/strict"; import { readFileSync, readdirSync } from "node:fs"; @@ -19,6 +20,8 @@ function changelogReleases(text) { return text.split(/^(?=## \[)/m).slice(1).map((part) => ({ release: /^## \[([^\]]+)\]/.exec(part)[1], breaks: (part.match(/^- \*\*Breaking:\*\*/gm) ?? []).length, + // a break written another way would be missed: "Breaking" in bold anywhere else + loose: (part.match(/\*\*Breaking/gi) ?? []).length, })); } @@ -35,9 +38,13 @@ function upgradingSections(text) { ])); } +/** The name of a module's section: "Pivot", or "Pivot showcase app" for PowerShellUniversal.Component.Pivot.Demo. */ +const sectionName = (folder) => folder.slice(PREFIX.length).replace(/\.Demo$/, " showcase app"); + test("changelogReleases and upgradingSections read releases, headings and breaks", () => { const log = "# Changelog\n\n## [Unreleased]\n\n- **Breaking:** a\n - Who\n\n## [0.2.0] - 2026-01-01\n\n- **Breaking:** b\n- c\n"; - assert.deepEqual(changelogReleases(log), [{ release: "Unreleased", breaks: 1 }, { release: "0.2.0", breaks: 1 }]); + assert.deepEqual(changelogReleases(log), [{ release: "Unreleased", breaks: 1, loose: 1 }, { release: "0.2.0", breaks: 1, loose: 1 }]); + assert.deepEqual(changelogReleases("# Changelog\n\n## [1.0.0]\n\n - **Breaking** a\n").map((r) => [r.breaks, r.loose]), [[0, 1]]); const page = "# U\n\n## What changed { #changes }\n\n### In the next release { #next }\n\n- **a**\n - Who\n\n### Pivot 0.2 { #pivot }\n\n- **b**\n"; assert.deepEqual([...upgradingSections(page)], [["In the next release", 1], ["Pivot 0.2", 1]]); }); @@ -47,12 +54,13 @@ test("the upgrading page lists the breaks of each module's newest minor release let next = 0; for (const folder of readdirSync(new URL("modules/", root)).filter((name) => name.startsWith(PREFIX)).sort()) { const releases = changelogReleases(read(`modules/${folder}/CHANGELOG.md`)); + for (const r of releases) assert.equal(r.loose, r.breaks, `${folder} ${r.release}: write each break as a top-level item "- **Breaking:** ..."`); next += releases.find((r) => r.release === "Unreleased")?.breaks ?? 0; const newest = releases.find((r) => r.release !== "Unreleased"); if (!newest) continue; const minor = newest.release.split(".").slice(0, 2).join("."); const breaks = releases.filter((r) => r.release.startsWith(`${minor}.`)).reduce((sum, r) => sum + r.breaks, 0); - if (breaks) expected.set(`${folder.slice(PREFIX.length)} ${minor}`, breaks); + if (breaks) expected.set(`${sectionName(folder)} ${minor}`, breaks); } if (next) expected.set("In the next release", next); const sections = upgradingSections(read("docs/upgrading.md"));