@modern-js/main-doc 2.52.0 → 2.53.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/docs/en/guides/basic-features/routes.mdx +2 -2
  2. package/docs/en/guides/get-started/tech-stack.mdx +0 -6
  3. package/docs/en/guides/topic-detail/framework-plugin/plugin-api.mdx +1 -1
  4. package/docs/en/guides/topic-detail/generator/create/option.md +0 -5
  5. package/docs/en/guides/topic-detail/generator/create/use.mdx +1 -10
  6. package/docs/en/guides/topic-detail/generator/new/config.md +0 -29
  7. package/docs/en/guides/topic-detail/generator/new/use.md +0 -20
  8. package/docs/zh/guides/basic-features/routes.mdx +2 -2
  9. package/docs/zh/guides/get-started/tech-stack.mdx +0 -6
  10. package/docs/zh/guides/topic-detail/framework-plugin/plugin-api.mdx +1 -1
  11. package/docs/zh/guides/topic-detail/generator/create/option.md +0 -5
  12. package/docs/zh/guides/topic-detail/generator/create/use.mdx +1 -10
  13. package/docs/zh/guides/topic-detail/generator/new/config.md +0 -31
  14. package/docs/zh/guides/topic-detail/generator/new/use.md +0 -20
  15. package/package.json +5 -5
  16. package/docs/en/apis/app/runtime/testing/_category_.json +0 -4
  17. package/docs/en/apis/app/runtime/testing/act.mdx +0 -35
  18. package/docs/en/apis/app/runtime/testing/cleanup.mdx +0 -40
  19. package/docs/en/apis/app/runtime/testing/render.mdx +0 -71
  20. package/docs/en/apis/app/runtime/testing/renderApp.mdx +0 -34
  21. package/docs/en/configure/app/testing/_category_.json +0 -4
  22. package/docs/en/configure/app/testing/transformer.mdx +0 -17
  23. package/docs/en/configure/app/tools/jest.mdx +0 -40
  24. package/docs/en/guides/advanced-features/testing.mdx +0 -47
  25. package/docs/en/guides/topic-detail/changesets/_category_.json +0 -4
  26. package/docs/en/guides/topic-detail/changesets/add.mdx +0 -125
  27. package/docs/en/guides/topic-detail/changesets/changelog.mdx +0 -238
  28. package/docs/en/guides/topic-detail/changesets/commit.mdx +0 -269
  29. package/docs/en/guides/topic-detail/changesets/config.mdx +0 -147
  30. package/docs/en/guides/topic-detail/changesets/github.mdx +0 -175
  31. package/docs/en/guides/topic-detail/changesets/introduce.mdx +0 -56
  32. package/docs/en/guides/topic-detail/changesets/release-note.mdx +0 -274
  33. package/docs/en/guides/topic-detail/changesets/release-pre.mdx +0 -49
  34. package/docs/en/guides/topic-detail/changesets/release.mdx +0 -229
  35. package/docs/en/guides/topic-detail/model/test-model.mdx +0 -45
  36. package/docs/zh/apis/app/runtime/testing/_category_.json +0 -4
  37. package/docs/zh/apis/app/runtime/testing/act.mdx +0 -35
  38. package/docs/zh/apis/app/runtime/testing/cleanup.mdx +0 -40
  39. package/docs/zh/apis/app/runtime/testing/render.mdx +0 -71
  40. package/docs/zh/apis/app/runtime/testing/renderApp.mdx +0 -32
  41. package/docs/zh/configure/app/testing/_category_.json +0 -4
  42. package/docs/zh/configure/app/testing/transformer.mdx +0 -19
  43. package/docs/zh/configure/app/tools/jest.mdx +0 -40
  44. package/docs/zh/guides/advanced-features/testing.mdx +0 -47
  45. package/docs/zh/guides/topic-detail/changesets/_category_.json +0 -4
  46. package/docs/zh/guides/topic-detail/changesets/add.mdx +0 -126
  47. package/docs/zh/guides/topic-detail/changesets/changelog.mdx +0 -238
  48. package/docs/zh/guides/topic-detail/changesets/commit.mdx +0 -269
  49. package/docs/zh/guides/topic-detail/changesets/config.mdx +0 -147
  50. package/docs/zh/guides/topic-detail/changesets/github.mdx +0 -175
  51. package/docs/zh/guides/topic-detail/changesets/introduce.mdx +0 -56
  52. package/docs/zh/guides/topic-detail/changesets/release-note.mdx +0 -274
  53. package/docs/zh/guides/topic-detail/changesets/release-pre.mdx +0 -50
  54. package/docs/zh/guides/topic-detail/changesets/release.mdx +0 -231
  55. package/docs/zh/guides/topic-detail/model/test-model.mdx +0 -45
  56. package/docs/zh/guides/topic-detail/monorepo/_category_.json +0 -4
  57. package/docs/zh/guides/topic-detail/monorepo/create-sub-project.mdx +0 -53
  58. package/docs/zh/guides/topic-detail/monorepo/intro.mdx +0 -14
  59. package/docs/zh/guides/topic-detail/monorepo/publish.mdx +0 -69
  60. package/docs/zh/guides/topic-detail/monorepo/sub-project-interface.mdx +0 -143
@@ -1,147 +0,0 @@
1
- ---
2
- sidebar_position: 5
3
- ---
4
-
5
- # Changesets Configuration
6
-
7
- When initializing a Modern.js repository, the configuration file for changesets will be initialized by default, that is, the `.changeset/config.json` file. Below, we will learn in detail what configurations are supported in this file.
8
-
9
- ## Introduction
10
-
11
- ### commit
12
-
13
- Type: `boolean`
14
-
15
- Default: `false`
16
-
17
- When this field is configured as `true`, the code submission operation will be automatically executed when running the `change` and `bump` commands.
18
-
19
- The default commit information format is as follows:
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
- This commit information supports customization, which we will discuss in detail in the [Customizing Commit Messages](/guides/topic-detail/changesets/commit) chapter.
25
-
26
- ### access
27
-
28
- Type: `restricted` | `public`
29
-
30
- Default: `restricted`
31
-
32
- Used to configure the publishing form of the current package. If configured as `restricted`, it will be published as a private package. If it is `public`, it will be published as a public scope package.
33
-
34
- For packages that need to configure access in the repository, `publishConfig` can be configured in `package.json`, for example:
35
-
36
- ```json title=package.json
37
- {
38
- "publishConfig": {
39
- "registry": "https://registry.npmjs.org/",
40
- "access": "public"
41
- }
42
- }
43
- ```
44
-
45
- For packages that don't need to be published, you can set `private` to `true` in `package.json` to prevent them from being published.
46
-
47
- ### baseBranch
48
-
49
- Type: `string`
50
-
51
- Default: `main`
52
-
53
- Repository main branch. This configuration is used to calculate the changed packages of the current branch and classify them.
54
-
55
- ### ignore
56
-
57
- Type: `string[]`
58
-
59
- Default: `[]`
60
-
61
- Used to declare packages to be ignored when running the `bump` command. The usage is consistent with the `--ignore` parameter of the `bump` command. Note that the two cannot be used at the same time.
62
-
63
- ### fixed
64
-
65
- Type: `string[][]`
66
-
67
- Default: `[]`
68
-
69
- Used to group packages in monorepos. The version of packages in the same group will be bound, and each time the `bump` command is run, a package in the same group is upgraded, others will be upgraded together.
70
- Regular expressions can be used to match package names.
71
-
72
- ### linked
73
-
74
- Type: `string[][]`
75
-
76
- Default: `[]`
77
-
78
- Similar to `fixed`, it also groups packages in monorepos, but only the packages related to the changeset declaration will be upgraded when the `bump` command is run, and the version of the changeset packages in the same group will remain consistent.
79
- Regular expressions can be used to match package names.
80
-
81
- ### updateInternalDependencies
82
-
83
- Type: `patch` | `minor`
84
-
85
- Default: `patch`
86
-
87
- Used to declare the version number rule for updating internal dependencies.
88
-
89
- When upgrading the version number by running the `bump` command, the dependency declaration using the package in the repository will be automatically updated by default. After configuring this field as `minor`, if the version number is upgraded to `patch`, the reference dependency declaration will not be updated automatically.
90
-
91
- For example:
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
- By default, when upgrading `pkg-a` to `1.0.1`, the dependency version of `pkg-a` in `pkg-b` will be updated to `^1.0.1`.
100
-
101
- When configuring `updateInternalDependencies` as `minor`, when upgrading `pkg-a` to `1.0.1`, the dependency version of `pkg-a` in `pkg-b` will not be updated. Only when the version number of `pkg-a` is upgraded to `1.1.0` or `2.0.0`, the dependency of `pkg-a` in `pkg-b` will be updated.
102
-
103
- ### changelog
104
-
105
- Type: `boolean` | `string` | `[string, unknow]`
106
-
107
- Default: `@changesets/cli/changelog`
108
-
109
- The rule for generating changelog.
110
-
111
- When configured as `false`, only the version number will be declared in the `CHANGELOG.md` file when running the `bump` command, and no other changelog information will be declared.
112
-
113
- ![Close changelog configuration](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-empty-changelog.png)
114
-
115
- When configured as `@changesets/cli/changelog`, the official provided changelog generation rule will be used to convert the changeset information into changelog content.
116
-
117
- When configured as an array, the first parameter is a custom NPM package or path, and the second parameter is the default parameter configuration that needs to be passed in. We will explain the custom format in the subsequent [Custom Changelog](/guides/topic-detail/changesets/changelog) section.
118
-
119
- ### \_\_\_experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH
120
-
121
- Some experimental configurations.
122
-
123
- #### onlyUpdatePeerDependentsWhenOutOfRange
124
-
125
- Type: `boolean`
126
-
127
- Default: `false`
128
-
129
- Configuration for the upgrade strategy of `peerDependence` dependencies. By default, when `peerDependence` is upgraded to a `minor` or `major` version, the current package will be upgraded to a major version.
130
-
131
- When this configuration is set to `true`, the version will only be updated when the declared dependencies of `peerDependence` are outside the declared range.
132
-
133
- #### updateInternalDependents
134
-
135
- Type: `always` | `out-of-range`
136
-
137
- Default: `always`
138
-
139
- When upgrading the version number by running the `bump` command, the dependency declaration using the package in the repository will be automatically updated by default. When this parameter is set to `out-of-range`, the dependency declaration using the package in the repository will be updated only when it is outside the declared range.
140
-
141
- #### useCalculatedVersionForSnapshots
142
-
143
- Type: `boolean`
144
-
145
- Default: `false`
146
-
147
- When publishing snapshots, the version format of `0.0.0-timestamp` will be used by default to ensure that users can use pre-release versions normally. When you need to ignore the above problem and use the normal version number format, that is, the current version is `1.0.1`, and the snapshot version is expected to use `1.0.1-timestamp`, you can configure this parameter as `true`.
@@ -1,175 +0,0 @@
1
- ---
2
- sidebar_position: 9
3
- ---
4
-
5
- # Using Github related tools
6
-
7
- ## BOT
8
-
9
- On Github, changesets provide a robot to detect whether the current Pull Request has changeset, and provide a UI interface to add and modify changeset.
10
-
11
- ### Installation
12
-
13
- Click [link](https://github.com/apps/changeset-bot), select Install in the upper right corner, and confirm to complete the installation.
14
-
15
- ![](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-install-bot.png)
16
-
17
- ### Configuration
18
-
19
- After successful installation, you can enter the configuration page and select the application repository according to your needs.
20
-
21
- ![](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-config-bot.png)
22
-
23
- ### Usage
24
-
25
- After the configuration is completed, the robot will automatically check whether each Pull Request has added changeset and provide prompt information through reply.
26
-
27
- #### No changeset added
28
-
29
- ![](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-bot-no-changeset.png)
30
-
31
- You can run `pnpm run change` in the repository to add changeset, or click the second link below to fill in changeset directly.
32
-
33
- #### Changeset added
34
-
35
- ![](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-bot-exist-changeset.png)
36
-
37
- You can click the link below to modify and add new changeset.
38
-
39
- #### No need for changeset
40
-
41
- You can directly ignore the prompt information when no changeset is added, which will not cause problems with the merging of Pull Requests.
42
-
43
- ## Action
44
-
45
- ### Automatically create Release Pull Request
46
-
47
- Modern.js provides a Github Action to automatically create release Pull Request, which can automatically run bump command, update lock file and create Pull Request operation based on the selected branch.
48
-
49
- #### Usage
50
-
51
- - Create a `.github/workflows/release-pull-request.yml` file in the repository and fill in the following content:
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
- - After merging Workflow into the main branch, go to the Action page corresponding to the Github repository and select 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
- - Select the release type of this release, and click the Run workflow button:
101
-
102
- ![Run Release Pull Request](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/action-pull-request.jpeg)
103
-
104
- - After the workflow is completed, a `Release-${version}` Pull Request will be automatically created, the related version number of `bump` changeset will be automatically updated, and the lock file will be updated. The content of Pull Request is the Release Note automatically generated by running the `gen-release-note` command.
105
-
106
- ![Release Pull Request](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/release-pull-request.jpeg)
107
-
108
- ### Automatic Release
109
-
110
- Modern.js provides a Github Action to automatically release versions, which can automatically run release command based on the selected branch and publish the package to NPM.
111
-
112
- #### Usage
113
-
114
- - Create a `.github/workflows/release.yml` file in the repository and fill in the following content:
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
- - Configure the NPM_TOKEN of the repository:
164
-
165
- ![](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/github-set-npm-token.png)
166
-
167
- - After merging Workflow into the main branch, go to the Action page corresponding to the Github repository and select Release:
168
-
169
- ![Release Action](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/release-action.png)
170
-
171
- - Select the branch name and release version type, and click the Run workflow button:
172
-
173
- ![Run Release Action](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/run-release-workflow.png)
174
-
175
- - Workflow will automatically complete the build and release to NPM process of the repository.
@@ -1,56 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
-
5
- # Introducing Changesets
6
-
7
- Modern.js integrates [changesets](https://github.com/changesets/changesets) for package version management in Npm Module and Monorepo project.
8
-
9
- ## Features
10
-
11
- Changesets have the following features:
12
-
13
- - During development, developers need to provide the package names, the type of version upgrade (`pathch`, `minor`, `major`), and change information involved in this change.
14
-
15
- - When releasing a version, the version number of the corresponding package will be automatically upgraded based on the content of the changeset, and changelog information will be generated in the corresponding package.
16
-
17
- - In the Monorepo project, changesets will automatically generate a repository dependency graph, and only upgrade the version numbers of the changed packages and related dependent packages during upgrade.
18
-
19
- ## Initialization
20
-
21
- The Npm Module and Monorepo project created by Modern.js have already initialized changesets. The `.changeset` directory and the configuration file `.changeset/config.json` will be automatically created in the project root directory.
22
-
23
- In addition, Modern.js provides corresponding commands for changesets in its corresponding project tools `@modern-js/module-tools` and `@modern-js/monorepo-tools`, and there is no need to manually install changeset-related dependencies.
24
-
25
- The default configuration for changesets is as follows:
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
- The configuration file provides some basic configurations for generating changesets. For detailed field descriptions, please refer to [Changesets configuration](/guides/topic-detail/changesets/config).
41
-
42
- ## Commands
43
-
44
- - `change`: Creates a changeset. After running this command, a changeset file will be automatically generated in the `.changeset` directory.
45
-
46
- - `bump`: Upgrades the version of the corresponding package based on the current changeset.
47
-
48
- - `pre`: Marks entering and exiting `pre release` mode. When running the `bump` command in `pre release` mode, the version format will be `x.x.x-${pre-tag}.x`.
49
-
50
- - `release`: Publishes the package to NPM.
51
-
52
- - `status`: Views the current changeset status.
53
-
54
- - `gen-release-note`: Generates Release Note information based on the current chagneset status.
55
-
56
- For specific command-supported parameters, please refer to the corresponding chapter introduction.
@@ -1,274 +0,0 @@
1
- ---
2
- sidebar_position: 8
3
- ---
4
-
5
- # Customizing Release Note Format
6
-
7
- Modern.js provides the `modern gen-release-note` command, which supports automatically generating Release Note through the current existing changeset and git commit information. Before running the release command, you can run this command to generate the Release Note for this release.
8
-
9
- The default generated Release Note format is:
10
-
11
- ```markdown
12
- - fix: add missing type definitions by @zllkjc in https://github.com/web-infra-dev/modern.js/pull/3835
13
- ```
14
-
15
- Get the Pull Request ID of the changeset through the commit information, and generate a Github link, which includes the changeset's changelog information and author information.
16
-
17
- :::info
18
- To get author information, you need to provide the Github Token environment variable, which is passed in through GITHUB_AUTH_TOKEN.
19
- :::
20
-
21
- When the default generated Release Note logic cannot meet the requirements, custom Release Note format is supported.
22
-
23
- ## Information
24
-
25
- ### getReleaseInfo
26
-
27
- To generate Release Note information, some information needs to be collected, such as commit ID, Pull Request ID, commit message, etc.
28
-
29
- This logic can be implemented through the `getReleaseInfo` function.
30
-
31
- #### Params
32
-
33
- - commit
34
-
35
- Type: string;
36
-
37
- The commit message information corresponding to the current changeset.
38
-
39
- The result of executing `git log --pretty=format:%h--%s--%ae .changeset/${changeset.id}.md`.
40
-
41
- - commitObj
42
-
43
- Basic information about commit.
44
-
45
- ```ts
46
- export enum CommitType {
47
- Performance = 'performance',
48
- Features = 'features',
49
- BugFix = 'bugFix',
50
- Doc = 'doc',
51
- Other = 'other',
52
- }
53
-
54
- interface Commit {
55
- id: string; // commit id
56
- type: CommitType;
57
- repository?: string; // Repo information passed in as a parameter or defined in package.json
58
- pullRequestId?: string;
59
- author?: string;
60
- message: string; // Commit message
61
- summary: string; // Changeset summary
62
- summary_zh: string; // Changeset summary in Chinese
63
- [key: string]: string | undefined;
64
- }
65
- ```
66
-
67
- #### Returns
68
-
69
- commitObj, the complete commit object after supplementation.
70
-
71
- #### Default Implementation
72
-
73
- The default implementation of Modern.js is to split out the Pull Request ID based on the commit information, and get the user information based on the commit ID and add it to the commitObj.
74
-
75
- ```ts
76
- function getReleaseInfo(commit: string, commitObj: Commit) {
77
- const commitRegex = /(.*)\(#(\d*)\)/;
78
-
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
- }
104
-
105
- if ((message || commitObj.summary).match(commitRegex)) {
106
- const [, messageShort, pullRequestId] = (
107
- message || commitObj.summary
108
- ).match(commitRegex)!;
109
- commitObj.pullRequestId = pullRequestId;
110
- commitObj.message = messageShort.trim();
111
- }
112
-
113
- return commitObj;
114
- }
115
- ```
116
-
117
- ### getReleaseNoteLine
118
-
119
- Generate the corresponding Release Note based on the commit object information getted in `getReleaseInfo`.
120
-
121
- This logic can be implemented through the `getReleaseNoteLine` function.
122
-
123
- #### Params
124
-
125
- - commit
126
-
127
- The type is the same as the above `commitObj` type.
128
-
129
- - lang
130
-
131
- Type: string;
132
-
133
- Get the Release Note information of the corresponding language, supporting `en` and `zh`, the default is `en`.
134
-
135
- #### Returns
136
-
137
- The generated Release Note.
138
-
139
- #### Default Implementation
140
-
141
- The default implementation of Modern.js is:
142
-
143
- ```ts
144
- export function getReleaseNoteLine(
145
- commit: Commit,
146
- lang: 'en' | 'zh' = 'en',
147
- ) {
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`;
157
- }
158
- return `- ${summary_zh}${author ? ` 由 @${author} 实现` : ''}${
159
- pullRequest ? `, 详情可查看 ${pullRequest}` : ''
160
- }\n`;
161
- }
162
- ```
163
-
164
- ## Using Custom Modules
165
-
166
- The `gen-release-note` command supports the `--custom` parameter, which can pass in the module name or path of the custom Release Note module.
167
-
168
- ### Configuring Relative Paths
169
-
170
- If the custom parameter value is a relative path, it is the **project root directory**.
171
-
172
- For example, create the `scripts/my-release-note-config.js` file and define the following content:
173
-
174
- ```ts title="scripts/my-release-note-config.js"
175
- function getReleaseInfo(commit, commitObj) {
176
- return commitObj;
177
- }
178
-
179
- function getReleaseNoteLine(commit) {}
180
-
181
- module.exports = {
182
- getReleaseInfo,
183
- getReleaseNoteLine,
184
- };
185
- ```
186
-
187
- Run the following command:
188
-
189
- ```bash
190
- pnpm run gen-release-note --custom ./scripts/my-release-note-config.js
191
- ```
192
-
193
- You can also define the command parameters directly in `package.json`:
194
-
195
- ```json title="package.json"
196
- {
197
- "scripts": {
198
- ...
199
- "gen-release-note": "modern gen-release-note --custom ./scripts/my-release-note-config.js"
200
- },
201
- ...
202
- }
203
- ```
204
-
205
- Run the command `pnpm run gen-release-note` directly.
206
-
207
- ### Using Modern.js Module
208
-
209
- Customizing release note can also be managed using the Modern.js Module to provide a common solution.
210
-
211
- #### Use `npx @modern-js/create@latest` to create a Modern.js Module
212
-
213
- ```md
214
- ? Please select the type of project you want to create: Npm Module
215
- ? Please fill in the project name: custom-release-note
216
- ? Please select the programming language: TS
217
- ? Please select the package manager: pnpm
218
- ```
219
-
220
- #### Implement Custom Content
221
-
222
- ```ts title="src/index.ts"
223
- export function getReleaseInfo() {}
224
-
225
- export function getReleaseNoteLine() {}
226
- ```
227
-
228
- #### Publish the module to NPM
229
- #### Install the corresponding module in the root directory of the target repository, such as `custom-release-note`
230
- #### Run the `gen-release-note` command with the `custom` parameter added
231
-
232
- ```bash
233
- pnpm run gen-release-note --custom custom-release-note
234
- ```
235
-
236
- ### Using Monorepo Sub-Project
237
-
238
- If your current repository is Monorepo, you can directly manage it using NPM module sub-projects.
239
-
240
- #### Run `pnpm run new` to create a module sub-project
241
-
242
- ```md
243
- ? Please select the type of project you want to create: Npm Module
244
- ? Please fill in the sub-project name: custom-release-note
245
- ? Please fill in the sub-project directory name: custom-release-note
246
- ? Please select the programming language: TS
247
- ```
248
-
249
- #### Implement Custom Content
250
-
251
- ```ts title="src/index.ts"
252
- export function getReleaseInfo() {}
253
-
254
- export function getReleaseNoteLine() {}
255
- ```
256
-
257
- #### Add the sub-project module dependency, such as `custom-release-note`, to the Monorepo root directory
258
-
259
- ```json title="package.json"
260
- {
261
- "devDependencies": {
262
- "custom-release-note": "workspace:*",
263
- ...
264
- }
265
- }
266
- ```
267
-
268
- #### Run the `gen-release-note` command with the `custom` parameter added
269
-
270
- ```bash
271
- pnpm run gen-release-note --custom custom-release-note
272
- ```
273
-
274
- After the module is published to NPM, it can still be used like a module type for other repositories.
@@ -1,49 +0,0 @@
1
- ---
2
- sidebar_position: 4
3
- ---
4
-
5
- # Publishing Pre-Release Version
6
-
7
- Before doing an actual release, we also need to publish a pre-release version for internal testing and user use. Changesets also support publishing pre-release versions.
8
-
9
- ## Steps
10
-
11
- :::info
12
- The following example commands are all using pnpm. If you need to use other package managers, please replace them as needed.
13
- :::
14
-
15
- #### Run the bump command to upgrade the version of the pre-release
16
-
17
- ```bash
18
- pnpm run bump --canary --preid <preid>
19
- ```
20
-
21
- `preid` is the tag for the pre-release version, such as `alpha`, `beta`, etc., and the default value is `next`.
22
-
23
- After using the `--canary` parameter, the `bump` command completes the following three steps:
24
-
25
- - `changeset pre enter <preid>`: Enters pre-release mode.
26
-
27
- - `changeset version`: Upgrades the version.
28
-
29
- - `changeset pre exit`: Exits pre-release mode.
30
-
31
- #### Check the changes and submit
32
-
33
- Check whether the version changes are correct and submit the changes.
34
-
35
- It is recommended to perform pre-release operations not on the main branch and not merge them into the main branch. After the pre-release verification is completed, an actual version can be directly released based on the main branch.
36
-
37
- #### Run the release command to publish the pre-release version:
38
-
39
- ```bash
40
- pnpm run release --tag <tag>
41
- ```
42
-
43
- When publishing a pre-release version, you must use the `--tag` parameter. The parameter value is best the same as the `preid` value to facilitate user use.
44
-
45
- ## Notes
46
-
47
- ### Exiting pre-release mode
48
-
49
- After entering pre-release mode, changesets will automatically create a `pre.json` file in the `.changeset` directory to record some status information when entering pre-release mode. When the status information is inconsistent with the current repository status, you can directly delete this file to exit pre-release mode.