Skip to content

Commit a806034

Browse files
committed
feat: add configuration management for changelog generation with YAML and JSON support
1 parent 7f2d1d9 commit a806034

File tree

9 files changed

+523
-61
lines changed

9 files changed

+523
-61
lines changed

changelog_cli/.changelog_cli.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Changelog CLI Configuration
2+
# This file can be named .changelog_cli.yaml and placed in your project root
3+
# or home directory
4+
5+
changelog:
6+
# Git reference settings
7+
start: "" # Start git reference (e.g. commit SHA or tag)
8+
end: "" # End git reference (e.g. commit SHA or tag)
9+
path: "." # Path to the git repository or folder
10+
11+
# Changelog content settings
12+
include: # List of conventional commit types to include
13+
- feat
14+
- fix
15+
- refactor
16+
- perf
17+
18+
# Output settings
19+
printer: simple # Output format: simple, markdown, slack-markdown
20+
version: "" # Version to display in changelog header
21+
limit: 0 # Max length of changelog (0 = no limit)
22+
23+
# Grouping and formatting
24+
group_by: "" # Group entries: date-asc, date-desc, scope-asc, scope-desc
25+
date_format: "" # Date format (e.g. yyyy-MM-dd)
26+
date_format_locale: en_US
27+
28+
# Auto-detection settings
29+
auto: false # Automatically detect previous tag
30+
auto_tag_glob_pattern: "" # Pattern for auto tag detection
31+
32+
# Integration settings
33+
jira_url: "" # JIRA URL for issue linking

changelog_cli/.changelogrc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"_comment": "Changelog CLI Configuration - JSON format",
3+
"_comment2": "This file can be named .changelogrc and placed in your project root or home directory",
4+
5+
"changelog": {
6+
"start": "",
7+
"end": "",
8+
"path": ".",
9+
10+
"include": [
11+
"feat",
12+
"fix",
13+
"refactor",
14+
"perf"
15+
],
16+
17+
"printer": "simple",
18+
"version": "",
19+
"limit": 0,
20+
21+
"group_by": "",
22+
"date_format": "",
23+
"date_format_locale": "en_US",
24+
25+
"auto": false,
26+
"auto_tag_glob_pattern": "",
27+
28+
"jira_url": ""
29+
}
30+
}

changelog_cli/README.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ CLI to generate an opinionated changelog.
66

77
By default it just generates the changelog based on the whole git history. You can pass custom `--start` and `--end` parameters which are git refs to get a subset of changes between two commits or tags. That was my main goal with this CLI as it doesn't necessarily require semantic versioning.
88

9+
**Features:**
10+
11+
- Generate changelogs from conventional commits
12+
- Support for multiple output formats (simple, markdown, slack-markdown)
13+
- Configuration files support (YAML/JSON) with command-line override
14+
- Auto-detection of previous tags
15+
- Filtering by commit types and date ranges
16+
- Integration with JIRA for issue linking
17+
918
---
1019

1120
## Installation
@@ -38,9 +47,36 @@ brew install changelog_cli
3847
Get usage information:
3948

4049
```sh
50+
# Get general help
51+
changelog_cli --help
52+
53+
# Get help for generate command
4154
changelog_cli generate --help
55+
56+
# Get help for config command
57+
changelog_cli config --help
4258
```
4359

60+
### Managing Configuration
61+
62+
Create and manage configuration files:
63+
64+
```sh
65+
# Get help for config command
66+
changelog_cli config --help
67+
68+
# Create a YAML configuration file
69+
changelog_cli config --init
70+
71+
# Create a JSON configuration file
72+
changelog_cli config --init --format json
73+
74+
# Create a global configuration file
75+
changelog_cli config --init --global
76+
```
77+
78+
### Generating Changelog
79+
4480
Generate a changelog:
4581

4682
```sh
@@ -56,6 +92,114 @@ changelog_cli generate --path packages/something --start $CM_PREVIOUS_COMMIT --v
5692
changelog_cli generate --path lib/packages/my_package --auto true --auto-tag-glob-pattern "my_package*"
5793
```
5894

95+
## Configuration Files
96+
97+
You can use configuration files to avoid repeating command-line arguments. The CLI supports both YAML and JSON configuration formats.
98+
99+
### Supported Configuration Files
100+
101+
The CLI looks for configuration files in the following order:
102+
103+
1. `.changelog_cli.yaml` (project-specific YAML)
104+
2. `.changelogrc` (project-specific JSON)
105+
3. `~/.changelog_cli.yaml` (global YAML)
106+
4. `~/.changelogrc` (global JSON)
107+
108+
### Creating Configuration Files
109+
110+
Use the `config` command to create configuration files:
111+
112+
```sh
113+
# Create a YAML configuration file in the current directory
114+
changelog_cli config --init
115+
116+
# Create a JSON configuration file
117+
changelog_cli config --init --format json
118+
119+
# Create a global configuration file
120+
changelog_cli config --init --global
121+
```
122+
123+
### Configuration Format
124+
125+
#### YAML Configuration (`.changelog_cli.yaml`)
126+
127+
```yaml
128+
# Changelog CLI Configuration
129+
changelog:
130+
# Git reference settings
131+
start: "" # Start git reference (e.g. commit SHA or tag)
132+
end: "" # End git reference (e.g. commit SHA or tag)
133+
path: "." # Path to the git repository or folder
134+
135+
# Changelog content settings
136+
include: # List of conventional commit types to include
137+
- feat
138+
- fix
139+
- refactor
140+
- perf
141+
142+
# Output settings
143+
printer: simple # Output format: simple, markdown, slack-markdown
144+
version: "" # Version to display in changelog header
145+
limit: 0 # Max length of changelog (0 = no limit)
146+
147+
# Grouping and formatting
148+
group_by: "" # Group entries: date-asc, date-desc, scope-asc, scope-desc
149+
date_format: "" # Date format (e.g. yyyy-MM-dd)
150+
date_format_locale: en_US
151+
152+
# Auto-detection settings
153+
auto: false # Automatically detect previous tag
154+
auto_tag_glob_pattern: "" # Pattern for auto tag detection
155+
156+
# Integration settings
157+
jira_url: "" # JIRA URL for issue linking
158+
```
159+
160+
#### JSON Configuration (`.changelogrc`)
161+
162+
```json
163+
{
164+
"changelog": {
165+
"start": "",
166+
"end": "",
167+
"path": ".",
168+
"include": ["feat", "fix", "refactor", "perf"],
169+
"printer": "simple",
170+
"version": "",
171+
"limit": 0,
172+
"group_by": "",
173+
"date_format": "",
174+
"date_format_locale": "en_US",
175+
"auto": false,
176+
"auto_tag_glob_pattern": "",
177+
"jira_url": ""
178+
}
179+
}
180+
```
181+
182+
### Precedence
183+
184+
Command-line arguments take precedence over configuration file settings. This allows you to:
185+
186+
1. Set common defaults in a configuration file
187+
2. Override specific settings using command-line arguments when needed
188+
189+
For example, with this configuration file:
190+
191+
```yaml
192+
changelog:
193+
printer: markdown
194+
include:
195+
- feat
196+
- fix
197+
```
198+
199+
Running `changelog_cli generate --printer simple` will use the simple printer (overriding the config file) but still include only feat and fix commits from the configuration.
200+
201+
### Detection of Previous Tags
202+
59203
You can get the previous tag using git command and then pass it to `changelog_cli`:
60204

61205
```sh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export 'config_command.dart';
12
export 'generate_command.dart';
23
export 'sample_command.dart';
34
export 'update_command.dart';

0 commit comments

Comments
 (0)