standard-changelog 3.0.0 → 4.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.
package/README.md CHANGED
@@ -48,7 +48,7 @@ $ standard-changelog --help
48
48
 
49
49
  ## API
50
50
 
51
- See the [conventional-changelog](https://github.com/ajoslin/conventional-changelog) docs with the angular preset.
51
+ See the [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) docs with the angular preset.
52
52
 
53
53
  ## License
54
54
 
@@ -1,14 +1,24 @@
1
1
  #!/usr/bin/env node
2
- 'use strict'
3
- const addStream = require('add-stream')
4
- const chalk = require('chalk')
5
- const standardChangelog = require('./')
6
- const fs = require('fs')
7
- const meow = require('meow')
8
- const tempfile = require('tempfile')
9
- const resolve = require('path').resolve
10
- const Readable = require('stream').Readable
11
- const rimraf = require('rimraf')
2
+ import {
3
+ createReadStream,
4
+ createWriteStream
5
+ } from 'fs'
6
+ import {
7
+ readFile,
8
+ rm
9
+ } from 'fs/promises'
10
+ import { resolve } from 'path'
11
+ import { pathToFileURL } from 'url'
12
+ import { Readable } from 'stream'
13
+ import addStream from 'add-stream'
14
+ import pc from 'picocolors'
15
+ import tempfile from 'tempfile'
16
+ import meow from 'meow'
17
+ import standardChangelog from './index.js'
18
+
19
+ function relativeResolve (filePath) {
20
+ return pathToFileURL(resolve(process.cwd(), filePath))
21
+ }
12
22
 
13
23
  const cli = meow(`
14
24
  Usage
@@ -28,55 +38,56 @@ const cli = meow(`
28
38
  -l, --lerna-package Generate a changelog for a specific lerna package (:pkg-name@1.0.0)
29
39
  --commit-path Generate a changelog scoped to a specific directory
30
40
  `, {
41
+ importMeta: import.meta,
31
42
  booleanDefault: undefined,
32
43
  flags: {
33
44
  infile: {
34
- alias: 'i',
45
+ shortFlag: 'i',
35
46
  default: 'CHANGELOG.md',
36
47
  type: 'string'
37
48
  },
38
49
  help: {
39
- alias: 'h'
50
+ shortFlag: 'h'
40
51
  },
41
52
  outfile: {
42
- alias: 'o',
53
+ shortFlag: 'o',
43
54
  type: 'string'
44
55
  },
45
- 'same-file': {
46
- alias: 's',
56
+ sameFile: {
57
+ shortFlag: 's',
47
58
  default: true,
48
59
  type: 'boolean'
49
60
  },
50
61
  preset: {
51
- alias: 'p',
62
+ shortFlag: 'p',
52
63
  type: 'string'
53
64
  },
54
65
  pkg: {
55
- alias: 'k',
66
+ shortFlag: 'k',
56
67
  type: 'string'
57
68
  },
58
69
  append: {
59
- alias: 'a',
70
+ shortFlag: 'a',
60
71
  type: 'boolean'
61
72
  },
62
- 'release-count': {
63
- alias: 'r',
73
+ releaseCount: {
74
+ shortFlag: 'r',
64
75
  type: 'number'
65
76
  },
66
77
  verbose: {
67
- alias: 'v',
78
+ shortFlag: 'v',
68
79
  type: 'boolean'
69
80
  },
70
81
  context: {
71
- alias: 'c',
82
+ shortFlag: 'c',
72
83
  type: 'string'
73
84
  },
74
- 'first-release': {
75
- alias: 'f',
85
+ firstRelease: {
86
+ shortFlag: 'f',
76
87
  type: 'boolean'
77
88
  },
78
- 'lerna-package': {
79
- alias: 'l',
89
+ lernaPackage: {
90
+ shortFlag: 'l',
80
91
  type: 'string'
81
92
  }
82
93
  }
@@ -94,8 +105,8 @@ const options = {
94
105
  pkg: {
95
106
  path: flags.pkg
96
107
  },
97
- append: append,
98
- releaseCount: releaseCount,
108
+ append,
109
+ releaseCount,
99
110
  lernaPackage: flags.lernaPackage
100
111
  }
101
112
 
@@ -107,23 +118,23 @@ let templateContext
107
118
 
108
119
  function outputError (err) {
109
120
  if (flags.verbose) {
110
- console.error(chalk.grey(err.stack))
121
+ console.error(pc.gray(err.stack))
111
122
  } else {
112
- console.error(chalk.red(err.toString()))
123
+ console.error(pc.red(err.toString()))
113
124
  }
114
125
  process.exit(1)
115
126
  }
116
127
 
117
128
  try {
118
129
  if (flags.context) {
119
- templateContext = require(resolve(process.cwd(), flags.context))
130
+ templateContext = JSON.parse(await readFile(relativeResolve(flags.context), 'utf8'))
120
131
  }
121
132
  } catch (err) {
122
133
  outputError(err)
123
134
  }
124
135
 
125
136
  const changelogStream = standardChangelog(options, templateContext, flags.commitPath ? { path: flags.commitPath } : {})
126
- .on('error', function (err) {
137
+ .on('error', (err) => {
127
138
  outputError(err)
128
139
  })
129
140
 
@@ -131,8 +142,8 @@ standardChangelog.createIfMissing(infile)
131
142
 
132
143
  let readStream = null
133
144
  if (releaseCount !== 0) {
134
- readStream = fs.createReadStream(infile)
135
- .on('error', function (err) {
145
+ readStream = createReadStream(infile)
146
+ .on('error', (err) => {
136
147
  outputError(err)
137
148
  })
138
149
  } else {
@@ -142,10 +153,10 @@ if (releaseCount !== 0) {
142
153
 
143
154
  if (options.append) {
144
155
  changelogStream
145
- .pipe(fs.createWriteStream(outfile, {
156
+ .pipe(createWriteStream(outfile, {
146
157
  flags: 'a'
147
158
  }))
148
- .on('finish', function () {
159
+ .on('finish', () => {
149
160
  standardChangelog.checkpoint('appended changes to %s', [outfile])
150
161
  })
151
162
  } else {
@@ -153,13 +164,13 @@ if (options.append) {
153
164
 
154
165
  changelogStream
155
166
  .pipe(addStream(readStream))
156
- .pipe(fs.createWriteStream(tmp))
157
- .on('finish', function () {
158
- fs.createReadStream(tmp)
159
- .pipe(fs.createWriteStream(outfile))
160
- .on('finish', function () {
167
+ .pipe(createWriteStream(tmp))
168
+ .on('finish', () => {
169
+ createReadStream(tmp)
170
+ .pipe(createWriteStream(outfile))
171
+ .on('finish', () => {
161
172
  standardChangelog.checkpoint('output changes to %s', [outfile])
162
- rimraf.sync(tmp)
173
+ rm(tmp, { recursive: true })
163
174
  })
164
175
  })
165
176
  }
package/index.js CHANGED
@@ -3,8 +3,7 @@
3
3
  const conventionalChangelogCore = require('conventional-changelog-core')
4
4
  const angular = require('conventional-changelog-angular')
5
5
  const fs = require('fs')
6
- const accessSync = require('fs-access').sync
7
- const chalk = require('chalk')
6
+ const pc = require('picocolors')
8
7
  const figures = require('figures')
9
8
  const sprintf = require('sprintf-js').sprintf
10
9
 
@@ -16,7 +15,7 @@ function conventionalChangelog (options, context, gitRawCommitsOpts, parserOpts,
16
15
 
17
16
  conventionalChangelog.createIfMissing = function (infile) {
18
17
  try {
19
- accessSync(infile, fs.F_OK)
18
+ fs.accessSync(infile, fs.F_OK)
20
19
  } catch (err) {
21
20
  if (err.code === 'ENOENT') {
22
21
  conventionalChangelog.checkpoint('created %s', [infile])
@@ -26,8 +25,8 @@ conventionalChangelog.createIfMissing = function (infile) {
26
25
  }
27
26
 
28
27
  conventionalChangelog.checkpoint = function (msg, args) {
29
- console.info(chalk.green(figures.tick) + ' ' + sprintf(msg, args.map(function (arg) {
30
- return chalk.bold(arg)
28
+ console.info(pc.green(figures.tick) + ' ' + sprintf(msg, args.map(function (arg) {
29
+ return pc.bold(arg)
31
30
  })))
32
31
  }
33
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "standard-changelog",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Generate a changelog from git metadata with Angular commit convention",
5
5
  "bugs": {
6
6
  "url": "https://github.com/conventional-changelog/conventional-changelog/issues"
@@ -19,26 +19,21 @@
19
19
  ],
20
20
  "license": "MIT",
21
21
  "engines": {
22
- "node": ">=14"
22
+ "node": ">=16"
23
23
  },
24
24
  "files": [
25
25
  "index.js",
26
- "cli.js"
26
+ "cli.mjs"
27
27
  ],
28
28
  "dependencies": {
29
29
  "add-stream": "^1.0.0",
30
- "chalk": "^4.1.2",
31
- "conventional-changelog-angular": "^6.0.0",
32
- "conventional-changelog-core": "^5.0.0",
33
30
  "figures": "^3.2.0",
34
- "fs-access": "^1.0.1",
35
- "meow": "^8.1.2",
36
- "rimraf": "^3.0.2",
31
+ "meow": "^12.0.1",
32
+ "picocolors": "^1.0.0",
37
33
  "sprintf-js": "^1.1.2",
38
- "tempfile": "^3.0.0"
34
+ "tempfile": "^5.0.0",
35
+ "conventional-changelog-core": "^6.0.0",
36
+ "conventional-changelog-angular": "^7.0.0"
39
37
  },
40
- "bin": "cli.js",
41
- "scripts": {
42
- "test-windows": "echo 'make work on windows'"
43
- }
38
+ "bin": "cli.mjs"
44
39
  }