conventional-changelog 5.1.0 → 7.0.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.
Files changed (3) hide show
  1. package/README.md +236 -35
  2. package/package.json +42 -30
  3. package/index.js +0 -26
package/README.md CHANGED
@@ -1,66 +1,267 @@
1
- # [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverage-image]][coverage-url]
1
+ # conventional-changelog
2
2
 
3
- > Generate a changelog from git metadata
3
+ [![ESM-only package][package]][package-url]
4
+ [![NPM version][npm]][npm-url]
5
+ [![Node version][node]][node-url]
6
+ [![Dependencies status][deps]][deps-url]
7
+ [![Install size][size]][size-url]
8
+ [![Build status][build]][build-url]
9
+ [![Coverage status][coverage]][coverage-url]
4
10
 
11
+ [package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
12
+ [package-url]: https://nodejs.org/api/esm.html
13
+
14
+ [npm]: https://img.shields.io/npm/v/conventional-changelog.svg
15
+ [npm-url]: https://npmjs.com/package/conventional-changelog
16
+
17
+ [node]: https://img.shields.io/node/v/conventional-changelog.svg
18
+ [node-url]: https://nodejs.org
19
+
20
+ [deps]: https://img.shields.io/librariesio/release/npm/conventional-changelog
21
+ [deps-url]: https://libraries.io/npm/conventional-changelog/tree
22
+
23
+ [size]: https://packagephobia.com/badge?p=conventional-changelog
24
+ [size-url]: https://packagephobia.com/result?p=conventional-changelog
25
+
26
+ [build]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/tests.yaml?branch=master
27
+ [build-url]: https://github.com/conventional-changelog/conventional-changelog/actions
28
+
29
+ [coverage]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
30
+ [coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
31
+
32
+ Generate a changelog from git metadata.
33
+
34
+ *[Changelog?](https://speakerdeck.com/stevemao/compose-a-changelog)*
35
+
36
+ > [!NOTE]
37
+ > You don't have to use the angular commit convention. For the best result of the tool to tokenize your commit and produce flexible output, it's recommended to use a commit convention.
38
+
39
+ <hr />
40
+ <a href="#install">Install</a>
41
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
42
+ <a href="#usage">Usage</a>
43
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
44
+ <a href="#recommended-workflow">Recommended workflow</a>
45
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
46
+ <a href="#why">Why</a>
47
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
48
+ <a href="#presets">Presets</a>
49
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
50
+ <a href="#js-api">JS API</a>
51
+ <br />
52
+ <hr />
53
+
54
+ ## Install
55
+
56
+ ```bash
57
+ # pnpm
58
+ pnpm add conventional-changelog
59
+ # yarn
60
+ yarn add conventional-changelog
61
+ # npm
62
+ npm i conventional-changelog
63
+ ```
5
64
 
6
65
  ## Usage
7
66
 
8
- You most likely only need to use this module if you're building a library that provides an abstraction on top of conventional commits, See [Getting started](https://github.com/conventional-changelog/conventional-changelog#getting-started) if you're an end-user.
67
+ ```sh
68
+ conventional-changelog -p angular
69
+ ```
70
+
71
+ This will *not* overwrite any previous changelogs. The above generates a changelog based on commits since the last semver tag that matches the pattern of "Feature", "Fix", "Performance Improvement" or "Breaking Changes".
72
+
73
+ If this is your first time using this tool and you want to generate all previous changelogs, you could do
9
74
 
10
75
  ```sh
11
- $ npm install --save conventional-changelog
76
+ conventional-changelog -p angular -r 0
12
77
  ```
13
78
 
14
- ```js
15
- var conventionalChangelog = require('conventional-changelog');
79
+ This *will* overwrite any previous changelogs if they exist.
80
+
81
+ All available command line parameters can be listed using CLI: `conventional-changelog --help`.
82
+
83
+ > [!TIP]
84
+ > You can alias your command or add it to your package.json. EG: `"changelog": "conventional-changelog -p angular -r 0"`.
85
+
86
+ ## Recommended workflow
87
+
88
+ 1. Make changes
89
+ 2. Commit those changes
90
+ 3. Make sure Travis turns green
91
+ 4. Bump version in `package.json`
92
+ 5. `conventional-changelog`
93
+ 6. Commit `package.json` and `CHANGELOG.md` files
94
+ 7. Tag
95
+ 8. Push
16
96
 
17
- conventionalChangelog({
18
- preset: 'angular'
19
- })
20
- .pipe(process.stdout); // or any writable stream
97
+ The reason why you should commit and tag after `conventional-changelog` is that the CHANGELOG should be included in the new release, hence `commits.from` defaults to the latest semver tag.
98
+
99
+ ### With `npm version`
100
+
101
+ Using the npm scripts to our advantage with the following hooks:
102
+
103
+ ```json
104
+ {
105
+ "scripts": {
106
+ "version": "conventional-changelog -p angular && git add CHANGELOG.md"
107
+ }
108
+ }
21
109
  ```
22
110
 
23
- Or if you want to use your own custom preset:
111
+ You could follow the following workflow
112
+
113
+ 1. Make changes
114
+ 2. Commit those changes
115
+ 3. Pull all the tags
116
+ 4. Run the [`npm version [patch|minor|major]`](https://docs.npmjs.com/cli/version) command
117
+ 5. Push
118
+
119
+ You could optionally add a `preversion` script to package your project or running a full suit of test.
120
+ And a `postversion` script to clean your system and push your release and tags.
121
+
122
+ By adding a `.npmrc` you could also automate your commit message and set your tag prefix as such:
123
+
124
+ ```
125
+ tag-version-prefix=""
126
+ message="chore(release): %s :tada:"
127
+ ```
128
+
129
+ ## Why
130
+
131
+ - Easy fully automate changelog generation. You could still add more points on top of it.
132
+ - Ignoring reverted commits, templating with [handlebars.js](https://github.com/handlebars-lang/handlebars.js) and links to references, etc.
133
+ - Intelligently setup defaults but yet fully configurable with presets of [popular projects](#presets).
134
+ - Everything internally or externally is pluggable.
135
+ - A lot of tests and actively maintained.
136
+
137
+ ## Presets
138
+
139
+ - [angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular)
140
+ - [atom](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-atom)
141
+ - [codemirror](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-codemirror)
142
+ - [conventionalcommits](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits)
143
+ - [ember](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-ember)
144
+ - [eslint](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint)
145
+ - [express](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-express)
146
+ - [jquery](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-jquery)
147
+ - [jshint](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-jshint)
148
+
149
+ ## JS API
24
150
 
25
151
  ```js
26
- var conventionalChangelog = require('conventional-changelog');
152
+ import { ConventionalChangelog } from 'conventional-changelog'
153
+
154
+ const generator = new ConventionalChangelog()
155
+ .readPackage()
156
+ .loadPreset('angular')
157
+
158
+ generator
159
+ .writeStream()
160
+ .pipe(process.stdout)
161
+
162
+ // or
27
163
 
28
- var config = require('@org/conventional-changelog-custom-preset');
29
- conventionalChangelog({config})
30
- .pipe(process.stdout); // or any writable stream
164
+ for await (const chunk of generator.write()) {
165
+ console.log(chunk)
166
+ }
31
167
  ```
32
168
 
33
- ## API
169
+ ### `new ConventionalChangelog(cwdOrGitClient: string | ConventionalGitClient = process.cwd())`
170
+
171
+ Create a new instance of conventional-changelog generator. `cwdOrGitClient` is the current working directory or a `ConventionalGitClient` instance.
172
+
173
+ #### `generator.loadPreset(preset: PresetParams): this`
174
+
175
+ Load and set necessary params from a preset.
176
+
177
+ #### `generator.config(config: Preset | Promise<Preset>): this`
178
+
179
+ Set the config directly.
180
+
181
+ #### `generator.readPackage(transform?: PackageTransform): this`
182
+
183
+ Find `package.json` up the directory tree and read it. Optionally transform the package data.
184
+
185
+ #### `generator.readPackage(path: string, transform?: PackageTransform): this`
186
+
187
+ Read a `package.json` file from a specific path. Optionally transform the package data.
188
+
189
+ #### `generator.package(pkg: Record<string, unknown>): this`
190
+
191
+ Set the package data directly.
192
+
193
+ #### `generator.readRepository(): this`
34
194
 
35
- ### conventionalChangelog([options, [context, [gitRawCommitsOpts, [parserOpts, [writerOpts]]]]])
195
+ Read and parse the repository URL from current git repository.
36
196
 
37
- Returns a readable stream.
197
+ #### `generator.repository(infoOrGitUrl: string | Partial<HostedGitInfo>): this`
38
198
 
39
- #### options
199
+ Set the repository info directly.
40
200
 
41
- See the [conventional-changelog-core](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-core) docs. The API is the same with the following changes or additions:
201
+ #### `generator.options(options: Options): this`
42
202
 
43
- ##### preset
203
+ Set conventional-changelog options.
44
204
 
45
- Type: `string` Possible values: `'angular', 'atom', 'codemirror', 'conventionalcommits', 'ember', 'eslint', 'express', 'jquery', 'jshint'`
205
+ | Name | Type | Default | Description |
206
+ | --- | --- | --- | --- |
207
+ | reset | `boolean` | `false` | Whether to reset the changelog or not. |
208
+ | append | `boolean` | `false` | Should the log be appended to existing data. |
209
+ | releaseCount | `number` | 1 | How many releases of changelog you want to generate. It counts from the upcoming release. Useful when you forgot to generate any previous changelog. Set to `0` to regenerate all. |
210
+ | outputUnreleased | `boolean` | `true` if a different version than last release is given. Otherwise `false` | If this value is `true` and `context.version` equals last release then `context.version` will be changed to `'Unreleased'`. |
211
+ | transformCommit | `(commit: Commit, params: Params) => Partial<Commit> \| Promise<Partial<Commit> \| null> \| null` | | A transform function that applies after the parser and before the writer. |
212
+ | warn | `function` | | Logger for warnings |
213
+ | debug | `function` | | Logger for debug messages |
214
+ | fromatDate | `(date: Date) => string` | | Custom date formatter function. |
46
215
 
47
- It's recommended to use a preset so you don't have to define everything yourself. Presets are names of built-in `config`.
216
+ #### `generator.context(context: Context): this`
48
217
 
49
- A scoped preset package such as `@scope/conventional-changelog-custom-preset` can be used by passing `@scope/custom-preset` to this option.
218
+ Set the [writer context](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer#context).
50
219
 
51
- **NOTE:** `options.config` will be overwritten by the values of preset. You should use either `preset` or `config`, but not both.
220
+ #### `generator.tags(params: GetSemverTagsParams): this`
52
221
 
53
- ## [Notes for parent modules](https://github.com/conventional-changelog/conventional-changelog-core#notes-for-parent-modules)
222
+ Set params to get semver tags.
223
+
224
+ | Name | Type | Default | Description |
225
+ | --- | --- | --- | --- |
226
+ | prefix | `string \| RegExp` | | Specify a prefix for the git tag that will be taken into account during the comparison. |
227
+ | skipUnstable | `boolean` | `false` | If set, unstable release tags will be skipped, e.g. x.x.x-rc. |
228
+ | clean | `boolean` | `false` | Clean version from prefix and trash. |
229
+
230
+ If you want to take package-prefixed tags, for example lerna-style tags, you should use `packagePrefix` utility function:
231
+
232
+ ```js
233
+ import {
234
+ ConventionalChangelog,
235
+ packagePrefix
236
+ } from 'conventional-changelog'
237
+
238
+ const generator = new ConventionalChangelog()
239
+ .readPackage()
240
+ .loadPreset('angular')
241
+ .tags({
242
+ prefix: packagePrefix('foo-package')
243
+ })
244
+ ```
245
+
246
+ #### `generator.commits(params: GetCommitsParams, parserOptions?: ParserStreamOptions): this`
247
+
248
+ Set params to get commits.
249
+
250
+ - [GetCommitsParams](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/git-client/src/types.ts#L1-L41)
251
+ - [ParserStreamOptions](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-commits-parser/src/types.ts#L1-L68)
252
+
253
+ #### `generator.writer(params: WriterOptions): this`
254
+
255
+ Set [writer options](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer#options).
256
+
257
+ #### `generator.write(includeDetails?: boolean): AsyncGenerator<string | Details<Commit>, void>`
258
+
259
+ Generate changelog.
260
+
261
+ #### `generator.writeStream(includeDetails?: boolean): Readable`
262
+
263
+ Generate changelog stream.
54
264
 
55
265
  ## License
56
266
 
57
267
  MIT
58
-
59
- [npm-image]: https://badge.fury.io/js/conventional-changelog.svg
60
- [npm-url]: https://npmjs.org/package/conventional-changelog
61
- [travis-image]: https://travis-ci.org/conventional-changelog/conventional-changelog.svg?branch=master
62
- [travis-url]: https://travis-ci.org/conventional-changelog/conventional-changelog
63
- [daviddm-image]: https://david-dm.org/conventional-changelog/conventional-changelog.svg?theme=shields.io
64
- [daviddm-url]: https://david-dm.org/conventional-changelog/conventional-changelog
65
- [coverage-image]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
66
- [coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
package/package.json CHANGED
@@ -1,24 +1,13 @@
1
1
  {
2
2
  "name": "conventional-changelog",
3
- "version": "5.1.0",
4
- "description": "Generate a changelog from git metadata",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/conventional-changelog/conventional-changelog.git"
3
+ "type": "module",
4
+ "version": "7.0.0",
5
+ "description": "Generate a changelog from git metadata.",
6
+ "author": {
7
+ "name": "Steve Mao",
8
+ "email": "maochenyan@gmail.com",
9
+ "url": "https://github.com/stevemao"
8
10
  },
9
- "keywords": [
10
- "conventional-changelog",
11
- "conventional",
12
- "changelog",
13
- "log"
14
- ],
15
- "engines": {
16
- "node": ">=16"
17
- },
18
- "license": "MIT",
19
- "files": [
20
- "index.js"
21
- ],
22
11
  "contributors": [
23
12
  {
24
13
  "name": "Brian Ford"
@@ -30,21 +19,44 @@
30
19
  "name": "Andrew Joslin"
31
20
  }
32
21
  ],
22
+ "license": "MIT",
23
+ "homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog#readme",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/conventional-changelog/conventional-changelog.git",
27
+ "directory": "packages/conventional-changelog"
28
+ },
33
29
  "bugs": {
34
30
  "url": "https://github.com/conventional-changelog/conventional-changelog/issues"
35
31
  },
36
- "homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog#readme",
32
+ "keywords": [
33
+ "conventional-changelog",
34
+ "conventional",
35
+ "changelog",
36
+ "log",
37
+ "cli"
38
+ ],
39
+ "engines": {
40
+ "node": ">=18"
41
+ },
42
+ "exports": {
43
+ "types": "./dist/index.d.ts",
44
+ "import": "./dist/index.js"
45
+ },
46
+ "files": [
47
+ "dist"
48
+ ],
37
49
  "dependencies": {
38
- "conventional-changelog-angular": "^7.0.0",
39
- "conventional-changelog-atom": "^4.0.0",
40
- "conventional-changelog-codemirror": "^4.0.0",
41
- "conventional-changelog-conventionalcommits": "^7.0.2",
42
- "conventional-changelog-core": "^7.0.0",
43
- "conventional-changelog-ember": "^4.0.0",
44
- "conventional-changelog-eslint": "^5.0.0",
45
- "conventional-changelog-express": "^4.0.0",
46
- "conventional-changelog-jquery": "^5.0.0",
47
- "conventional-changelog-jshint": "^4.0.0",
48
- "conventional-changelog-preset-loader": "^4.1.0"
50
+ "@types/normalize-package-data": "^2.4.4",
51
+ "fd-package-json": "^1.2.0",
52
+ "meow": "^13.0.0",
53
+ "normalize-package-data": "^7.0.0",
54
+ "@conventional-changelog/git-client": "^2.1.0",
55
+ "conventional-changelog-writer": "^8.1.0",
56
+ "conventional-commits-parser": "^6.1.0",
57
+ "conventional-changelog-preset-loader": "^5.0.0"
58
+ },
59
+ "bin": {
60
+ "conventional-changelog": "./dist/cli/index.js"
49
61
  }
50
62
  }
package/index.js DELETED
@@ -1,26 +0,0 @@
1
- 'use strict'
2
-
3
- const conventionalChangelogCore = require('conventional-changelog-core')
4
- const { loadPreset } = require('conventional-changelog-preset-loader')
5
-
6
- function conventionalChangelog (options, context, gitRawCommitsOpts, parserOpts, writerOpts) {
7
- options.warn = options.warn || function () {}
8
-
9
- if (options.preset) {
10
- try {
11
- options.config = loadPreset(options.preset)
12
- } catch (err) {
13
- if (typeof options.preset === 'object') {
14
- options.warn(`Preset: "${options.preset.name}" ${err.message}`)
15
- } else if (typeof options.preset === 'string') {
16
- options.warn(`Preset: "${options.preset}" ${err.message}`)
17
- } else {
18
- options.warn(`Preset: ${err.message}`)
19
- }
20
- }
21
- }
22
-
23
- return conventionalChangelogCore(options, context, gitRawCommitsOpts, parserOpts, writerOpts)
24
- }
25
-
26
- module.exports = conventionalChangelog