A local-first personal finance app
[AI] Add auto-generated Upcoming Release docs page (#8065)
Matiss Janis Aboltins75dd9f674a9e
diff --git a/packages/ci-actions/bin/release-notes-generate.mjs b/packages/ci-actions/bin/release-notes-generate.mjsindex 579c9bb12f..25cbd91a65 100644--- a/packages/ci-actions/bin/release-notes-generate.mjs+++ b/packages/ci-actions/bin/release-notes-generate.mjs@@ -3,13 +3,7 @@ import * as fs from 'node:fs/promises';import { join } from 'node:path';import { inspect, promisify } from 'node:util';-import matter from 'gray-matter';-import listify from 'listify';--import {- categoryAutocorrections,- categoryOrder,-} from '../src/release-notes/util.mjs';+import { formatNotes, parseReleaseNotes } from '../src/release-notes/util.mjs';const exec = promisify(childProcess.exec);@@ -134,6 +128,7 @@ await group('Prepare branch', async () => {const { notesByCategory, files } = await parseReleaseNotes('upcoming-release-notes',+ repo,);const categorizedNotes = formatNotes(notesByCategory);@@ -273,48 +268,10 @@ await group('Commit and push', async () => {await exec('git push origin', { stdio: 'inherit' });});-async function parseReleaseNotes(dir) {- const files = (await fs.readdir(dir)).filter(f => f.match(/^\d+\.md$/));- const notes = files.map(async name => {- const content = await fs.readFile(join(dir, name), 'utf-8');- const { data, content: body } = matter(content);- const number = name.replace('.md', '');- const authors = listify(- data.authors.map(a => `@${a}`),- { finalWord: '&' },- );- return {- category: categoryAutocorrections[data.category] ?? data.category,- value: `- [#${number}](https://github.com/actualbudget/${repo}/pull/${number}) ${body.trim()} — thanks ${authors}`,- };- });-- const notesByCategory = (await Promise.all(notes)).reduce(- (acc, note) => {- if (!acc[note.category]) {- console.log(`WARNING: Unrecognized category "${note.category}"`);- acc[note.category] = [];- }- acc[note.category].push(note.value);- return acc;- },- Object.fromEntries(categoryOrder.map(c => [c, []])),- );-- return { notesByCategory, files };-}-function escapeRegExp(str) {return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');}-function formatNotes(notes) {- return Object.entries(notes)- .filter(([_, values]) => values.length > 0)- .map(([category, values]) => `#### ${category}\n\n${values.join('\n')}`)- .join('\n\n');-}-async function collapsedLog(name, value) {await group(name, () => {if (typeof value === 'string') {diff --git a/packages/ci-actions/src/release-notes/util.mjs b/packages/ci-actions/src/release-notes/util.mjsindex f25eb5ca70..5ccd13bb16 100644--- a/packages/ci-actions/src/release-notes/util.mjs+++ b/packages/ci-actions/src/release-notes/util.mjs@@ -1,3 +1,9 @@+import * as fs from 'node:fs/promises';+import { join } from 'node:path';++import matter from 'gray-matter';+import listify from 'listify';+export const categoryAutocorrections = {Feature: 'Features',Enhancement: 'Enhancements',@@ -10,3 +16,41 @@ export const categoryOrder = ['Bugfixes','Maintenance',];++export async function parseReleaseNotes(dir, repo) {+ const files = (await fs.readdir(dir)).filter(f => f.match(/^\d+\.md$/));+ const notes = files.map(async name => {+ const content = await fs.readFile(join(dir, name), 'utf-8');+ const { data, content: body } = matter(content);+ const number = name.replace('.md', '');+ const authors = listify(+ data.authors.map(a => `@${a}`),+ { finalWord: '&' },+ );+ return {+ category: categoryAutocorrections[data.category] ?? data.category,+ value: `- [#${number}](https://github.com/actualbudget/${repo}/pull/${number}) ${body.trim()} — thanks ${authors}`,+ };+ });++ const notesByCategory = (await Promise.all(notes)).reduce(+ (acc, note) => {+ if (!acc[note.category]) {+ console.log(`WARNING: Unrecognized category "${note.category}"`);+ acc[note.category] = [];+ }+ acc[note.category].push(note.value);+ return acc;+ },+ Object.fromEntries(categoryOrder.map(c => [c, []])),+ );++ return { notesByCategory, files };+}++export function formatNotes(notes) {+ return Object.entries(notes)+ .filter(([_, values]) => values.length > 0)+ .map(([category, values]) => `#### ${category}\n\n${values.join('\n')}`)+ .join('\n\n');+}diff --git a/packages/docs/.gitignore b/packages/docs/.gitignoreindex d858cd6517..c15db37627 100644--- a/packages/docs/.gitignore+++ b/packages/docs/.gitignore@@ -1,2 +1,5 @@.docusaurusbuild++# Auto-generated on every docs build from the repo-root upcoming-release-notes/ directory+docs/upcoming-release-notes.mddiff --git a/packages/docs/docs-sidebar.js b/packages/docs/docs-sidebar.jsindex 6d924076c4..f2fadc3eab 100644--- a/packages/docs/docs-sidebar.js+++ b/packages/docs/docs-sidebar.js@@ -27,6 +27,7 @@ const sidebars = {'index','vision','releases',+ 'upcoming-release-notes',{type: 'category',label: 'Getting Started',diff --git a/packages/docs/package.json b/packages/docs/package.jsonindex f1f17482e0..3587b366c3 100644--- a/packages/docs/package.json+++ b/packages/docs/package.json@@ -4,8 +4,8 @@"private": true,"scripts": {"docusaurus": "docusaurus",- "start": "docusaurus start",- "build": "docusaurus build",+ "start": "node scripts/generate-upcoming-release-notes.mjs && docusaurus start",+ "build": "node scripts/generate-upcoming-release-notes.mjs && docusaurus build","swizzle": "docusaurus swizzle","deploy": "docusaurus deploy","clear": "docusaurus clear",@@ -28,6 +28,7 @@"react-dom": "19.2.4"},"devDependencies": {+ "@actual-app/ci-actions": "workspace:*","@docusaurus/module-type-aliases": "^3.10.0","@types/react": "^19.2.14"},diff --git a/packages/docs/scripts/generate-upcoming-release-notes.mjs b/packages/docs/scripts/generate-upcoming-release-notes.mjsnew file mode 100644index 0000000000..b6c3550c12--- /dev/null+++ b/packages/docs/scripts/generate-upcoming-release-notes.mjs@@ -0,0 +1,58 @@+// Generates `docs/upcoming-release-notes.md` from the repo-root+// `upcoming-release-notes/` directory. These per-PR notes are the changes that+// have been merged but not yet published in a stable release — i.e. what ships+// in the nightly builds. The page is regenerated on every docs build, so+// it always reflects the current set of unreleased changes.+//+// This runs before `docusaurus start` / `docusaurus build` (see package.json).++import * as fs from 'node:fs/promises';+import { join } from 'node:path';+import { fileURLToPath } from 'node:url';++import {+ formatNotes,+ parseReleaseNotes,+} from '@actual-app/ci-actions/src/release-notes/util.mjs';++const repoRoot = fileURLToPath(new URL('../../..', import.meta.url));++const notesDir = join(repoRoot, 'upcoming-release-notes');+const outputPath = join(+ repoRoot,+ 'packages/docs/docs/upcoming-release-notes.md',+);++const intro = `:::info++These changes have been merged but are **not yet part of a stable release**. They+ship in the nightly builds — try them via the \`nightly\` Docker image tag, or the+hosted demo at [nightly.actualbudget.org](https://nightly.actualbudget.org).+For changes in stable releases, see the [Release Notes](/docs/releases).++:::`;++const header = `---+title: Upcoming Release+description: Release notes for changes that are merged but not yet released, available in the nightly builds.+sidebar_label: Upcoming Release+---++<!-- This page is auto-generated from the upcoming-release-notes/ directory. Do not edit it by hand. -->++# Upcoming Release++${intro}`;++const { notesByCategory, files } = await parseReleaseNotes(notesDir, 'actual');++const body =+ files.length === 0+ ? `There are no unreleased changes right now — everything has shipped in a stable [release](/docs/releases).`+ : formatNotes(notesByCategory);++await fs.writeFile(outputPath, `${header}\n\n${body}\n`);++console.log(+ `Generated ${outputPath} from ${files.length} upcoming release note(s).`,+);diff --git a/upcoming-release-notes/8065.md b/upcoming-release-notes/8065.mdnew file mode 100644index 0000000000..8b9f8627ea--- /dev/null+++ b/upcoming-release-notes/8065.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MatissJanis]+---++Add auto-generated documentation page for upcoming release notes in Docusaurus.diff --git a/yarn.lock b/yarn.lockindex 3db2607df9..447e0ee9ce 100644--- a/yarn.lock+++ b/yarn.lock@@ -37,7 +37,7 @@ __metadata:languageName: unknownlinkType: soft-"@actual-app/ci-actions@workspace:packages/ci-actions":+"@actual-app/ci-actions@workspace:*, @actual-app/ci-actions@workspace:packages/ci-actions":version: 0.0.0-use.localresolution: "@actual-app/ci-actions@workspace:packages/ci-actions"dependencies:@@ -14786,6 +14786,7 @@ __metadata:version: 0.0.0-use.localresolution: "docs@workspace:packages/docs"dependencies:+ "@actual-app/ci-actions": "workspace:*""@docusaurus/core": "npm:^3.10.0""@docusaurus/module-type-aliases": "npm:^3.10.0""@docusaurus/plugin-content-docs": "npm:^3.10.0"