standard-changelog 6.0.0 → 7.0.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.
package/README.md CHANGED
@@ -1,15 +1,60 @@
1
- # Standard CHANGELOG
1
+ # standard-changelog
2
2
 
3
- [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverage-image]][coverage-url]
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
 
5
- > An opinionated approach to CHANGELOG generation using angular commit conventions.
11
+ [package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
12
+ [package-url]: https://nodejs.org/api/esm.html
6
13
 
7
- ## Quick Start
14
+ [npm]: https://img.shields.io/npm/v/standard-changelog.svg
15
+ [npm-url]: https://npmjs.com/package/standard-changelog
16
+
17
+ [node]: https://img.shields.io/node/v/standard-changelog.svg
18
+ [node-url]: https://nodejs.org
19
+
20
+ [deps]: https://img.shields.io/librariesio/release/npm/standard-changelog
21
+ [deps-url]: https://libraries.io/npm/standard-changelog/tree
22
+
23
+ [size]: https://packagephobia.com/badge?p=standard-changelog
24
+ [size-url]: https://packagephobia.com/result?p=standard-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
+ An opinionated approach to CHANGELOG generation using angular commit conventions.
33
+
34
+ <hr />
35
+ <a href="#install">Install</a>
36
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
37
+ <a href="#usage">Usage</a>
38
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
39
+ <a href="#js-api">JS API</a>
40
+ <br />
41
+ <hr />
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ # pnpm
47
+ pnpm add standard-changelog
48
+ # yarn
49
+ yarn add standard-changelog
50
+ # npm
51
+ npm i standard-changelog
52
+ ```
53
+
54
+ ## Usage
8
55
 
9
56
  ```sh
10
- $ npm install -g standard-changelog
11
- $ cd my-project
12
- $ standard-changelog
57
+ standard-changelog
13
58
  ```
14
59
 
15
60
  The above generates a changelog based on commits since the last semver tag that match the pattern of a "Feature", "Fix", "Performance Improvement" or "Breaking Changes".
@@ -19,46 +64,36 @@ The above generates a changelog based on commits since the last semver tag that
19
64
  If you're using this tool for the first time and want to generate new content in CHANGELOG.md, you can run:
20
65
 
21
66
  ```sh
22
- $ standard-changelog --first-release
67
+ standard-changelog --first-release
23
68
  ```
24
69
 
25
70
  **advanced topics:**
26
71
 
27
- All available command line parameters can be listed using [CLI](#cli) : `standard-changelog --help`.
72
+ All available command line parameters can be listed using CLI: `standard-changelog --help`.
28
73
 
29
- ## Programmatic Usage
30
-
31
- ```sh
32
- $ npm install --save standard-changelog
33
- ```
74
+ ## JS API
34
75
 
35
76
  ```js
36
- import standardChangelog from 'standard-changelog';
77
+ import { StandardChangelog } from 'standard-changelog'
37
78
 
38
- standardChangelog()
39
- .pipe(process.stdout); // or any writable stream
40
- ```
79
+ const generator = new StandardChangelog()
80
+ .readPackage()
41
81
 
42
- ## CLI
82
+ generator
83
+ .writeStream()
84
+ .pipe(process.stdout)
43
85
 
44
- ```sh
45
- $ npm install -g standard-changelog
46
- $ standard-changelog --help
86
+ // or
87
+
88
+ for await (const chunk of generator.write()) {
89
+ console.log(chunk)
90
+ }
47
91
  ```
48
92
 
49
- ## API
93
+ StandardChangelog is a class based on ConventionalChangelog and with preloaded angular preset.
50
94
 
51
- See the [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) docs with the angular preset.
95
+ See the [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog/README.md#js-api) JS API docs.
52
96
 
53
97
  ## License
54
98
 
55
99
  MIT
56
-
57
- [npm-image]: https://badge.fury.io/js/standard-changelog.svg
58
- [npm-url]: https://npmjs.org/package/standard-changelog
59
- [travis-image]: https://travis-ci.org/conventional-changelog/standard-changelog.svg?branch=master
60
- [travis-url]: https://travis-ci.org/conventional-changelog/standard-changelog
61
- [daviddm-image]: https://david-dm.org/conventional-changelog/standard-changelog.svg?theme=shields.io
62
- [daviddm-url]: https://david-dm.org/conventional-changelog/standard-changelog
63
- [coverage-image]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
64
- [coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ import meow from 'meow';
3
+ import { flags, runProgram } from 'conventional-changelog';
4
+ import { StandardChangelog } from './index.js';
5
+ const cli = meow(`
6
+ Usage
7
+ standard-changelog
8
+
9
+ Example
10
+ standard-changelog -i changelog -o CHANGELOG.md
11
+
12
+ Options
13
+ -i, --infile Read the CHANGELOG from this file (default: CHANGELOG.md)
14
+ -o, --outfile Write the CHANGELOG to this file (default: infile)
15
+ --stdout Output the result to stdout
16
+ -p, --preset Name of the preset you want to use (default: angular)
17
+ -k, --pkg A filepath of where your package.json is located (default: closest package.json)
18
+ -a, --append Should the newer release be appended to the older release (default: false)
19
+ -f, --first-release Generate the CHANGELOG for the first time
20
+ -r, --release-count How many releases to be generated from the latest (default: 1)
21
+ If 0, the whole changelog will be regenerated and the outfile will be overwritten
22
+ --skip-unstable If given, unstable tags will be skipped, e.g., x.x.x-alpha.1, x.x.x-rc.2
23
+ -u, --output-unreleased Output unreleased changelog
24
+ -v, --verbose Verbose output. Use this for debugging (default: false)
25
+ -n, --config A filepath of your config script
26
+ -c, --context A filepath of a json that is used to define template variables
27
+ -l, --lerna-package Generate a changelog for a specific lerna package (:pkg-name@1.0.0)
28
+ -t, --tag-prefix Tag prefix to consider when reading the tags
29
+ --commit-path Generate a changelog scoped to a specific directory
30
+ `, {
31
+ importMeta: import.meta,
32
+ booleanDefault: undefined,
33
+ flags
34
+ });
35
+ await runProgram(new StandardChangelog(process.cwd()), cli.flags);
36
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2NsaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsT0FBTyxJQUFJLE1BQU0sTUFBTSxDQUFBO0FBQ3ZCLE9BQU8sRUFDTCxLQUFLLEVBQ0wsVUFBVSxFQUNYLE1BQU0sd0JBQXdCLENBQUE7QUFDL0IsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sWUFBWSxDQUFBO0FBRTlDLE1BQU0sR0FBRyxHQUFHLElBQUksQ0FBQzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztDQXlCaEIsRUFBRTtJQUNELFVBQVUsRUFBRSxNQUFNLENBQUMsSUFBSTtJQUN2QixjQUFjLEVBQUUsU0FBUztJQUN6QixLQUFLO0NBQ04sQ0FBQyxDQUFBO0FBRUYsTUFBTSxVQUFVLENBQ2QsSUFBSSxpQkFBaUIsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLENBQUMsRUFDcEMsR0FBRyxDQUFDLEtBQUssQ0FDVixDQUFBIn0=
@@ -0,0 +1,7 @@
1
+ import type { ConventionalGitClient } from '@conventional-changelog/git-client';
2
+ import { ConventionalChangelog } from 'conventional-changelog';
3
+ export * from 'conventional-changelog';
4
+ export declare class StandardChangelog extends ConventionalChangelog {
5
+ constructor(cwdOrGitClient: string | ConventionalGitClient);
6
+ }
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAG9D,cAAc,wBAAwB,CAAA;AAEtC,qBAAa,iBAAkB,SAAQ,qBAAqB;gBAC9C,cAAc,EAAE,MAAM,GAAG,qBAAqB;CAK3D"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { ConventionalChangelog } from 'conventional-changelog';
2
+ import angular from 'conventional-changelog-angular';
3
+ export * from 'conventional-changelog';
4
+ export class StandardChangelog extends ConventionalChangelog {
5
+ constructor(cwdOrGitClient) {
6
+ super(cwdOrGitClient);
7
+ this.config(angular());
8
+ }
9
+ }
10
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sd0JBQXdCLENBQUE7QUFDOUQsT0FBTyxPQUFPLE1BQU0sZ0NBQWdDLENBQUE7QUFFcEQsY0FBYyx3QkFBd0IsQ0FBQTtBQUV0QyxNQUFNLE9BQU8saUJBQWtCLFNBQVEscUJBQXFCO0lBQzFELFlBQVksY0FBOEM7UUFDeEQsS0FBSyxDQUFDLGNBQWMsQ0FBQyxDQUFBO1FBRXJCLElBQUksQ0FBQyxNQUFNLENBQUMsT0FBTyxFQUFFLENBQUMsQ0FBQTtJQUN4QixDQUFDO0NBQ0YifQ==
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "standard-changelog",
3
3
  "type": "module",
4
- "version": "6.0.0",
4
+ "version": "7.0.1",
5
5
  "description": "Generate a changelog from git metadata with Angular commit convention.",
6
6
  "author": "Steve Mao",
7
7
  "license": "MIT",
@@ -24,17 +24,20 @@
24
24
  "engines": {
25
25
  "node": ">=18"
26
26
  },
27
- "bin": "cli.js",
28
- "exports": "./index.js",
27
+ "bin": {
28
+ "standard-changelog": "./dist/cli.js"
29
+ },
30
+ "exports": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ },
29
34
  "files": [
30
- "index.js",
31
- "figures.js",
32
- "cli.js"
35
+ "dist"
33
36
  ],
34
37
  "dependencies": {
35
38
  "meow": "^13.0.0",
36
- "picocolors": "^1.0.0",
39
+ "@conventional-changelog/git-client": "^2.2.0",
37
40
  "conventional-changelog-angular": "^8.0.0",
38
- "conventional-changelog-core": "^8.0.0"
41
+ "conventional-changelog": "^7.0.1"
39
42
  }
40
43
  }
package/cli.js DELETED
@@ -1,179 +0,0 @@
1
- #!/usr/bin/env node
2
- import { resolve, extname } from 'path'
3
- import { pathToFileURL } from 'url'
4
- import { createWriteStream } from 'fs'
5
- import {
6
- readFile,
7
- writeFile
8
- } from 'fs/promises'
9
- import pc from 'picocolors'
10
- import meow from 'meow'
11
- import standardChangelog, {
12
- createIfMissing,
13
- checkpoint
14
- } from './index.js'
15
-
16
- function relativeResolve (filePath) {
17
- return pathToFileURL(resolve(process.cwd(), filePath))
18
- }
19
-
20
- async function loadDataFile (filePath) {
21
- const resolvedFilePath = relativeResolve(filePath)
22
- const ext = extname(resolvedFilePath.toString())
23
-
24
- if (ext === '.json') {
25
- return JSON.parse(await readFile(resolvedFilePath, 'utf8'))
26
- }
27
-
28
- return (await import(resolvedFilePath)).default
29
- }
30
-
31
- function printError (err) {
32
- if (flags.verbose) {
33
- console.error(pc.gray(err.stack))
34
- } else {
35
- console.error(pc.red(err.toString()))
36
- }
37
-
38
- process.exit(1)
39
- }
40
-
41
- function waitStreamFinish (stream) {
42
- return new Promise((resolve) => {
43
- stream.on('finish', resolve)
44
- stream.on('error', printError)
45
- })
46
- }
47
-
48
- const cli = meow(`
49
- Usage
50
- standard-changelog
51
-
52
- Options
53
- -i, --infile Read the CHANGELOG from this file
54
- -f, --first-release Generate the CHANGELOG for the first time
55
- -o, --outfile Write the CHANGELOG to this file. If unspecified (default: CHANGELOG.md)
56
- -s, --same-file Overwrite the infile (default: true)
57
- -p, --preset Name of the preset you want to use (default: angular)
58
- -k, --pkg A filepath of where your package.json is located
59
- -a, --append Should the generated block be appended
60
- -r, --release-count How many releases to be generated from the latest
61
- -v, --verbose Verbose output
62
- -c, --context A filepath of a json that is used to define template variables
63
- -l, --lerna-package Generate a changelog for a specific lerna package (:pkg-name@1.0.0)
64
- --commit-path Generate a changelog scoped to a specific directory
65
- `, {
66
- importMeta: import.meta,
67
- booleanDefault: undefined,
68
- flags: {
69
- infile: {
70
- shortFlag: 'i',
71
- default: 'CHANGELOG.md',
72
- type: 'string'
73
- },
74
- help: {
75
- shortFlag: 'h'
76
- },
77
- outfile: {
78
- shortFlag: 'o',
79
- type: 'string'
80
- },
81
- sameFile: {
82
- shortFlag: 's',
83
- default: true,
84
- type: 'boolean'
85
- },
86
- preset: {
87
- shortFlag: 'p',
88
- type: 'string'
89
- },
90
- pkg: {
91
- shortFlag: 'k',
92
- type: 'string'
93
- },
94
- append: {
95
- shortFlag: 'a',
96
- type: 'boolean'
97
- },
98
- releaseCount: {
99
- shortFlag: 'r',
100
- type: 'number'
101
- },
102
- verbose: {
103
- shortFlag: 'v',
104
- type: 'boolean'
105
- },
106
- context: {
107
- shortFlag: 'c',
108
- type: 'string'
109
- },
110
- firstRelease: {
111
- shortFlag: 'f',
112
- type: 'boolean'
113
- },
114
- lernaPackage: {
115
- shortFlag: 'l',
116
- type: 'string'
117
- }
118
- }
119
- })
120
-
121
- const flags = cli.flags
122
- const infile = flags.infile
123
- const sameFile = flags.sameFile
124
- const outfile = sameFile ? (flags.outfile || infile) : flags.outfile
125
- const append = flags.append
126
- const releaseCount = flags.firstRelease ? 0 : flags.releaseCount
127
-
128
- const options = {
129
- preset: flags.preset,
130
- pkg: {
131
- path: flags.pkg
132
- },
133
- append,
134
- releaseCount,
135
- lernaPackage: flags.lernaPackage
136
- }
137
-
138
- if (flags.verbose) {
139
- options.warn = console.warn.bind(console)
140
- }
141
-
142
- let templateContext
143
-
144
- try {
145
- if (flags.context) {
146
- templateContext = await loadDataFile(flags.context)
147
- }
148
- } catch (err) {
149
- printError(err)
150
- }
151
-
152
- const changelogStream = standardChangelog(options, templateContext, flags.commitPath ? { path: flags.commitPath } : {})
153
-
154
- await createIfMissing(infile)
155
-
156
- if (options.append) {
157
- await waitStreamFinish(
158
- changelogStream
159
- .pipe(createWriteStream(outfile, {
160
- flags: 'a'
161
- }))
162
- )
163
-
164
- checkpoint('appended changes to %s', [outfile])
165
- } else {
166
- let changelog = ''
167
-
168
- for await (const chunk of changelogStream) {
169
- changelog += chunk.toString()
170
- }
171
-
172
- if (releaseCount !== 0) {
173
- changelog += await readFile(infile, 'utf8')
174
- }
175
-
176
- await writeFile(outfile, changelog)
177
-
178
- checkpoint('output changes to %s', [outfile])
179
- }
package/figures.js DELETED
@@ -1,17 +0,0 @@
1
- function isUnicodeSupported () {
2
- if (process.platform !== 'win32') {
3
- return process.env.TERM !== 'linux' // Linux console (kernel)
4
- }
5
-
6
- return Boolean(process.env.CI) ||
7
- Boolean(process.env.WT_SESSION) || // Windows Terminal
8
- Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
9
- process.env.ConEmuTask === '{cmd::Cmder}' || // ConEmu and cmder
10
- process.env.TERM_PROGRAM === 'Terminus-Sublime' ||
11
- process.env.TERM_PROGRAM === 'vscode' ||
12
- process.env.TERM === 'xterm-256color' ||
13
- process.env.TERM === 'alacritty' ||
14
- process.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm'
15
- }
16
-
17
- export const tick = isUnicodeSupported() ? '✔' : '√'
package/index.js DELETED
@@ -1,27 +0,0 @@
1
- import fs from 'fs/promises'
2
- import pc from 'picocolors'
3
- import conventionalChangelogCore from 'conventional-changelog-core'
4
- import angular from 'conventional-changelog-angular'
5
- import { tick } from './figures.js'
6
-
7
- export default function conventionalChangelog (options, context, gitRawCommitsOpts, parserOpts, writerOpts) {
8
- options = options || {}
9
- options.config = angular
10
-
11
- return conventionalChangelogCore(options, context, gitRawCommitsOpts, parserOpts, writerOpts)
12
- }
13
-
14
- export async function createIfMissing (infile) {
15
- try {
16
- await fs.access(infile, fs.F_OK)
17
- } catch (err) {
18
- if (err.code === 'ENOENT') {
19
- checkpoint('created %s', [infile])
20
- await fs.writeFile(infile, '\n', 'utf-8')
21
- }
22
- }
23
- }
24
-
25
- export function checkpoint (msg, args) {
26
- console.info(`${pc.green(tick)} ${msg}`, ...args.map(arg => pc.bold(arg)))
27
- }