standard-changelog 5.0.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 (5) hide show
  1. package/README.md +68 -33
  2. package/package.json +24 -17
  3. package/cli.mjs +0 -162
  4. package/figures.js +0 -19
  5. package/index.js +0 -31
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
- var standardChangelog = require('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/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "standard-changelog",
3
- "version": "5.0.0",
4
- "description": "Generate a changelog from git metadata with Angular commit convention",
5
- "bugs": {
6
- "url": "https://github.com/conventional-changelog/conventional-changelog/issues"
7
- },
3
+ "type": "module",
4
+ "version": "7.0.0",
5
+ "description": "Generate a changelog from git metadata with Angular commit convention.",
6
+ "author": "Steve Mao",
7
+ "license": "MIT",
8
8
  "homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/standard-changelog#readme",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/conventional-changelog/conventional-changelog.git"
11
+ "url": "https://github.com/conventional-changelog/conventional-changelog.git",
12
+ "directory": "packages/standard-changelog"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/conventional-changelog/conventional-changelog/issues"
12
16
  },
13
17
  "keywords": [
14
18
  "conventional-changelog",
@@ -17,20 +21,23 @@
17
21
  "changelog",
18
22
  "log"
19
23
  ],
20
- "license": "MIT",
21
24
  "engines": {
22
- "node": ">=16"
25
+ "node": ">=18"
26
+ },
27
+ "bin": {
28
+ "standard-changelog": "./dist/cli.js"
29
+ },
30
+ "exports": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
23
33
  },
24
34
  "files": [
25
- "index.js",
26
- "figures.js",
27
- "cli.mjs"
35
+ "dist"
28
36
  ],
29
37
  "dependencies": {
30
- "meow": "^12.0.1",
31
- "picocolors": "^1.0.0",
32
- "conventional-changelog-angular": "^7.0.0",
33
- "conventional-changelog-core": "^7.0.0"
34
- },
35
- "bin": "cli.mjs"
38
+ "meow": "^13.0.0",
39
+ "@conventional-changelog/git-client": "^2.1.0",
40
+ "conventional-changelog-angular": "^8.0.0",
41
+ "conventional-changelog": "^7.0.0"
42
+ }
36
43
  }
package/cli.mjs DELETED
@@ -1,162 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createWriteStream } from 'fs'
3
- import {
4
- readFile,
5
- writeFile
6
- } from 'fs/promises'
7
- import pc from 'picocolors'
8
- import meow from 'meow'
9
- import standardChangelog, {
10
- createIfMissing,
11
- checkpoint
12
- } from './index.js'
13
-
14
- function printError (err) {
15
- if (flags.verbose) {
16
- console.error(pc.gray(err.stack))
17
- } else {
18
- console.error(pc.red(err.toString()))
19
- }
20
-
21
- process.exit(1)
22
- }
23
-
24
- function waitStreamFinish (stream) {
25
- return new Promise((resolve) => {
26
- stream.on('finish', resolve)
27
- stream.on('error', printError)
28
- })
29
- }
30
-
31
- const cli = meow(`
32
- Usage
33
- standard-changelog
34
-
35
- Options
36
- -i, --infile Read the CHANGELOG from this file
37
- -f, --first-release Generate the CHANGELOG for the first time
38
- -o, --outfile Write the CHANGELOG to this file. If unspecified (default: CHANGELOG.md)
39
- -s, --same-file Overwrite the infile (default: true)
40
- -p, --preset Name of the preset you want to use (default: angular)
41
- -k, --pkg A filepath of where your package.json is located
42
- -a, --append Should the generated block be appended
43
- -r, --release-count How many releases to be generated from the latest
44
- -v, --verbose Verbose output
45
- -c, --context A filepath of a json that is used to define template variables
46
- -l, --lerna-package Generate a changelog for a specific lerna package (:pkg-name@1.0.0)
47
- --commit-path Generate a changelog scoped to a specific directory
48
- `, {
49
- importMeta: import.meta,
50
- booleanDefault: undefined,
51
- flags: {
52
- infile: {
53
- shortFlag: 'i',
54
- default: 'CHANGELOG.md',
55
- type: 'string'
56
- },
57
- help: {
58
- shortFlag: 'h'
59
- },
60
- outfile: {
61
- shortFlag: 'o',
62
- type: 'string'
63
- },
64
- sameFile: {
65
- shortFlag: 's',
66
- default: true,
67
- type: 'boolean'
68
- },
69
- preset: {
70
- shortFlag: 'p',
71
- type: 'string'
72
- },
73
- pkg: {
74
- shortFlag: 'k',
75
- type: 'string'
76
- },
77
- append: {
78
- shortFlag: 'a',
79
- type: 'boolean'
80
- },
81
- releaseCount: {
82
- shortFlag: 'r',
83
- type: 'number'
84
- },
85
- verbose: {
86
- shortFlag: 'v',
87
- type: 'boolean'
88
- },
89
- context: {
90
- shortFlag: 'c',
91
- type: 'string'
92
- },
93
- firstRelease: {
94
- shortFlag: 'f',
95
- type: 'boolean'
96
- },
97
- lernaPackage: {
98
- shortFlag: 'l',
99
- type: 'string'
100
- }
101
- }
102
- })
103
-
104
- const flags = cli.flags
105
- const infile = flags.infile
106
- const sameFile = flags.sameFile
107
- const outfile = sameFile ? (flags.outfile || infile) : flags.outfile
108
- const append = flags.append
109
- const releaseCount = flags.firstRelease ? 0 : flags.releaseCount
110
-
111
- const options = {
112
- preset: flags.preset,
113
- pkg: {
114
- path: flags.pkg
115
- },
116
- append,
117
- releaseCount,
118
- lernaPackage: flags.lernaPackage
119
- }
120
-
121
- if (flags.verbose) {
122
- options.warn = console.warn.bind(console)
123
- }
124
-
125
- let templateContext
126
-
127
- try {
128
- if (flags.context) {
129
- templateContext = JSON.parse(await readFile(flags.context, 'utf8'))
130
- }
131
- } catch (err) {
132
- printError(err)
133
- }
134
-
135
- const changelogStream = standardChangelog(options, templateContext, flags.commitPath ? { path: flags.commitPath } : {})
136
-
137
- await createIfMissing(infile)
138
-
139
- if (options.append) {
140
- await waitStreamFinish(
141
- changelogStream
142
- .pipe(createWriteStream(outfile, {
143
- flags: 'a'
144
- }))
145
- )
146
-
147
- checkpoint('appended changes to %s', [outfile])
148
- } else {
149
- let changelog = ''
150
-
151
- for await (const chunk of changelogStream) {
152
- changelog += chunk.toString()
153
- }
154
-
155
- if (releaseCount !== 0) {
156
- changelog += await readFile(infile, 'utf8')
157
- }
158
-
159
- await writeFile(outfile, changelog)
160
-
161
- checkpoint('output changes to %s', [outfile])
162
- }
package/figures.js DELETED
@@ -1,19 +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
- const tick = isUnicodeSupported() ? '✔' : '√'
18
-
19
- exports.tick = tick
package/index.js DELETED
@@ -1,31 +0,0 @@
1
- const fs = require('fs/promises')
2
- const pc = require('picocolors')
3
- const conventionalChangelogCore = require('conventional-changelog-core')
4
- const angular = require('conventional-changelog-angular')
5
- const { tick } = require('./figures')
6
-
7
- 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
- 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
- function checkpoint (msg, args) {
26
- console.info(`${pc.green(tick)} ${msg}`, ...args.map(arg => pc.bold(arg)))
27
- }
28
-
29
- module.exports = conventionalChangelog
30
- module.exports.createIfMissing = createIfMissing
31
- module.exports.checkpoint = checkpoint