Update docs

This commit is contained in:
github-actions
2023-09-19 19:19:10 +00:00
commit dbe796d542
624 changed files with 107720 additions and 0 deletions

View File

@ -0,0 +1,33 @@
#!/usr/bin/env node
// Adjusts the format of the changelog that changesets generates.
// This is run automatically when npm version is run.
const fs = require('fs');
const changelog = fs.readFileSync('CHANGELOG.md', 'utf8');
// Groups:
// - 1: Pull Request Number and URL
// - 2: Changeset entry
const RELEASE_LINE_REGEX = /^- (\[#.*?\]\(.*?\))?.*?! - (.*)$/gm;
// Captures vX.Y.Z or vX.Y.Z-rc.W
const VERSION_TITLE_REGEX = /^## (\d+\.\d+\.\d+(-rc\.\d+)?)$/gm;
const isPrerelease = process.env.PRERELEASE === 'true';
const formatted = changelog
// Remove titles
.replace(/^### Major Changes\n\n/gm, '')
.replace(/^### Minor Changes\n\n/gm, '')
.replace(/^### Patch Changes\n\n/gm, '')
// Remove extra whitespace between items
.replace(/^(- \[.*\n)\n(?=-)/gm, '$1')
// Format each release line
.replace(RELEASE_LINE_REGEX, (_, pr, entry) => (pr ? `- ${entry} (${pr})` : `- ${entry}`))
// Add date to new version
.replace(VERSION_TITLE_REGEX, `\n## $1 (${new Date().toISOString().split('T')[0]})`)
// Conditionally allow vX.Y.Z.rc-.W sections only in prerelease
.replace(/^## \d\.\d\.\d-rc\S+[^]+?(?=^#)/gm, section => (isPrerelease ? section : ''));
fs.writeFileSync('CHANGELOG.md', formatted);