@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,238 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sidebar_position: 6
|
3
|
-
---
|
4
|
-
|
5
|
-
# Customizing Changelog
|
6
|
-
|
7
|
-
By default, Changesets will use `@changesets/cli/changelog` to generate changelog. If the default changelog cannot meet the requirements, you can customize the generation of changelog.
|
8
|
-
|
9
|
-
## Customizing Changelog Content
|
10
|
-
|
11
|
-
Changelog mainly includes the following two types of information:
|
12
|
-
|
13
|
-
- Changelog written in the changeset.
|
14
|
-
|
15
|
-
- Version change information of related packages in this version upgrade.
|
16
|
-
|
17
|
-
The custom logic mainly implements two functions, `getReleaseLine` and `getDependencyReleaseLine`, which are used to define the above two types of information, respectively.
|
18
|
-
|
19
|
-
### getReleaseLine
|
20
|
-
|
21
|
-
#### Params
|
22
|
-
|
23
|
-
- changeset
|
24
|
-
|
25
|
-
```ts
|
26
|
-
export type VersionType = 'major' | 'minor' | 'patch' | 'none';
|
27
|
-
|
28
|
-
export type Release = { name: string; type: VersionType };
|
29
|
-
|
30
|
-
export type Changeset = {
|
31
|
-
id: string; // changeset id
|
32
|
-
commit?: string; // changeset commit id
|
33
|
-
summary: string; // changeset summary content
|
34
|
-
releases: Array<Release>; // The name and type information of the current computed changeset upgrade package.
|
35
|
-
};
|
36
|
-
```
|
37
|
-
|
38
|
-
- type
|
39
|
-
|
40
|
-
The upgraded version type corresponding to the current package, which is of type `VersionType` mentioned above.
|
41
|
-
|
42
|
-
#### Returns
|
43
|
-
|
44
|
-
Changelog content.
|
45
|
-
|
46
|
-
#### Default Implementation
|
47
|
-
|
48
|
-
The default processing logic of `@changesets/cli/changelog` is to split the `summary` information according to the newline `\n`, add `-` as the list header before the first line, and organize other content as the supplement of the first line below the list.
|
49
|
-
|
50
|
-
```ts
|
51
|
-
async function getReleaseLine(changeset, type) {
|
52
|
-
const [firstLine, ...futureLines] = changeset.summary
|
53
|
-
.split('\n')
|
54
|
-
.map(l => l.trimRight());
|
55
|
-
|
56
|
-
let returnVal = `- ${
|
57
|
-
changeset.commit ? `${changeset.commit}: ` : ''
|
58
|
-
}${firstLine}`;
|
59
|
-
|
60
|
-
if (futureLines.length > 0) {
|
61
|
-
returnVal += `\n${futureLines.map(l => ` ${l}`).join('\n')}`;
|
62
|
-
}
|
63
|
-
|
64
|
-
return returnVal;
|
65
|
-
}
|
66
|
-
```
|
67
|
-
|
68
|
-
### getDependencyReleaseLine
|
69
|
-
|
70
|
-
#### Params
|
71
|
-
|
72
|
-
- changesets
|
73
|
-
|
74
|
-
All associated changeset information, which is an array of `getReleaseLine` changeset types.
|
75
|
-
|
76
|
-
- dependenciesUpdated
|
77
|
-
|
78
|
-
```ts
|
79
|
-
type ModCompWithPackage = {
|
80
|
-
name: string; // Name of the dependent module
|
81
|
-
type: VersionType; // Upgrade type of the dependent module
|
82
|
-
oldVersion: string; // Current version of the dependent module
|
83
|
-
newVersion: string; // New version of the dependent module
|
84
|
-
changesets: string[]; // List of associated changeset ids
|
85
|
-
packageJson: PackageJSON; // Complete package.json content of the dependent module
|
86
|
-
dir: string; // Path (absolute path) of the dependent module
|
87
|
-
};
|
88
|
-
|
89
|
-
type DependenciesUpdated = ModCompWithPackage[];
|
90
|
-
```
|
91
|
-
|
92
|
-
#### Returns
|
93
|
-
|
94
|
-
Changelog content.
|
95
|
-
|
96
|
-
#### Default Implementation
|
97
|
-
|
98
|
-
By default, `@changesets/cli/changelog` will display the corresponding `Updated dependencies + commit id` information of the changesets as a list. Then, based on the `dependenciesUpdated` information, it will display the package name and new version of the corresponding dependency package as a child list item of the list.
|
99
|
-
|
100
|
-
```ts
|
101
|
-
async function getDependencyReleaseLine(changesets, dependenciesUpdated) {
|
102
|
-
console.log('getDependencyReleaseLine', changesets, dependenciesUpdated);
|
103
|
-
if (dependenciesUpdated.length === 0) return '';
|
104
|
-
|
105
|
-
const changesetLinks = changesets.map(
|
106
|
-
changeset =>
|
107
|
-
`- Updated dependencies${
|
108
|
-
changeset.commit ? ` [${changeset.commit}]` : ''
|
109
|
-
}`,
|
110
|
-
);
|
111
|
-
|
112
|
-
const updatedDepenenciesList = dependenciesUpdated.map(
|
113
|
-
dependency => ` - ${dependency.name}@${dependency.newVersion}`,
|
114
|
-
);
|
115
|
-
|
116
|
-
return [...changesetLinks, ...updatedDepenenciesList].join('\n');
|
117
|
-
}
|
118
|
-
```
|
119
|
-
|
120
|
-
It is displayed as follows:
|
121
|
-
|
122
|
-
```markdown
|
123
|
-
- Updated dependencies [f0438ab]
|
124
|
-
- Updated dependencies [f0438ab]
|
125
|
-
- module-3@2.0.0
|
126
|
-
- module-1@0.2.0
|
127
|
-
```
|
128
|
-
|
129
|
-
## Configuration
|
130
|
-
|
131
|
-
The `changelog` field in the changesets configuration file is used to mark the way to get changelog.
|
132
|
-
|
133
|
-
This configuration can be a string, directly declaring the module name or path of the changelog module.
|
134
|
-
|
135
|
-
This configuration also supports configuring arrays. The first element in the array is the module name or path of the changelog module, and the second element is the parameter value passed to the corresponding function, which will be passed as the third parameter of the `getReleaseLine` and `getDependencyReleaseLine` functions.
|
136
|
-
|
137
|
-
### Configuring Relative Paths
|
138
|
-
|
139
|
-
If the changelog configuration is a relative path, it is a relative path under the `.changesets` directory.
|
140
|
-
|
141
|
-
For example, create the `.changeset/my-changelog-config.js` file and define the following content:
|
142
|
-
|
143
|
-
```ts title=".changeset/my-changelog-config.js"
|
144
|
-
async function getReleaseLine(changeset, type) {}
|
145
|
-
|
146
|
-
async function getDependencyReleaseLine(changesets, dependenciesUpdated) {}
|
147
|
-
|
148
|
-
module.exports = {
|
149
|
-
getReleaseLine,
|
150
|
-
getDependencyReleaseLine,
|
151
|
-
};
|
152
|
-
```
|
153
|
-
|
154
|
-
Configure `changlog` as `./my-changelog-config.js`:
|
155
|
-
|
156
|
-
```json title=".changesets/config.json"
|
157
|
-
{
|
158
|
-
"changelog": "./my-changelog-config.js",
|
159
|
-
...
|
160
|
-
}
|
161
|
-
```
|
162
|
-
|
163
|
-
### Using Modern.js Module
|
164
|
-
|
165
|
-
Customizing changelog can also be managed using the Modern.js Module to provide a common solution.
|
166
|
-
|
167
|
-
#### Use `npx @modern-js/create@latest` to create a Modern.js Module.
|
168
|
-
|
169
|
-
```md
|
170
|
-
? Please select the type of project you want to create: Npm Module
|
171
|
-
? Please fill in the project name: custom-changelog
|
172
|
-
? Please select the programming language: TS
|
173
|
-
? Please select the package manager: pnpm
|
174
|
-
```
|
175
|
-
|
176
|
-
#### Implement Custom Content
|
177
|
-
|
178
|
-
```ts title="src/index.ts"
|
179
|
-
export async function getReleaseLine() {}
|
180
|
-
|
181
|
-
export async function getDependencyReleaseLine() {}
|
182
|
-
```
|
183
|
-
|
184
|
-
#### Publish the module to NPM
|
185
|
-
|
186
|
-
#### Install the module in the root directory of the target repository, such as `custom-changelog`.
|
187
|
-
|
188
|
-
#### Configure the changelog configuration of changesets as the package name.
|
189
|
-
|
190
|
-
```json title=".changesets/config.json"
|
191
|
-
{
|
192
|
-
"changelog": "custom-changelog",
|
193
|
-
...
|
194
|
-
}
|
195
|
-
```
|
196
|
-
|
197
|
-
### Using Monorepo Sub-Project
|
198
|
-
|
199
|
-
If your current repository is Monorepo, you can directly manage it using NPM module sub-projects.
|
200
|
-
|
201
|
-
#### Run `pnpm run new` to create a NPM module sub-project
|
202
|
-
|
203
|
-
```bash
|
204
|
-
? Please select the type of project you want to create: Npm Module
|
205
|
-
? Please fill in the sub-project name: custom-changelog
|
206
|
-
? Please fill in the sub-project directory name: custom-changelog
|
207
|
-
? Please select the programming language: TS
|
208
|
-
```
|
209
|
-
|
210
|
-
#### Implement Custom Content
|
211
|
-
|
212
|
-
```ts title="src/index.ts"
|
213
|
-
export async function getReleaseLine() {}
|
214
|
-
|
215
|
-
export async function getDependencyReleaseLine() {}
|
216
|
-
```
|
217
|
-
|
218
|
-
#### Add the sub-project module dependency, such as `custom-changelog`, to the Monorepo root directory
|
219
|
-
|
220
|
-
```json title="package.json"
|
221
|
-
{
|
222
|
-
"devDependencies": {
|
223
|
-
"custom-changelog": "workspace:*",
|
224
|
-
...
|
225
|
-
}
|
226
|
-
}
|
227
|
-
```
|
228
|
-
|
229
|
-
#### Configure the changelog configuration of Changesets as the package name
|
230
|
-
|
231
|
-
```json title=".changesets/config.json"
|
232
|
-
{
|
233
|
-
"changelog": "custom-changelog",
|
234
|
-
...
|
235
|
-
}
|
236
|
-
```
|
237
|
-
|
238
|
-
After the module is published to NPM, it can still be used like a module type for other repositories.
|
@@ -1,269 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sidebar_position: 7
|
3
|
-
---
|
4
|
-
|
5
|
-
# Customizing Commit Messages
|
6
|
-
|
7
|
-
Changesets supports configuring `commit` to automatically submit the current changes when running the `change` and `bump` commands.
|
8
|
-
|
9
|
-
The default `commit` information is provided by `@changesets/cli/commit`, and the default information format is:
|
10
|
-
|
11
|
-

|
12
|
-

|
13
|
-
|
14
|
-
When the default commit information cannot meet the requirements, custom commit information is supported.
|
15
|
-
|
16
|
-
## Customizing Commit Message Content
|
17
|
-
|
18
|
-
Commit information is divided into two types:
|
19
|
-
|
20
|
-
- Commit information automatically generated when running the `change` command.
|
21
|
-
- Commit information automatically generated when running the `bump` command.
|
22
|
-
|
23
|
-
The custom logic mainly implements two functions, `getAddMessage` and `getVersionMessage`, which are used to define the above two types of information, respectively.
|
24
|
-
|
25
|
-
### getAddMessage
|
26
|
-
|
27
|
-
#### Params
|
28
|
-
|
29
|
-
- changeset
|
30
|
-
|
31
|
-
The current changeset information created.
|
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
|
-
Configuration information when committing.
|
48
|
-
|
49
|
-
> When the commit configuration is an array, the second parameter supports passing in default configuration information, which will be used to pass this parameter.
|
50
|
-
|
51
|
-
#### Returns
|
52
|
-
|
53
|
-
Commit message content.
|
54
|
-
|
55
|
-
#### Default Implementation
|
56
|
-
|
57
|
-
The default processing logic of `@changesets/cli/commit` is to start with `docs(changeset):`, and the commit information is the `summary` of the changeset, and [skip ci] information is added according to the `skipCI` parameter configuration passed in.
|
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) is used to remove the leading whitespace content of the template string to make the commit information more compliant with the specification.
|
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'; // Current state of pre mode
|
105
|
-
tag: string; // Type of pre
|
106
|
-
initialVersions: {
|
107
|
-
[pkgName: string]: string; // Package name and version information before version upgrade
|
108
|
-
};
|
109
|
-
changesets: string[]; // List of changeset ids for this upgrade
|
110
|
-
};
|
111
|
-
|
112
|
-
type ReleasePlan = {
|
113
|
-
changesets: Changeset[]; // List of changesets for this upgrade
|
114
|
-
releases: ComprehensiveRelease[]; // Information of the current upgrade, including package name, current version, upgraded version, and upgrade type
|
115
|
-
preState: PreState | undefined; // If it is a pre-release, provide relevant state information
|
116
|
-
};
|
117
|
-
```
|
118
|
-
|
119
|
-
- options
|
120
|
-
|
121
|
-
Configuration information when committing.
|
122
|
-
|
123
|
-
> When the commit configuration is an array, the second parameter supports passing in default configuration information, which will be used to pass this parameter.
|
124
|
-
|
125
|
-
#### Returns
|
126
|
-
|
127
|
-
Commit message content.
|
128
|
-
|
129
|
-
#### Default Implementation
|
130
|
-
|
131
|
-
The default processing logic of `@changesets/cli/commit` is to first display the number of packages that need to be released, then display the names and new version of the released packages, and [skip ci] information is added according to the `skipCI` parameter configuration passed in.
|
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
|
-
## Configuration
|
159
|
-
|
160
|
-
The `commit` field in the changesets configuration file is used to mark whether to submit commit information when running the `change` and `bump` commands, and the way to obtain commit information.
|
161
|
-
|
162
|
-
This configuration can be a `boolean`. When it is `true`, the default `@changesets/cli/commit` formatting commit information will be used.
|
163
|
-
|
164
|
-
This configuration can be a string, directly declaring the module name or path of the commit information acquisition module.
|
165
|
-
|
166
|
-
This configuration also supports configuring arrays. The first element in the array is the module name or path of the commit information acquisition module, and the second element is the parameter value passed to the corresponding function, which will be passed as the second parameter of the `getAddMessage` and `getVersionMessage` functions.
|
167
|
-
|
168
|
-
### Configuring Relative Paths
|
169
|
-
|
170
|
-
If the commit configuration is a relative path, it is a relative path under the `.changesets` directory.
|
171
|
-
|
172
|
-
For example, create the `.changeset/my-commit-config.js` file and define the following content:
|
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
|
-
Configure `commit` as `./my-commit-config.js`:
|
186
|
-
|
187
|
-
```json title=".changesets/config.json"
|
188
|
-
{
|
189
|
-
"changelog": "./my-commit-config.js",
|
190
|
-
...
|
191
|
-
}
|
192
|
-
```
|
193
|
-
|
194
|
-
### Using Modern.js Module
|
195
|
-
|
196
|
-
Customizing commit can also be managed using the Modern.js Module to provide a common solution.
|
197
|
-
|
198
|
-
#### Use `npx @modern-js/create@latest` to create a mModern.js Module
|
199
|
-
|
200
|
-
```md
|
201
|
-
? Please select the type of project you want to create: Npm Module
|
202
|
-
? Please fill in the project name: custom-commit
|
203
|
-
? Please select the programming language: TS
|
204
|
-
? Please select the package manager: pnpm
|
205
|
-
```
|
206
|
-
|
207
|
-
#### Implement Custom Content
|
208
|
-
|
209
|
-
```ts title="src/index.ts"
|
210
|
-
export async function getAddMessage() {}
|
211
|
-
|
212
|
-
export async function getVersionMessage() {}
|
213
|
-
```
|
214
|
-
|
215
|
-
#### Publish the module to NPM
|
216
|
-
|
217
|
-
#### Install the corresponding module in the root directory of the target repository, such as `custom-commit`
|
218
|
-
|
219
|
-
#### Configure the commit configuration of changesets as the package name
|
220
|
-
|
221
|
-
```json title="package.json"
|
222
|
-
{
|
223
|
-
"commit": "custom-commit",
|
224
|
-
...
|
225
|
-
}
|
226
|
-
```
|
227
|
-
|
228
|
-
### Using Monorepo Sub-Project
|
229
|
-
|
230
|
-
If your current repository is Monorepo, you can directly manage it using NPM module sub-projects.
|
231
|
-
|
232
|
-
#### Run `pnpm run new` to create a module sub-project
|
233
|
-
|
234
|
-
```bash
|
235
|
-
? Please select the type of project you want to create: Npm Module
|
236
|
-
? Please fill in the sub-project name: custom-commit
|
237
|
-
? Please fill in the sub-project directory name: custom-commit
|
238
|
-
? Please select the programming language: TS
|
239
|
-
```
|
240
|
-
|
241
|
-
#### Implement Custom Content
|
242
|
-
|
243
|
-
```ts title="src/index.ts"
|
244
|
-
export async function getAddMessage() {}
|
245
|
-
|
246
|
-
export async function getVersionMessage() {}
|
247
|
-
```
|
248
|
-
|
249
|
-
#### Add the sub-project module dependency, such as `custom-commit`, to the Monorepo root directory
|
250
|
-
|
251
|
-
```json title="package.json"
|
252
|
-
{
|
253
|
-
"devDependencies": {
|
254
|
-
"custom-commit": "workspace:*",
|
255
|
-
...
|
256
|
-
}
|
257
|
-
}
|
258
|
-
```
|
259
|
-
|
260
|
-
#### Configure the commit configuration of Changesets as the package name
|
261
|
-
|
262
|
-
```json title=".changesets/config.json"
|
263
|
-
{
|
264
|
-
"commit": "custom-commit",
|
265
|
-
...
|
266
|
-
}
|
267
|
-
```
|
268
|
-
|
269
|
-
After the module is published to NPM, it can still be used like a module type for other repositories.
|
@@ -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
|
-

|
22
|
-

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

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