@modern-js/plugin-changeset 1.2.6 → 1.3.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 +37 -0
- package/dist/js/modern/commands/index.js +3 -1
- package/dist/js/modern/commands/release-note.js +109 -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 +125 -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 +21 -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 +35 -11
- package/.eslintrc.js +0 -8
- package/jest.config.js +0 -7
- package/modern.config.js +0 -6
- package/tsconfig.json +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @modern-js/plugin-changeset
|
|
2
2
|
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 50eea41ee: feat: add change status command
|
|
8
|
+
- 4599e6914: feat: add gen-release-note command
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 0c17860e9: fix: changeset bump support ignore option
|
|
13
|
+
- Updated dependencies [63c354ad5]
|
|
14
|
+
- Updated dependencies [073e9ad78]
|
|
15
|
+
- Updated dependencies [f4a7d49e1]
|
|
16
|
+
- @modern-js/utils@1.7.8
|
|
17
|
+
|
|
18
|
+
## 1.2.8
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- a1198d509: feat: bump babel 7.18.0
|
|
23
|
+
- Updated dependencies [a1198d509]
|
|
24
|
+
- @modern-js/i18n-cli-language-detector@1.2.4
|
|
25
|
+
- @modern-js/plugin-i18n@1.2.7
|
|
26
|
+
|
|
27
|
+
## 1.2.7
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- d32f35134: chore: add modern/jest/eslint/ts config files to .npmignore
|
|
32
|
+
- Updated dependencies [d32f35134]
|
|
33
|
+
- Updated dependencies [6ae4a34ae]
|
|
34
|
+
- Updated dependencies [b80229c79]
|
|
35
|
+
- Updated dependencies [948cc4436]
|
|
36
|
+
- @modern-js/i18n-cli-language-detector@1.2.3
|
|
37
|
+
- @modern-js/plugin-i18n@1.2.6
|
|
38
|
+
- @modern-js/utils@1.7.3
|
|
39
|
+
|
|
3
40
|
## 1.2.6
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fs, execa } from '@modern-js/utils';
|
|
3
|
+
import readChangesets from '@changesets/read';
|
|
4
|
+
export function getReleaseInfo(commit, commitObj) {
|
|
5
|
+
const commitRegex = /(.*)\(#(\d*)\)/;
|
|
6
|
+
const [, message, author] = commit.split('--');
|
|
7
|
+
commitObj.author = author;
|
|
8
|
+
|
|
9
|
+
if ((message || commitObj.summary).match(commitRegex)) {
|
|
10
|
+
const [, messageShort, pullRequestId] = (message || commitObj.summary).match(commitRegex);
|
|
11
|
+
commitObj.pullRequestId = pullRequestId;
|
|
12
|
+
commitObj.message = messageShort.trim();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return commitObj;
|
|
16
|
+
}
|
|
17
|
+
export function getReleaseNoteLine(commit, customReleaseNoteFunction) {
|
|
18
|
+
if (customReleaseNoteFunction !== null && customReleaseNoteFunction !== void 0 && customReleaseNoteFunction.getReleaseNoteLine) {
|
|
19
|
+
return customReleaseNoteFunction.getReleaseNoteLine(commit);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
repository,
|
|
24
|
+
pullRequestId,
|
|
25
|
+
summary,
|
|
26
|
+
author
|
|
27
|
+
} = commit;
|
|
28
|
+
|
|
29
|
+
if (pullRequestId && repository) {
|
|
30
|
+
return `[[#${pullRequestId}](https://github.com/${repository}/pull/${pullRequestId})] ${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
31
|
+
} else if (pullRequestId) {
|
|
32
|
+
return `[#${pullRequestId}] ${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
33
|
+
} else {
|
|
34
|
+
return `${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export async function genReleaseNote(options) {
|
|
38
|
+
const cwd = process.cwd();
|
|
39
|
+
const {
|
|
40
|
+
repo,
|
|
41
|
+
custom
|
|
42
|
+
} = options;
|
|
43
|
+
let repository = repo;
|
|
44
|
+
let customReleaseNoteFunction;
|
|
45
|
+
|
|
46
|
+
if (!repo) {
|
|
47
|
+
const pkg = await fs.readJSON(path.join(cwd, 'package.json'));
|
|
48
|
+
({
|
|
49
|
+
repository
|
|
50
|
+
} = pkg);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (custom) {
|
|
54
|
+
customReleaseNoteFunction = require(custom);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const changesets = await readChangesets(cwd);
|
|
58
|
+
|
|
59
|
+
if (changesets.length === 0) {
|
|
60
|
+
console.warn('No unreleased changesets found.'); // eslint-disable-next-line no-process-exit
|
|
61
|
+
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const features = [];
|
|
66
|
+
const bugFix = [];
|
|
67
|
+
|
|
68
|
+
for (const changeset of changesets) {
|
|
69
|
+
var _customReleaseNoteFun;
|
|
70
|
+
|
|
71
|
+
const {
|
|
72
|
+
stdout
|
|
73
|
+
} = await execa('git', ['log', '--pretty=format:%h--%s--%an', `.changeset/${changeset.id}.md`]);
|
|
74
|
+
const [id, message] = stdout.split('--');
|
|
75
|
+
let commitObj = {
|
|
76
|
+
id,
|
|
77
|
+
type: (message || changeset.summary).startsWith('fix') ? 'fix' : 'feature',
|
|
78
|
+
repository,
|
|
79
|
+
message: (message || changeset.summary).trim(),
|
|
80
|
+
summary: changeset.summary
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if ((_customReleaseNoteFun = customReleaseNoteFunction) !== null && _customReleaseNoteFun !== void 0 && _customReleaseNoteFun.getReleaseInfo) {
|
|
84
|
+
commitObj = customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
|
|
85
|
+
} else {
|
|
86
|
+
commitObj = getReleaseInfo(stdout, commitObj);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (commitObj.type === 'fix') {
|
|
90
|
+
bugFix.push(commitObj);
|
|
91
|
+
} else {
|
|
92
|
+
features.push(commitObj);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!features.length && !bugFix.length) {
|
|
97
|
+
console.warn('no release note found, you can run `pnpm run add` to add changeset');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (features.length) {
|
|
101
|
+
console.info('Features:\n');
|
|
102
|
+
features.forEach(commit => console.info(getReleaseNoteLine(commit, customReleaseNoteFunction)));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (bugFix.length) {
|
|
106
|
+
console.info('Bug Fix:\n');
|
|
107
|
+
bugFix.forEach(commit => console.info(getReleaseNoteLine(commit, customReleaseNoteFunction)));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -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,125 @@
|
|
|
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 _utils = require("@modern-js/utils");
|
|
13
|
+
|
|
14
|
+
var _read = _interopRequireDefault(require("@changesets/read"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function getReleaseInfo(commit, commitObj) {
|
|
19
|
+
const commitRegex = /(.*)\(#(\d*)\)/;
|
|
20
|
+
const [, message, author] = commit.split('--');
|
|
21
|
+
commitObj.author = author;
|
|
22
|
+
|
|
23
|
+
if ((message || commitObj.summary).match(commitRegex)) {
|
|
24
|
+
const [, messageShort, pullRequestId] = (message || commitObj.summary).match(commitRegex);
|
|
25
|
+
commitObj.pullRequestId = pullRequestId;
|
|
26
|
+
commitObj.message = messageShort.trim();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return commitObj;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getReleaseNoteLine(commit, customReleaseNoteFunction) {
|
|
33
|
+
if (customReleaseNoteFunction !== null && customReleaseNoteFunction !== void 0 && customReleaseNoteFunction.getReleaseNoteLine) {
|
|
34
|
+
return customReleaseNoteFunction.getReleaseNoteLine(commit);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
repository,
|
|
39
|
+
pullRequestId,
|
|
40
|
+
summary,
|
|
41
|
+
author
|
|
42
|
+
} = commit;
|
|
43
|
+
|
|
44
|
+
if (pullRequestId && repository) {
|
|
45
|
+
return `[[#${pullRequestId}](https://github.com/${repository}/pull/${pullRequestId})] ${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
46
|
+
} else if (pullRequestId) {
|
|
47
|
+
return `[#${pullRequestId}] ${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
48
|
+
} else {
|
|
49
|
+
return `${summary}${author ? ` -- ${author}` : ''}\n`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function genReleaseNote(options) {
|
|
54
|
+
const cwd = process.cwd();
|
|
55
|
+
const {
|
|
56
|
+
repo,
|
|
57
|
+
custom
|
|
58
|
+
} = options;
|
|
59
|
+
let repository = repo;
|
|
60
|
+
let customReleaseNoteFunction;
|
|
61
|
+
|
|
62
|
+
if (!repo) {
|
|
63
|
+
const pkg = await _utils.fs.readJSON(_path.default.join(cwd, 'package.json'));
|
|
64
|
+
({
|
|
65
|
+
repository
|
|
66
|
+
} = pkg);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (custom) {
|
|
70
|
+
customReleaseNoteFunction = require(custom);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const changesets = await (0, _read.default)(cwd);
|
|
74
|
+
|
|
75
|
+
if (changesets.length === 0) {
|
|
76
|
+
console.warn('No unreleased changesets found.'); // eslint-disable-next-line no-process-exit
|
|
77
|
+
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const features = [];
|
|
82
|
+
const bugFix = [];
|
|
83
|
+
|
|
84
|
+
for (const changeset of changesets) {
|
|
85
|
+
var _customReleaseNoteFun;
|
|
86
|
+
|
|
87
|
+
const {
|
|
88
|
+
stdout
|
|
89
|
+
} = await (0, _utils.execa)('git', ['log', '--pretty=format:%h--%s--%an', `.changeset/${changeset.id}.md`]);
|
|
90
|
+
const [id, message] = stdout.split('--');
|
|
91
|
+
let commitObj = {
|
|
92
|
+
id,
|
|
93
|
+
type: (message || changeset.summary).startsWith('fix') ? 'fix' : 'feature',
|
|
94
|
+
repository,
|
|
95
|
+
message: (message || changeset.summary).trim(),
|
|
96
|
+
summary: changeset.summary
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
if ((_customReleaseNoteFun = customReleaseNoteFunction) !== null && _customReleaseNoteFun !== void 0 && _customReleaseNoteFun.getReleaseInfo) {
|
|
100
|
+
commitObj = customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
|
|
101
|
+
} else {
|
|
102
|
+
commitObj = getReleaseInfo(stdout, commitObj);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (commitObj.type === 'fix') {
|
|
106
|
+
bugFix.push(commitObj);
|
|
107
|
+
} else {
|
|
108
|
+
features.push(commitObj);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!features.length && !bugFix.length) {
|
|
113
|
+
console.warn('no release note found, you can run `pnpm run add` to add changeset');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (features.length) {
|
|
117
|
+
console.info('Features:\n');
|
|
118
|
+
features.forEach(commit => console.info(getReleaseNoteLine(commit, customReleaseNoteFunction)));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (bugFix.length) {
|
|
122
|
+
console.info('Bug Fix:\n');
|
|
123
|
+
bugFix.forEach(commit => console.info(getReleaseNoteLine(commit, customReleaseNoteFunction)));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -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,21 @@
|
|
|
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
|
+
}
|
|
10
|
+
interface ReleaseNoteOptions {
|
|
11
|
+
repo?: string;
|
|
12
|
+
custom?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare type CustomReleaseNoteFunction = {
|
|
15
|
+
getReleaseInfo?: (commit: string, commitObj: Commit) => Commit;
|
|
16
|
+
getReleaseNoteLine?: (commit: Commit) => string;
|
|
17
|
+
} | undefined;
|
|
18
|
+
export declare function getReleaseInfo(commit: string, commitObj: Commit): Commit;
|
|
19
|
+
export declare function getReleaseNoteLine(commit: Commit, customReleaseNoteFunction?: CustomReleaseNoteFunction): string;
|
|
20
|
+
export declare function genReleaseNote(options: ReleaseNoteOptions): Promise<void>;
|
|
21
|
+
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.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,18 +32,19 @@
|
|
|
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/
|
|
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.7",
|
|
41
|
+
"@modern-js/utils": "^1.7.8",
|
|
41
42
|
"execa": "^5.1.1"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@modern-js/core": "1.
|
|
45
|
+
"@modern-js/core": "1.12.1",
|
|
45
46
|
"@scripts/build": "0.0.0",
|
|
46
|
-
"@types/jest": "^
|
|
47
|
+
"@types/jest": "^27",
|
|
47
48
|
"@types/node": "^14",
|
|
48
49
|
"typescript": "^4",
|
|
49
50
|
"jest": "^27",
|
|
@@ -54,11 +55,34 @@
|
|
|
54
55
|
"registry": "https://registry.npmjs.org/",
|
|
55
56
|
"access": "public"
|
|
56
57
|
},
|
|
58
|
+
"wireit": {
|
|
59
|
+
"build": {
|
|
60
|
+
"command": "modern build",
|
|
61
|
+
"files": [
|
|
62
|
+
"src/**/*",
|
|
63
|
+
"tsconfig.json",
|
|
64
|
+
"package.json"
|
|
65
|
+
],
|
|
66
|
+
"output": [
|
|
67
|
+
"dist/**/*"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"test": {
|
|
71
|
+
"command": "jest --passWithNoTests",
|
|
72
|
+
"files": [
|
|
73
|
+
"src/**/*",
|
|
74
|
+
"tsconfig.json",
|
|
75
|
+
"package.json",
|
|
76
|
+
"tests/**/*"
|
|
77
|
+
],
|
|
78
|
+
"output": []
|
|
79
|
+
}
|
|
80
|
+
},
|
|
57
81
|
"scripts": {
|
|
58
82
|
"new": "modern new",
|
|
59
83
|
"dev": "modern build --watch",
|
|
60
|
-
"build": "
|
|
61
|
-
"test": "
|
|
84
|
+
"build": "wireit",
|
|
85
|
+
"test": "wireit"
|
|
62
86
|
},
|
|
63
87
|
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
|
64
88
|
}
|
package/.eslintrc.js
DELETED
package/jest.config.js
DELETED
package/modern.config.js
DELETED