@modern-js/plugin-changeset 1.3.0 → 1.4.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/CHANGELOG.md +26 -0
- package/dist/js/modern/commands/release-note.js +53 -13
- package/dist/js/modern/utils/language.js +1 -1
- package/dist/js/node/commands/release-note.js +53 -13
- package/dist/js/node/utils/language.js +2 -2
- package/dist/types/commands/release-note.d.ts +4 -3
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @modern-js/plugin-changeset
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 33cebd2: chore(plugin-i18n): merge `@modern-js/i18n-cli-language-detector` to `@modern-js/plugin-i18n`
|
|
8
|
+
|
|
9
|
+
chore(plugin-i18n): 合并 `@modern-js/i18n-cli-language-detector` 包到 `@modern-js/plugin-i18n` 包作为子路径
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 2e8ea92: feat: optimize release note
|
|
14
|
+
|
|
15
|
+
feat: 优化 Release Note 格式
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [33cebd2]
|
|
18
|
+
- @modern-js/plugin-i18n@1.3.0
|
|
19
|
+
- @modern-js/utils@1.7.12
|
|
20
|
+
|
|
21
|
+
## 1.3.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 42741db: perf(plugin-changeset): optimize custom generator release note
|
|
26
|
+
- Updated dependencies [a90bc96]
|
|
27
|
+
- @modern-js/utils@1.7.9
|
|
28
|
+
|
|
3
29
|
## 1.3.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
+
import resolveFrom from 'resolve-from';
|
|
2
3
|
import { fs, execa } from '@modern-js/utils';
|
|
3
4
|
import readChangesets from '@changesets/read';
|
|
4
5
|
export function getReleaseInfo(commit, commitObj) {
|
|
@@ -14,6 +15,24 @@ export function getReleaseInfo(commit, commitObj) {
|
|
|
14
15
|
|
|
15
16
|
return commitObj;
|
|
16
17
|
}
|
|
18
|
+
|
|
19
|
+
function formatSummary(summary, pullRequestId) {
|
|
20
|
+
const [firstLine, ...futureLines] = summary.split('\n').map(l => l.trimRight());
|
|
21
|
+
let returnVal = firstLine;
|
|
22
|
+
|
|
23
|
+
if (futureLines.length > 0) {
|
|
24
|
+
if (pullRequestId) {
|
|
25
|
+
returnVal = `\n\n ${returnVal}`;
|
|
26
|
+
} else {
|
|
27
|
+
returnVal = `\n ${returnVal}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
returnVal += `\n\n ${futureLines.filter(l => Boolean(l)).map(l => l).join('\n\n')}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return returnVal;
|
|
34
|
+
}
|
|
35
|
+
|
|
17
36
|
export function getReleaseNoteLine(commit, customReleaseNoteFunction) {
|
|
18
37
|
if (customReleaseNoteFunction !== null && customReleaseNoteFunction !== void 0 && customReleaseNoteFunction.getReleaseNoteLine) {
|
|
19
38
|
return customReleaseNoteFunction.getReleaseNoteLine(commit);
|
|
@@ -22,17 +41,18 @@ export function getReleaseNoteLine(commit, customReleaseNoteFunction) {
|
|
|
22
41
|
const {
|
|
23
42
|
repository,
|
|
24
43
|
pullRequestId,
|
|
25
|
-
summary
|
|
26
|
-
author
|
|
44
|
+
summary
|
|
27
45
|
} = commit;
|
|
28
46
|
|
|
29
47
|
if (pullRequestId && repository) {
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
48
|
+
return `- [#${pullRequestId}](https://github.com/${repository}/pull/${pullRequestId}) ${formatSummary(summary, pullRequestId)}\n`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (pullRequestId) {
|
|
52
|
+
return `#${pullRequestId} ${formatSummary(summary, pullRequestId)}\n`;
|
|
35
53
|
}
|
|
54
|
+
|
|
55
|
+
return `${formatSummary(summary, pullRequestId)}\n`;
|
|
36
56
|
}
|
|
37
57
|
export async function genReleaseNote(options) {
|
|
38
58
|
const cwd = process.cwd();
|
|
@@ -51,7 +71,19 @@ export async function genReleaseNote(options) {
|
|
|
51
71
|
}
|
|
52
72
|
|
|
53
73
|
if (custom) {
|
|
54
|
-
|
|
74
|
+
let possibleReleaseNoteFunc;
|
|
75
|
+
const releasenotePath = resolveFrom(cwd, custom);
|
|
76
|
+
possibleReleaseNoteFunc = require(releasenotePath);
|
|
77
|
+
|
|
78
|
+
if (possibleReleaseNoteFunc.default) {
|
|
79
|
+
possibleReleaseNoteFunc = possibleReleaseNoteFunc.default;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (typeof possibleReleaseNoteFunc.getReleaseInfo === 'function' && typeof possibleReleaseNoteFunc.getReleaseNoteLine === 'function') {
|
|
83
|
+
customReleaseNoteFunction = possibleReleaseNoteFunc;
|
|
84
|
+
} else {
|
|
85
|
+
throw new Error('Could not resolve relesae note generation functions');
|
|
86
|
+
}
|
|
55
87
|
}
|
|
56
88
|
|
|
57
89
|
const changesets = await readChangesets(cwd);
|
|
@@ -81,7 +113,7 @@ export async function genReleaseNote(options) {
|
|
|
81
113
|
};
|
|
82
114
|
|
|
83
115
|
if ((_customReleaseNoteFun = customReleaseNoteFunction) !== null && _customReleaseNoteFun !== void 0 && _customReleaseNoteFun.getReleaseInfo) {
|
|
84
|
-
commitObj = customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
|
|
116
|
+
commitObj = await customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
|
|
85
117
|
} else {
|
|
86
118
|
commitObj = getReleaseInfo(stdout, commitObj);
|
|
87
119
|
}
|
|
@@ -98,12 +130,20 @@ export async function genReleaseNote(options) {
|
|
|
98
130
|
}
|
|
99
131
|
|
|
100
132
|
if (features.length) {
|
|
101
|
-
console.info('Features:\n');
|
|
102
|
-
|
|
133
|
+
console.info('## Features:\n');
|
|
134
|
+
|
|
135
|
+
for (const commit of features) {
|
|
136
|
+
const releaseNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
|
|
137
|
+
console.info(releaseNote);
|
|
138
|
+
}
|
|
103
139
|
}
|
|
104
140
|
|
|
105
141
|
if (bugFix.length) {
|
|
106
|
-
console.info('Bug Fix:\n');
|
|
107
|
-
|
|
142
|
+
console.info('## Bug Fix:\n');
|
|
143
|
+
|
|
144
|
+
for (const commit of bugFix) {
|
|
145
|
+
const relesaeNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
|
|
146
|
+
console.info(relesaeNote);
|
|
147
|
+
}
|
|
108
148
|
}
|
|
109
149
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I18CLILanguageDetector } from '@modern-js/i18n
|
|
1
|
+
import { I18CLILanguageDetector } from '@modern-js/plugin-i18n/language-detector';
|
|
2
2
|
export function getLocaleLanguage() {
|
|
3
3
|
const detector = new I18CLILanguageDetector();
|
|
4
4
|
return detector.detect();
|
|
@@ -9,6 +9,8 @@ exports.getReleaseNoteLine = getReleaseNoteLine;
|
|
|
9
9
|
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
|
|
12
|
+
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
13
|
+
|
|
12
14
|
var _utils = require("@modern-js/utils");
|
|
13
15
|
|
|
14
16
|
var _read = _interopRequireDefault(require("@changesets/read"));
|
|
@@ -29,6 +31,23 @@ function getReleaseInfo(commit, commitObj) {
|
|
|
29
31
|
return commitObj;
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
function formatSummary(summary, pullRequestId) {
|
|
35
|
+
const [firstLine, ...futureLines] = summary.split('\n').map(l => l.trimRight());
|
|
36
|
+
let returnVal = firstLine;
|
|
37
|
+
|
|
38
|
+
if (futureLines.length > 0) {
|
|
39
|
+
if (pullRequestId) {
|
|
40
|
+
returnVal = `\n\n ${returnVal}`;
|
|
41
|
+
} else {
|
|
42
|
+
returnVal = `\n ${returnVal}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
returnVal += `\n\n ${futureLines.filter(l => Boolean(l)).map(l => l).join('\n\n')}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return returnVal;
|
|
49
|
+
}
|
|
50
|
+
|
|
32
51
|
function getReleaseNoteLine(commit, customReleaseNoteFunction) {
|
|
33
52
|
if (customReleaseNoteFunction !== null && customReleaseNoteFunction !== void 0 && customReleaseNoteFunction.getReleaseNoteLine) {
|
|
34
53
|
return customReleaseNoteFunction.getReleaseNoteLine(commit);
|
|
@@ -37,17 +56,18 @@ function getReleaseNoteLine(commit, customReleaseNoteFunction) {
|
|
|
37
56
|
const {
|
|
38
57
|
repository,
|
|
39
58
|
pullRequestId,
|
|
40
|
-
summary
|
|
41
|
-
author
|
|
59
|
+
summary
|
|
42
60
|
} = commit;
|
|
43
61
|
|
|
44
62
|
if (pullRequestId && repository) {
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
63
|
+
return `- [#${pullRequestId}](https://github.com/${repository}/pull/${pullRequestId}) ${formatSummary(summary, pullRequestId)}\n`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (pullRequestId) {
|
|
67
|
+
return `#${pullRequestId} ${formatSummary(summary, pullRequestId)}\n`;
|
|
50
68
|
}
|
|
69
|
+
|
|
70
|
+
return `${formatSummary(summary, pullRequestId)}\n`;
|
|
51
71
|
}
|
|
52
72
|
|
|
53
73
|
async function genReleaseNote(options) {
|
|
@@ -67,7 +87,19 @@ async function genReleaseNote(options) {
|
|
|
67
87
|
}
|
|
68
88
|
|
|
69
89
|
if (custom) {
|
|
70
|
-
|
|
90
|
+
let possibleReleaseNoteFunc;
|
|
91
|
+
const releasenotePath = (0, _resolveFrom.default)(cwd, custom);
|
|
92
|
+
possibleReleaseNoteFunc = require(releasenotePath);
|
|
93
|
+
|
|
94
|
+
if (possibleReleaseNoteFunc.default) {
|
|
95
|
+
possibleReleaseNoteFunc = possibleReleaseNoteFunc.default;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (typeof possibleReleaseNoteFunc.getReleaseInfo === 'function' && typeof possibleReleaseNoteFunc.getReleaseNoteLine === 'function') {
|
|
99
|
+
customReleaseNoteFunction = possibleReleaseNoteFunc;
|
|
100
|
+
} else {
|
|
101
|
+
throw new Error('Could not resolve relesae note generation functions');
|
|
102
|
+
}
|
|
71
103
|
}
|
|
72
104
|
|
|
73
105
|
const changesets = await (0, _read.default)(cwd);
|
|
@@ -97,7 +129,7 @@ async function genReleaseNote(options) {
|
|
|
97
129
|
};
|
|
98
130
|
|
|
99
131
|
if ((_customReleaseNoteFun = customReleaseNoteFunction) !== null && _customReleaseNoteFun !== void 0 && _customReleaseNoteFun.getReleaseInfo) {
|
|
100
|
-
commitObj = customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
|
|
132
|
+
commitObj = await customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
|
|
101
133
|
} else {
|
|
102
134
|
commitObj = getReleaseInfo(stdout, commitObj);
|
|
103
135
|
}
|
|
@@ -114,12 +146,20 @@ async function genReleaseNote(options) {
|
|
|
114
146
|
}
|
|
115
147
|
|
|
116
148
|
if (features.length) {
|
|
117
|
-
console.info('Features:\n');
|
|
118
|
-
|
|
149
|
+
console.info('## Features:\n');
|
|
150
|
+
|
|
151
|
+
for (const commit of features) {
|
|
152
|
+
const releaseNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
|
|
153
|
+
console.info(releaseNote);
|
|
154
|
+
}
|
|
119
155
|
}
|
|
120
156
|
|
|
121
157
|
if (bugFix.length) {
|
|
122
|
-
console.info('Bug Fix:\n');
|
|
123
|
-
|
|
158
|
+
console.info('## Bug Fix:\n');
|
|
159
|
+
|
|
160
|
+
for (const commit of bugFix) {
|
|
161
|
+
const relesaeNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
|
|
162
|
+
console.info(relesaeNote);
|
|
163
|
+
}
|
|
124
164
|
}
|
|
125
165
|
}
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getLocaleLanguage = getLocaleLanguage;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _languageDetector = require("@modern-js/plugin-i18n/language-detector");
|
|
9
9
|
|
|
10
10
|
function getLocaleLanguage() {
|
|
11
|
-
const detector = new
|
|
11
|
+
const detector = new _languageDetector.I18CLILanguageDetector();
|
|
12
12
|
return detector.detect();
|
|
13
13
|
}
|
|
@@ -6,16 +6,17 @@ export interface Commit {
|
|
|
6
6
|
author?: string;
|
|
7
7
|
message: string;
|
|
8
8
|
summary: string;
|
|
9
|
+
[key: string]: string | undefined;
|
|
9
10
|
}
|
|
10
11
|
interface ReleaseNoteOptions {
|
|
11
12
|
repo?: string;
|
|
12
13
|
custom?: string;
|
|
13
14
|
}
|
|
14
15
|
export declare type CustomReleaseNoteFunction = {
|
|
15
|
-
getReleaseInfo?: (commit: string, commitObj: Commit) => Commit
|
|
16
|
-
getReleaseNoteLine?: (commit: Commit) => string
|
|
16
|
+
getReleaseInfo?: (commit: string, commitObj: Commit) => Commit | Promise<Commit>;
|
|
17
|
+
getReleaseNoteLine?: (commit: Commit) => string | Promise<string>;
|
|
17
18
|
} | undefined;
|
|
18
19
|
export declare function getReleaseInfo(commit: string, commitObj: Commit): Commit;
|
|
19
|
-
export declare function getReleaseNoteLine(commit: Commit, customReleaseNoteFunction?: CustomReleaseNoteFunction): string
|
|
20
|
+
export declare function getReleaseNoteLine(commit: Commit, customReleaseNoteFunction?: CustomReleaseNoteFunction): string | Promise<string>;
|
|
20
21
|
export declare function genReleaseNote(options: ReleaseNoteOptions): Promise<void>;
|
|
21
22
|
export {};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.4.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"@changesets/cli": "^2.23.0",
|
|
37
37
|
"@changesets/git": "^1.3.2",
|
|
38
38
|
"@changesets/read": "^0.5.5",
|
|
39
|
-
"@modern-js/i18n
|
|
40
|
-
"@modern-js/
|
|
41
|
-
"
|
|
42
|
-
"
|
|
39
|
+
"@modern-js/plugin-i18n": "^1.3.0",
|
|
40
|
+
"@modern-js/utils": "^1.7.12",
|
|
41
|
+
"execa": "^5.1.1",
|
|
42
|
+
"resolve-from": "^5.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@modern-js/core": "1.
|
|
45
|
+
"@modern-js/core": "1.13.0",
|
|
46
46
|
"@scripts/build": "0.0.0",
|
|
47
47
|
"@types/jest": "^27",
|
|
48
48
|
"@types/node": "^14",
|