package-versioner 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -6
- package/dist/index.cjs +1072 -174
- package/dist/index.js +1063 -165
- package/docs/changelogs.md +65 -0
- package/docs/{VERSIONING_STRATEGIES.md → versioning.md} +1 -1
- package/package-versioner.schema.json +32 -1
- package/package.json +11 -7
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Changelog Generation
|
|
2
|
+
|
|
3
|
+
`package-versioner` automatically generates and maintains a [Keep a Changelog](https://keepachangelog.com/) or Angular-style changelog for each package in your project.
|
|
4
|
+
|
|
5
|
+
## How It Works
|
|
6
|
+
|
|
7
|
+
1. When a package is versioned, `package-versioner` scans the git history since the last release tag.
|
|
8
|
+
2. It parses conventional commit messages and sorts them into appropriate changelog sections:
|
|
9
|
+
- `feat` prefixed commits become "Added" entries
|
|
10
|
+
- `fix` prefixed commits become "Fixed" entries
|
|
11
|
+
- `deprecate` prefixed commits become "Deprecated" entries
|
|
12
|
+
- `refactor`, `style`, `perf`, `build`, `ci` become "Changed" entries
|
|
13
|
+
- `revert` becomes "Removed" entries
|
|
14
|
+
- Any commits with `!` after the type or containing `BREAKING CHANGE:` text get a **BREAKING** prefix
|
|
15
|
+
- Other commit types are mapped to sensible defaults
|
|
16
|
+
|
|
17
|
+
## Changelog Structure
|
|
18
|
+
|
|
19
|
+
The generated changelogs follow the Keep a Changelog structure:
|
|
20
|
+
|
|
21
|
+
- An "Unreleased" section for tracking upcoming changes
|
|
22
|
+
- Version sections with release dates and sorted entries
|
|
23
|
+
- Entries grouped by type (Added, Changed, Fixed, etc.)
|
|
24
|
+
- Automatic linking between versions if repository info is available
|
|
25
|
+
- Smart detection of issue references (like `Fixes #123`)
|
|
26
|
+
|
|
27
|
+
## Changelog Formats
|
|
28
|
+
|
|
29
|
+
`package-versioner` supports two changelog formats:
|
|
30
|
+
|
|
31
|
+
1. **Keep a Changelog** (default): A standard format following [keepachangelog.com](https://keepachangelog.com/) conventions
|
|
32
|
+
2. **Angular**: A format similar to that used by Angular projects
|
|
33
|
+
|
|
34
|
+
You can configure the preferred format in your `version.config.json`:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"updateChangelog": true,
|
|
39
|
+
"changelogFormat": "keep-a-changelog" // or "angular"
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Customization Options
|
|
44
|
+
|
|
45
|
+
- **Enable/Disable**: Set `updateChangelog: false` in your config to disable changelog generation
|
|
46
|
+
- **Format Selection**: Use `changelogFormat` to choose between "keep-a-changelog" or "angular"
|
|
47
|
+
- **Repository URL**: Automatically detected from package.json, or can be configured explicitly
|
|
48
|
+
- **Issue References**: Commit messages containing `fixes #123` or similar will link issues in the changelog
|
|
49
|
+
|
|
50
|
+
## Regenerating Changelogs
|
|
51
|
+
|
|
52
|
+
For projects with existing history, you can regenerate a complete changelog from scratch using the CLI:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npx package-versioner changelog --regenerate
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This will scan your entire git history and create a comprehensive changelog based on all version tags found in your repository.
|
|
59
|
+
|
|
60
|
+
## Tips for Better Changelogs
|
|
61
|
+
|
|
62
|
+
- Use conventional commit format (`type(scope): message`) for consistent changelog entries
|
|
63
|
+
- Include issue references in commits (`fixes #123`) to automatically link related issues
|
|
64
|
+
- Add `BREAKING CHANGE:` in commit bodies when introducing breaking changes
|
|
65
|
+
- Keep commit messages clear and user-focused for better changelog readability
|
|
@@ -213,4 +213,4 @@ This would produce tags like `release-1.2.3` instead of `v1.2.3`.
|
|
|
213
213
|
"packageTagTemplate": "${packageName}-${prefix}${version}"
|
|
214
214
|
}
|
|
215
215
|
```
|
|
216
|
-
This would produce package tags like `@scope/package-name-v1.2.3` instead of `@scope/package-name@v1.2.3`.
|
|
216
|
+
This would produce package tags like `@scope/package-name-v1.2.3` instead of `@scope/package-name@v1.2.3`.
|
|
@@ -30,6 +30,12 @@
|
|
|
30
30
|
"default": "angular",
|
|
31
31
|
"description": "The commit message convention preset"
|
|
32
32
|
},
|
|
33
|
+
"changelogFormat": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"enum": ["keep-a-changelog", "angular"],
|
|
36
|
+
"default": "keep-a-changelog",
|
|
37
|
+
"description": "The format to use for generating changelogs"
|
|
38
|
+
},
|
|
33
39
|
"baseBranch": {
|
|
34
40
|
"type": "string",
|
|
35
41
|
"minLength": 1,
|
|
@@ -84,7 +90,7 @@
|
|
|
84
90
|
"type": "string",
|
|
85
91
|
"minLength": 1,
|
|
86
92
|
"default": "chore(release): v${version}",
|
|
87
|
-
"description": "Template for commit messages"
|
|
93
|
+
"description": "Template for commit messages. Available variables: ${version}, ${packageName}, ${scope}"
|
|
88
94
|
},
|
|
89
95
|
"prereleaseIdentifier": {
|
|
90
96
|
"type": "string",
|
|
@@ -95,6 +101,31 @@
|
|
|
95
101
|
"type": "boolean",
|
|
96
102
|
"default": false,
|
|
97
103
|
"description": "Whether to skip Git hooks"
|
|
104
|
+
},
|
|
105
|
+
"updateChangelog": {
|
|
106
|
+
"type": "boolean",
|
|
107
|
+
"default": true,
|
|
108
|
+
"description": "Whether to automatically generate and update changelogs"
|
|
109
|
+
},
|
|
110
|
+
"cargo": {
|
|
111
|
+
"type": "object",
|
|
112
|
+
"properties": {
|
|
113
|
+
"enabled": {
|
|
114
|
+
"type": "boolean",
|
|
115
|
+
"default": true,
|
|
116
|
+
"description": "Whether to enable Cargo.toml version handling"
|
|
117
|
+
},
|
|
118
|
+
"paths": {
|
|
119
|
+
"type": "array",
|
|
120
|
+
"items": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"minLength": 1
|
|
123
|
+
},
|
|
124
|
+
"description": "Specify directories to search for Cargo.toml files"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"additionalProperties": false,
|
|
128
|
+
"description": "Configuration options for Rust/Cargo support"
|
|
98
129
|
}
|
|
99
130
|
},
|
|
100
131
|
"required": ["versionPrefix", "preset", "updateInternalDependencies"],
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "package-versioner",
|
|
3
3
|
"description": "A lightweight yet powerful CLI tool for automated semantic versioning based on Git history and conventional commits.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -39,14 +39,15 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@biomejs/biome": "^1.9.4",
|
|
41
41
|
"@types/figlet": "^1.5.5",
|
|
42
|
-
"@types/node": "^22.15.
|
|
42
|
+
"@types/node": "^22.15.17",
|
|
43
43
|
"@types/semver": "^7.3.13",
|
|
44
|
-
"@vitest/coverage-v8": "^3.1.
|
|
44
|
+
"@vitest/coverage-v8": "^3.1.3",
|
|
45
45
|
"husky": "^9.1.7",
|
|
46
|
-
"lint-staged": "^
|
|
46
|
+
"lint-staged": "^16.0.0",
|
|
47
47
|
"tsup": "^8.4.0",
|
|
48
|
+
"tsx": "^4.19.4",
|
|
48
49
|
"typescript": "^5.8.3",
|
|
49
|
-
"vitest": "^3.1.
|
|
50
|
+
"vitest": "^3.1.3"
|
|
50
51
|
},
|
|
51
52
|
"dependencies": {
|
|
52
53
|
"@manypkg/get-packages": "^3.0.0",
|
|
@@ -57,15 +58,18 @@
|
|
|
57
58
|
"conventional-recommended-bump": "^11.0.0",
|
|
58
59
|
"figlet": "^1.8.1",
|
|
59
60
|
"git-semver-tags": "^8.0.0",
|
|
60
|
-
"semver": "^7.7.
|
|
61
|
+
"semver": "^7.7.2",
|
|
61
62
|
"smol-toml": "^1.3.4"
|
|
62
63
|
},
|
|
63
64
|
"scripts": {
|
|
64
65
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
65
66
|
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
|
|
66
67
|
"clean": "rm -rf node_modules && rm -rf dist",
|
|
67
|
-
"test": "
|
|
68
|
+
"test": "pnpm run test:unit && pnpm run test:integration",
|
|
68
69
|
"test:watch": "vitest --coverage",
|
|
70
|
+
"test:integration": "vitest --run --dir test/integration",
|
|
71
|
+
"posttest:integration": "pnpm tsx scripts/cleanup-fixtures.ts",
|
|
72
|
+
"test:unit": "vitest --run --coverage --dir test/unit",
|
|
69
73
|
"lint": "biome check .",
|
|
70
74
|
"lint:fix": "biome check --write .",
|
|
71
75
|
"format": "biome format --write .",
|