standard-changelog 4.0.0 → 6.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 +1 -1
- package/{cli.mjs → cli.js} +60 -57
- package/figures.js +17 -0
- package/index.js +13 -19
- package/package.json +19 -18
package/README.md
CHANGED
package/{cli.mjs → cli.js}
RENAMED
|
@@ -1,25 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from 'fs'
|
|
2
|
+
import { resolve, extname } from 'path'
|
|
3
|
+
import { pathToFileURL } from 'url'
|
|
4
|
+
import { createWriteStream } from 'fs'
|
|
6
5
|
import {
|
|
7
6
|
readFile,
|
|
8
|
-
|
|
7
|
+
writeFile
|
|
9
8
|
} 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
9
|
import pc from 'picocolors'
|
|
15
|
-
import tempfile from 'tempfile'
|
|
16
10
|
import meow from 'meow'
|
|
17
|
-
import standardChangelog
|
|
11
|
+
import standardChangelog, {
|
|
12
|
+
createIfMissing,
|
|
13
|
+
checkpoint
|
|
14
|
+
} from './index.js'
|
|
18
15
|
|
|
19
16
|
function relativeResolve (filePath) {
|
|
20
17
|
return pathToFileURL(resolve(process.cwd(), filePath))
|
|
21
18
|
}
|
|
22
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
|
+
|
|
23
48
|
const cli = meow(`
|
|
24
49
|
Usage
|
|
25
50
|
standard-changelog
|
|
@@ -116,61 +141,39 @@ if (flags.verbose) {
|
|
|
116
141
|
|
|
117
142
|
let templateContext
|
|
118
143
|
|
|
119
|
-
function outputError (err) {
|
|
120
|
-
if (flags.verbose) {
|
|
121
|
-
console.error(pc.gray(err.stack))
|
|
122
|
-
} else {
|
|
123
|
-
console.error(pc.red(err.toString()))
|
|
124
|
-
}
|
|
125
|
-
process.exit(1)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
144
|
try {
|
|
129
145
|
if (flags.context) {
|
|
130
|
-
templateContext =
|
|
146
|
+
templateContext = await loadDataFile(flags.context)
|
|
131
147
|
}
|
|
132
148
|
} catch (err) {
|
|
133
|
-
|
|
149
|
+
printError(err)
|
|
134
150
|
}
|
|
135
151
|
|
|
136
152
|
const changelogStream = standardChangelog(options, templateContext, flags.commitPath ? { path: flags.commitPath } : {})
|
|
137
|
-
.on('error', (err) => {
|
|
138
|
-
outputError(err)
|
|
139
|
-
})
|
|
140
153
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
let readStream = null
|
|
144
|
-
if (releaseCount !== 0) {
|
|
145
|
-
readStream = createReadStream(infile)
|
|
146
|
-
.on('error', (err) => {
|
|
147
|
-
outputError(err)
|
|
148
|
-
})
|
|
149
|
-
} else {
|
|
150
|
-
readStream = new Readable()
|
|
151
|
-
readStream.push(null)
|
|
152
|
-
}
|
|
154
|
+
await createIfMissing(infile)
|
|
153
155
|
|
|
154
156
|
if (options.append) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
await waitStreamFinish(
|
|
158
|
+
changelogStream
|
|
159
|
+
.pipe(createWriteStream(outfile, {
|
|
160
|
+
flags: 'a'
|
|
161
|
+
}))
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
checkpoint('appended changes to %s', [outfile])
|
|
162
165
|
} else {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
changelogStream
|
|
166
|
-
.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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])
|
|
176
179
|
}
|
package/figures.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
CHANGED
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
|
|
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'
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
const angular = require('conventional-changelog-angular')
|
|
5
|
-
const fs = require('fs')
|
|
6
|
-
const pc = require('picocolors')
|
|
7
|
-
const figures = require('figures')
|
|
8
|
-
const sprintf = require('sprintf-js').sprintf
|
|
9
|
-
|
|
10
|
-
function conventionalChangelog (options, context, gitRawCommitsOpts, parserOpts, writerOpts) {
|
|
7
|
+
export default function conventionalChangelog (options, context, gitRawCommitsOpts, parserOpts, writerOpts) {
|
|
11
8
|
options = options || {}
|
|
12
9
|
options.config = angular
|
|
10
|
+
|
|
13
11
|
return conventionalChangelogCore(options, context, gitRawCommitsOpts, parserOpts, writerOpts)
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
export async function createIfMissing (infile) {
|
|
17
15
|
try {
|
|
18
|
-
fs.
|
|
16
|
+
await fs.access(infile, fs.F_OK)
|
|
19
17
|
} catch (err) {
|
|
20
18
|
if (err.code === 'ENOENT') {
|
|
21
|
-
|
|
22
|
-
fs.
|
|
19
|
+
checkpoint('created %s', [infile])
|
|
20
|
+
await fs.writeFile(infile, '\n', 'utf-8')
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
console.info(pc.green(
|
|
29
|
-
return pc.bold(arg)
|
|
30
|
-
})))
|
|
25
|
+
export function checkpoint (msg, args) {
|
|
26
|
+
console.info(`${pc.green(tick)} ${msg}`, ...args.map(arg => pc.bold(arg)))
|
|
31
27
|
}
|
|
32
|
-
|
|
33
|
-
module.exports = conventionalChangelog
|
package/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "standard-changelog",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "6.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,23 +21,20 @@
|
|
|
17
21
|
"changelog",
|
|
18
22
|
"log"
|
|
19
23
|
],
|
|
20
|
-
"license": "MIT",
|
|
21
24
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
25
|
+
"node": ">=18"
|
|
23
26
|
},
|
|
27
|
+
"bin": "cli.js",
|
|
28
|
+
"exports": "./index.js",
|
|
24
29
|
"files": [
|
|
25
30
|
"index.js",
|
|
26
|
-
"
|
|
31
|
+
"figures.js",
|
|
32
|
+
"cli.js"
|
|
27
33
|
],
|
|
28
34
|
"dependencies": {
|
|
29
|
-
"
|
|
30
|
-
"figures": "^3.2.0",
|
|
31
|
-
"meow": "^12.0.1",
|
|
35
|
+
"meow": "^13.0.0",
|
|
32
36
|
"picocolors": "^1.0.0",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
"conventional-changelog-angular": "^7.0.0"
|
|
37
|
-
},
|
|
38
|
-
"bin": "cli.mjs"
|
|
37
|
+
"conventional-changelog-angular": "^8.0.0",
|
|
38
|
+
"conventional-changelog-core": "^8.0.0"
|
|
39
|
+
}
|
|
39
40
|
}
|