CommunitySolidServer/scripts/formatChangelog.ts
Jasper Vaneessen 7c6eae0ee6
chore: Use conventional changelog and automate config version bumps
* chore: add the reference change to npm version

* chore: remove unused require

* chore: add conventional-changelog

* chore: add git to pre-release config changes

* style: formatting

* chore: fix commit message

* chore: add no-verify to commit of configs

* chore: no more shellJs

* chore: fixing async

* chore: committing restored

* refactor: move and rename

* chore: remove shelljs devdep and old script

* chore: change npm script ref after refactor

* chore: upgrade-config code improvements

* chore: edit package.json (not package-lock)

* chore(changelog): use conventionalcommits preset

* chore: add conventional changelog config

* chore: use .versionrc directly

* chore: update changelog config

* chore: update .versionrc.json

* chore: use standard-version

* chore: change to standard version

* styling(changelog): remove a tags + formatting

* styling: conventiontal-changelog styling

* chore: postformatting of changelog

* chore: remove unnecessary dependencies

* chore: add upgrade-config to version as backup

* docs: update release.md

* styling: order scripts alphabetically

* docs: requested changes + dry-run explanation

* chore: release script to TS

* chore: use ts-node to execute the TS scripts

* docs: add some documentation comments to script

* docs: remove unnecessary newline

* docs: fix comment linting

* chore: add test/integration and templates configs

* chore: correct automated commit message

* chore: remove fdir dependency

* chore: remove manual-git-changelog dependency

* chore: impl requested changes

* docs: update script comments

* chore: ensure full cov

* chore: review comments
2022-05-17 11:36:12 +02:00

34 lines
996 B
TypeScript

#!/usr/bin/env ts-node
/* eslint-disable no-console */
import { readFile, writeFile } from 'fs-extra';
/**
* Script called after the changelog changes of standard-version
* This script can be extended to add further custom formatting
* to the changelog.
* Current automatic changes:
* - Change all version titles to H2 ("### [vX.Y.Z]" to "## [vX.Y.Z]")
*/
/**
* @param from - Regular expression to search for
* @param to - String to replace to
* @param filePath - File to search/replace
* @returns Promise
*/
async function replaceInFile(from: RegExp, to: string, filePath: string): Promise<void> {
const data = await readFile(filePath, 'utf8');
const result = data.replace(from, to);
return writeFile(filePath, result, 'utf8');
}
/**
* Ends the process and writes out an error in case something goes wrong.
*/
function endProcess(error: Error): never {
console.error(error);
process.exit(1);
}
replaceInFile(/### \[/gu, '## [', 'CHANGELOG.md').catch(endProcess);