@modern-js/plugin-changeset 1.2.8 → 1.3.1

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 CHANGED
@@ -1,5 +1,28 @@
1
1
  # @modern-js/plugin-changeset
2
2
 
3
+ ## 1.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 42741db: perf(plugin-changeset): optimize custom generator release note
8
+ - Updated dependencies [a90bc96]
9
+ - @modern-js/utils@1.7.9
10
+
11
+ ## 1.3.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 50eea41ee: feat: add change status command
16
+ - 4599e6914: feat: add gen-release-note command
17
+
18
+ ### Patch Changes
19
+
20
+ - 0c17860e9: fix: changeset bump support ignore option
21
+ - Updated dependencies [63c354ad5]
22
+ - Updated dependencies [073e9ad78]
23
+ - Updated dependencies [f4a7d49e1]
24
+ - @modern-js/utils@1.7.8
25
+
3
26
  ## 1.2.8
4
27
 
5
28
  ### Patch Changes
@@ -1,4 +1,6 @@
1
1
  export * from "./change";
2
2
  export * from "./bump";
3
3
  export * from "./pre";
4
- export * from "./release";
4
+ export * from "./release";
5
+ export * from "./status";
6
+ export * from "./release-note";
@@ -0,0 +1,130 @@
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
+
116
+ for (const commit of features) {
117
+ const releaseNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
118
+ console.info(releaseNote);
119
+ }
120
+ }
121
+
122
+ if (bugFix.length) {
123
+ console.info('## Bug Fix:\n');
124
+
125
+ for (const commit of bugFix) {
126
+ const relesaeNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
127
+ console.info(relesaeNote);
128
+ }
129
+ }
130
+ }
@@ -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
+ }
@@ -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('--preid <tag>', i18n.t(localeKeys.command.bump.preid), 'next').option('--snapshot [snapshot]', i18n.t(localeKeys.command.bump.snapshot), false).action(options => bump(options));
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 special kind of publishing for testing',
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,147 @@
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
+
133
+ for (const commit of features) {
134
+ const releaseNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
135
+ console.info(releaseNote);
136
+ }
137
+ }
138
+
139
+ if (bugFix.length) {
140
+ console.info('## Bug Fix:\n');
141
+
142
+ for (const commit of bugFix) {
143
+ const relesaeNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
144
+ console.info(relesaeNote);
145
+ }
146
+ }
147
+ }
@@ -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
+ }
@@ -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('--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));
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 special kind of publishing for testing',
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
  };
@@ -1,4 +1,6 @@
1
1
  export * from './change';
2
2
  export * from './bump';
3
3
  export * from './pre';
4
- export * from './release';
4
+ export * from './release';
5
+ export * from './status';
6
+ export * from './release-note';
@@ -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 PublishOptions {
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: PublishOptions): Promise<void>;
7
+ export declare function release(options: ReleaseOptions): Promise<void>;
7
8
  export {};
@@ -0,0 +1,7 @@
1
+ interface StatusOptions {
2
+ verbose: boolean;
3
+ output: string;
4
+ since: string;
5
+ }
6
+ export declare function status(options: StatusOptions): Promise<void>;
7
+ export {};
@@ -1,4 +1,5 @@
1
1
  import type { CliPlugin } from '@modern-js/core';
2
+ export * from './commands';
2
3
 
3
4
  declare const _default: () => CliPlugin;
4
5
 
@@ -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.2.8",
14
+ "version": "1.3.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -33,15 +33,17 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7.18.0",
36
- "@changesets/cli": "2.16.0",
37
- "@changesets/git": "^1.1.2",
36
+ "@changesets/cli": "^2.23.0",
37
+ "@changesets/git": "^1.3.2",
38
+ "@changesets/read": "^0.5.5",
38
39
  "@modern-js/i18n-cli-language-detector": "^1.2.4",
39
40
  "@modern-js/plugin-i18n": "^1.2.7",
40
- "@modern-js/utils": "^1.7.6",
41
- "execa": "^5.1.1"
41
+ "@modern-js/utils": "^1.7.9",
42
+ "execa": "^5.1.1",
43
+ "resolve-from": "^5.0.0"
42
44
  },
43
45
  "devDependencies": {
44
- "@modern-js/core": "1.11.2",
46
+ "@modern-js/core": "1.12.2",
45
47
  "@scripts/build": "0.0.0",
46
48
  "@types/jest": "^27",
47
49
  "@types/node": "^14",