standard-changelog 5.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 CHANGED
@@ -33,7 +33,7 @@ $ npm install --save standard-changelog
33
33
  ```
34
34
 
35
35
  ```js
36
- var standardChangelog = require('standard-changelog');
36
+ import standardChangelog from 'standard-changelog';
37
37
 
38
38
  standardChangelog()
39
39
  .pipe(process.stdout); // or any writable stream
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { resolve, extname } from 'path'
3
+ import { pathToFileURL } from 'url'
2
4
  import { createWriteStream } from 'fs'
3
5
  import {
4
6
  readFile,
@@ -11,6 +13,21 @@ import standardChangelog, {
11
13
  checkpoint
12
14
  } from './index.js'
13
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
+
14
31
  function printError (err) {
15
32
  if (flags.verbose) {
16
33
  console.error(pc.gray(err.stack))
@@ -126,7 +143,7 @@ let templateContext
126
143
 
127
144
  try {
128
145
  if (flags.context) {
129
- templateContext = JSON.parse(await readFile(flags.context, 'utf8'))
146
+ templateContext = await loadDataFile(flags.context)
130
147
  }
131
148
  } catch (err) {
132
149
  printError(err)
package/figures.js CHANGED
@@ -14,6 +14,4 @@ function isUnicodeSupported () {
14
14
  process.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm'
15
15
  }
16
16
 
17
- const tick = isUnicodeSupported() ? '✔' : '√'
18
-
19
- exports.tick = tick
17
+ export const tick = isUnicodeSupported() ? '✔' : '√'
package/index.js CHANGED
@@ -1,17 +1,17 @@
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')
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
6
 
7
- function conventionalChangelog (options, context, gitRawCommitsOpts, parserOpts, writerOpts) {
7
+ export default function conventionalChangelog (options, context, gitRawCommitsOpts, parserOpts, writerOpts) {
8
8
  options = options || {}
9
9
  options.config = angular
10
10
 
11
11
  return conventionalChangelogCore(options, context, gitRawCommitsOpts, parserOpts, writerOpts)
12
12
  }
13
13
 
14
- async function createIfMissing (infile) {
14
+ export async function createIfMissing (infile) {
15
15
  try {
16
16
  await fs.access(infile, fs.F_OK)
17
17
  } catch (err) {
@@ -22,10 +22,6 @@ async function createIfMissing (infile) {
22
22
  }
23
23
  }
24
24
 
25
- function checkpoint (msg, args) {
25
+ export function checkpoint (msg, args) {
26
26
  console.info(`${pc.green(tick)} ${msg}`, ...args.map(arg => pc.bold(arg)))
27
27
  }
28
-
29
- module.exports = conventionalChangelog
30
- module.exports.createIfMissing = createIfMissing
31
- module.exports.checkpoint = checkpoint
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": "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,20 +21,20 @@
17
21
  "changelog",
18
22
  "log"
19
23
  ],
20
- "license": "MIT",
21
24
  "engines": {
22
- "node": ">=16"
25
+ "node": ">=18"
23
26
  },
27
+ "bin": "cli.js",
28
+ "exports": "./index.js",
24
29
  "files": [
25
30
  "index.js",
26
31
  "figures.js",
27
- "cli.mjs"
32
+ "cli.js"
28
33
  ],
29
34
  "dependencies": {
30
- "meow": "^12.0.1",
35
+ "meow": "^13.0.0",
31
36
  "picocolors": "^1.0.0",
32
- "conventional-changelog-angular": "^7.0.0",
33
- "conventional-changelog-core": "^7.0.0"
34
- },
35
- "bin": "cli.mjs"
37
+ "conventional-changelog-angular": "^8.0.0",
38
+ "conventional-changelog-core": "^8.0.0"
39
+ }
36
40
  }