From d4f11d8bb74fd9ecc09fb27eac7ff6a805adea56 Mon Sep 17 00:00:00 2001 From: AlCalzone Date: Fri, 30 Apr 2021 10:05:59 +0200 Subject: [PATCH] feat: support ** and __ in the new version placeholder (#62) --- CHANGELOG.md | 4 +++- README.md | 10 +++++----- build/release.js | 10 ++++++---- src/release.ts | 9 +++++---- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 398ce02..73bdbd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ # Changelog +## **WORK IN PROGRESS** +* Support both `**WORK IN PROGRESS**` and `__WORK IN PROGRESS__` as placeholders ## 1.9.0 (2021-04-23) * Allow defining different remotes than origin by using `r` flag, e.g. `-r upstream/master` diff --git a/README.md b/README.md index fcd7168..049c631 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Together with the corresponding **Github Actions** workflow (more on that below) ## Changelog ``` @@ -38,7 +38,7 @@ Together with the corresponding **Github Actions** workflow (more on that below) # Changelog ``` @@ -50,10 +50,10 @@ In order to use this script, you need to maintain the changelog in either `READM # Changelog -## __WORK IN PROGRESS__ +## **WORK IN PROGRESS** * Did some changes * Did some more changes @@ -71,7 +71,7 @@ If you are using `README.md`, the script can automatically move old changelog en ### Add free text in the changelog entry headline Starting with `v1.8.0`, you can add free text after the placeholder: ```md -## __WORK IN PROGRESS__ - 2020 Doomsday release +## **WORK IN PROGRESS** - 2020 Doomsday release ``` will be turned into ```md diff --git a/build/release.js b/build/release.js index a636328..935f998 100644 --- a/build/release.js +++ b/build/release.js @@ -10,10 +10,10 @@ npx AlCalzone/release-script#v1.0.0 -- [--dry] PLACEHOLDER for next version in CHANGELOG.md: - ## __WORK IN PROGRESS__ + ## **WORK IN PROGRESS** PLACEHOLDER for next version in README.md: - ### __WORK IN PROGRESS__ + ### **WORK IN PROGRESS** */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { @@ -124,10 +124,11 @@ else { // CHANGELOG_OLD is only used if the main changelog is in the readme const changelogOldPath = path.join(rootDir, "CHANGELOG_OLD.md"); const hasChangelogOld = isChangelogInReadme && fs.existsSync(changelogOldPath); -const CHANGELOG_PLACEHOLDER = CHANGELOG_PLACEHOLDER_PREFIX + " __WORK IN PROGRESS__"; +const CHANGELOG_MARKERS = ["**WORK IN PROGRESS**", "__WORK IN PROGRESS__"]; +const CHANGELOG_PLACEHOLDER = `${CHANGELOG_PLACEHOLDER_PREFIX} ${CHANGELOG_MARKERS[0]}`; // The regex for the placeholder includes an optional free text at the end, e.g. // ### __WORK IN PROGRESS__ "2020 Doomsday release" -const CHANGELOG_PLACEHOLDER_REGEX = new RegExp("^" + CHANGELOG_PLACEHOLDER + "(.*?)$", "gm"); +const CHANGELOG_PLACEHOLDER_REGEX = new RegExp(`^${CHANGELOG_PLACEHOLDER_PREFIX} (?:${CHANGELOG_MARKERS.map(m => m.replace(/\*/g, "\\*")).join("|")})(.*?)$`, "gm"); // check if the changelog contains exactly 1 occurence of the changelog placeholder switch ((changelog.match(CHANGELOG_PLACEHOLDER_REGEX) || []).length) { case 0: @@ -310,6 +311,7 @@ ${newChangelog}`); ? [ `git add -A -- ":(exclude).commitmessage"`, `git commit -F ".commitmessage" --no-verify`, + // lerna does the rest for us ] : [ isYarn ? `yarn install` : `npm install`, diff --git a/src/release.ts b/src/release.ts index 23563a3..08844dd 100644 --- a/src/release.ts +++ b/src/release.ts @@ -9,10 +9,10 @@ npx AlCalzone/release-script#v1.0.0 -- [--dry] PLACEHOLDER for next version in CHANGELOG.md: - ## __WORK IN PROGRESS__ + ## **WORK IN PROGRESS** PLACEHOLDER for next version in README.md: - ### __WORK IN PROGRESS__ + ### **WORK IN PROGRESS** */ @@ -113,12 +113,13 @@ if (!fs.existsSync(changelogPath)) { const changelogOldPath = path.join(rootDir, "CHANGELOG_OLD.md"); const hasChangelogOld = isChangelogInReadme && fs.existsSync(changelogOldPath); +const CHANGELOG_MARKERS = ["**WORK IN PROGRESS**", "__WORK IN PROGRESS__"] as const; const CHANGELOG_PLACEHOLDER = - CHANGELOG_PLACEHOLDER_PREFIX + " __WORK IN PROGRESS__"; + `${CHANGELOG_PLACEHOLDER_PREFIX} ${CHANGELOG_MARKERS[0]}`; // The regex for the placeholder includes an optional free text at the end, e.g. // ### __WORK IN PROGRESS__ "2020 Doomsday release" const CHANGELOG_PLACEHOLDER_REGEX = new RegExp( - "^" + CHANGELOG_PLACEHOLDER + "(.*?)$", + `^${CHANGELOG_PLACEHOLDER_PREFIX} (?:${CHANGELOG_MARKERS.map(m => m.replace(/\*/g, "\\*")).join("|")})(.*?)$`, "gm", );