@modern-js/main-doc 2.52.0 → 2.54.0
Sign up to get free protection for your applications and to get access to all the features.
- package/docs/en/configure/app/server/ssr.mdx +2 -0
- package/docs/en/guides/advanced-features/bff/index.mdx +1 -1
- package/docs/en/guides/advanced-features/code-split.mdx +4 -4
- package/docs/en/guides/advanced-features/ssr/index.mdx +1 -0
- package/docs/en/guides/basic-features/routes.mdx +3 -3
- package/docs/en/guides/get-started/introduction.mdx +1 -1
- package/docs/en/guides/get-started/tech-stack.mdx +0 -6
- package/docs/en/guides/topic-detail/framework-plugin/plugin-api.mdx +1 -1
- package/docs/en/guides/topic-detail/generator/create/config.mdx +0 -6
- package/docs/en/guides/topic-detail/generator/create/option.md +0 -5
- package/docs/en/guides/topic-detail/generator/create/use.mdx +1 -10
- package/docs/en/guides/topic-detail/generator/new/config.md +0 -29
- package/docs/en/guides/topic-detail/generator/new/use.md +1 -21
- package/docs/zh/configure/app/server/ssr.mdx +2 -0
- package/docs/zh/guides/advanced-features/bff/index.mdx +2 -2
- package/docs/zh/guides/advanced-features/code-split.mdx +5 -5
- package/docs/zh/guides/advanced-features/rspack-start.mdx +1 -1
- package/docs/zh/guides/advanced-features/ssr/index.mdx +2 -1
- package/docs/zh/guides/advanced-features/ssr/usage.mdx +2 -2
- package/docs/zh/guides/basic-features/data/data-fetch.mdx +2 -2
- package/docs/zh/guides/basic-features/data/data-write.mdx +1 -2
- package/docs/zh/guides/basic-features/mock.mdx +1 -1
- package/docs/zh/guides/basic-features/routes.mdx +6 -6
- package/docs/zh/guides/get-started/introduction.mdx +1 -1
- package/docs/zh/guides/get-started/tech-stack.mdx +0 -6
- package/docs/zh/guides/topic-detail/framework-plugin/plugin-api.mdx +1 -1
- package/docs/zh/guides/topic-detail/generator/create/config.mdx +0 -6
- package/docs/zh/guides/topic-detail/generator/create/option.md +0 -5
- package/docs/zh/guides/topic-detail/generator/create/use.mdx +1 -10
- package/docs/zh/guides/topic-detail/generator/new/config.md +0 -31
- package/docs/zh/guides/topic-detail/generator/new/use.md +1 -21
- package/package.json +5 -5
- package/docs/en/apis/app/runtime/testing/_category_.json +0 -4
- package/docs/en/apis/app/runtime/testing/act.mdx +0 -35
- package/docs/en/apis/app/runtime/testing/cleanup.mdx +0 -40
- package/docs/en/apis/app/runtime/testing/render.mdx +0 -71
- package/docs/en/apis/app/runtime/testing/renderApp.mdx +0 -34
- package/docs/en/configure/app/testing/_category_.json +0 -4
- package/docs/en/configure/app/testing/transformer.mdx +0 -17
- package/docs/en/configure/app/tools/jest.mdx +0 -40
- package/docs/en/guides/advanced-features/testing.mdx +0 -47
- package/docs/en/guides/topic-detail/changesets/_category_.json +0 -4
- package/docs/en/guides/topic-detail/changesets/add.mdx +0 -125
- package/docs/en/guides/topic-detail/changesets/changelog.mdx +0 -238
- package/docs/en/guides/topic-detail/changesets/commit.mdx +0 -269
- package/docs/en/guides/topic-detail/changesets/config.mdx +0 -147
- package/docs/en/guides/topic-detail/changesets/github.mdx +0 -175
- package/docs/en/guides/topic-detail/changesets/introduce.mdx +0 -56
- package/docs/en/guides/topic-detail/changesets/release-note.mdx +0 -274
- package/docs/en/guides/topic-detail/changesets/release-pre.mdx +0 -49
- package/docs/en/guides/topic-detail/changesets/release.mdx +0 -229
- package/docs/en/guides/topic-detail/model/test-model.mdx +0 -45
- package/docs/zh/apis/app/runtime/testing/_category_.json +0 -4
- package/docs/zh/apis/app/runtime/testing/act.mdx +0 -35
- package/docs/zh/apis/app/runtime/testing/cleanup.mdx +0 -40
- package/docs/zh/apis/app/runtime/testing/render.mdx +0 -71
- package/docs/zh/apis/app/runtime/testing/renderApp.mdx +0 -32
- package/docs/zh/configure/app/testing/_category_.json +0 -4
- package/docs/zh/configure/app/testing/transformer.mdx +0 -19
- package/docs/zh/configure/app/tools/jest.mdx +0 -40
- package/docs/zh/guides/advanced-features/testing.mdx +0 -47
- package/docs/zh/guides/topic-detail/changesets/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/changesets/add.mdx +0 -126
- package/docs/zh/guides/topic-detail/changesets/changelog.mdx +0 -238
- package/docs/zh/guides/topic-detail/changesets/commit.mdx +0 -269
- package/docs/zh/guides/topic-detail/changesets/config.mdx +0 -147
- package/docs/zh/guides/topic-detail/changesets/github.mdx +0 -175
- package/docs/zh/guides/topic-detail/changesets/introduce.mdx +0 -56
- package/docs/zh/guides/topic-detail/changesets/release-note.mdx +0 -274
- package/docs/zh/guides/topic-detail/changesets/release-pre.mdx +0 -50
- package/docs/zh/guides/topic-detail/changesets/release.mdx +0 -231
- package/docs/zh/guides/topic-detail/model/test-model.mdx +0 -45
- package/docs/zh/guides/topic-detail/monorepo/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/monorepo/create-sub-project.mdx +0 -53
- package/docs/zh/guides/topic-detail/monorepo/intro.mdx +0 -14
- package/docs/zh/guides/topic-detail/monorepo/publish.mdx +0 -69
- package/docs/zh/guides/topic-detail/monorepo/sub-project-interface.mdx +0 -143
@@ -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
|
-

|
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
|
-

|
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
|
-

|
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
|
-

|
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
|
-

|
99
|
-
|
100
|
-
- Select the release type of this release, and click the Run workflow button:
|
101
|
-
|
102
|
-

|
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
|
-

|
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
|
-

|
166
|
-
|
167
|
-
- After merging Workflow into the main branch, go to the Action page corresponding to the Github repository and select Release:
|
168
|
-
|
169
|
-

|
170
|
-
|
171
|
-
- Select the branch name and release version type, and click the Run workflow button:
|
172
|
-
|
173
|
-

|
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.
|