Skip to content

Commit

Permalink
feat: support ** and __ in the new version placeholder (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Apr 30, 2021
1 parent 803a38a commit d4f11d8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Changelog
<!--
Placeholder for the next version (at the beginning of the line):
## __WORK IN PROGRESS__
## **WORK IN PROGRESS**
-->
## **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`
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Together with the corresponding **Github Actions** workflow (more on that below)
## Changelog
<!--
Placeholder for the next version (at the beginning of the line):
### __WORK IN PROGRESS__
### **WORK IN PROGRESS**
-->
```

Expand All @@ -38,7 +38,7 @@ Together with the corresponding **Github Actions** workflow (more on that below)
# Changelog
<!--
Placeholder for the next version (at the beginning of the line):
## __WORK IN PROGRESS__
## **WORK IN PROGRESS**
-->
```

Expand All @@ -50,10 +50,10 @@ In order to use this script, you need to maintain the changelog in either `READM
# Changelog
<!--
Placeholder for the next version (at the beginning of the line):
## __WORK IN PROGRESS__
## **WORK IN PROGRESS**
-->
## __WORK IN PROGRESS__
## **WORK IN PROGRESS**
* Did some changes
* Did some more changes
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions build/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
npx AlCalzone/release-script#v1.0.0 -- <version> [--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) {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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`,
Expand Down
9 changes: 5 additions & 4 deletions src/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
npx AlCalzone/release-script#v1.0.0 -- <version> [--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**
*/

Expand Down Expand Up @@ -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",
);

Expand Down

0 comments on commit d4f11d8

Please sign in to comment.