Skip to content

Commit 4ade721

Browse files
committed
docs(monorepo_guidance): fix wording and grammar issues, update structure
1 parent 295d7a9 commit 4ade721

File tree

1 file changed

+63
-57
lines changed

1 file changed

+63
-57
lines changed
Lines changed: 63 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,87 @@
11
# Configuring Commitizen in a monorepo
22

3-
This tutorial assumes the monorepo layout is designed with multiple components that can be released independently of each
4-
other, it also assumes that conventional commits with scopes are in use. Some suggested layouts:
5-
6-
```shell-session
7-
.
8-
├── library-b
9-
│   └── .cz.toml
10-
└── library-z
11-
└── .cz.toml
12-
```
13-
14-
```shell-session
15-
src
16-
├── library-b
17-
│   └── .cz.toml
18-
└── library-z
19-
└── .cz.toml
20-
```
21-
22-
Sample `.cz.toml` for each component:
23-
24-
```toml
25-
# library-b/.cz.toml
26-
[tool.commitizen]
27-
name = "cz_customize"
28-
version = "0.0.0"
29-
tag_format = "${version}-library-b" # the component name can be a prefix or suffix with or without a separator
30-
ignored_tag_formats = ["${version}-library-*"] # Avoid noise from other tags
31-
update_changelog_on_bump = true
32-
```
33-
34-
```toml
35-
# library-z/.cz.toml
36-
[tool.commitizen]
37-
name = "cz_customize"
38-
version = "0.0.0"
39-
tag_format = "${version}-library-z"
40-
ignored_tag_formats = ["${version}-library-*"] # Avoid noise from other tags
41-
update_changelog_on_bump = true
42-
```
43-
44-
And finally, to bump each of these:
45-
46-
```sh
47-
cz --config library-b/.cz.toml bump --yes
48-
cz --config library-z/.cz.toml bump --yes
49-
```
3+
This tutorial assumes that your monorepo is structured with multiple components that can be released independently of each other.
4+
It also assumes that you are using conventional commits with scopes.
5+
6+
Here is a step-by-step example using two libraries, `library-b` and `library-z`:
7+
8+
1. **Organize your monorepo**
9+
10+
For example, you might have one of these layouts:
11+
12+
```shell-session
13+
.
14+
├── library-b
15+
│   └── .cz.toml
16+
└── library-z
17+
└── .cz.toml
18+
```
19+
20+
```shell-session
21+
src
22+
├── library-b
23+
│   └── .cz.toml
24+
└── library-z
25+
└── .cz.toml
26+
```
27+
28+
2. **Add a Commitizen configuration for each component**
29+
30+
```toml
31+
# library-b/.cz.toml
32+
[tool.commitizen]
33+
name = "cz_customize"
34+
version = "0.0.0"
35+
tag_format = "${version}-library-b" # the component name can be a prefix or suffix with or without a separator
36+
ignored_tag_formats = ["${version}-library-*"] # Avoid noise from other tags
37+
update_changelog_on_bump = true
38+
```
39+
40+
```toml
41+
# library-z/.cz.toml
42+
[tool.commitizen]
43+
name = "cz_customize"
44+
version = "0.0.0"
45+
tag_format = "${version}-library-z"
46+
ignored_tag_formats = ["${version}-library-*"] # Avoid noise from other tags
47+
update_changelog_on_bump = true
48+
```
49+
50+
3. **Bump each component independently**
51+
52+
```sh
53+
cz --config library-b/.cz.toml bump --yes
54+
cz --config library-z/.cz.toml bump --yes
55+
```
5056
5157
5258
## Changelog per component
5359
54-
In order to filter the correct commits for each component, you'll have to come up with a strategy.
60+
To filter the correct commits for each component, you'll need to define a strategy.
5561
5662
For example:
5763
58-
- Trigger the pipeline based on the changed path, which can have some downsides, as you'll rely on the developer not including files from other files
59-
- [GitHub actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore) uses `path`
64+
- Trigger the pipeline based on the changed path. This can have some downsides, as you'll rely on the developer not including files from unrelated components.
65+
- [GitHub Actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore) uses `path`
6066
- [Jenkins](https://www.jenkins.io/doc/book/pipeline/syntax/#built-in-conditions) uses `changeset`
6167
- [GitLab](https://docs.gitlab.com/ee/ci/yaml/#ruleschanges) uses `rules:changes`
62-
- Filter certain pattern of the commit message (recommended)
68+
- Filter commits by a specific pattern in the commit message (recommended)
6369
6470
6571
### Example with scope in conventional commits
6672
67-
For this example, to include the message in the changelog, we will require commits to use a specific scope.
68-
This way, only relevant commits will be included in the appropriate change log for a given component, and any other commit will be ignored.
73+
In this example, we want `library-b`'s changelog to only include commits that use the `library-b` scope.
74+
To achieve this, we configure Commitizen to match only commit messages with that scope.
6975
70-
Example config and commit for `library-b`:
76+
Here is an example configuration for `library-b`:
7177
7278
```toml
7379
[tool.commitizen.customize]
74-
changelog_pattern = "^(feat|fix)\\(library-b\\)(!)?:" #the pattern on types can be a wild card or any types you wish to include
80+
changelog_pattern = "^(feat|fix)\\(library-b\\)(!)?:" # the type pattern can be a wildcard or any types you wish to include
7581
```
7682

77-
A commit message looking like this, would be included:
83+
With this configuration, a commit message like the following would be included in `library-b`'s changelog:
7884

79-
```
85+
```text
8086
fix(library-b): Some awesome message
8187
```

0 commit comments

Comments
 (0)