@modern-js/main-doc 2.51.0 → 2.53.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.
Files changed (68) hide show
  1. package/docs/en/apis/app/runtime/web-server/unstable_middleware.mdx +30 -4
  2. package/docs/en/guides/advanced-features/web-server.mdx +4 -2
  3. package/docs/en/guides/basic-features/data/data-fetch.mdx +28 -0
  4. package/docs/en/guides/basic-features/deploy.mdx +143 -33
  5. package/docs/en/guides/basic-features/routes.mdx +2 -2
  6. package/docs/en/guides/get-started/tech-stack.mdx +0 -6
  7. package/docs/en/guides/topic-detail/framework-plugin/plugin-api.mdx +1 -1
  8. package/docs/en/guides/topic-detail/generator/create/option.md +0 -5
  9. package/docs/en/guides/topic-detail/generator/create/use.mdx +1 -10
  10. package/docs/en/guides/topic-detail/generator/new/config.md +0 -29
  11. package/docs/en/guides/topic-detail/generator/new/use.md +0 -20
  12. package/docs/zh/apis/app/runtime/web-server/unstable_middleware.mdx +30 -4
  13. package/docs/zh/guides/advanced-features/web-server.mdx +1 -1
  14. package/docs/zh/guides/basic-features/data/data-fetch.mdx +27 -2
  15. package/docs/zh/guides/basic-features/deploy.mdx +140 -36
  16. package/docs/zh/guides/basic-features/routes.mdx +2 -2
  17. package/docs/zh/guides/get-started/tech-stack.mdx +0 -6
  18. package/docs/zh/guides/topic-detail/framework-plugin/plugin-api.mdx +1 -1
  19. package/docs/zh/guides/topic-detail/generator/create/option.md +0 -5
  20. package/docs/zh/guides/topic-detail/generator/create/use.mdx +1 -10
  21. package/docs/zh/guides/topic-detail/generator/new/config.md +0 -31
  22. package/docs/zh/guides/topic-detail/generator/new/use.md +0 -20
  23. package/package.json +5 -5
  24. package/docs/en/apis/app/runtime/testing/_category_.json +0 -4
  25. package/docs/en/apis/app/runtime/testing/act.mdx +0 -35
  26. package/docs/en/apis/app/runtime/testing/cleanup.mdx +0 -40
  27. package/docs/en/apis/app/runtime/testing/render.mdx +0 -71
  28. package/docs/en/apis/app/runtime/testing/renderApp.mdx +0 -34
  29. package/docs/en/configure/app/testing/_category_.json +0 -4
  30. package/docs/en/configure/app/testing/transformer.mdx +0 -17
  31. package/docs/en/configure/app/tools/jest.mdx +0 -40
  32. package/docs/en/guides/advanced-features/testing.mdx +0 -47
  33. package/docs/en/guides/topic-detail/changesets/_category_.json +0 -4
  34. package/docs/en/guides/topic-detail/changesets/add.mdx +0 -125
  35. package/docs/en/guides/topic-detail/changesets/changelog.mdx +0 -238
  36. package/docs/en/guides/topic-detail/changesets/commit.mdx +0 -269
  37. package/docs/en/guides/topic-detail/changesets/config.mdx +0 -147
  38. package/docs/en/guides/topic-detail/changesets/github.mdx +0 -175
  39. package/docs/en/guides/topic-detail/changesets/introduce.mdx +0 -56
  40. package/docs/en/guides/topic-detail/changesets/release-note.mdx +0 -274
  41. package/docs/en/guides/topic-detail/changesets/release-pre.mdx +0 -49
  42. package/docs/en/guides/topic-detail/changesets/release.mdx +0 -229
  43. package/docs/en/guides/topic-detail/model/test-model.mdx +0 -45
  44. package/docs/zh/apis/app/runtime/testing/_category_.json +0 -4
  45. package/docs/zh/apis/app/runtime/testing/act.mdx +0 -35
  46. package/docs/zh/apis/app/runtime/testing/cleanup.mdx +0 -40
  47. package/docs/zh/apis/app/runtime/testing/render.mdx +0 -71
  48. package/docs/zh/apis/app/runtime/testing/renderApp.mdx +0 -32
  49. package/docs/zh/configure/app/testing/_category_.json +0 -4
  50. package/docs/zh/configure/app/testing/transformer.mdx +0 -19
  51. package/docs/zh/configure/app/tools/jest.mdx +0 -40
  52. package/docs/zh/guides/advanced-features/testing.mdx +0 -47
  53. package/docs/zh/guides/topic-detail/changesets/_category_.json +0 -4
  54. package/docs/zh/guides/topic-detail/changesets/add.mdx +0 -126
  55. package/docs/zh/guides/topic-detail/changesets/changelog.mdx +0 -238
  56. package/docs/zh/guides/topic-detail/changesets/commit.mdx +0 -269
  57. package/docs/zh/guides/topic-detail/changesets/config.mdx +0 -147
  58. package/docs/zh/guides/topic-detail/changesets/github.mdx +0 -175
  59. package/docs/zh/guides/topic-detail/changesets/introduce.mdx +0 -56
  60. package/docs/zh/guides/topic-detail/changesets/release-note.mdx +0 -274
  61. package/docs/zh/guides/topic-detail/changesets/release-pre.mdx +0 -50
  62. package/docs/zh/guides/topic-detail/changesets/release.mdx +0 -231
  63. package/docs/zh/guides/topic-detail/model/test-model.mdx +0 -45
  64. package/docs/zh/guides/topic-detail/monorepo/_category_.json +0 -4
  65. package/docs/zh/guides/topic-detail/monorepo/create-sub-project.mdx +0 -53
  66. package/docs/zh/guides/topic-detail/monorepo/intro.mdx +0 -14
  67. package/docs/zh/guides/topic-detail/monorepo/publish.mdx +0 -69
  68. package/docs/zh/guides/topic-detail/monorepo/sub-project-interface.mdx +0 -143
@@ -1,269 +0,0 @@
1
- ---
2
- sidebar_position: 7
3
- ---
4
-
5
- # 自定义提交 commit 信息
6
-
7
- Changesets 支持配置 `commit` 为 true 时,在执行 `change` 和 `bump` 命令时自动提交当前变更。
8
-
9
- 默认的 `commit` 信息由 `@changesets/cli/commit` 提供,默认信息格式为:
10
-
11
- ![change commit](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-change-commit-info.png)
12
- ![bump commit](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-bump-commit-info.png)
13
-
14
- 当默认的 commit 信息不能满足需求时,支持自定义 commit 信息。
15
-
16
- ## 自定义 commit 信息内容
17
-
18
- commit 信息分为两种:
19
-
20
- - 执行 `change` 命令时自动生成的 commit 信息。
21
- - 执行 `bump` 命令时自动生成的 commit 信息。
22
-
23
- 自定义逻辑主要实现两个函数,`getAddMessage` 和 `getVersionMessage`,分别用来定义上述这两种信息。
24
-
25
- ### getAddMessage
26
-
27
- #### Params
28
-
29
- - changeset
30
-
31
- 当前创建的 chagneset 信息
32
-
33
- ```ts
34
- type Release = {
35
- name: string;
36
- type: VersionType;
37
- };
38
-
39
- type Changeset = {
40
- summary: string;
41
- releases: Array<Release>;
42
- };
43
- ```
44
-
45
- - options
46
-
47
- 配置 commit 时的配置信息。
48
-
49
- > commit 配置为数组时,第二个参数支持传入默认的配置信息,会对应的使用该参数传递。
50
-
51
- #### 返回值
52
-
53
- commit 信息内容。
54
-
55
- #### 默认实现
56
-
57
- `@changesets/cli/commit` 默认处理逻辑为以 `docs(changeset):` 开头,commit 信息为 changeset 的 `summary`,并根据传入的 `skipCI` 参数配置添加 [skip ci] 信息。
58
-
59
- ```ts
60
- type SkipCI = boolean | 'add' | 'version';
61
-
62
- const getAddMessage = async (
63
- changeset: Changeset,
64
- options: { skipCI?: SkipCI } | null,
65
- ) => {
66
- const skipCI = options?.skipCI === 'add' || options?.skipCI === true;
67
- return outdent`docs(changeset): ${changeset.summary}${
68
- skipCI ? `\n\n[skip ci]\n` : ''
69
- }`;
70
- };
71
- ```
72
-
73
- > [outdent](https://www.npmjs.com/package/outdent) 目的是删除模板字符串开头的空格内容,使 commit 信息更符合规范。
74
-
75
- ### getVersionMessage
76
-
77
- #### Params
78
-
79
- - releasePlan
80
-
81
- ```ts
82
- type VersionType = 'major' | 'minor' | 'patch' | 'none';
83
-
84
- type Release = {
85
- name: string;
86
- type: VersionType;
87
- };
88
-
89
- type Changeset = {
90
- id: string;
91
- summary: string;
92
- releases: Array<Release>;
93
- };
94
-
95
- type ComprehensiveRelease = {
96
- name: string;
97
- type: VersionType;
98
- oldVersion: string;
99
- newVersion: string;
100
- changesets: string[];
101
- };
102
-
103
- type PreState = {
104
- mode: 'pre' | 'exit'; // pre 模式当前状态
105
- tag: string; // pre 的类型
106
- initialVersions: {
107
- [pkgName: string]: string; // 版本升级前包名及版本号信息,Map 格式
108
- };
109
- changesets: string[]; // 本次升级的 changeset id 列表
110
- };
111
-
112
- type ReleasePlan = {
113
- changesets: Changeset[]; // 本次升级的 changeset 列表
114
- releases: ComprehensiveRelease[]; // 当前升级的包信息,包含包名称、当前版本、升级后版本、升级类型等
115
- preState: PreState | undefined; // 当前如果为 pre 发布,提供相关状态信息
116
- };
117
- ```
118
-
119
- - options
120
-
121
- 配置 commit 时的其他参数。
122
-
123
- > commit 配置为数组时,第二个参数支持传入默认的配置信息,会对应的使用该参数传递。
124
-
125
- #### 返回值
126
-
127
- commit 信息内容。
128
-
129
- #### 默认实现
130
-
131
- `@changesets/cli/commit` 默认处理逻辑为:先展示当前需要 release 的包数量,再展示 release 包的名称及新版本号,并根据传入的 `skipCI` 参数配置添加 [skip ci] 信息。
132
-
133
- ```ts
134
- const getVersionMessage = async (
135
- releasePlan: ReleasePlan,
136
- options: { skipCI?: SkipCI } | null,
137
- ) => {
138
- const skipCI = options?.skipCI === 'version' || options?.skipCI === true;
139
- const publishableReleases = releasePlan.releases.filter(
140
- release => release.type !== 'none',
141
- );
142
- const numPackagesReleased = publishableReleases.length;
143
-
144
- const releasesLines = publishableReleases
145
- .map(release => ` ${release.name}@${release.newVersion}`)
146
- .join('\n');
147
-
148
- return outdent`
149
- RELEASING: Releasing ${numPackagesReleased} package(s)
150
-
151
- Releases:
152
- ${releasesLines}
153
- ${skipCI ? `\n[skip ci]\n` : ''}
154
- `;
155
- };
156
- ```
157
-
158
- ## 配置
159
-
160
- Changesets 配置文件中 `commit` 字段,该字段用于标记是否需要在 `change` 和 `bump` 命令是提交 commit 信息及 commit 信息的获取途径。
161
-
162
- 该配置可以为 `boolean`,为 true 时使用默认 `@changesets/cli/commit` 格式化 commit 信息。
163
-
164
- 该配置可以为字符串,直接声明获取 commit 信息模块的模块名称或者路径。
165
-
166
- 该配置还支持配置数组,数组中第一个元素为获取 commit 信息模块的模块名称或者路径,第二个元素为传入对应函数的参数值,会作为 `getAddMessage` 和 `getVersionMessage` 函数的第二个参数传入。
167
-
168
- ### 配置相对路径
169
-
170
- commit 配置如果为相对路径为 `.changesets` 目录下的相对路径。
171
-
172
- 例如创建 `.changeset/my-commit-config.js` 文件,定义如下内容:
173
-
174
- ```js title=".changeset/my-commit-config.js"
175
- async function getAddMessage(changeset, options) {}
176
-
177
- async function getVersionMessage(releasePlan, options) {}
178
-
179
- module.exports = {
180
- getAddMessage,
181
- getVersionMessage,
182
- };
183
- ```
184
-
185
- commit 配置为 ./my-commit-config.js 即可:
186
-
187
- ```json title=".changesets/config.json"
188
- {
189
- "changelog": "./my-commit-config.js",
190
- ...
191
- }
192
- ```
193
-
194
- ### 使用 Modern.js Module
195
-
196
- 自定义 commit 还可以使用 Modern.js Module 进行管理,提供通用方案。
197
-
198
- #### 使用 `npx @modern-js/create@latest` 创建 Modern.js Module
199
-
200
- ```md
201
- ? 请选择你想创建的工程类型:Npm 模块
202
- ? 请填写项目名称:custom-commit
203
- ? 请选择开发语言:TS
204
- ? 请选择包管理工具:pnpm
205
- ```
206
-
207
- #### 实现自定义内容
208
-
209
- ```ts title="src/index.ts"
210
- export async function getAddMessage() {}
211
-
212
- export async function getVersionMessage() {}
213
- ```
214
-
215
- #### 将模块发布到 NPM
216
-
217
- #### 在目标仓库根目录安装对应模块,例如 `custom-commit`
218
-
219
- #### 配置 changeset 的 commit 配置为包名称
220
-
221
- ```json title="package.json"
222
- {
223
- "commit": "custom-commit",
224
- ...
225
- }
226
- ```
227
-
228
- ### 使用 Monorepo 工程方案
229
-
230
- 如果你当前仓库为 Monorepo 工程方案,可以直接使用模块子项目进行管理。
231
-
232
- #### 执行 `pnpm run new` 创建模块子项目
233
-
234
- ```md
235
- ? 请选择你想创建的工程类型:Npm 模块
236
- ? 请填写子项目名称:custom-commit
237
- ? 请填写子项目目录名称:custom-commit
238
- ? 请选择开发语言:TS
239
- ```
240
-
241
- #### 实现自定义内容
242
-
243
- ```ts title="src/index.ts"
244
- export async function getAddMessage() {}
245
-
246
- export async function getVersionMessage() {}
247
- ```
248
-
249
- #### 在 Monorepo 根目录添加子项目模块依赖,例如 `custom-commit`
250
-
251
- ```json title="package.json"
252
- {
253
- "devDependencies": {
254
- "custom-commit": "workspace:*",
255
- ...
256
- }
257
- }
258
- ```
259
-
260
- #### 配置 changeset 的 commit 配置为包名称
261
-
262
- ```json title=".changesets/config.json"
263
- {
264
- "commit": "custom-commit",
265
- ...
266
- }
267
- ```
268
-
269
- 该模块发布到 NPM 后,依然可以和模块类型一样供其他仓库使用。
@@ -1,147 +0,0 @@
1
- ---
2
- sidebar_position: 5
3
- ---
4
-
5
- # Changesets 配置文件
6
-
7
- 我们前面了解到,初始化 Modern.js 仓库时,会默认初始化 changesets 的配置文件,即 `.changeset/config.json` 文件,下面我们将详细了解一下该文件中支持哪些配置。
8
-
9
- ## 配置介绍
10
-
11
- ### commit
12
-
13
- 类型: `boolean`
14
-
15
- 默认值: `false`
16
-
17
- 当配置该字段为 `true` 时,在执行 `change` 和 `bump` 命令时,将自动执行提交代码操作。
18
-
19
- 默认的 commit 信息格式如下:
20
-
21
- ![change commit](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-change-commit-info.png)
22
- ![bump commit](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-bump-commit-info.png)
23
-
24
- 该 commit 信息支持自定义,我们将在[自定义提交 commit 信息](/guides/topic-detail/changesets/commit)章节进行详细介绍。
25
-
26
- ### access
27
-
28
- 类型:`restricted` | `public`
29
-
30
- 默认值:`restricted`
31
-
32
- 用于配置当前包的发布形式,如果配置为 `restricted`,将作为私有包发布,如果为 `public`,则发布公共范围包。
33
-
34
- 对于仓库中存在部分包需要配置 access,可以在 `package.json` 中配置 `publishConfig`,例如:
35
-
36
- ```json title=package.json
37
- {
38
- "publishConfig": {
39
- "registry": "https://registry.npmjs.org/",
40
- "access": "public"
41
- }
42
- }
43
- ```
44
-
45
- 对于不需要发布的包,可以在 `package.json` 中设置 `private` 为 `true`,阻止其进行发布。
46
-
47
- ### baseBranch
48
-
49
- 类型: `string`
50
-
51
- 默认值: `main`
52
-
53
- 仓库主分支。该配置用于计算当前分支的变更包并进行分类。
54
-
55
- ### ignore
56
-
57
- 类型:`string[]`
58
-
59
- 默认值:`[]`
60
-
61
- 用于声明执行 `bump` 命令时忽略的包,和 `bump` 命令的 `--ignore` 参数用法一致,注意两者不能同时使用。
62
-
63
- ### fixed
64
-
65
- 类型: `string[][]`
66
-
67
- 默认值:`[]`
68
-
69
- 用于 monorepo 中对包进行分组,相同分组中的包版本号将进行绑定,每次执行 `bump` 命令时,同一分组中的包只要有一个升级版本号,其他会一起升级。
70
- 支持使用正则匹配包名称。
71
-
72
- ### linked
73
-
74
- 类型: `string[][]`
75
-
76
- 默认值:`[]`
77
-
78
- 和 `fixed` 类似,也是对 monorepo 中对包进行分组,但是每次执行 `bump` 命令时,只有和 changeset 声明的变更相关的包才会升级版本号,同一分组的变更包的版本号将保持一致。
79
- 支持使用正则匹配包名称。
80
-
81
- ### updateInternalDependencies
82
-
83
- 类型:`patch` | `minor`
84
-
85
- 默认值:`patch`
86
-
87
- 用于声明更新内部依赖的版本号规则。
88
-
89
- 当执行 `bump` 命令升级版本号时,默认会自动更新仓库中使用该包的依赖声明。配置该字段为 `minor` 后,如果升级版本号为 `patch` 类型,将不会自动更新引用依赖声明。
90
-
91
- 例如:
92
-
93
- ```
94
- pkg-a @ version 1.0.0
95
- pkg-b @ version 1.0.0
96
- depends on pkg-a at range `^1.0.0
97
- ```
98
-
99
- 默认情况下,升级 `pkg-a` 至 `1.0.1` 时,会更新 `pkg-b` 中的 `pkg-a` 的依赖版本为 `^1.0.1`。
100
-
101
- 当配置 `updateInternalDependencies` 为 `minor` 时,升级 `pkg-a` 至 `1.0.1` 时,`pkg-b` 中的 `pkg-a` 的依赖版本将不会更新,只有 `pkg-a` 升级版本号为 `1.1.0` 或者 `2.0.0` 时,才会更新 `pkg-b` 中的 `pkg-a` 的依赖。
102
-
103
- ### changelog
104
-
105
- 类型:`boolean` | `string` | `[string, unknow]`
106
-
107
- 默认值:`@changesets/cli/changelog`
108
-
109
- 生成 changelog 规则。
110
-
111
- 配置为 `false` 时,执行 bump 命令时,在 `CHANGELOG.md` 文件中只声明版本号,不声明其他 changelog 信息。
112
-
113
- ![关闭 changelog 配置](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-empty-changelog.png)
114
-
115
- 配置为 `@changesets/cli/changelog` 将使用官方提供的 changlog 生成规则,将 changeset 信息转换为 changlog 内容。
116
-
117
- 配置为数组时,第一个参数为自定义 NPM 包或者路径,第二个参数为需要传入的默认参数配置,自定义格式我们将在后续[自定义 changelog](/guides/topic-detail/changesets/changelog) 章节讲解。
118
-
119
- ### \_\_\_experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH
120
-
121
- 一些实验性配置。
122
-
123
- #### onlyUpdatePeerDependentsWhenOutOfRange
124
-
125
- 类型:`boolean`
126
-
127
- 默认值:`false`
128
-
129
- 针对于 `peerDependence` 依赖的升级策略配置,默认针对 `peerDependence` 在 `minor` 和 `major` 版本升级时,当前包会升级大版本。
130
-
131
- 该配置设置为 true 时,仅当 `peerDependence` 声明包依赖超出声明范围时才更新版本。
132
-
133
- #### updateInternalDependents
134
-
135
- 类型: `always` | `out-of-range`
136
-
137
- 默认值:`always`
138
-
139
- 当执行 `bump` 命令升级版本号时,默认会自动更新仓库中使用该包的依赖声明。当设置该参数为 `out-of-range` 时,只有当依赖声明超出范围时才会更新仓库中使用该包的依赖声明。
140
-
141
- #### useCalculatedVersionForSnapshots
142
-
143
- 类型:`boolean`
144
-
145
- 默认值:`false`
146
-
147
- 使用快照发布时,默认会使用 `0.0.0-timestamp` 的版本格式,保证用户可以正常使用预发布版本。当你需要忽略上述问题,使用正常的版本号格式时,即当前版本为 `1.0.1` 快照版本期望使用`1.0.1-timestamp`,可配置该参数为 `true`。
@@ -1,175 +0,0 @@
1
- ---
2
- sidebar_position: 9
3
- ---
4
-
5
- # 使用 Github 相关工具
6
-
7
- ## BOT
8
-
9
- 在 Github 上,changesets 提供了机器人用于检测当前 Pull Request 是否存在 changeset,并提供了 UI 界面添加和修改 changeset。
10
-
11
- ### 安装
12
-
13
- 点击进入[链接](https://github.com/apps/changeset-bot),右上角选择安装,确认即可安装成功。
14
-
15
- ![安装机器人](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-install-bot.png)
16
-
17
- ### 配置
18
-
19
- 安装成功后,即可进入配置页面,根据需求选择应用仓库即可。
20
-
21
- ![配置机器人](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-config-bot.png)
22
-
23
- ### 使用
24
-
25
- 配置完成后,该机器人将会自动 check 每个 Pull Request 是否添加了 changeset,并通过回复的方式给到提示信息。
26
-
27
- #### 未添加 changeset
28
-
29
- ![未添加 changeset 状态](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-bot-no-changeset.png)
30
-
31
- 可在仓库执行 `pnpm run change` 添加 changeset,也可直接点击下方第二个链接填写 changeset。
32
-
33
- #### 已添加 changeset
34
-
35
- ![已添加 changeset 状态](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-bot-exist-changeset.png)
36
-
37
- 可点击下方链接修改和添加新的 changeset。
38
-
39
- #### 不需要 changeset
40
-
41
- 可直接忽略未添加时的提示信息,它不会造成 Pull Request 不能合并的问题。
42
-
43
- ## Action
44
-
45
- ### 自动创建 Release Pull Request
46
-
47
- Modern.js 提供了自动创建发版 Pull Request 的 Github Action,提供基于选择的分支自动执行 bump 操作,更新 lock 文件及创建 Pull Request 操作。
48
-
49
- #### 使用
50
-
51
- - 在仓库中创建 `.github/workflows/release-pull-request.yml` 文件,填入以下内容:
52
-
53
- ```yaml
54
- name: Release Pull Request
55
-
56
- on:
57
- workflow_dispatch:
58
- inputs:
59
- version:
60
- type: choice
61
- description: 'Release Type(canary, beta, alpha, latest)'
62
- required: true
63
- default: 'latest'
64
- options:
65
- - canary
66
- - beta
67
- - alpha
68
- - latest
69
-
70
- jobs:
71
- release:
72
- name: Create Release Pull Request
73
- runs-on: ubuntu-latest
74
- steps:
75
- - name: Checkout Repo
76
- uses: actions/checkout@master
77
- with:
78
- # This makes Actions fetch only one branch to release
79
- fetch-depth: 100
80
-
81
- - ... # install dependencies and build repo package
82
- - name: Create Release Pull Request
83
- uses: web-infra-dev/actions@v2
84
- with:
85
- version: ${{ github.event.inputs.version }}
86
- versionNumber: 'auto'
87
- type: 'pull request'
88
- tools: 'modern'
89
- env:
90
- GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}
91
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
92
- REPOSITORY: ${{ github.repository }}
93
- REF: ${{ github.ref }}
94
- ```
95
-
96
- - 将 Workflow 合并到主分支后,进入 Github 仓库对应的 Action 页面,选择 Release Pull Request:
97
-
98
- ![Release Pull Request Action](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/action-pull-request.png)
99
-
100
- - 选择本次发布类型,点击 Run workflow 按钮:
101
-
102
- ![Run Release Pull Request](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/action-pull-request.jpeg)
103
-
104
- - Workflow 运行完成后将自动创建 `Release-${version}` 的 Pull Request,自动完成 `bump` changeset 相关版本号并更新 lock 文件,Pull Request 的内容为执行 `gen-release-note` 命令自动生成的 Release Note。
105
-
106
- ![Release Pull Request](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/release-pull-request.jpeg)
107
-
108
- ### 自动 Release
109
-
110
- Modern.js 提供了自动发布版本 的 Github Action,提供基于选择的分支自动执行 release 操作,将包发布到 NPM 上。
111
-
112
- #### 使用
113
-
114
- - 在仓库中创建 `.github/workflows/release.yml` 文件,填入以下内容:
115
-
116
- ```yaml
117
- name: Release
118
-
119
- on:
120
- workflow_dispatch:
121
- inputs:
122
- version:
123
- type: choice
124
- description: 'Release Version(canary, beta, alpha, latest)'
125
- required: true
126
- default: 'next'
127
- options:
128
- - canary
129
- - beta
130
- - alpha
131
- - latest
132
- branch:
133
- description: 'Release Branch(confirm release branch)'
134
- required: true
135
- default: 'main'
136
-
137
- jobs:
138
- release:
139
- name: Release
140
- runs-on: ubuntu-latest
141
- steps:
142
- - name: Checkout Repo
143
- uses: actions/checkout@master
144
- with:
145
- # This makes Actions fetch only one branch to release
146
- fetch-depth: 1
147
-
148
- - ... # install dependencies and build repo package
149
- - name: Release
150
- uses: web-infra-dev/actions@v2
151
- with:
152
- version: ${{ github.event.inputs.version }}
153
- branch: ${{ github.event.inputs.branch }}
154
- type: 'release'
155
- tools: 'modern'
156
- env:
157
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
159
- REPOSITORY: ${{ github.repository }}
160
- REF: ${{ github.ref }}
161
- ```
162
-
163
- - 配置仓库的 NPM_TOKEN:
164
-
165
- ![配置 Token](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/github-set-npm-token.png)
166
-
167
- - 将 Workflow 合并到主分支后,进入 Github 仓库对应的 Action 页面,选择 Release:
168
-
169
- ![Release Action](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/release-action.png)
170
-
171
- - 选择分支名称和发布版本类型,点击 Run workflow 按钮:
172
-
173
- ![Run Release Action](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/run-release-workflow.png)
174
-
175
- - Workflow 将自动完成仓库 build 和发布到 NPM 流程。
@@ -1,56 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
-
5
- # 认识 Changesets
6
-
7
- Modern.js 默认集成了 [changesets](https://github.com/changesets/changesets) 用于模块和 Monorepo 工程方案的包版本管理。
8
-
9
- ## 特点
10
-
11
- Changesets 具有以下几个特点:
12
-
13
- - 在开发时,需要开发者提供本次变更涉及的包名称、升级版本类型(`pathch`、`minor`、`major`)及变更信息,即 changeset。
14
-
15
- - 在发布版本时,会根据 changeset 内容自动升级对应包的版本号,并在对应的包中生成 changelog 信息。
16
-
17
- - 在 Monorepo 项目中,changeset 会自动生成仓库依赖图,升级时只会升级变更包及相关依赖包的版本号。
18
-
19
- ## 初始化
20
-
21
- Modern.js 默认创建的模块和 Monorepo 工程方案项目已经初始化完成 changesets,在项目根目录会自动创建 `.changeset` 目录,及 `.changeset/config.json` 的配置文件。
22
-
23
- 并且,Modern.js 在其对应的工程方案工具 `@modern-js/module-tools` 和 `@modern-js/monorepo-tools` 提供了 changesets 相应的命令,无需再手动安装 changesets 相关依赖。
24
-
25
- Changesets 默认配置如下:
26
-
27
- ```json title=".changeset/config.json"
28
- {
29
- "$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json",
30
- "changelog": "@changesets/cli/changelog",
31
- "commit": false,
32
- "linked": [],
33
- "access": "restricted",
34
- "baseBranch": "main",
35
- "updateInternalDependencies": "patch",
36
- "ignore": []
37
- }
38
- ```
39
-
40
- 配置文件提供了生成 changesets 的一些基本配置,字段详细介绍请参考 [Changesets 配置文件](/guides/topic-detail/changesets/config)。
41
-
42
- ## 命令
43
-
44
- - `change`: 创建一个 changeset,执行完成该命令后会自动在 `.changeset` 目录生成一个 changeset 文件。
45
-
46
- - `bump`: 根据当前 changeset 升级对应包版本号。
47
-
48
- - `pre`: 标记进入和退出 pre-release 模式,在 pre release 模式下执行 `bump` 命令,将会生成 `x.x.x-${pre-tag}.x` 的版本号格式。
49
-
50
- - `release`: 发布包到 NPM。
51
-
52
- - `status`: 查看当前 changeset 状态。
53
-
54
- - `gen-release-note`: 根据当前的 chagneset 状态生成 Release Note 信息。
55
-
56
- 具体命令支持的参数可以查看后续对应章节介绍。