@modern-js/plugin-changeset 1.2.7 → 1.3.1-alpha.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 +33 -0
- package/dist/js/modern/commands/index.js +3 -1
- package/dist/js/modern/commands/release-note.js +128 -0
- package/dist/js/modern/commands/release.js +6 -0
- package/dist/js/modern/commands/status.js +25 -0
- package/dist/js/modern/index.js +9 -3
- package/dist/js/modern/locale/en.js +13 -1
- package/dist/js/modern/locale/zh.js +13 -1
- package/dist/js/node/commands/index.js +26 -0
- package/dist/js/node/commands/release-note.js +145 -0
- package/dist/js/node/commands/release.js +6 -0
- package/dist/js/node/commands/status.js +33 -0
- package/dist/js/node/index.js +20 -2
- package/dist/js/node/locale/en.js +13 -1
- package/dist/js/node/locale/zh.js +13 -1
- package/dist/types/commands/index.d.ts +3 -1
- package/dist/types/commands/release-note.d.ts +22 -0
- package/dist/types/commands/release.d.ts +3 -2
- package/dist/types/commands/status.d.ts +7 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/locale/en.d.ts +12 -0
- package/dist/types/locale/index.d.ts +24 -0
- package/dist/types/locale/zh.d.ts +12 -0
- package/package.json +13 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @modern-js/plugin-changeset
|
|
2
2
|
|
|
3
|
+
## 1.3.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [9cd364e06]
|
|
8
|
+
- Updated dependencies [a90bc96bd]
|
|
9
|
+
- @modern-js/utils@1.7.9-alpha.0
|
|
10
|
+
- @modern-js/plugin-i18n@1.2.8-alpha.0
|
|
11
|
+
|
|
12
|
+
## 1.3.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- 50eea41ee: feat: add change status command
|
|
17
|
+
- 4599e6914: feat: add gen-release-note command
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 0c17860e9: fix: changeset bump support ignore option
|
|
22
|
+
- Updated dependencies [63c354ad5]
|
|
23
|
+
- Updated dependencies [073e9ad78]
|
|
24
|
+
- Updated dependencies [f4a7d49e1]
|
|
25
|
+
- @modern-js/utils@1.7.8
|
|
26
|
+
|
|
27
|
+
## 1.2.8
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- a1198d509: feat: bump babel 7.18.0
|
|
32
|
+
- Updated dependencies [a1198d509]
|
|
33
|
+
- @modern-js/i18n-cli-language-detector@1.2.4
|
|
34
|
+
- @modern-js/plugin-i18n@1.2.7
|
|
35
|
+
|
|
3
36
|
## 1.2.7
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import resolveFrom from 'resolve-from';
|
|
3
|
+
import { fs, execa } from '@modern-js/utils';
|
|
4
|
+
import readChangesets from '@changesets/read';
|
|
5
|
+
export function getReleaseInfo(commit, commitObj) {
|
|
6
|
+
const commitRegex = /(.*)\(#(\d*)\)/;
|
|
7
|
+
const [, message, author] = commit.split('--');
|
|
8
|
+
commitObj.author = author;
|
|
9
|
+
|
|
10
|
+
if ((message || commitObj.summary).match(commitRegex)) {
|
|
11
|
+
const [, messageShort, pullRequestId] = (message || commitObj.summary).match(commitRegex);
|
|
12
|
+
commitObj.pullRequestId = pullRequestId;
|
|
13
|
+
commitObj.message = messageShort.trim();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return commitObj;
|
|
17
|
+
}
|
|
18
|
+
export function getReleaseNoteLine(commit, customReleaseNoteFunction) {
|
|
19
|
+
if (customReleaseNoteFunction !== null && customReleaseNoteFunction !== void 0 && customReleaseNoteFunction.getReleaseNoteLine) {
|
|
20
|
+
return customReleaseNoteFunction.getReleaseNoteLine(commit);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
repository,
|
|
25
|
+
pullRequestId,
|
|
26
|
+
summary,
|
|
27
|
+
author
|
|
28
|
+
} = commit;
|
|
29
|
+
|
|
30
|
+
if (pullRequestId && repository) {
|
|
31
|
+
return `[[#${pullRequestId}](https://github.com/${repository}/pull/${pullRequestId})] ${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
32
|
+
} else if (pullRequestId) {
|
|
33
|
+
return `[#${pullRequestId}] ${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
34
|
+
} else {
|
|
35
|
+
return `${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export async function genReleaseNote(options) {
|
|
39
|
+
const cwd = process.cwd();
|
|
40
|
+
const {
|
|
41
|
+
repo,
|
|
42
|
+
custom
|
|
43
|
+
} = options;
|
|
44
|
+
let repository = repo;
|
|
45
|
+
let customReleaseNoteFunction;
|
|
46
|
+
|
|
47
|
+
if (!repo) {
|
|
48
|
+
const pkg = await fs.readJSON(path.join(cwd, 'package.json'));
|
|
49
|
+
({
|
|
50
|
+
repository
|
|
51
|
+
} = pkg);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (custom) {
|
|
55
|
+
let possibleReleaseNoteFunc;
|
|
56
|
+
const releasenotePath = resolveFrom(cwd, custom);
|
|
57
|
+
possibleReleaseNoteFunc = require(releasenotePath);
|
|
58
|
+
|
|
59
|
+
if (possibleReleaseNoteFunc.default) {
|
|
60
|
+
possibleReleaseNoteFunc = possibleReleaseNoteFunc.default;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (typeof possibleReleaseNoteFunc.getReleaseInfo === 'function' && typeof possibleReleaseNoteFunc.getReleaseNoteLine === 'function') {
|
|
64
|
+
customReleaseNoteFunction = possibleReleaseNoteFunc;
|
|
65
|
+
} else {
|
|
66
|
+
throw new Error('Could not resolve relesae note generation functions');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const changesets = await readChangesets(cwd);
|
|
71
|
+
|
|
72
|
+
if (changesets.length === 0) {
|
|
73
|
+
console.warn('No unreleased changesets found.'); // eslint-disable-next-line no-process-exit
|
|
74
|
+
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const features = [];
|
|
79
|
+
const bugFix = [];
|
|
80
|
+
|
|
81
|
+
for (const changeset of changesets) {
|
|
82
|
+
var _customReleaseNoteFun;
|
|
83
|
+
|
|
84
|
+
const {
|
|
85
|
+
stdout
|
|
86
|
+
} = await execa('git', ['log', '--pretty=format:%h--%s--%an', `.changeset/${changeset.id}.md`]);
|
|
87
|
+
const [id, message] = stdout.split('--');
|
|
88
|
+
let commitObj = {
|
|
89
|
+
id,
|
|
90
|
+
type: (message || changeset.summary).startsWith('fix') ? 'fix' : 'feature',
|
|
91
|
+
repository,
|
|
92
|
+
message: (message || changeset.summary).trim(),
|
|
93
|
+
summary: changeset.summary
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
if ((_customReleaseNoteFun = customReleaseNoteFunction) !== null && _customReleaseNoteFun !== void 0 && _customReleaseNoteFun.getReleaseInfo) {
|
|
97
|
+
commitObj = await customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
|
|
98
|
+
} else {
|
|
99
|
+
commitObj = getReleaseInfo(stdout, commitObj);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (commitObj.type === 'fix') {
|
|
103
|
+
bugFix.push(commitObj);
|
|
104
|
+
} else {
|
|
105
|
+
features.push(commitObj);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!features.length && !bugFix.length) {
|
|
110
|
+
console.warn('no release note found, you can run `pnpm run add` to add changeset');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (features.length) {
|
|
114
|
+
console.info('Features:\n');
|
|
115
|
+
features.forEach(async commit => {
|
|
116
|
+
const releaseNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
|
|
117
|
+
console.info(releaseNote);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (bugFix.length) {
|
|
122
|
+
console.info('Bug Fix:\n');
|
|
123
|
+
bugFix.forEach(async commit => {
|
|
124
|
+
const relesaeNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
|
|
125
|
+
console.info(relesaeNote);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -9,6 +9,7 @@ export async function release(options) {
|
|
|
9
9
|
const params = ['publish'];
|
|
10
10
|
const {
|
|
11
11
|
tag,
|
|
12
|
+
otp,
|
|
12
13
|
ignoreScripts,
|
|
13
14
|
gitChecks
|
|
14
15
|
} = options;
|
|
@@ -18,6 +19,11 @@ export async function release(options) {
|
|
|
18
19
|
params.push(tag);
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
if (otp) {
|
|
23
|
+
params.push('--otp');
|
|
24
|
+
params.push(otp);
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
if (!isMonorepo || packageManager === 'yarn' || packageManager === 'npm') {
|
|
22
28
|
await execaWithStreamLog(process.execPath, [CHANGESET_PATH, ...params]);
|
|
23
29
|
return;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
2
|
+
export async function status(options) {
|
|
3
|
+
const params = [CHANGESET_PATH, 'status'];
|
|
4
|
+
const {
|
|
5
|
+
verbose,
|
|
6
|
+
output,
|
|
7
|
+
since
|
|
8
|
+
} = options;
|
|
9
|
+
|
|
10
|
+
if (verbose) {
|
|
11
|
+
params.push('--verbose');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (output) {
|
|
15
|
+
params.push('--output');
|
|
16
|
+
params.push(output);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (since) {
|
|
20
|
+
params.push('--since');
|
|
21
|
+
params.push(since);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
await execaWithStreamLog(process.execPath, params);
|
|
25
|
+
}
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { change, bump, pre, release } from "./commands";
|
|
1
|
+
import { change, bump, pre, release, status, genReleaseNote } from "./commands";
|
|
2
2
|
import { i18n, localeKeys } from "./locale";
|
|
3
3
|
import { getLocaleLanguage } from "./utils";
|
|
4
|
+
export * from "./commands";
|
|
4
5
|
export default (() => ({
|
|
5
6
|
name: '@modern-js/plugin-changeset',
|
|
6
7
|
setup: () => {
|
|
@@ -17,9 +18,14 @@ export default (() => ({
|
|
|
17
18
|
program
|
|
18
19
|
}) {
|
|
19
20
|
program.command('change').description(i18n.t(localeKeys.command.change.describe)).option('--empty', i18n.t(localeKeys.command.change.empty), false).option('--open', i18n.t(localeKeys.command.change.open), false).action(options => change(options));
|
|
20
|
-
program.command('bump').description(i18n.t(localeKeys.command.bump.describe)).option('--canary', i18n.t(localeKeys.command.bump.canary), false).option('--
|
|
21
|
+
program.command('bump').description(i18n.t(localeKeys.command.bump.describe)).option('--canary', i18n.t(localeKeys.command.bump.canary), false).option('--ignore <package>', i18n.t(localeKeys.command.bump.ignore), (val, memo) => {
|
|
22
|
+
memo.push(val);
|
|
23
|
+
return memo;
|
|
24
|
+
}, []).option('--preid <tag>', i18n.t(localeKeys.command.bump.preid), 'next').option('--snapshot [snapshot]', i18n.t(localeKeys.command.bump.snapshot), false).action(options => bump(options));
|
|
21
25
|
program.command('pre <enter|exit> [tag]').description(i18n.t(localeKeys.command.pre.describe)).action((type, tag) => pre(type, tag));
|
|
22
|
-
program.command('release').description(i18n.t(localeKeys.command.release.describe)).option('--tag <tag>', i18n.t(localeKeys.command.release.tag), '').option('--ignore-scripts', i18n.t(localeKeys.command.release.ignore_scripts), '').option('--no-git-checks', i18n.t(localeKeys.command.release.no_git_checks), '').action(options => release(options));
|
|
26
|
+
program.command('release').description(i18n.t(localeKeys.command.release.describe)).option('--tag <tag>', i18n.t(localeKeys.command.release.tag), '').option('--otp <token>', i18n.t(localeKeys.command.release.otp), '').option('--ignore-scripts', i18n.t(localeKeys.command.release.ignore_scripts), '').option('--no-git-checks', i18n.t(localeKeys.command.release.no_git_checks), '').action(options => release(options));
|
|
27
|
+
program.command('change-status').description(i18n.t(localeKeys.command.status.describe)).option('--verbose', i18n.t(localeKeys.command.status.verbose)).option('--output <file>', i18n.t(localeKeys.command.status.output)).option('--since <ref>', i18n.t(localeKeys.command.status.since)).action(options => status(options));
|
|
28
|
+
program.command('gen-release-note').description(i18n.t(localeKeys.command.gen_release_note.describe)).option('--repo <repo>', i18n.t(localeKeys.command.gen_release_note.repo)).option('--custom <cumtom>', i18n.t(localeKeys.command.gen_release_note.custom)).action(options => genReleaseNote(options));
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
};
|
|
@@ -10,7 +10,7 @@ export const EN_LOCALE = {
|
|
|
10
10
|
describe: 'auto update publish version and changelog using changeset',
|
|
11
11
|
canary: 'create a prerelease version of publishing for testing',
|
|
12
12
|
preid: 'specify the identifier when versioning a prerelease',
|
|
13
|
-
snapshot: 'create a
|
|
13
|
+
snapshot: 'create a snapshot version of publishing for testing',
|
|
14
14
|
ignore: 'skip packages from being published'
|
|
15
15
|
},
|
|
16
16
|
pre: {
|
|
@@ -19,8 +19,20 @@ export const EN_LOCALE = {
|
|
|
19
19
|
release: {
|
|
20
20
|
describe: 'publish changes to npm',
|
|
21
21
|
tag: 'publish use special tag',
|
|
22
|
+
otp: 'publish package use one-time password, if you have auth and writes enabled on npm ',
|
|
22
23
|
ignore_scripts: 'publish command ignore npm scripts, only can use in pnpm monorepo',
|
|
23
24
|
no_git_checks: 'publish command ignore checking if current branch is your publish branch, clean, and up-to-date, only can use in pnpm monorepo'
|
|
25
|
+
},
|
|
26
|
+
status: {
|
|
27
|
+
describe: 'provides information about the changesets that currently exist',
|
|
28
|
+
verbose: 'provides detail information about the changesets that currently exist with table',
|
|
29
|
+
output: 'write the information about the changesets that currently exist to json file',
|
|
30
|
+
since: 'only display information about changesets since a specific branch or git tag'
|
|
31
|
+
},
|
|
32
|
+
gen_release_note: {
|
|
33
|
+
describe: 'generator release note info from changesets',
|
|
34
|
+
repo: 'reponame to generator pull request link, like modern-js-dev/modern.js',
|
|
35
|
+
custom: 'custom release note render rules'
|
|
24
36
|
}
|
|
25
37
|
}
|
|
26
38
|
};
|
|
@@ -10,7 +10,7 @@ export const ZH_LOCALE = {
|
|
|
10
10
|
describe: '使用变更集自动更新发布版本和变更日志',
|
|
11
11
|
canary: '创建一个预发布版本进行测试',
|
|
12
12
|
preid: '在对预发布版本进行版本控制时指定标识符',
|
|
13
|
-
snapshot: '
|
|
13
|
+
snapshot: '创建一个快照版本进行测试',
|
|
14
14
|
ignore: '跳过部分包发布版本'
|
|
15
15
|
},
|
|
16
16
|
pre: {
|
|
@@ -19,8 +19,20 @@ export const ZH_LOCALE = {
|
|
|
19
19
|
release: {
|
|
20
20
|
describe: '发布 npm 包',
|
|
21
21
|
tag: '发布 npm 包使用特定的 tag',
|
|
22
|
+
otp: '发布 npm 包的一次性 token,该 token 需要写权限',
|
|
22
23
|
ignore_scripts: '发布时忽略 package.json 中的 scripts 命令,仅支持在 pnpm monorepo 中使用',
|
|
23
24
|
no_git_checks: '发布命令忽略检查当前分支是否是发布分支,干净且最新,仅支持在 pnpm monorepo 中使用'
|
|
25
|
+
},
|
|
26
|
+
status: {
|
|
27
|
+
describe: '展示当前存在的变更集的状态信息',
|
|
28
|
+
verbose: '使用表格展示当前存在的变更集状态信息,包含变更集文件名称',
|
|
29
|
+
output: '将当前存在的变更集状态信息导出为 JSON 文件',
|
|
30
|
+
since: '展示基于指定分支或者 tag 的变更集状态信息'
|
|
31
|
+
},
|
|
32
|
+
gen_release_note: {
|
|
33
|
+
describe: '根据当前仓库 changeset 文件生成 Release Note',
|
|
34
|
+
repo: '仓库名称,用于生成 Pull Request 链接, 例如: modern-js-dev/modern.js',
|
|
35
|
+
custom: '自定义 Release Note 生成函数'
|
|
24
36
|
}
|
|
25
37
|
}
|
|
26
38
|
};
|
|
@@ -54,4 +54,30 @@ Object.keys(_release).forEach(function (key) {
|
|
|
54
54
|
return _release[key];
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
var _status = require("./status");
|
|
60
|
+
|
|
61
|
+
Object.keys(_status).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (key in exports && exports[key] === _status[key]) return;
|
|
64
|
+
Object.defineProperty(exports, key, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () {
|
|
67
|
+
return _status[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
var _releaseNote = require("./release-note");
|
|
73
|
+
|
|
74
|
+
Object.keys(_releaseNote).forEach(function (key) {
|
|
75
|
+
if (key === "default" || key === "__esModule") return;
|
|
76
|
+
if (key in exports && exports[key] === _releaseNote[key]) return;
|
|
77
|
+
Object.defineProperty(exports, key, {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () {
|
|
80
|
+
return _releaseNote[key];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
57
83
|
});
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.genReleaseNote = genReleaseNote;
|
|
7
|
+
exports.getReleaseInfo = getReleaseInfo;
|
|
8
|
+
exports.getReleaseNoteLine = getReleaseNoteLine;
|
|
9
|
+
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
|
|
12
|
+
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
13
|
+
|
|
14
|
+
var _utils = require("@modern-js/utils");
|
|
15
|
+
|
|
16
|
+
var _read = _interopRequireDefault(require("@changesets/read"));
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function getReleaseInfo(commit, commitObj) {
|
|
21
|
+
const commitRegex = /(.*)\(#(\d*)\)/;
|
|
22
|
+
const [, message, author] = commit.split('--');
|
|
23
|
+
commitObj.author = author;
|
|
24
|
+
|
|
25
|
+
if ((message || commitObj.summary).match(commitRegex)) {
|
|
26
|
+
const [, messageShort, pullRequestId] = (message || commitObj.summary).match(commitRegex);
|
|
27
|
+
commitObj.pullRequestId = pullRequestId;
|
|
28
|
+
commitObj.message = messageShort.trim();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return commitObj;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getReleaseNoteLine(commit, customReleaseNoteFunction) {
|
|
35
|
+
if (customReleaseNoteFunction !== null && customReleaseNoteFunction !== void 0 && customReleaseNoteFunction.getReleaseNoteLine) {
|
|
36
|
+
return customReleaseNoteFunction.getReleaseNoteLine(commit);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
repository,
|
|
41
|
+
pullRequestId,
|
|
42
|
+
summary,
|
|
43
|
+
author
|
|
44
|
+
} = commit;
|
|
45
|
+
|
|
46
|
+
if (pullRequestId && repository) {
|
|
47
|
+
return `[[#${pullRequestId}](https://github.com/${repository}/pull/${pullRequestId})] ${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
48
|
+
} else if (pullRequestId) {
|
|
49
|
+
return `[#${pullRequestId}] ${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
50
|
+
} else {
|
|
51
|
+
return `${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function genReleaseNote(options) {
|
|
56
|
+
const cwd = process.cwd();
|
|
57
|
+
const {
|
|
58
|
+
repo,
|
|
59
|
+
custom
|
|
60
|
+
} = options;
|
|
61
|
+
let repository = repo;
|
|
62
|
+
let customReleaseNoteFunction;
|
|
63
|
+
|
|
64
|
+
if (!repo) {
|
|
65
|
+
const pkg = await _utils.fs.readJSON(_path.default.join(cwd, 'package.json'));
|
|
66
|
+
({
|
|
67
|
+
repository
|
|
68
|
+
} = pkg);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (custom) {
|
|
72
|
+
let possibleReleaseNoteFunc;
|
|
73
|
+
const releasenotePath = (0, _resolveFrom.default)(cwd, custom);
|
|
74
|
+
possibleReleaseNoteFunc = require(releasenotePath);
|
|
75
|
+
|
|
76
|
+
if (possibleReleaseNoteFunc.default) {
|
|
77
|
+
possibleReleaseNoteFunc = possibleReleaseNoteFunc.default;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (typeof possibleReleaseNoteFunc.getReleaseInfo === 'function' && typeof possibleReleaseNoteFunc.getReleaseNoteLine === 'function') {
|
|
81
|
+
customReleaseNoteFunction = possibleReleaseNoteFunc;
|
|
82
|
+
} else {
|
|
83
|
+
throw new Error('Could not resolve relesae note generation functions');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const changesets = await (0, _read.default)(cwd);
|
|
88
|
+
|
|
89
|
+
if (changesets.length === 0) {
|
|
90
|
+
console.warn('No unreleased changesets found.'); // eslint-disable-next-line no-process-exit
|
|
91
|
+
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const features = [];
|
|
96
|
+
const bugFix = [];
|
|
97
|
+
|
|
98
|
+
for (const changeset of changesets) {
|
|
99
|
+
var _customReleaseNoteFun;
|
|
100
|
+
|
|
101
|
+
const {
|
|
102
|
+
stdout
|
|
103
|
+
} = await (0, _utils.execa)('git', ['log', '--pretty=format:%h--%s--%an', `.changeset/${changeset.id}.md`]);
|
|
104
|
+
const [id, message] = stdout.split('--');
|
|
105
|
+
let commitObj = {
|
|
106
|
+
id,
|
|
107
|
+
type: (message || changeset.summary).startsWith('fix') ? 'fix' : 'feature',
|
|
108
|
+
repository,
|
|
109
|
+
message: (message || changeset.summary).trim(),
|
|
110
|
+
summary: changeset.summary
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
if ((_customReleaseNoteFun = customReleaseNoteFunction) !== null && _customReleaseNoteFun !== void 0 && _customReleaseNoteFun.getReleaseInfo) {
|
|
114
|
+
commitObj = await customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
|
|
115
|
+
} else {
|
|
116
|
+
commitObj = getReleaseInfo(stdout, commitObj);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (commitObj.type === 'fix') {
|
|
120
|
+
bugFix.push(commitObj);
|
|
121
|
+
} else {
|
|
122
|
+
features.push(commitObj);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!features.length && !bugFix.length) {
|
|
127
|
+
console.warn('no release note found, you can run `pnpm run add` to add changeset');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (features.length) {
|
|
131
|
+
console.info('Features:\n');
|
|
132
|
+
features.forEach(async commit => {
|
|
133
|
+
const releaseNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
|
|
134
|
+
console.info(releaseNote);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (bugFix.length) {
|
|
139
|
+
console.info('Bug Fix:\n');
|
|
140
|
+
bugFix.forEach(async commit => {
|
|
141
|
+
const relesaeNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
|
|
142
|
+
console.info(relesaeNote);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -22,6 +22,7 @@ async function release(options) {
|
|
|
22
22
|
const params = ['publish'];
|
|
23
23
|
const {
|
|
24
24
|
tag,
|
|
25
|
+
otp,
|
|
25
26
|
ignoreScripts,
|
|
26
27
|
gitChecks
|
|
27
28
|
} = options;
|
|
@@ -31,6 +32,11 @@ async function release(options) {
|
|
|
31
32
|
params.push(tag);
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
if (otp) {
|
|
36
|
+
params.push('--otp');
|
|
37
|
+
params.push(otp);
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
if (!isMonorepo || packageManager === 'yarn' || packageManager === 'npm') {
|
|
35
41
|
await (0, _utils2.execaWithStreamLog)(process.execPath, [_utils2.CHANGESET_PATH, ...params]);
|
|
36
42
|
return;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.status = status;
|
|
7
|
+
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
|
|
10
|
+
async function status(options) {
|
|
11
|
+
const params = [_utils.CHANGESET_PATH, 'status'];
|
|
12
|
+
const {
|
|
13
|
+
verbose,
|
|
14
|
+
output,
|
|
15
|
+
since
|
|
16
|
+
} = options;
|
|
17
|
+
|
|
18
|
+
if (verbose) {
|
|
19
|
+
params.push('--verbose');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (output) {
|
|
23
|
+
params.push('--output');
|
|
24
|
+
params.push(output);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (since) {
|
|
28
|
+
params.push('--since');
|
|
29
|
+
params.push(since);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await (0, _utils.execaWithStreamLog)(process.execPath, params);
|
|
33
|
+
}
|
package/dist/js/node/index.js
CHANGED
|
@@ -3,10 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {};
|
|
6
7
|
exports.default = void 0;
|
|
7
8
|
|
|
8
9
|
var _commands = require("./commands");
|
|
9
10
|
|
|
11
|
+
Object.keys(_commands).forEach(function (key) {
|
|
12
|
+
if (key === "default" || key === "__esModule") return;
|
|
13
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
14
|
+
if (key in exports && exports[key] === _commands[key]) return;
|
|
15
|
+
Object.defineProperty(exports, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () {
|
|
18
|
+
return _commands[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
10
23
|
var _locale = require("./locale");
|
|
11
24
|
|
|
12
25
|
var _utils = require("./utils");
|
|
@@ -28,9 +41,14 @@ var _default = () => ({
|
|
|
28
41
|
program
|
|
29
42
|
}) {
|
|
30
43
|
program.command('change').description(_locale.i18n.t(_locale.localeKeys.command.change.describe)).option('--empty', _locale.i18n.t(_locale.localeKeys.command.change.empty), false).option('--open', _locale.i18n.t(_locale.localeKeys.command.change.open), false).action(options => (0, _commands.change)(options));
|
|
31
|
-
program.command('bump').description(_locale.i18n.t(_locale.localeKeys.command.bump.describe)).option('--canary', _locale.i18n.t(_locale.localeKeys.command.bump.canary), false).option('--
|
|
44
|
+
program.command('bump').description(_locale.i18n.t(_locale.localeKeys.command.bump.describe)).option('--canary', _locale.i18n.t(_locale.localeKeys.command.bump.canary), false).option('--ignore <package>', _locale.i18n.t(_locale.localeKeys.command.bump.ignore), (val, memo) => {
|
|
45
|
+
memo.push(val);
|
|
46
|
+
return memo;
|
|
47
|
+
}, []).option('--preid <tag>', _locale.i18n.t(_locale.localeKeys.command.bump.preid), 'next').option('--snapshot [snapshot]', _locale.i18n.t(_locale.localeKeys.command.bump.snapshot), false).action(options => (0, _commands.bump)(options));
|
|
32
48
|
program.command('pre <enter|exit> [tag]').description(_locale.i18n.t(_locale.localeKeys.command.pre.describe)).action((type, tag) => (0, _commands.pre)(type, tag));
|
|
33
|
-
program.command('release').description(_locale.i18n.t(_locale.localeKeys.command.release.describe)).option('--tag <tag>', _locale.i18n.t(_locale.localeKeys.command.release.tag), '').option('--ignore-scripts', _locale.i18n.t(_locale.localeKeys.command.release.ignore_scripts), '').option('--no-git-checks', _locale.i18n.t(_locale.localeKeys.command.release.no_git_checks), '').action(options => (0, _commands.release)(options));
|
|
49
|
+
program.command('release').description(_locale.i18n.t(_locale.localeKeys.command.release.describe)).option('--tag <tag>', _locale.i18n.t(_locale.localeKeys.command.release.tag), '').option('--otp <token>', _locale.i18n.t(_locale.localeKeys.command.release.otp), '').option('--ignore-scripts', _locale.i18n.t(_locale.localeKeys.command.release.ignore_scripts), '').option('--no-git-checks', _locale.i18n.t(_locale.localeKeys.command.release.no_git_checks), '').action(options => (0, _commands.release)(options));
|
|
50
|
+
program.command('change-status').description(_locale.i18n.t(_locale.localeKeys.command.status.describe)).option('--verbose', _locale.i18n.t(_locale.localeKeys.command.status.verbose)).option('--output <file>', _locale.i18n.t(_locale.localeKeys.command.status.output)).option('--since <ref>', _locale.i18n.t(_locale.localeKeys.command.status.since)).action(options => (0, _commands.status)(options));
|
|
51
|
+
program.command('gen-release-note').description(_locale.i18n.t(_locale.localeKeys.command.gen_release_note.describe)).option('--repo <repo>', _locale.i18n.t(_locale.localeKeys.command.gen_release_note.repo)).option('--custom <cumtom>', _locale.i18n.t(_locale.localeKeys.command.gen_release_note.custom)).action(options => (0, _commands.genReleaseNote)(options));
|
|
34
52
|
}
|
|
35
53
|
|
|
36
54
|
};
|
|
@@ -16,7 +16,7 @@ const EN_LOCALE = {
|
|
|
16
16
|
describe: 'auto update publish version and changelog using changeset',
|
|
17
17
|
canary: 'create a prerelease version of publishing for testing',
|
|
18
18
|
preid: 'specify the identifier when versioning a prerelease',
|
|
19
|
-
snapshot: 'create a
|
|
19
|
+
snapshot: 'create a snapshot version of publishing for testing',
|
|
20
20
|
ignore: 'skip packages from being published'
|
|
21
21
|
},
|
|
22
22
|
pre: {
|
|
@@ -25,8 +25,20 @@ const EN_LOCALE = {
|
|
|
25
25
|
release: {
|
|
26
26
|
describe: 'publish changes to npm',
|
|
27
27
|
tag: 'publish use special tag',
|
|
28
|
+
otp: 'publish package use one-time password, if you have auth and writes enabled on npm ',
|
|
28
29
|
ignore_scripts: 'publish command ignore npm scripts, only can use in pnpm monorepo',
|
|
29
30
|
no_git_checks: 'publish command ignore checking if current branch is your publish branch, clean, and up-to-date, only can use in pnpm monorepo'
|
|
31
|
+
},
|
|
32
|
+
status: {
|
|
33
|
+
describe: 'provides information about the changesets that currently exist',
|
|
34
|
+
verbose: 'provides detail information about the changesets that currently exist with table',
|
|
35
|
+
output: 'write the information about the changesets that currently exist to json file',
|
|
36
|
+
since: 'only display information about changesets since a specific branch or git tag'
|
|
37
|
+
},
|
|
38
|
+
gen_release_note: {
|
|
39
|
+
describe: 'generator release note info from changesets',
|
|
40
|
+
repo: 'reponame to generator pull request link, like modern-js-dev/modern.js',
|
|
41
|
+
custom: 'custom release note render rules'
|
|
30
42
|
}
|
|
31
43
|
}
|
|
32
44
|
};
|
|
@@ -16,7 +16,7 @@ const ZH_LOCALE = {
|
|
|
16
16
|
describe: '使用变更集自动更新发布版本和变更日志',
|
|
17
17
|
canary: '创建一个预发布版本进行测试',
|
|
18
18
|
preid: '在对预发布版本进行版本控制时指定标识符',
|
|
19
|
-
snapshot: '
|
|
19
|
+
snapshot: '创建一个快照版本进行测试',
|
|
20
20
|
ignore: '跳过部分包发布版本'
|
|
21
21
|
},
|
|
22
22
|
pre: {
|
|
@@ -25,8 +25,20 @@ const ZH_LOCALE = {
|
|
|
25
25
|
release: {
|
|
26
26
|
describe: '发布 npm 包',
|
|
27
27
|
tag: '发布 npm 包使用特定的 tag',
|
|
28
|
+
otp: '发布 npm 包的一次性 token,该 token 需要写权限',
|
|
28
29
|
ignore_scripts: '发布时忽略 package.json 中的 scripts 命令,仅支持在 pnpm monorepo 中使用',
|
|
29
30
|
no_git_checks: '发布命令忽略检查当前分支是否是发布分支,干净且最新,仅支持在 pnpm monorepo 中使用'
|
|
31
|
+
},
|
|
32
|
+
status: {
|
|
33
|
+
describe: '展示当前存在的变更集的状态信息',
|
|
34
|
+
verbose: '使用表格展示当前存在的变更集状态信息,包含变更集文件名称',
|
|
35
|
+
output: '将当前存在的变更集状态信息导出为 JSON 文件',
|
|
36
|
+
since: '展示基于指定分支或者 tag 的变更集状态信息'
|
|
37
|
+
},
|
|
38
|
+
gen_release_note: {
|
|
39
|
+
describe: '根据当前仓库 changeset 文件生成 Release Note',
|
|
40
|
+
repo: '仓库名称,用于生成 Pull Request 链接, 例如: modern-js-dev/modern.js',
|
|
41
|
+
custom: '自定义 Release Note 生成函数'
|
|
30
42
|
}
|
|
31
43
|
}
|
|
32
44
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Commit {
|
|
2
|
+
id: string;
|
|
3
|
+
type: 'feature' | 'fix';
|
|
4
|
+
repository?: string;
|
|
5
|
+
pullRequestId?: string;
|
|
6
|
+
author?: string;
|
|
7
|
+
message: string;
|
|
8
|
+
summary: string;
|
|
9
|
+
[key: string]: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
interface ReleaseNoteOptions {
|
|
12
|
+
repo?: string;
|
|
13
|
+
custom?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare type CustomReleaseNoteFunction = {
|
|
16
|
+
getReleaseInfo?: (commit: string, commitObj: Commit) => Commit | Promise<Commit>;
|
|
17
|
+
getReleaseNoteLine?: (commit: Commit) => string | Promise<string>;
|
|
18
|
+
} | undefined;
|
|
19
|
+
export declare function getReleaseInfo(commit: string, commitObj: Commit): Commit;
|
|
20
|
+
export declare function getReleaseNoteLine(commit: Commit, customReleaseNoteFunction?: CustomReleaseNoteFunction): string | Promise<string>;
|
|
21
|
+
export declare function genReleaseNote(options: ReleaseNoteOptions): Promise<void>;
|
|
22
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface ReleaseOptions {
|
|
2
2
|
tag: string;
|
|
3
3
|
ignoreScripts: boolean;
|
|
4
4
|
gitChecks: boolean;
|
|
5
|
+
otp: string;
|
|
5
6
|
}
|
|
6
|
-
export declare function release(options:
|
|
7
|
+
export declare function release(options: ReleaseOptions): Promise<void>;
|
|
7
8
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -19,8 +19,20 @@ export declare const EN_LOCALE: {
|
|
|
19
19
|
release: {
|
|
20
20
|
describe: string;
|
|
21
21
|
tag: string;
|
|
22
|
+
otp: string;
|
|
22
23
|
ignore_scripts: string;
|
|
23
24
|
no_git_checks: string;
|
|
24
25
|
};
|
|
26
|
+
status: {
|
|
27
|
+
describe: string;
|
|
28
|
+
verbose: string;
|
|
29
|
+
output: string;
|
|
30
|
+
since: string;
|
|
31
|
+
};
|
|
32
|
+
gen_release_note: {
|
|
33
|
+
describe: string;
|
|
34
|
+
repo: string;
|
|
35
|
+
custom: string;
|
|
36
|
+
};
|
|
25
37
|
};
|
|
26
38
|
};
|
|
@@ -21,9 +21,21 @@ declare const localeKeys: {
|
|
|
21
21
|
release: {
|
|
22
22
|
describe: string;
|
|
23
23
|
tag: string;
|
|
24
|
+
otp: string;
|
|
24
25
|
ignore_scripts: string;
|
|
25
26
|
no_git_checks: string;
|
|
26
27
|
};
|
|
28
|
+
status: {
|
|
29
|
+
describe: string;
|
|
30
|
+
verbose: string;
|
|
31
|
+
output: string;
|
|
32
|
+
since: string;
|
|
33
|
+
};
|
|
34
|
+
gen_release_note: {
|
|
35
|
+
describe: string;
|
|
36
|
+
repo: string;
|
|
37
|
+
custom: string;
|
|
38
|
+
};
|
|
27
39
|
};
|
|
28
40
|
} | {
|
|
29
41
|
command: {
|
|
@@ -46,9 +58,21 @@ declare const localeKeys: {
|
|
|
46
58
|
release: {
|
|
47
59
|
describe: string;
|
|
48
60
|
tag: string;
|
|
61
|
+
otp: string;
|
|
49
62
|
ignore_scripts: string;
|
|
50
63
|
no_git_checks: string;
|
|
51
64
|
};
|
|
65
|
+
status: {
|
|
66
|
+
describe: string;
|
|
67
|
+
verbose: string;
|
|
68
|
+
output: string;
|
|
69
|
+
since: string;
|
|
70
|
+
};
|
|
71
|
+
gen_release_note: {
|
|
72
|
+
describe: string;
|
|
73
|
+
repo: string;
|
|
74
|
+
custom: string;
|
|
75
|
+
};
|
|
52
76
|
};
|
|
53
77
|
};
|
|
54
78
|
export { i18n, localeKeys };
|
|
@@ -19,8 +19,20 @@ export declare const ZH_LOCALE: {
|
|
|
19
19
|
release: {
|
|
20
20
|
describe: string;
|
|
21
21
|
tag: string;
|
|
22
|
+
otp: string;
|
|
22
23
|
ignore_scripts: string;
|
|
23
24
|
no_git_checks: string;
|
|
24
25
|
};
|
|
26
|
+
status: {
|
|
27
|
+
describe: string;
|
|
28
|
+
verbose: string;
|
|
29
|
+
output: string;
|
|
30
|
+
since: string;
|
|
31
|
+
};
|
|
32
|
+
gen_release_note: {
|
|
33
|
+
describe: string;
|
|
34
|
+
repo: string;
|
|
35
|
+
custom: string;
|
|
36
|
+
};
|
|
25
37
|
};
|
|
26
38
|
};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.3.1-alpha.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -32,16 +32,18 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@babel/runtime": "^7",
|
|
36
|
-
"@changesets/cli": "2.
|
|
37
|
-
"@changesets/git": "^1.
|
|
38
|
-
"@
|
|
39
|
-
"@modern-js/
|
|
40
|
-
"@modern-js/
|
|
41
|
-
"
|
|
35
|
+
"@babel/runtime": "^7.18.0",
|
|
36
|
+
"@changesets/cli": "^2.23.0",
|
|
37
|
+
"@changesets/git": "^1.3.2",
|
|
38
|
+
"@changesets/read": "^0.5.5",
|
|
39
|
+
"@modern-js/i18n-cli-language-detector": "^1.2.4",
|
|
40
|
+
"@modern-js/plugin-i18n": "^1.2.8-alpha.0",
|
|
41
|
+
"@modern-js/utils": "^1.7.9-alpha.0",
|
|
42
|
+
"execa": "^5.1.1",
|
|
43
|
+
"resolve-from": "^5.0.0"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
|
-
"@modern-js/core": "1.
|
|
46
|
+
"@modern-js/core": "1.12.2-alpha.0",
|
|
45
47
|
"@scripts/build": "0.0.0",
|
|
46
48
|
"@types/jest": "^27",
|
|
47
49
|
"@types/node": "^14",
|
|
@@ -71,7 +73,8 @@
|
|
|
71
73
|
"files": [
|
|
72
74
|
"src/**/*",
|
|
73
75
|
"tsconfig.json",
|
|
74
|
-
"package.json"
|
|
76
|
+
"package.json",
|
|
77
|
+
"tests/**/*"
|
|
75
78
|
],
|
|
76
79
|
"output": []
|
|
77
80
|
}
|