@modern-js/main-doc 0.0.0-next-1686023023547 → 0.0.0-next-1686044917772

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +12 -3
  2. package/docs/en/components/debug-app.mdx +1 -1
  3. package/docs/en/components/deploy.mdx +1 -0
  4. package/docs/en/components/init-app.mdx +4 -8
  5. package/docs/en/components/release-note.mdx +1 -0
  6. package/docs/en/configure/app/tools/swc.mdx +2 -16
  7. package/docs/en/guides/get-started/glossary.mdx +12 -12
  8. package/docs/en/guides/get-started/introduction.mdx +18 -21
  9. package/docs/en/guides/get-started/quick-start.mdx +21 -37
  10. package/docs/en/guides/get-started/upgrade.mdx +15 -14
  11. package/docs/en/guides/topic-detail/changesets/_category_.json +4 -0
  12. package/docs/en/guides/topic-detail/changesets/add.mdx +125 -0
  13. package/docs/en/guides/topic-detail/changesets/changelog.mdx +238 -0
  14. package/docs/en/guides/topic-detail/changesets/commit.mdx +269 -0
  15. package/docs/en/guides/topic-detail/changesets/config.mdx +147 -0
  16. package/docs/en/guides/topic-detail/changesets/github.mdx +175 -0
  17. package/docs/en/guides/topic-detail/changesets/introduce.mdx +56 -0
  18. package/docs/en/guides/topic-detail/changesets/release-note.mdx +273 -0
  19. package/docs/en/guides/topic-detail/changesets/release-pre.mdx +49 -0
  20. package/docs/en/guides/topic-detail/changesets/release.mdx +229 -0
  21. package/docs/zh/community/blog/v2-release-note.mdx +1 -1
  22. package/docs/zh/components/init-app.mdx +5 -9
  23. package/docs/zh/configure/app/tools/swc.mdx +2 -16
  24. package/docs/zh/guides/get-started/quick-start.mdx +7 -10
  25. package/docs/zh/guides/get-started/upgrade.mdx +1 -1
  26. package/docs/zh/guides/topic-detail/changesets/add.mdx +15 -13
  27. package/docs/zh/guides/topic-detail/changesets/changelog.mdx +20 -20
  28. package/docs/zh/guides/topic-detail/changesets/commit.mdx +12 -14
  29. package/docs/zh/guides/topic-detail/changesets/config.mdx +5 -5
  30. package/docs/zh/guides/topic-detail/changesets/github.mdx +38 -27
  31. package/docs/zh/guides/topic-detail/changesets/introduce.mdx +12 -12
  32. package/docs/zh/guides/topic-detail/changesets/release-note.mdx +84 -70
  33. package/docs/zh/guides/topic-detail/changesets/release-pre.mdx +9 -9
  34. package/docs/zh/guides/topic-detail/changesets/release.mdx +29 -29
  35. package/package.json +5 -5
@@ -4,7 +4,7 @@ sidebar_position: 5
4
4
 
5
5
  # Changesets 配置文件
6
6
 
7
- 我们前面了解到,初始化 Modern.js 仓库时,会默认初始化 Changesets 的配置文件,即 `.changeset/config.json` 文件,下面我们将详细了解一下该文件中支持哪些配置。
7
+ 我们前面了解到,初始化 Modern.js 仓库时,会默认初始化 changesets 的配置文件,即 `.changeset/config.json` 文件,下面我们将详细了解一下该文件中支持哪些配置。
8
8
 
9
9
  ## 配置介绍
10
10
 
@@ -106,15 +106,15 @@ pkg-b @ version 1.0.0
106
106
 
107
107
  默认值:`@changesets/cli/changelog`
108
108
 
109
- 生成 Changelog 规则。
109
+ 生成 changelog 规则。
110
110
 
111
- 配置为 `false` 时,执行 bump 命令时,在 `CHANGELOG.md` 文件中只声明版本号,不声明其他 Changelog 信息。
111
+ 配置为 `false` 时,执行 bump 命令时,在 `CHANGELOG.md` 文件中只声明版本号,不声明其他 changelog 信息。
112
112
 
113
113
  ![关闭 changelog 配置](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-empty-changelog.png)
114
114
 
115
- 配置为 `@changesets/cli/changelog` 将使用官方提供的 Changlog 生成规则,将 changeset 信息转换为 Changlog 内容。
115
+ 配置为 `@changesets/cli/changelog` 将使用官方提供的 changlog 生成规则,将 changeset 信息转换为 changlog 内容。
116
116
 
117
- 配置为数组时,第一个参数为自定义 NPM 包或者路径,第二个参数为需要传入的默认参数配置,自定义格式我们将在后续[自定义 Changelog](/guides/topic-detail/changesets/changelog) 章节讲解。
117
+ 配置为数组时,第一个参数为自定义 NPM 包或者路径,第二个参数为需要传入的默认参数配置,自定义格式我们将在后续[自定义 changelog](/guides/topic-detail/changesets/changelog) 章节讲解。
118
118
 
119
119
  ### \_\_\_experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH
120
120
 
@@ -6,7 +6,7 @@ sidebar_position: 9
6
6
 
7
7
  ## BOT
8
8
 
9
- 在 Github 上,Changesets 提供了机器人用于检测当前 Pull Request 是否存在 changeset,并提供了 UI 界面添加和修改 changeset。
9
+ 在 Github 上,changesets 提供了机器人用于检测当前 Pull Request 是否存在 changeset,并提供了 UI 界面添加和修改 changeset。
10
10
 
11
11
  ### 安装
12
12
 
@@ -46,9 +46,9 @@ sidebar_position: 9
46
46
 
47
47
  Modern.js 提供了自动创建发版 Pull Request 的 Github Action,提供基于选择的分支自动执行 bump 操作,更新 lock 文件及创建 Pull Request 操作。
48
48
 
49
- ### 使用
49
+ #### 使用
50
50
 
51
- 在仓库中创建 `.github/workflows/release-pull-request.yml` 文件,填入以下内容:
51
+ - 在仓库中创建 `.github/workflows/release-pull-request.yml` 文件,填入以下内容:
52
52
 
53
53
  ```yaml
54
54
  name: Release Pull Request
@@ -57,8 +57,15 @@ on:
57
57
  workflow_dispatch:
58
58
  inputs:
59
59
  version:
60
- description: 'Release Version(v1.0.0)'
60
+ type: choice
61
+ description: 'Release Type(canary, beta, alpha, latest)'
61
62
  required: true
63
+ default: 'latest'
64
+ options:
65
+ - canary
66
+ - beta
67
+ - alpha
68
+ - latest
62
69
 
63
70
  jobs:
64
71
  release:
@@ -71,37 +78,40 @@ jobs:
71
78
  # This makes Actions fetch only one branch to release
72
79
  fetch-depth: 100
73
80
 
81
+ - ... # install dependencies and build repo package
74
82
  - name: Create Release Pull Request
75
- uses: web-infra-dev/actions@main
83
+ uses: web-infra-dev/actions@v2
76
84
  with:
77
- # this expects you to have a script called release which does a build for your packages and calls changeset publish
78
- versionNumber: ${{ github.event.inputs.version }}
85
+ version: ${{ github.event.inputs.version }}
86
+ versionNumber: 'auto'
79
87
  type: 'pull request'
88
+ tools: 'modern'
80
89
  env:
81
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90
+ GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}
91
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
82
92
  REPOSITORY: ${{ github.repository }}
83
93
  REF: ${{ github.ref }}
84
94
  ```
85
95
 
86
- 将 Workflow 合并到主分支后,进入 Github 仓库对应的 Action 页面,选择 Release Pull Request:
96
+ - 将 Workflow 合并到主分支后,进入 Github 仓库对应的 Action 页面,选择 Release Pull Request:
87
97
 
88
98
  ![Release Pull Request Action](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/action-pull-request.png)
89
99
 
90
- 选择本次发布的分支并填入版本号,版本号格式推荐 v1.0.0,点击 Run workflow 按钮:
100
+ - 选择本次发布类型,点击 Run workflow 按钮:
91
101
 
92
- ![Run Release Pull Request](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/run-pull-request-action.png)
102
+ ![Run Release Pull Request](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/action-pull-request.jpeg)
93
103
 
94
- workflow 运行完成后将自动创建 `Release-${version}` 的 Pull Request,自动完成 `bump` changeset 相关版本号并更新 lock 文件,Pull Request 的内容为执行 `gen-release-note` 命令自动生成的 Release Note。
104
+ - Workflow 运行完成后将自动创建 `Release-${version}` 的 Pull Request,自动完成 `bump` changeset 相关版本号并更新 lock 文件,Pull Request 的内容为执行 `gen-release-note` 命令自动生成的 Release Note。
95
105
 
96
- ![Release Pull Request](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/release-pull-request.png)
106
+ ![Release Pull Request](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/release-pull-request.jpeg)
97
107
 
98
108
  ### 自动 Release
99
109
 
100
- Modern.js 提供了自动创建发版 Pull Request 的 Github Action,提供基于选择的分支自动执行 release 操作,将包发布到 NPM 上。
110
+ Modern.js 提供了自动发布版本 的 Github Action,提供基于选择的分支自动执行 release 操作,将包发布到 NPM 上。
101
111
 
102
112
  #### 使用
103
113
 
104
- 在仓库中创建 `.github/workflows/release.yml` 文件,填入以下内容:
114
+ - 在仓库中创建 `.github/workflows/release.yml` 文件,填入以下内容:
105
115
 
106
116
  ```yaml
107
117
  name: Release
@@ -111,14 +121,14 @@ on:
111
121
  inputs:
112
122
  version:
113
123
  type: choice
114
- description: 'Release Version(canary, alpha, pre, latest)'
124
+ description: 'Release Version(canary, beta, alpha, latest)'
115
125
  required: true
116
- default: 'canary'
126
+ default: 'next'
117
127
  options:
118
- - canary
119
- - alpha
120
- - pre
121
- - latest
128
+ - canary
129
+ - beta
130
+ - alpha
131
+ - latest
122
132
  branch:
123
133
  description: 'Release Branch(confirm release branch)'
124
134
  required: true
@@ -135,13 +145,14 @@ jobs:
135
145
  # This makes Actions fetch only one branch to release
136
146
  fetch-depth: 1
137
147
 
148
+ - ... # install dependencies and build repo package
138
149
  - name: Release
139
- uses: web-infra-dev/actions@main
150
+ uses: web-infra-dev/actions@v2
140
151
  with:
141
- # this expects you to have a script called release which does a build for your packages and calls changeset publish
142
152
  version: ${{ github.event.inputs.version }}
143
153
  branch: ${{ github.event.inputs.branch }}
144
154
  type: 'release'
155
+ tools: 'modern'
145
156
  env:
146
157
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147
158
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -149,16 +160,16 @@ jobs:
149
160
  REF: ${{ github.ref }}
150
161
  ```
151
162
 
152
- 配置仓库的 NPM_TOKEN:
163
+ - 配置仓库的 NPM_TOKEN:
153
164
 
154
165
  ![配置 Token](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/github-set-npm-token.png)
155
166
 
156
- 将 Workflow 合并到主分支后,进入 Github 仓库对应的 Action 页面,选择 Release:
167
+ - 将 Workflow 合并到主分支后,进入 Github 仓库对应的 Action 页面,选择 Release:
157
168
 
158
169
  ![Release Action](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/release-action.png)
159
170
 
160
- 选择分支名称和发布版本类型,点击 Run workflow 按钮:
171
+ - 选择分支名称和发布版本类型,点击 Run workflow 按钮:
161
172
 
162
173
  ![Run Release Action](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/run-release-workflow.png)
163
174
 
164
- Workflow 将自动完成仓库 build 和发布到 NPM 流程。
175
+ - Workflow 将自动完成仓库 build 和发布到 NPM 流程。
@@ -4,7 +4,7 @@ sidebar_position: 1
4
4
 
5
5
  # 认识 Changesets
6
6
 
7
- Modern.js 默认集成了 [Changesets](https://github.com/changesets/changesets) 用于模块和 Monorepo 工程方案项目中的包版本管理。
7
+ Modern.js 默认集成了 [changesets](https://github.com/changesets/changesets) 用于模块和 Monorepo 工程方案的包版本管理。
8
8
 
9
9
  ## 特点
10
10
 
@@ -12,15 +12,15 @@ Changesets 具有以下几个特点:
12
12
 
13
13
  - 在开发时,需要开发者提供本次变更涉及的包名称、升级版本类型(`pathch`、`minor`、`major`)及变更信息,即 changeset。
14
14
 
15
- - 在发布版本时,会根据 changeset 自动升级对应包的版本号,并在对应的包中生成 Changelog 信息。
15
+ - 在发布版本时,会根据 changeset 内容自动升级对应包的版本号,并在对应的包中生成 changelog 信息。
16
16
 
17
- - 在 Monorepo 场景中,changeset 会自动生成仓库依赖图,升级时只会升级变更包及相关依赖包的版本号。
17
+ - 在 Monorepo 项目中,changeset 会自动生成仓库依赖图,升级时只会升级变更包及相关依赖包的版本号。
18
18
 
19
19
  ## 初始化
20
20
 
21
- Modern.js 默认创建的模块和 Monorepo 工程方案项目已经初始化完成 Changesets,在项目根目录会自动创建 `.changeset` 目录,及 `.changeset/config.json` 的配置文件。
21
+ Modern.js 默认创建的模块和 Monorepo 工程方案项目已经初始化完成 changesets,在项目根目录会自动创建 `.changeset` 目录,及 `.changeset/config.json` 的配置文件。
22
22
 
23
- 并且,Modern.js 在其对应的工程方案工具 `@modern-js/module-tools` 和 `@modern-js/monorepo-tools` 提供了 Changesets 相应的命令,无需再手动安装 Changesets 相关依赖。
23
+ 并且,Modern.js 在其对应的工程方案工具 `@modern-js/module-tools` 和 `@modern-js/monorepo-tools` 提供了 changesets 相应的命令,无需再手动安装 changesets 相关依赖。
24
24
 
25
25
  Changesets 默认配置如下:
26
26
 
@@ -37,20 +37,20 @@ Changesets 默认配置如下:
37
37
  }
38
38
  ```
39
39
 
40
- 配置文件提供了生成 Changesets 的一些基本配置,字段详细介绍请参考后续章节: [Changesets 配置文件](/guides/topic-detail/changesets/config)。
40
+ 配置文件提供了生成 changesets 的一些基本配置,字段详细介绍请参考 [Changesets 配置文件](/guides/topic-detail/changesets/config)。
41
41
 
42
42
  ## 命令
43
43
 
44
- - `change` 创建一个 changeset,执行完成该命令后会自动在 `.changeset` 目录生成一个 changeset 文件。
44
+ - `change`: 创建一个 changeset,执行完成该命令后会自动在 `.changeset` 目录生成一个 changeset 文件。
45
45
 
46
- - `bump` 根据当前 changeset 升级对应包版本号。
46
+ - `bump`: 根据当前 changeset 升级对应包版本号。
47
47
 
48
- - `pre` 标记进入和退出 `pre release` 模式,在 `pre release` 模式下执行 `bump` 命令,将会生成 `x.x.x-${pre-tag}.x` 的版本号格式。
48
+ - `pre`: 标记进入和退出 pre-release 模式,在 pre release 模式下执行 `bump` 命令,将会生成 `x.x.x-${pre-tag}.x` 的版本号格式。
49
49
 
50
- - `release` 发布包到 NPM。
50
+ - `release`: 发布包到 NPM。
51
51
 
52
- - `status` 查看当前 changeset 状态。
52
+ - `status`: 查看当前 changeset 状态。
53
53
 
54
- - `gen-release-note` 根据当前的 chagneset 状态生成 Release Note 信息。
54
+ - `gen-release-note`: 根据当前的 chagneset 状态生成 Release Note 信息。
55
55
 
56
56
  具体命令支持的参数可以查看后续对应章节介绍。
@@ -9,24 +9,26 @@ Modern.js 提供了 `modern gen-release-note` 命令,支持通过当前存在
9
9
  默认生成的 Release Note 格式为:
10
10
 
11
11
  ```markdown
12
- [[#1220](https://github.com/web-infra-dev/modern.js/pull/1220)] feat: support bff operators -- Ming
12
+ - fix: add missing type definitions by @zllkjc in https://github.com/web-infra-dev/modern.js/pull/3835
13
13
  ```
14
14
 
15
15
  根据 commit 信息获取 changeset 的 Pull Request ID,并生成 Github 的链接,内容为 changeset 的 changelog 信息和作者信息。
16
16
 
17
+ :::info
18
+ 获取作者信息,需要提供 Github Token 环境变量,通过 GITHUB_AUTH_TOKEN 传入。
19
+ :::
20
+
17
21
  当默认生成 Release Note 逻辑不能满足需求时,支持自定义 Release Note 格式。
18
22
 
19
23
  ## 信息
20
24
 
21
- ### 自定义 Release Note 所需信息
25
+ ### getReleaseInfo
22
26
 
23
27
  生成 Release Note 信息需要先收集一些信息,比如 commit ID、Pull Request ID、commit message 等等。
24
28
 
25
29
  该逻辑可通过 `getReleaseInfo` 函数实现。
26
30
 
27
- #### getReleaseInfo
28
-
29
- ##### Params
31
+ #### Params
30
32
 
31
33
  - commit
32
34
 
@@ -34,40 +36,71 @@ Modern.js 提供了 `modern gen-release-note` 命令,支持通过当前存在
34
36
 
35
37
  当前 changeset 对应的 commit message 信息。
36
38
 
37
- 执行 `git log --pretty=format:%h--%s--%an .changeset/${changeset.id}.md` 的结果。
39
+ 执行 `git log --pretty=format:%h--%s--%ae .changeset/${changeset.id}.md` 的结果。
38
40
 
39
41
  - commitObj
40
42
 
41
43
  初步解析 commit 获取基本信息。
42
44
 
43
45
  ```ts
46
+ export enum CommitType {
47
+ Performance = 'performance',
48
+ Features = 'features',
49
+ BugFix = 'bugFix',
50
+ Doc = 'doc',
51
+ Other = 'other',
52
+ }
53
+
44
54
  interface Commit {
45
55
  id: string; // commit id
46
- type: 'feature' | 'fix'; // commit 类型,默认通过开头字符串如果为 fix,类型为 fix,其他为 feature
56
+ type: CommitType;
47
57
  repository?: string; // 参数传入的 repo 信息或者 package.json 中定义的 repository 信息
48
58
  pullRequestId?: string;
49
59
  author?: string;
50
60
  message: string; // commit message
51
61
  summary: string; // changeset summary
62
+ summary_zh: string; // changeset zh summary
52
63
  [key: string]: string | undefined;
53
64
  }
54
65
  ```
55
66
 
56
- ##### 返回值
67
+ #### 返回值
57
68
 
58
69
  commitObj, 补充后完整的 commit 对象。
59
70
 
60
- ##### 默认实现
71
+ #### 默认实现
61
72
 
62
- Modern.js 的默认实现为:根据 commit 信息拆分出 Pull Request ID 和作者,加入到 commitObj 中。
73
+ Modern.js 的默认实现为:根据 commit 信息拆分出 Pull Request ID,并根据 commit id 获取到用户信息,加入到 commitObj 中。
63
74
 
64
75
  ```ts
65
76
  function getReleaseInfo(commit: string, commitObj: Commit) {
66
77
  const commitRegex = /(.*)\(#(\d*)\)/;
67
78
 
68
- const [, message, author] = commit.split('--');
69
-
70
- commitObj.author = author;
79
+ const [commitId, message, email] = commit.split('--');
80
+
81
+ const author = AuthorMap.get(email);
82
+ const token = authToken || process.env.GITHUB_AUTH_TOKEN;
83
+ if (author) {
84
+ commitObj.author = author;
85
+ } else if (repo && token) {
86
+ try {
87
+ const res = await axios.get(
88
+ `https://api.github.com/repos/${repo}/commits/${commitId}`,
89
+ {
90
+ method: 'GET',
91
+ headers: {
92
+ 'Content-Type': 'application/json',
93
+ Authorization: token,
94
+ },
95
+ },
96
+ );
97
+ const author = res.data.author.login;
98
+ commitObj.author = author;
99
+ AuthorMap.set(email, author);
100
+ } catch (e) {
101
+ console.warn(e);
102
+ }
103
+ }
71
104
 
72
105
  if ((message || commitObj.summary).match(commitRegex)) {
73
106
  const [, messageShort, pullRequestId] = (
@@ -81,75 +114,56 @@ function getReleaseInfo(commit: string, commitObj: Commit) {
81
114
  }
82
115
  ```
83
116
 
84
- ### 使用获取的信息生成 Release Note
117
+ #### getReleaseNoteLine
85
118
 
86
119
  根据 `getReleaseInfo` 中获取的 commit 对象信息,生成对应的 Release Note。
87
120
 
88
121
  该逻辑可通过 `getReleaseNoteLine` 函数实现。
89
122
 
90
- #### getReleaseNoteLine
91
-
92
- ##### Params
123
+ #### Params
93
124
 
94
125
  - commit
95
126
 
96
127
  类型和上述 commitObj 类型一致。
97
128
 
98
- ##### 返回值
129
+ - lang
130
+
131
+ 类型: string;
132
+
133
+ 获取对应语言的 Release Note 信息,支持 `en` 和 `zh`,默认为 `en`。
134
+
135
+ #### 返回值
99
136
 
100
137
  生成的 Release Note。
101
138
 
102
- ##### 默认实现
139
+ #### 默认实现
103
140
 
104
141
  Modern.js 的默认实现为:
105
142
 
106
143
  ```ts
107
- function formatSummary(summary: string, pullRequestId?: string) {
108
- const [firstLine, ...futureLines] = summary
109
- .split('\n')
110
- .map(l => l.trimRight());
111
-
112
- let returnVal = firstLine;
113
-
114
- if (futureLines.length > 0) {
115
- if (pullRequestId) {
116
- returnVal = `\n\n ${returnVal}`;
117
- } else {
118
- returnVal = `\n ${returnVal}`;
119
- }
120
- returnVal += `\n\n ${futureLines
121
- .filter(l => Boolean(l))
122
- .map(l => l)
123
- .join('\n\n')}`;
124
- }
125
- return returnVal;
126
- }
127
-
128
- export async function getReleaseNoteLine(
144
+ export function getReleaseNoteLine(
129
145
  commit: Commit,
130
- customReleaseNoteFunction?: CustomReleaseNoteFunction,
146
+ lang: 'en' | 'zh' = 'en',
131
147
  ) {
132
- if (customReleaseNoteFunction?.getReleaseNoteLine) {
133
- return customReleaseNoteFunction.getReleaseNoteLine(commit);
134
- }
135
-
136
- const { repository, pullRequestId, summary } = commit;
137
- if (pullRequestId && repository) {
138
- return `- [#${pullRequestId}](https://github.com/${repository}/pull/${pullRequestId}) ${formatSummary(
139
- summary,
140
- pullRequestId,
141
- )}\n`;
142
- }
143
- if (pullRequestId) {
144
- return `#${pullRequestId} ${formatSummary(summary, pullRequestId)}\n`;
148
+ const { repository, pullRequestId, summary, summary_zh, author } = commit;
149
+ const pullRequest =
150
+ pullRequestId && repository
151
+ ? `https://github.com/${repository}/pull/${pullRequestId}`
152
+ : '';
153
+ if (lang === 'en') {
154
+ return `- ${summary}${author ? ` by @${author}` : ''}${
155
+ pullRequest ? ` in ${pullRequest}` : ''
156
+ }\n`;
145
157
  }
146
- return `${formatSummary(summary, pullRequestId)}\n`;
158
+ return `- ${summary_zh}${author ? ` 由 @${author} 实现` : ''}${
159
+ pullRequest ? `, 详情可查看 ${pullRequest}` : ''
160
+ }\n`;
147
161
  }
148
162
  ```
149
163
 
150
164
  ## 使用自定义模块
151
165
 
152
- `gen-release-note` 命令支持 `--custom` 参数,该参数可传入自定义 release note 模块的模块名称或者路径。
166
+ `gen-release-note` 命令支持 `--custom` 参数,该参数可传入自定义 Release Note 模块的模块名称或者路径。
153
167
 
154
168
  ### 配置相对路径
155
169
 
@@ -173,10 +187,10 @@ module.exports = {
173
187
  执行下面命令:
174
188
 
175
189
  ```bash
176
- pnpm run gen-release-note -- --custom ./scripts/my-release-note-config.js
190
+ pnpm run gen-release-note --custom ./scripts/my-release-note-config.js
177
191
  ```
178
192
 
179
- 也可以把命令参数直接定义到 package.json 中:
193
+ 也可以把命令参数直接定义到 `package.json` 中:
180
194
 
181
195
  ```json title="package.json"
182
196
  {
@@ -194,7 +208,7 @@ pnpm run gen-release-note -- --custom ./scripts/my-release-note-config.js
194
208
 
195
209
  custom 参数值还可以使用模块工程方案进行管理,提供通用方案。
196
210
 
197
- 1. 使用 npx @modern-js/create@latest 创建模块工程方案。
211
+ #### 使用 `npx @modern-js/create@latest` 创建模块工程方案
198
212
 
199
213
  ```md
200
214
  ? 请选择你想创建的工程类型:Npm 模块
@@ -203,7 +217,7 @@ custom 参数值还可以使用模块工程方案进行管理,提供通用方
203
217
  ? 请选择包管理工具:pnpm
204
218
  ```
205
219
 
206
- 2. 实现自定义内容。
220
+ #### 实现自定义内容
207
221
 
208
222
  ```ts title="src/index.ts"
209
223
  export function getReleaseInfo() {}
@@ -211,19 +225,19 @@ export function getReleaseInfo() {}
211
225
  export function getReleaseNoteLine() {}
212
226
  ```
213
227
 
214
- 3. 将模块发布到 NPM
215
- 4. 在目标仓库根目录安装对应模块,例如 `custom-release-note`。
216
- 5. 执行 gen-release-note 命令添加 custom 参数
228
+ #### 将模块发布到 NPM
229
+ #### 在目标仓库根目录安装对应模块,例如 `custom-release-note`
230
+ #### 执行 gen-release-note 命令添加 custom 参数
217
231
 
218
232
  ```bash
219
- pnpm run gen-release-note -- --custom custom-release-note
233
+ pnpm run gen-release-note --custom custom-release-note
220
234
  ```
221
235
 
222
236
  ### 使用 Monorepo 工程方案
223
237
 
224
238
  如果你当前仓库为 Monorepo 工程方案,可以直接使用模块子项目进行管理。
225
239
 
226
- 1. 执行 `pnpm run new` 创建模块子项目
240
+ #### 执行 `pnpm run new` 创建模块子项目
227
241
 
228
242
  ```md
229
243
  ? 请选择你想创建的工程类型:Npm 模块
@@ -232,7 +246,7 @@ pnpm run gen-release-note -- --custom custom-release-note
232
246
  ? 请选择开发语言:TS
233
247
  ```
234
248
 
235
- 2. 实现自定义内容。
249
+ #### 实现自定义内容
236
250
 
237
251
  ```ts title="src/index.ts"
238
252
  export function getReleaseInfo() {}
@@ -240,7 +254,7 @@ export function getReleaseInfo() {}
240
254
  export function getReleaseNoteLine() {}
241
255
  ```
242
256
 
243
- 3. 在 Monorepo 根目录添加子项目模块依赖,例如 `custom-release-note`。
257
+ #### 在 Monorepo 根目录添加子项目模块依赖,例如 `custom-release-note`。
244
258
 
245
259
  ```json title="package.json"
246
260
  {
@@ -250,10 +264,10 @@ export function getReleaseNoteLine() {}
250
264
  }
251
265
  ```
252
266
 
253
- 4. 执行 `gen-release-note` 命令添加 `--custom` 参数
267
+ #### 执行 `gen-release-note` 命令添加 `--custom` 参数
254
268
 
255
269
  ```bash
256
- pnpm run gen-release-note -- --custom custom-release-note
270
+ pnpm run gen-release-note --custom custom-release-note
257
271
  ```
258
272
 
259
273
  该模块发布到 NPM 后,依然可以和模块类型一样供其他仓库使用。
@@ -4,7 +4,7 @@ sidebar_position: 4
4
4
 
5
5
  # 发布预发布版本
6
6
 
7
- 在发布正式版本之前,我们也需要发布预发布版本供内部测试和用户使用,Changesets 也支持发布预发布版本。
7
+ 在发布正式版本之前,我们也需要发布预发布版本供内部测试和用户使用,changesets 也支持发布预发布版本。
8
8
 
9
9
  ## 步骤
10
10
 
@@ -13,21 +13,21 @@ sidebar_position: 4
13
13
 
14
14
  :::
15
15
 
16
- #### 执行以下命令升级预发布版本版本号:
16
+ #### 执行 bump 命令升级预发布版本版本号
17
17
 
18
18
  ```bash
19
- pnpm run bump -- --canary --preid <preid>
19
+ pnpm run bump --canary --preid <preid>
20
20
  ```
21
21
 
22
22
  `preid` 为预发布版本标记,例如 `alpha`、`beta` 等,默认值为 `next`。
23
23
 
24
24
  使用 `--canary` 参数后,`bump` 命令由以下三个步骤完成:
25
25
 
26
- - `changeset pre enter <preid>` 进入预发布模式
26
+ - `changeset pre enter <preid>` 进入预发布模式。
27
27
 
28
- - `changeset version` 升级版本号
28
+ - `changeset version` 升级版本号。
29
29
 
30
- - `changeset pre exit` 退出预发布模式
30
+ - `changeset pre exit` 退出预发布模式。
31
31
 
32
32
  #### 检查相关变更并提交
33
33
 
@@ -35,10 +35,10 @@ pnpm run bump -- --canary --preid <preid>
35
35
 
36
36
  建议预发布操作不在主分支上进行,不合入主分支,当预发布验证完成后,直接基于主分支发布正式版本。
37
37
 
38
- #### 执行以下命令发布预发布版本:
38
+ #### 执行 release 命令发布预发布版本
39
39
 
40
40
  ```bash
41
- pnpm run release -- --tag <tag>
41
+ pnpm run release --tag <tag>
42
42
  ```
43
43
 
44
44
  发布预发布版本一定要使用 `--tag` 参数,参数值最好和 `preid` 值相同,方便用户使用。
@@ -47,4 +47,4 @@ pnpm run release -- --tag <tag>
47
47
 
48
48
  ### 退出预发布模式
49
49
 
50
- 在进入预发布模式后,Changesets 会自动在 `.changeset` 目录创建 `pre.json` 文件用于记录当时进入预发布模式的一些状态信息,当出现状态信息和当前仓库状态不一致时,可直接删除该文件退出预发布模式。
50
+ 在进入预发布模式后,changesets 会自动在 `.changeset` 目录创建 `pre.json` 文件用于记录当时进入预发布模式的一些状态信息,当出现状态信息和当前仓库状态不一致时,可直接删除该文件退出预发布模式。