package-versioner 0.6.4 → 0.7.1

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.
@@ -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,
@@ -50,6 +56,11 @@
50
56
  "default": [],
51
57
  "description": "List of packages to include in versioning"
52
58
  },
59
+ "mainPackage": {
60
+ "type": "string",
61
+ "minLength": 1,
62
+ "description": "The package to use for version determination"
63
+ },
53
64
  "versionStrategy": {
54
65
  "type": "string",
55
66
  "enum": ["branchPattern", "commitMessage"],
@@ -95,6 +106,31 @@
95
106
  "type": "boolean",
96
107
  "default": false,
97
108
  "description": "Whether to skip Git hooks"
109
+ },
110
+ "updateChangelog": {
111
+ "type": "boolean",
112
+ "default": true,
113
+ "description": "Whether to automatically generate and update changelogs"
114
+ },
115
+ "cargo": {
116
+ "type": "object",
117
+ "properties": {
118
+ "enabled": {
119
+ "type": "boolean",
120
+ "default": true,
121
+ "description": "Whether to enable Cargo.toml version handling"
122
+ },
123
+ "paths": {
124
+ "type": "array",
125
+ "items": {
126
+ "type": "string",
127
+ "minLength": 1
128
+ },
129
+ "description": "Specify directories to search for Cargo.toml files"
130
+ }
131
+ },
132
+ "additionalProperties": false,
133
+ "description": "Configuration options for Rust/Cargo support"
98
134
  }
99
135
  },
100
136
  "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.6.4",
4
+ "version": "0.7.1",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -39,33 +39,37 @@
39
39
  "devDependencies": {
40
40
  "@biomejs/biome": "^1.9.4",
41
41
  "@types/figlet": "^1.5.5",
42
- "@types/node": "^22.15.3",
42
+ "@types/node": "^24.0.3",
43
43
  "@types/semver": "^7.3.13",
44
- "@vitest/coverage-v8": "^3.1.2",
44
+ "@vitest/coverage-v8": "^3.2.3",
45
45
  "husky": "^9.1.7",
46
- "lint-staged": "^15.5.1",
47
- "tsup": "^8.4.0",
46
+ "lint-staged": "^16.1.2",
47
+ "tsup": "^8.5.0",
48
+ "tsx": "^4.20.3",
48
49
  "typescript": "^5.8.3",
49
- "vitest": "^3.1.2"
50
+ "vitest": "^3.2.3"
50
51
  },
51
52
  "dependencies": {
52
53
  "@manypkg/get-packages": "^3.0.0",
53
54
  "chalk": "^5.4.1",
54
- "commander": "^13.1.0",
55
+ "commander": "^14.0.0",
55
56
  "conventional-changelog-angular": "^8.0.0",
56
57
  "conventional-commits-filter": "^5.0.0",
57
- "conventional-recommended-bump": "^11.0.0",
58
+ "conventional-recommended-bump": "^11.2.0",
58
59
  "figlet": "^1.8.1",
59
60
  "git-semver-tags": "^8.0.0",
60
- "semver": "^7.7.1",
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": "vitest run --coverage",
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 .",