@taiga-ui/release-it-config 0.540.0 → 0.542.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-it.js +6 -1
- package/insert-changelog-release.js +86 -0
- package/package.json +4 -4
package/.release-it.js
CHANGED
|
@@ -18,6 +18,10 @@ const createChangelog = (template) =>
|
|
|
18
18
|
].join(' ');
|
|
19
19
|
|
|
20
20
|
const changelog = createChangelog('template.hbs');
|
|
21
|
+
const changelogRelease = '.auto-changelog-release.md';
|
|
22
|
+
const insertChangelogRelease = path
|
|
23
|
+
.join(__dirname, 'insert-changelog-release.js')
|
|
24
|
+
.replaceAll('\\', '/');
|
|
21
25
|
|
|
22
26
|
module.exports = {
|
|
23
27
|
plugins: {
|
|
@@ -57,7 +61,8 @@ module.exports = {
|
|
|
57
61
|
'after:bump': [
|
|
58
62
|
'git tag v${version}', // for include last tag inside CHANGELOG
|
|
59
63
|
'echo "new version is v${version}"',
|
|
60
|
-
`${changelog} --
|
|
64
|
+
`${changelog} --stdout --starting-version v\${version} > ${changelogRelease}`,
|
|
65
|
+
`node ${JSON.stringify(insertChangelogRelease)} CHANGELOG.md ${changelogRelease}`,
|
|
61
66
|
'npx prettier CHANGELOG.md --write > /dev/null',
|
|
62
67
|
'git fetch --prune --prune-tags origin',
|
|
63
68
|
'git add CHANGELOG.md',
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const {existsSync, readFileSync, rmSync, writeFileSync} = require('node:fs');
|
|
2
|
+
|
|
3
|
+
const [, , changelogPath, releasePath] = process.argv;
|
|
4
|
+
|
|
5
|
+
if (!changelogPath || !releasePath) {
|
|
6
|
+
throw new Error(
|
|
7
|
+
'Usage: node insert-changelog-release.js <CHANGELOG.md> <release.md>',
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const marker = 'All notable changes to this project will be documented in this file.';
|
|
12
|
+
const titlePattern = /^#\s*changelog(?:\.md)?\s*$/im;
|
|
13
|
+
const releaseTitlePattern =
|
|
14
|
+
/^#{2,3}\s+\[v?\d+\.\d+\.\d[^\]]*\](?:\([^)]+\))?(?:\s+\(\d{4}-\d{2}-\d{2}\))?\s*$/m;
|
|
15
|
+
|
|
16
|
+
function getLineBreak(text) {
|
|
17
|
+
return text.includes('\r\n') ? '\r\n' : '\n';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function insertAfter(text, search, value) {
|
|
21
|
+
const index = text.indexOf(search);
|
|
22
|
+
|
|
23
|
+
if (index === -1) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const insertIndex = index + search.length;
|
|
28
|
+
|
|
29
|
+
return `${text.slice(0, insertIndex)}${value}${text.slice(insertIndex)}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function insertAfterTitle(text, value) {
|
|
33
|
+
const match = titlePattern.exec(text);
|
|
34
|
+
|
|
35
|
+
if (!match) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const lineBreak = getLineBreak(text);
|
|
40
|
+
const lineEndIndex = text.indexOf(lineBreak, match.index);
|
|
41
|
+
|
|
42
|
+
const insertIndex =
|
|
43
|
+
lineEndIndex === -1 ? match.index + match[0].length : lineEndIndex;
|
|
44
|
+
|
|
45
|
+
return `${text.slice(0, insertIndex)}${value}${text.slice(insertIndex)}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function insertBeforeFirstRelease(text, value) {
|
|
49
|
+
const match = releaseTitlePattern.exec(text);
|
|
50
|
+
|
|
51
|
+
if (!match) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return `${text.slice(0, match.index).trimEnd()}${value}${text.slice(match.index)}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const changelog = existsSync(changelogPath)
|
|
60
|
+
? readFileSync(changelogPath, 'utf8')
|
|
61
|
+
: '';
|
|
62
|
+
|
|
63
|
+
const release = readFileSync(releasePath, 'utf8').trim();
|
|
64
|
+
|
|
65
|
+
if (!release) {
|
|
66
|
+
throw new Error(`Generated release changelog is empty: ${releasePath}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const lineBreak = getLineBreak(changelog);
|
|
70
|
+
const trimmedChangelog = changelog.trim();
|
|
71
|
+
|
|
72
|
+
const releaseBlock = `${lineBreak}${lineBreak}${release}${lineBreak}${lineBreak}`;
|
|
73
|
+
const markerReleaseBlock = `${lineBreak}${lineBreak}${release}`;
|
|
74
|
+
const titleReleaseBlock = `${lineBreak}${lineBreak}${release}`;
|
|
75
|
+
|
|
76
|
+
const nextChangelog = trimmedChangelog
|
|
77
|
+
? (insertBeforeFirstRelease(changelog, releaseBlock) ??
|
|
78
|
+
insertAfter(changelog, marker, markerReleaseBlock) ??
|
|
79
|
+
insertAfterTitle(changelog, titleReleaseBlock) ??
|
|
80
|
+
`${release}${lineBreak}${lineBreak}${trimmedChangelog}${lineBreak}`)
|
|
81
|
+
: `${release}${lineBreak}`;
|
|
82
|
+
|
|
83
|
+
writeFileSync(changelogPath, nextChangelog);
|
|
84
|
+
} finally {
|
|
85
|
+
rmSync(releasePath, {force: true});
|
|
86
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taiga-ui/release-it-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.542.0",
|
|
4
4
|
"description": "Taiga UI release-it config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"release-it"
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
],
|
|
35
35
|
"main": ".release-it.js",
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@release-it/conventional-changelog": "^11.0.
|
|
38
|
-
"@taiga-ui/auto-changelog-config": "^0.
|
|
39
|
-
"release-it": "^20.0
|
|
37
|
+
"@release-it/conventional-changelog": "^11.0.1",
|
|
38
|
+
"@taiga-ui/auto-changelog-config": "^0.542.0",
|
|
39
|
+
"release-it": "^20.2.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|