conventional-changelog-writer
Advanced tools
Comparing version 7.0.1 to 8.0.0
{ | ||
"name": "conventional-changelog-writer", | ||
"version": "7.0.1", | ||
"description": "Write logs based on conventional commits and templates", | ||
"bugs": { | ||
"url": "https://github.com/conventional-changelog/conventional-changelog/issues" | ||
}, | ||
"homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer#readme", | ||
"type": "module", | ||
"version": "8.0.0", | ||
"description": "Write logs based on conventional commits and templates.", | ||
"author": { | ||
@@ -14,16 +11,12 @@ "name": "Steve Mao", | ||
}, | ||
"license": "MIT", | ||
"homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/conventional-changelog/conventional-changelog.git" | ||
"url": "https://github.com/conventional-changelog/conventional-changelog.git", | ||
"directory": "packages/conventional-changelog-writer" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=16" | ||
"bugs": { | ||
"url": "https://github.com/conventional-changelog/conventional-changelog/issues" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"cli.mjs", | ||
"lib", | ||
"templates" | ||
], | ||
"keywords": [ | ||
@@ -39,17 +32,23 @@ "conventional-changelog-writer", | ||
], | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"exports": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js" | ||
}, | ||
"files": [ | ||
"dist", | ||
"templates/*.hbs" | ||
], | ||
"dependencies": { | ||
"@types/semver": "^7.5.5", | ||
"handlebars": "^4.7.7", | ||
"json-stringify-safe": "^5.0.1", | ||
"meow": "^12.0.1", | ||
"meow": "^13.0.0", | ||
"semver": "^7.5.2", | ||
"split2": "^4.0.0", | ||
"conventional-commits-filter": "^4.0.0" | ||
"conventional-commits-filter": "^5.0.0" | ||
}, | ||
"bin": { | ||
"conventional-changelog-writer": "cli.mjs" | ||
}, | ||
"devDependencies": { | ||
"dedent": "^1.0.0", | ||
"forceable-tty": "^0.1.0" | ||
"conventional-changelog-writer": "./dist/cli/index.js" | ||
} | ||
} |
196
README.md
@@ -1,9 +0,56 @@ | ||
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverage-image]][coverage-url] | ||
# conventional-changelog-writer | ||
> Write logs based on conventional commits and templates | ||
[![ESM-only package][package]][package-url] | ||
[![NPM version][npm]][npm-url] | ||
[![Node version][node]][node-url] | ||
[![Dependencies status][deps]][deps-url] | ||
[![Install size][size]][size-url] | ||
[![Build status][build]][build-url] | ||
[![Coverage status][coverage]][coverage-url] | ||
[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg | ||
[package-url]: https://nodejs.org/api/esm.html | ||
[npm]: https://img.shields.io/npm/v/conventional-changelog-writer.svg | ||
[npm-url]: https://npmjs.com/package/conventional-changelog-writer | ||
[node]: https://img.shields.io/node/v/conventional-changelog-writer.svg | ||
[node-url]: https://nodejs.org | ||
[deps]: https://img.shields.io/librariesio/release/npm/conventional-changelog-writer | ||
[deps-url]: https://libraries.io/npm/conventional-changelog-writer/tree | ||
[size]: https://packagephobia.com/badge?p=conventional-changelog-writer | ||
[size-url]: https://packagephobia.com/result?p=conventional-changelog-writer | ||
[build]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/tests.yaml?branch=master | ||
[build-url]: https://github.com/conventional-changelog/conventional-changelog/actions | ||
[coverage]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master | ||
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master | ||
Write logs based on conventional commits and templates. | ||
<hr /> | ||
<a href="#install">Install</a> | ||
<span> • </span> | ||
<a href="#usage">Usage</a> | ||
<span> • </span> | ||
<a href="#api">API</a> | ||
<span> • </span> | ||
<a href="#customization-guide">Customization</a> | ||
<span> • </span> | ||
<a href="#cli">CLI</a> | ||
<br /> | ||
<hr /> | ||
## Install | ||
```sh | ||
$ npm install --save conventional-changelog-writer | ||
```bash | ||
# pnpm | ||
pnpm add conventional-changelog-writer | ||
# yarn | ||
yarn add conventional-changelog-writer | ||
# npm | ||
npm i conventional-changelog-writer | ||
``` | ||
@@ -14,11 +61,31 @@ | ||
```js | ||
var conventionalChangelogWriter = require('conventional-changelog-writer'); | ||
import { | ||
writeChangelogString, | ||
writeChangelog, | ||
writeChangelogStream | ||
} from 'conventional-changelog-writer' | ||
import { pipeline } from 'stream/promises' | ||
conventionalChangelogWriter(context, options); | ||
// to write changelog from commits to string: | ||
console.log(await writeChangelogString(commits, context, options)) | ||
// to write changelog from commits to async iterable: | ||
await pipeline( | ||
commits, | ||
writeChangelog(context, options), | ||
async function* (changelog) { | ||
for await (const chunk of changelog) { | ||
console.log(chunk) | ||
} | ||
} | ||
) | ||
// to write changelog from commits to stream: | ||
commitsStream | ||
.pipe(writeChangelogStream(context, options)) | ||
.pipe(process.stdout) | ||
``` | ||
It returns a transform stream. | ||
Commits it an async iterable of commit objects that looks like this: | ||
It expects an object mode upstream that looks something like this: | ||
```js | ||
@@ -45,5 +112,5 @@ { hash: '9b1aff905b638aa274a5fc8f88662df446d374bd', | ||
Each chunk should be a commit. Json object is also **valid**. Parts of the objects will be formatted and combined into a log based on the handlebars context, templates and options. | ||
Parts of the commits will be formatted and combined into a log based on the handlebars context, templates and options. | ||
The downstream might look something like this: | ||
The output log might look something like this: | ||
@@ -65,14 +132,20 @@ ```js | ||
## API | ||
### conventionalChangelogWriter([context, [options]]) | ||
### writeChangelog(context?: Context, options?: Options, includeDetails?: boolean) | ||
Returns a transform stream. | ||
Creates an async generator function to generate changelog entries from commits. | ||
### conventionalChangelogWriter.parseArray(commits, [context, [options]]) | ||
If `includeDetails` is `true`, instead of emitting strings of changelog, it emits objects containing the details the block. | ||
Rather than returning a transform stream for parsing commits, | ||
parses the array of commits provided generating a CHANGELOG entry. | ||
### writeChangelogStream(context?: Context, options?: Options, includeDetails?: boolean): Transform | ||
Creates a transform stream which takes commits and outputs changelog entries. | ||
If `includeDetails` is `true`, instead of emitting strings of changelog, it emits objects containing the details the block. | ||
### writeChangelogString(commits: Iterable<Commit> | AsyncIterable<Commit>, context?: Context, options?: Options): Promise<string> | ||
Create a changelog from commits. | ||
#### context | ||
@@ -121,3 +194,3 @@ | ||
The whole repository url. Eg: `'https://github.com/conventional-changelog/conventional-changelog-writer'`. | ||
The should be used as a fallback when `context.repository` doesn't exist. | ||
Should be used as a fallback when `context.repository` doesn't exist. | ||
@@ -144,3 +217,3 @@ ##### linkReferences | ||
Type: `string` Default: formatted (`'yyyy-mm-dd'`) today's date in UTC timezone | ||
Type: `string` Default: formatted (`'yyyy-mm-dd'`) today's date in timezone set by [`timeZone`](#timeZone) option. | ||
@@ -151,16 +224,10 @@ If `version` is found in the last commit, `committerDate` will overwrite this. | ||
Type: `object` | ||
Writer options. | ||
##### transform | ||
Type: `object` or `function` Default: get the first 7 digits of hash, and `committerDate` will be formatted as `'yyyy-mm-dd'`. | ||
Type: `function` Default: `defaultCommitTransform` exported function. | ||
Replace with new values in each commit. | ||
A function to transform commits. Should return diff object which will be merged with the original commit. | ||
If this is an object, the keys are paths to a nested object property. the values can be a string (static) and a function (dynamic) with the old value and path passed as arguments. This value is merged with your own transform object. | ||
If this is a function, the commit chunk will be passed as the argument and the returned value would be the new commit object. This is a handy function if you can't provide a transform stream as an upstream of this one. If returns a falsy value this commit is ignored. | ||
a `raw` object that is originally poured form upstream is attached to `commit`. | ||
##### groupBy | ||
@@ -198,30 +265,14 @@ | ||
Type: `function`, `string` or `any` Default: if `commit.version` is a valid semver. | ||
Type: `function`, `string` or `null` Default: if `commit.version` is a valid semver. | ||
When the upstream finishes pouring the commits it will generate a block of logs if `doFlush` is `true`. However, you can generate more than one block based on this criteria (usually a version) even if there are still commits from the upstream. | ||
###### generateOn(commit, commits, context, options) | ||
If this value is a `string`, it checks the existence of the field. Set to `null` to disable it. | ||
####### commit | ||
###### generateOn(keyCommit: Commit, commitsGroup: Commit[], context: FinalContext, options: FinalOptions): boolean | ||
Current commit. | ||
####### commits | ||
Current collected commits. | ||
####### context | ||
The generated context based on original input `context` and `options`. | ||
####### options | ||
Normalized options. | ||
**NOTE**: It checks on the transformed commit chunk instead of the original one (you can check on the original by access the `raw` object on the `commit`). However, if the transformed commit is ignored it falls back to the original commit. | ||
If this value is a `string`, it checks the existence of the field. Set to other type to disable it. | ||
##### finalizeContext(context: FinalContext, options: FinalOptions, filteredCommits: Commit[], keyCommit: Commit | null, commits: Commit[]): FinalContext | Promise<FinalContext> | ||
##### finalizeContext | ||
Type: `function` Default: pass through | ||
@@ -231,23 +282,5 @@ | ||
###### finalizeContext(context, options, commits, keyCommit) | ||
####### context | ||
The generated context based on original input `context` and `options`. | ||
####### options | ||
Normalized options. | ||
####### commits | ||
Filtered commits from your git metadata. | ||
####### keyCommit | ||
The commit that triggers to generate the log. | ||
##### debug | ||
Type: `function` Default: `function() {}` | ||
Type: `function` Default: `() => {}` | ||
@@ -262,11 +295,2 @@ A function to get debug information. | ||
##### includeDetails | ||
Type: `boolean` Default: `false` | ||
If this value is `true`, instead of emitting strings of changelog, it emits objects containing the details the block. | ||
*NOTE:* The downstream must be in object mode if this is `true`. | ||
*NOTE:* This is only supported when using streaming mode. | ||
##### ignoreReverted | ||
@@ -284,4 +308,2 @@ | ||
*NOTE:* This is only supported when using streaming mode. | ||
##### mainTemplate | ||
@@ -311,3 +333,8 @@ | ||
##### timeZone | ||
Type: `string` Default: `'UTC'` | ||
The timezone to use. The date in the changelog is generated based on timezone. | ||
## Customization Guide | ||
@@ -327,7 +354,5 @@ | ||
## CLI | ||
```sh | ||
$ npm install --global conventional-changelog-writer | ||
$ conventional-changelog-writer --help # for more details | ||
@@ -368,15 +393,4 @@ ``` | ||
## License | ||
MIT © [Steve Mao](https://github.com/stevemao) | ||
[npm-image]: https://badge.fury.io/js/conventional-changelog-writer.svg | ||
[npm-url]: https://npmjs.org/package/conventional-changelog-writer | ||
[travis-image]: https://travis-ci.org/conventional-changelog/conventional-changelog-writer.svg?branch=master | ||
[travis-url]: https://travis-ci.org/conventional-changelog/conventional-changelog-writer | ||
[daviddm-image]: https://david-dm.org/conventional-changelog/conventional-changelog-writer.svg?theme=shields.io | ||
[daviddm-url]: https://david-dm.org/conventional-changelog/conventional-changelog-writer | ||
[coverage-image]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master | ||
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
89221
5
0
49
971
384
2
Yes
1
+ Added@types/semver@^7.5.5
+ Added@types/semver@7.5.8(transitive)
+ Addedconventional-commits-filter@5.0.0(transitive)
+ Addedmeow@13.2.0(transitive)
- Removedjson-stringify-safe@^5.0.1
- Removedsplit2@^4.0.0
- Removedconventional-commits-filter@4.0.0(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedmeow@12.1.1(transitive)
- Removedsplit2@4.2.0(transitive)
Updatedmeow@^13.0.0