conventional-changelog-angular 7.0.0 → 8.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
@@ -1,11 +1,16 @@
1
1
  # conventional-changelog-angular
2
2
 
3
+ [![ESM-only package][package]][package-url]
3
4
  [![NPM version][npm]][npm-url]
4
5
  [![Node version][node]][node-url]
5
6
  [![Dependencies status][deps]][deps-url]
7
+ [![Install size][size]][size-url]
6
8
  [![Build status][build]][build-url]
7
9
  [![Coverage status][coverage]][coverage-url]
8
10
 
11
+ [package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
12
+ [package-url]: https://nodejs.org/api/esm.html
13
+
9
14
  [npm]: https://img.shields.io/npm/v/conventional-changelog-angular.svg
10
15
  [npm-url]: https://npmjs.com/package/conventional-changelog-angular
11
16
 
@@ -15,7 +20,10 @@
15
20
  [deps]: https://img.shields.io/librariesio/release/npm/conventional-changelog-angular
16
21
  [deps-url]: https://libraries.io/npm/conventional-changelog-angular/tree
17
22
 
18
- [build]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/ci.yaml?branch=master
23
+ [size]: https://packagephobia.com/badge?p=conventional-changelog-angular
24
+ [size-url]: https://packagephobia.com/result?p=conventional-changelog-angular
25
+
26
+ [build]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/tests.yaml?branch=master
19
27
  [build-url]: https://github.com/conventional-changelog/conventional-changelog/actions
20
28
 
21
29
  [coverage]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
package/package.json CHANGED
@@ -1,34 +1,31 @@
1
1
  {
2
2
  "name": "conventional-changelog-angular",
3
- "version": "7.0.0",
4
- "description": "conventional-changelog angular preset",
5
- "main": "index.js",
3
+ "type": "module",
4
+ "version": "8.0.0",
5
+ "description": "Angular preset for conventional-changelog.",
6
+ "author": "Steve Mao",
7
+ "license": "ISC",
8
+ "homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular#readme",
6
9
  "repository": {
7
10
  "type": "git",
8
- "url": "https://github.com/conventional-changelog/conventional-changelog.git"
11
+ "url": "https://github.com/conventional-changelog/conventional-changelog.git",
12
+ "directory": "packages/conventional-changelog-angular"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/conventional-changelog/conventional-changelog/issues"
9
16
  },
10
17
  "keywords": [
11
18
  "conventional-changelog",
12
19
  "angular",
13
20
  "preset"
14
21
  ],
15
- "files": [
16
- "conventionalChangelog.js",
17
- "conventionalRecommendedBump.js",
18
- "index.js",
19
- "parserOpts.js",
20
- "writerOpts.js",
21
- "templates"
22
- ],
23
- "author": "Steve Mao",
24
22
  "engines": {
25
- "node": ">=16"
26
- },
27
- "license": "ISC",
28
- "bugs": {
29
- "url": "https://github.com/conventional-changelog/conventional-changelog/issues"
23
+ "node": ">=18"
30
24
  },
31
- "homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular#readme",
25
+ "exports": "./src/index.js",
26
+ "files": [
27
+ "src"
28
+ ],
32
29
  "dependencies": {
33
30
  "compare-func": "^2.0.0"
34
31
  }
package/src/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { createParserOpts } from './parser.js'
2
+ import { createWriterOpts } from './writer.js'
3
+ import { whatBump } from './whatBump.js'
4
+
5
+ export default async function createPreset () {
6
+ return {
7
+ parser: createParserOpts(),
8
+ writer: await createWriterOpts(),
9
+ whatBump
10
+ }
11
+ }
@@ -1,6 +1,4 @@
1
- 'use strict'
2
-
3
- function createParserOpts () {
1
+ export function createParserOpts () {
4
2
  return {
5
3
  headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/,
6
4
  headerCorrespondence: [
@@ -9,9 +7,7 @@ function createParserOpts () {
9
7
  'subject'
10
8
  ],
11
9
  noteKeywords: ['BREAKING CHANGE'],
12
- revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
10
+ revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w{7,40})\b/i,
13
11
  revertCorrespondence: ['header', 'hash']
14
12
  }
15
13
  }
16
-
17
- module.exports.createParserOpts = createParserOpts
@@ -0,0 +1,24 @@
1
+ export function whatBump (commits) {
2
+ let level = 2
3
+ let breakings = 0
4
+ let features = 0
5
+
6
+ commits.forEach(commit => {
7
+ if (commit.notes.length > 0) {
8
+ breakings += commit.notes.length
9
+ level = 0
10
+ } else if (commit.type === 'feat') {
11
+ features += 1
12
+ if (level === 2) {
13
+ level = 1
14
+ }
15
+ }
16
+ })
17
+
18
+ return {
19
+ level,
20
+ reason: breakings === 1
21
+ ? `There is ${breakings} BREAKING CHANGE and ${features} features`
22
+ : `There are ${breakings} BREAKING CHANGES and ${features} features`
23
+ }
24
+ }
@@ -1,15 +1,16 @@
1
- 'use strict'
1
+ import { readFile } from 'fs/promises'
2
+ import { resolve } from 'path'
3
+ import { fileURLToPath } from 'url'
4
+ import compareFunc from 'compare-func'
2
5
 
3
- const compareFunc = require('compare-func')
4
- const { readFile } = require('fs').promises
5
- const { resolve } = require('path')
6
+ const dirname = fileURLToPath(new URL('.', import.meta.url))
6
7
 
7
- async function createWriterOpts () {
8
+ export async function createWriterOpts () {
8
9
  const [template, header, commit, footer] = await Promise.all([
9
- readFile(resolve(__dirname, './templates/template.hbs'), 'utf-8'),
10
- readFile(resolve(__dirname, './templates/header.hbs'), 'utf-8'),
11
- readFile(resolve(__dirname, './templates/commit.hbs'), 'utf-8'),
12
- readFile(resolve(__dirname, './templates/footer.hbs'), 'utf-8')
10
+ readFile(resolve(dirname, './templates/template.hbs'), 'utf-8'),
11
+ readFile(resolve(dirname, './templates/header.hbs'), 'utf-8'),
12
+ readFile(resolve(dirname, './templates/commit.hbs'), 'utf-8'),
13
+ readFile(resolve(dirname, './templates/footer.hbs'), 'utf-8')
13
14
  ])
14
15
  const writerOpts = getWriterOpts()
15
16
 
@@ -21,66 +22,68 @@ async function createWriterOpts () {
21
22
  return writerOpts
22
23
  }
23
24
 
24
- module.exports.createWriterOpts = createWriterOpts
25
-
26
25
  function getWriterOpts () {
27
26
  return {
28
27
  transform: (commit, context) => {
29
28
  let discard = true
30
- const issues = []
31
-
32
- commit.notes.forEach(note => {
33
- note.title = 'BREAKING CHANGES'
29
+ const notes = commit.notes.map(note => {
34
30
  discard = false
31
+
32
+ return {
33
+ ...note,
34
+ title: 'BREAKING CHANGES'
35
+ }
35
36
  })
36
37
 
38
+ let type = commit.type
39
+
37
40
  if (commit.type === 'feat') {
38
- commit.type = 'Features'
41
+ type = 'Features'
39
42
  } else if (commit.type === 'fix') {
40
- commit.type = 'Bug Fixes'
43
+ type = 'Bug Fixes'
41
44
  } else if (commit.type === 'perf') {
42
- commit.type = 'Performance Improvements'
45
+ type = 'Performance Improvements'
43
46
  } else if (commit.type === 'revert' || commit.revert) {
44
- commit.type = 'Reverts'
47
+ type = 'Reverts'
45
48
  } else if (discard) {
46
49
  return
47
50
  } else if (commit.type === 'docs') {
48
- commit.type = 'Documentation'
51
+ type = 'Documentation'
49
52
  } else if (commit.type === 'style') {
50
- commit.type = 'Styles'
53
+ type = 'Styles'
51
54
  } else if (commit.type === 'refactor') {
52
- commit.type = 'Code Refactoring'
55
+ type = 'Code Refactoring'
53
56
  } else if (commit.type === 'test') {
54
- commit.type = 'Tests'
57
+ type = 'Tests'
55
58
  } else if (commit.type === 'build') {
56
- commit.type = 'Build System'
59
+ type = 'Build System'
57
60
  } else if (commit.type === 'ci') {
58
- commit.type = 'Continuous Integration'
61
+ type = 'Continuous Integration'
59
62
  }
60
63
 
61
- if (commit.scope === '*') {
62
- commit.scope = ''
63
- }
64
+ const scope = commit.scope === '*' ? '' : commit.scope
65
+ const shortHash = typeof commit.hash === 'string'
66
+ ? commit.hash.substring(0, 7)
67
+ : commit.shortHash
64
68
 
65
- if (typeof commit.hash === 'string') {
66
- commit.shortHash = commit.hash.substring(0, 7)
67
- }
69
+ const issues = []
70
+ let subject = commit.subject
68
71
 
69
- if (typeof commit.subject === 'string') {
72
+ if (typeof subject === 'string') {
70
73
  let url = context.repository
71
74
  ? `${context.host}/${context.owner}/${context.repository}`
72
75
  : context.repoUrl
73
76
  if (url) {
74
77
  url = `${url}/issues/`
75
78
  // Issue URLs.
76
- commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
79
+ subject = subject.replace(/#([0-9]+)/g, (_, issue) => {
77
80
  issues.push(issue)
78
81
  return `[#${issue}](${url}${issue})`
79
82
  })
80
83
  }
81
84
  if (context.host) {
82
85
  // User URLs.
83
- commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
86
+ subject = subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
84
87
  if (username.includes('/')) {
85
88
  return `@${username}`
86
89
  }
@@ -91,15 +94,16 @@ function getWriterOpts () {
91
94
  }
92
95
 
93
96
  // remove references that already appear in the subject
94
- commit.references = commit.references.filter(reference => {
95
- if (issues.indexOf(reference.issue) === -1) {
96
- return true
97
- }
97
+ const references = commit.references.filter(reference => !issues.includes(reference.issue))
98
98
 
99
- return false
100
- })
101
-
102
- return commit
99
+ return {
100
+ notes,
101
+ type,
102
+ scope,
103
+ shortHash,
104
+ subject,
105
+ references
106
+ }
103
107
  },
104
108
  groupBy: 'type',
105
109
  commitGroupsSort: 'title',
@@ -1,10 +0,0 @@
1
- 'use strict'
2
-
3
- function createConventionalChangelogOpts (parserOpts, writerOpts) {
4
- return {
5
- parserOpts,
6
- writerOpts
7
- }
8
- }
9
-
10
- module.exports.createConventionalChangelogOpts = createConventionalChangelogOpts
@@ -1,34 +0,0 @@
1
- 'use strict'
2
-
3
- function createConventionalRecommendedBumpOpts (parserOpts) {
4
- return {
5
- parserOpts,
6
-
7
- whatBump (commits) {
8
- let level = 2
9
- let breakings = 0
10
- let features = 0
11
-
12
- commits.forEach(commit => {
13
- if (commit.notes.length > 0) {
14
- breakings += commit.notes.length
15
- level = 0
16
- } else if (commit.type === 'feat') {
17
- features += 1
18
- if (level === 2) {
19
- level = 1
20
- }
21
- }
22
- })
23
-
24
- return {
25
- level,
26
- reason: breakings === 1
27
- ? `There is ${breakings} BREAKING CHANGE and ${features} features`
28
- : `There are ${breakings} BREAKING CHANGES and ${features} features`
29
- }
30
- }
31
- }
32
- }
33
-
34
- module.exports.createConventionalRecommendedBumpOpts = createConventionalRecommendedBumpOpts
package/index.js DELETED
@@ -1,22 +0,0 @@
1
- 'use strict'
2
-
3
- const { createParserOpts } = require('./parserOpts')
4
- const { createWriterOpts } = require('./writerOpts')
5
- const { createConventionalChangelogOpts } = require('./conventionalChangelog')
6
- const { createConventionalRecommendedBumpOpts } = require('./conventionalRecommendedBump')
7
-
8
- async function createPreset () {
9
- const parserOpts = createParserOpts()
10
- const writerOpts = await createWriterOpts()
11
- const recommendedBumpOpts = createConventionalRecommendedBumpOpts(parserOpts)
12
- const conventionalChangelog = createConventionalChangelogOpts(parserOpts, writerOpts)
13
-
14
- return {
15
- parserOpts,
16
- writerOpts,
17
- recommendedBumpOpts,
18
- conventionalChangelog
19
- }
20
- }
21
-
22
- module.exports = createPreset
File without changes
File without changes
File without changes
File without changes