@npmcli/template-oss 4.21.4 → 4.23.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 (50) hide show
  1. package/bin/apply.js +2 -5
  2. package/bin/check.js +2 -4
  3. package/bin/release-manager.js +1 -1
  4. package/bin/release-please.js +22 -18
  5. package/lib/apply/apply-files.js +14 -19
  6. package/lib/apply/apply-version.js +1 -5
  7. package/lib/apply/index.js +1 -4
  8. package/lib/check/check-apply.js +38 -39
  9. package/lib/check/check-changelog.js +1 -4
  10. package/lib/check/check-engines.js +5 -6
  11. package/lib/check/check-gitignore.js +14 -14
  12. package/lib/check/check-required.js +13 -15
  13. package/lib/check/check-unwanted.js +2 -3
  14. package/lib/check/index.js +9 -8
  15. package/lib/config.js +86 -35
  16. package/lib/content/LICENSE-md.hbs +2 -2
  17. package/lib/content/_job-matrix-yml.hbs +10 -0
  18. package/lib/content/_job-release-integration-yml.hbs +5 -10
  19. package/lib/content/_step-git-yml.hbs +1 -1
  20. package/lib/content/_step-node-yml.hbs +1 -1
  21. package/lib/content/action-create-check-yml.hbs +1 -1
  22. package/lib/content/ci-release-yml.hbs +2 -2
  23. package/lib/content/eslintrc-js.hbs +4 -5
  24. package/lib/content/gitignore.hbs +0 -3
  25. package/lib/content/index.js +39 -38
  26. package/lib/content/package-json.hbs +12 -2
  27. package/lib/content/prettier-js.hbs +6 -0
  28. package/lib/content/prettierignore.hbs +3 -0
  29. package/lib/content/release-yml.hbs +3 -3
  30. package/lib/index.js +3 -3
  31. package/lib/release/changelog.js +41 -44
  32. package/lib/release/node-workspace-format.js +29 -16
  33. package/lib/release/release-manager.js +61 -76
  34. package/lib/release/release-please.js +50 -61
  35. package/lib/release/util.js +11 -8
  36. package/lib/util/ci-versions.js +3 -3
  37. package/lib/util/dependabot.js +2 -2
  38. package/lib/util/files.js +34 -32
  39. package/lib/util/git.js +8 -5
  40. package/lib/util/gitignore.js +13 -11
  41. package/lib/util/has-package.js +7 -12
  42. package/lib/util/import-or-require.js +1 -1
  43. package/lib/util/json-diff.js +22 -21
  44. package/lib/util/merge.js +19 -16
  45. package/lib/util/output.js +8 -5
  46. package/lib/util/parser.js +86 -70
  47. package/lib/util/path.js +4 -4
  48. package/lib/util/template.js +13 -9
  49. package/package.json +13 -8
  50. package/lib/release/node-workspace.js +0 -103
@@ -11,6 +11,9 @@ strategy:
11
11
  - name: macOS
12
12
  os: macos-latest
13
13
  shell: bash
14
+ - name: macOS
15
+ os: macos-13
16
+ shell: bash
14
17
  {{/if}}
15
18
  {{#if windowsCI}}
16
19
  - name: Windows
@@ -21,6 +24,13 @@ strategy:
21
24
  {{#each ciVersions}}
22
25
  - {{ . }}
23
26
  {{/each}}
27
+ {{#if macCI}}
28
+ exclude:
29
+ {{#each ciVersions}}
30
+ - platform: {name: macOS, os: macos-{{#if (lte (semverRangeMajor .) 14)}}latest{{else}}13{{/if}}, shell: bash}
31
+ node-version: {{ . }}
32
+ {{/each}}
33
+ {{/if}}
24
34
  runs-on: $\{{ matrix.platform.os }}
25
35
  defaults:
26
36
  run:
@@ -19,26 +19,21 @@ steps:
19
19
  {{else}}
20
20
  {{> stepsSetupYml }}
21
21
  - name: Check If Published
22
+ env:
23
+ RELEASES: $\{{ inputs.releases }}
22
24
  {{/if}}
23
25
  run: |
24
26
  EXIT_CODE=0
25
27
 
26
- function each_release {
27
- if {{#if publish}}npm publish --provenance --tag="$1"{{else}}npm view "$@" --loglevel=error > /dev/null{{/if}}; then
28
- echo 0
29
- else
30
- echo 1
31
- fi
32
- }
33
-
34
28
  for release in $(echo $RELEASES | jq -r '.[] | @base64'); do
35
29
  {{#if publish}}
36
30
  PUBLISH_TAG=$(echo "$release" | base64 --decode | jq -r .publishTag)
37
- STATUS=$(each_release "$PUBLISH_TAG")
31
+ npm publish --provenance --tag="$PUBLISH_TAG"
38
32
  {{else}}
39
33
  SPEC="$(echo "$release" | base64 --decode | jq -r .pkgName)@$(echo "$release" | base64 --decode | jq -r .version)"
40
- STATUS=$(each_release "$SPEC")
34
+ npm view "$SPEC" --json
41
35
  {{/if}}
36
+ STATUS=$?
42
37
  if [[ "$STATUS" -eq 1 ]]; then
43
38
  EXIT_CODE=$STATUS
44
39
  {{#unless publish}}
@@ -1,5 +1,5 @@
1
1
  - name: Checkout
2
- uses: actions/checkout@v3
2
+ uses: actions/checkout@v4
3
3
  {{#if jobCheckout}}
4
4
  with:
5
5
  {{#each jobCheckout}}
@@ -1,5 +1,5 @@
1
1
  - name: Setup Node
2
- uses: actions/setup-node@v3
2
+ uses: actions/setup-node@v4
3
3
  id: node
4
4
  with:
5
5
  node-version: {{#if jobIsMatrix}}$\{{ matrix.node-version }}{{else}}{{ last ciVersions }}{{/if}}
@@ -15,7 +15,7 @@ runs:
15
15
  using: "composite"
16
16
  steps:
17
17
  - name: Get Workflow Job
18
- uses: actions/github-script@v6
18
+ uses: actions/github-script@v7
19
19
  id: workflow
20
20
  env:
21
21
  JOB_NAME: "$\{{ inputs.name }}"
@@ -27,7 +27,7 @@ jobs:
27
27
  {{> stepLintYml jobRunFlags=allFlags }}
28
28
  - name: Conclude Check
29
29
  uses: LouisBrunner/checks-action@v1.6.0
30
- if: always()
30
+ if: steps.create-check.outputs.check-id && always()
31
31
  with:
32
32
  token: $\{{ secrets.GITHUB_TOKEN }}
33
33
  conclusion: $\{{ job.status }}
@@ -42,7 +42,7 @@ jobs:
42
42
  {{> stepTestYml jobRunFlags=allFlags }}
43
43
  - name: Conclude Check
44
44
  uses: LouisBrunner/checks-action@v1.6.0
45
- if: always()
45
+ if: steps.create-check.outputs.check-id && always()
46
46
  with:
47
47
  token: $\{{ secrets.GITHUB_TOKEN }}
48
48
  conclusion: $\{{ job.status }}
@@ -9,13 +9,9 @@ const localConfigs = readdir(__dirname)
9
9
  module.exports = {
10
10
  root: true,
11
11
  ignorePatterns: [
12
- 'tap-testdir*/',
13
- {{#each workspaceGlobs}}
12
+ {{#each lintIgnorePaths}}
14
13
  '{{ . }}',
15
14
  {{/each}}
16
- {{#if typescript}}
17
- 'dist/',
18
- {{/if}}
19
15
  ],
20
16
  {{#if typescript}}
21
17
  parser: '@typescript-eslint/parser',
@@ -28,5 +24,8 @@ module.exports = {
28
24
  extends: [
29
25
  '@npmcli',
30
26
  ...localConfigs,
27
+ {{#if prettier}}
28
+ 'prettier',
29
+ {{/if}}
31
30
  ],
32
31
  }
@@ -1,9 +1,6 @@
1
1
  # ignore everything in the root
2
2
  /*
3
- # transient test directories
4
- tap-testdir*/
5
3
 
6
- # keep these
7
4
  {{#each ignorePaths}}
8
5
  {{ . }}
9
6
  {{/each}}
@@ -1,8 +1,8 @@
1
1
  const { name: NAME, version: LATEST_VERSION } = require('../../package.json')
2
2
 
3
- const isPublic = (p) => p.config.isPublic
3
+ const isPublic = p => p.config.isPublic
4
4
 
5
- const sharedRootAdd = (name) => ({
5
+ const sharedRootAdd = name => ({
6
6
  // release
7
7
  '.github/workflows/release.yml': {
8
8
  file: 'release-yml.hbs',
@@ -19,17 +19,17 @@ const sharedRootAdd = (name) => ({
19
19
  '.release-please-manifest.json': {
20
20
  file: 'release-please-manifest-json.hbs',
21
21
  filter: isPublic,
22
- parser: (p) => p.JsonMergeNoComment,
22
+ parser: p => p.JsonMergeNoComment,
23
23
  },
24
24
  'release-please-config.json': {
25
25
  file: 'release-please-config-json.hbs',
26
26
  filter: isPublic,
27
- parser: (p) => p.JsonMergeNoComment,
27
+ parser: p => p.JsonMergeNoComment,
28
28
  },
29
29
  'tsconfig.json': {
30
30
  file: 'tsconfig-json.hbs',
31
- filter: (p) => p.config.typescript,
32
- parser: (p) => p.JsonMergeNoComment,
31
+ filter: p => p.config.typescript,
32
+ parser: p => p.JsonMergeNoComment,
33
33
  },
34
34
  // this lint commits which is only necessary for releases
35
35
  '.github/workflows/pull-request.yml': {
@@ -42,15 +42,15 @@ const sharedRootAdd = (name) => ({
42
42
  // dependabot
43
43
  '.github/dependabot.yml': {
44
44
  file: 'dependabot-yml.hbs',
45
- filter: (p) => p.config.dependabot,
45
+ filter: p => p.config.dependabot,
46
46
  },
47
47
  '.github/workflows/post-dependabot.yml': {
48
48
  file: 'post-dependabot-yml.hbs',
49
- filter: (p) => p.config.dependabot,
49
+ filter: p => p.config.dependabot,
50
50
  },
51
51
  '.github/settings.yml': {
52
52
  file: 'settings-yml.hbs',
53
- filter: (p) => !p.config.isReleaseBranch,
53
+ filter: p => !p.config.isReleaseBranch,
54
54
  },
55
55
  // composite actions
56
56
  '.github/actions/install-latest-npm/action.yml': 'action-install-latest-npm-yml.hbs',
@@ -59,10 +59,10 @@ const sharedRootAdd = (name) => ({
59
59
 
60
60
  const sharedRootRm = () => ({
61
61
  '.github/workflows/pull-request.yml': {
62
- filter: (p) => p.config.allPrivate,
62
+ filter: p => p.config.allPrivate,
63
63
  },
64
64
  '.github/settings.yml': {
65
- filter: (p) => p.config.isReleaseBranch,
65
+ filter: p => p.config.isReleaseBranch,
66
66
  },
67
67
  })
68
68
 
@@ -94,7 +94,15 @@ const rootModule = {
94
94
  add: {
95
95
  '.eslintrc.{{ cjsExt }}': {
96
96
  file: 'eslintrc-js.hbs',
97
- filter: (p) => p.config.eslint,
97
+ filter: p => p.config.eslint,
98
+ },
99
+ '.prettierrc.{{ cjsExt }}': {
100
+ file: 'prettier-js.hbs',
101
+ filter: p => p.config.prettier,
102
+ },
103
+ '.prettierignore': {
104
+ file: 'prettierignore.hbs',
105
+ filter: p => p.config.prettier,
98
106
  },
99
107
  '.gitignore': 'gitignore.hbs',
100
108
  '.npmrc': 'npmrc.hbs',
@@ -103,9 +111,7 @@ const rootModule = {
103
111
  'CONTRIBUTING.md': 'CONTRIBUTING-md.hbs',
104
112
  'package.json': 'package-json.hbs',
105
113
  },
106
- rm: [
107
- '.eslintrc.!({{ cjsExt }}|local.*)',
108
- ],
114
+ rm: ['.eslintrc.!({{ cjsExt }}|local.*)'],
109
115
  }
110
116
 
111
117
  // Changes for each workspace but applied to the root of the repo
@@ -125,16 +131,12 @@ const workspaceModule = {
125
131
  add: {
126
132
  '.eslintrc.{{ cjsExt }}': {
127
133
  file: 'eslintrc-js.hbs',
128
- filter: (p) => p.config.eslint,
134
+ filter: p => p.config.eslint,
129
135
  },
130
136
  '.gitignore': 'gitignore.hbs',
131
137
  'package.json': 'package-json.hbs',
132
138
  },
133
- rm: [
134
- '.npmrc',
135
- '.eslintrc.!({{ cjsExt }}|local.*)',
136
- 'SECURITY.md',
137
- ],
139
+ rm: ['.npmrc', '.eslintrc.!({{ cjsExt }}|local.*)', 'SECURITY.md'],
138
140
  }
139
141
 
140
142
  module.exports = {
@@ -151,10 +153,7 @@ module.exports = {
151
153
  // {{major}} to have the major version being published replaced in the string.
152
154
  defaultPublishTag: 'latest',
153
155
  releaseBranch: 'release/v*',
154
- distPaths: [
155
- 'bin/',
156
- 'lib/',
157
- ],
156
+ distPaths: ['bin/', 'lib/'],
158
157
  allowDistPaths: true,
159
158
  allowPaths: [
160
159
  '/.eslintrc.local.*',
@@ -167,15 +166,21 @@ module.exports = {
167
166
  '/README*',
168
167
  '/LICENSE*',
169
168
  '/CHANGELOG*',
169
+ '/.git-blame-ignore-revs',
170
170
  ],
171
- ignorePaths: [
172
- /* to be provided by consuming package */
171
+ ignorePaths: ['tap-testdir*/'],
172
+ lintIgnorePaths: [
173
+ // can be set by consumer
173
174
  ],
175
+ lintExtensions: ['js', 'cjs', 'ts', 'mjs', 'jsx', 'tsx'],
176
+ formatIgnorePaths: ['tap-snapshots/', 'test/fixtures/**/*.json'],
177
+ formatExtensions: ['js', 'cjs', 'ts', 'mjs', 'jsx', 'tsx', 'json'],
174
178
  ciVersions: {},
175
- latestCiVersion: 20,
179
+ latestCiVersion: 22,
176
180
  lockfile: false,
177
181
  codeowner: '@npm/cli-team',
178
182
  eslint: true,
183
+ prettier: false,
179
184
  publish: false,
180
185
  typescript: false,
181
186
  esm: false,
@@ -191,18 +196,14 @@ module.exports = {
191
196
  'standard',
192
197
  ],
193
198
  requiredPackages: {
194
- devDependencies: [
195
- `${NAME}@${LATEST_VERSION}`,
196
- '@npmcli/eslint-config',
197
- 'tap',
198
- ],
199
+ devDependencies: [`${NAME}@${LATEST_VERSION}`, '@npmcli/eslint-config', 'tap'],
199
200
  },
200
201
  allowedPackages: [],
201
202
  changelogTypes: [
202
- { type: 'feat', section: 'Features', hidden: false, collapse: false },
203
- { type: 'fix', section: 'Bug Fixes', hidden: false, collapse: false },
204
- { type: 'docs', section: 'Documentation', hidden: false, collapse: false },
205
- { type: 'deps', section: 'Dependencies', hidden: false, collapse: false },
206
- { type: 'chore', section: 'Chores', hidden: false, collapse: false },
203
+ { type: 'feat', section: 'Features', hidden: false },
204
+ { type: 'fix', section: 'Bug Fixes', hidden: false },
205
+ { type: 'docs', section: 'Documentation', hidden: false },
206
+ { type: 'deps', section: 'Dependencies', hidden: false },
207
+ { type: 'chore', section: 'Chores', hidden: true },
207
208
  ],
208
209
  }
@@ -3,10 +3,20 @@
3
3
  "files": {{{ json distPaths }}},
4
4
  "type": {{#if esm}}"module"{{else}}{{{ del }}}{{/if}},
5
5
  "scripts": {
6
- "lint": "{{#if eslint}}eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"{{else}}echo linting disabled{{/if}}",
6
+ {{#if eslint}}
7
+ "eslint": "eslint \"**/*.{{{ extGlob lintExtensions }}}\"",
8
+ "lint": "{{ localNpmPath }} run eslint {{~#if prettier}} && {{ localNpmPath }} run prettier -- --check{{/if}}",
9
+ "lintfix": "{{ localNpmPath }} run eslint -- --fix {{~#if prettier}} && {{ localNpmPath }} run prettier -- --write{{/if}}",
10
+ {{#if prettier}}
11
+ "prettier": "prettier \"**/*.{{{ extGlob formatExtensions }}}\"",
12
+ {{/if}}
13
+ {{else}}
14
+ "eslint": {{{ del }}},
15
+ "lint": "echo linting disabled",
16
+ "lintfix": {{{ del }}},
17
+ {{/if}}
7
18
  "postlint": "template-oss-check",
8
19
  "template-oss-apply": "template-oss-apply --force",
9
- "lintfix": "{{ localNpmPath }} run lint -- --fix",
10
20
  "snap": "{{#if typescript}}{{#if tap16}}c8 {{/if}}{{/if}}tap",
11
21
  "test": "{{#if typescript}}{{#if tap16}}c8 {{/if}}{{/if}}tap",
12
22
  "posttest": "{{ localNpmPath }} run lint",
@@ -0,0 +1,6 @@
1
+ const githubConfig = require('@github/prettier-config')
2
+
3
+ module.exports = {
4
+ ...githubConfig,
5
+ bracketSpacing: true,
6
+ }
@@ -0,0 +1,3 @@
1
+ {{#each formatIgnorePaths}}
2
+ {{ . }}
3
+ {{/each}}
@@ -30,7 +30,7 @@ jobs:
30
30
  run: {{ rootNpxPath }} --offline template-oss-release-please --branch="$\{{ github.ref_name }}" --backport="{{ backport }}" --defaultTag="{{ defaultPublishTag }}"
31
31
  - name: Create Release Manager Comment Text
32
32
  if: steps.release.outputs.pr-number
33
- uses: actions/github-script@v6
33
+ uses: actions/github-script@v7
34
34
  id: comment-text
35
35
  with:
36
36
  result-encoding: string
@@ -156,7 +156,7 @@ jobs:
156
156
  {{> jobYml jobName="Post Release - Release" jobIf="needs.release.outputs.releases" jobSkipSetup=true }}
157
157
  - name: Create Release PR Comment Text
158
158
  id: comment-text
159
- uses: actions/github-script@v6
159
+ uses: actions/github-script@v7
160
160
  env:
161
161
  RELEASES: $\{{ needs.release.outputs.releases }}
162
162
  with:
@@ -217,7 +217,7 @@ jobs:
217
217
  - name: Create Release PR Comment Text
218
218
  id: comment-text
219
219
  if: steps.found-comment.outputs.comment-id
220
- uses: actions/github-script@v6
220
+ uses: actions/github-script@v7
221
221
  env:
222
222
  RESULT: $\{{ steps.conclusion.outputs.result }}
223
223
  BODY: $\{{ steps.found-comment.outputs.comment-body }}
package/lib/index.js CHANGED
@@ -4,7 +4,7 @@ const getConfig = require('./config.js')
4
4
  const PackageJson = require('@npmcli/package-json')
5
5
  const mapWorkspaces = require('@npmcli/map-workspaces')
6
6
 
7
- const getPkg = async (path) => {
7
+ const getPkg = async path => {
8
8
  log.verbose('get-pkg', path)
9
9
 
10
10
  const pkgJson = (await PackageJson.load(path)).content
@@ -27,7 +27,7 @@ const getWsPkgs = async (root, rootPkg) => {
27
27
 
28
28
  // Include all by default
29
29
  const { workspaces } = rootPkg.config
30
- const include = (name) => Array.isArray(workspaces) ? workspaces.includes(name) : true
30
+ const include = name => (Array.isArray(workspaces) ? workspaces.includes(name) : true)
31
31
 
32
32
  // Look through all workspaces on the root pkg
33
33
  const rootWorkspaces = await mapWorkspaces({ pkg: rootPkg.pkgJson, cwd: root })
@@ -43,7 +43,7 @@ const getWsPkgs = async (root, rootPkg) => {
43
43
  return wsPkgs
44
44
  }
45
45
 
46
- const getPkgs = async (root) => {
46
+ const getPkgs = async root => {
47
47
  log.verbose('get-pkgs', 'root', root)
48
48
 
49
49
  const rootPkg = await getPkg(root)
@@ -11,7 +11,7 @@ class Changelog {
11
11
  [Changelog.BREAKING]: '⚠️ BREAKING CHANGES',
12
12
  }
13
13
 
14
- constructor ({ version, url, sections }) {
14
+ constructor({ version, url, sections }) {
15
15
  this.#title = `## ${url ? link(version, url) : version} (${formatDate()})`
16
16
  for (const section of sections) {
17
17
  this.#types.add(section.type)
@@ -20,7 +20,7 @@ class Changelog {
20
20
  }
21
21
  }
22
22
 
23
- add (type, ...entries) {
23
+ add(type, ...entries) {
24
24
  if (!this.#types.has(type) || !entries.length) {
25
25
  return
26
26
  }
@@ -28,29 +28,29 @@ class Changelog {
28
28
  this.#entries[type].push(...entries)
29
29
  }
30
30
 
31
- #getEntries (type) {
32
- const section = this.#sections[type]
33
- const entries = this.#entries[type].map(list)
34
- // Ignoring coverage until we use this again
35
- /* istanbul ignore next */
36
- if (section?.collapse) {
37
- entries.unshift('<details><summary>Commits</summary>\n')
38
- entries.push('\n</details>')
39
- }
40
- return entries.join('\n')
31
+ #getEntries(type) {
32
+ return this.#entries[type].map(list).join('\n')
41
33
  }
42
34
 
43
- toString () {
35
+ toString() {
44
36
  const body = [this.#title]
37
+ const includedTypes = []
38
+
45
39
  for (const type of this.#types) {
46
- const title = this.#titles[type]
47
40
  if (this.#entries[type]?.length) {
48
- body.push(
49
- `### ${title}`,
50
- this.#getEntries(type)
51
- )
41
+ includedTypes.push(type)
42
+ body.push(`### ${this.#titles[type]}`, this.#getEntries(type))
52
43
  }
53
44
  }
45
+
46
+ // If every commit is from a hidden section then we return an
47
+ // empty string which will skip the release PR being created.
48
+ // We do this because we don't want PRs opened if they only contain
49
+ // chores but we do want to rebuild existing PRs if chores are added.
50
+ if (includedTypes.every(type => this.#sections[type]?.hidden)) {
51
+ return ''
52
+ }
53
+
54
54
  return body.join('\n\n').trim()
55
55
  }
56
56
  }
@@ -62,7 +62,7 @@ class ChangelogNotes {
62
62
  #graphql
63
63
  #ghUrl
64
64
 
65
- constructor (github) {
65
+ constructor(github) {
66
66
  this.#owner = github.repository.owner
67
67
  this.#repo = github.repository.repo
68
68
  this.#rest = github.octokit.rest
@@ -70,7 +70,7 @@ class ChangelogNotes {
70
70
  this.#ghUrl = makeGitHubUrl(this.#owner, this.#repo)
71
71
  }
72
72
 
73
- async #getAuthorsForCommits (commits) {
73
+ async #getAuthorsForCommits(commits) {
74
74
  const shas = commits
75
75
  .filter(c => c.type !== 'deps')
76
76
  .map(c => c.sha)
@@ -82,7 +82,7 @@ class ChangelogNotes {
82
82
 
83
83
  const authorsByCommit = {}
84
84
  const { repository } = await this.#graphql(
85
- `fragment CommitAuthors on GitObject {
85
+ `fragment CommitAuthors on GitObject {
86
86
  ... on Commit {
87
87
  authors (first:10) {
88
88
  nodes {
@@ -94,23 +94,23 @@ class ChangelogNotes {
94
94
  }
95
95
  query {
96
96
  repository (owner:"${this.#owner}", name:"${this.#repo}") {
97
- ${shas.map((s) => {
97
+ ${shas.map(s => {
98
98
  return `_${s}: object (expression: "${s}") { ...CommitAuthors }`
99
99
  })}
100
100
  }
101
- }`
101
+ }`,
102
102
  )
103
103
  for (const [key, commit] of Object.entries(repository)) {
104
104
  if (commit) {
105
105
  authorsByCommit[key.slice(1)] = commit.authors.nodes
106
- .map((a) => a.user && a.user.login ? `@${a.user.login}` : a.name)
106
+ .map(a => (a.user && a.user.login ? `@${a.user.login}` : a.name))
107
107
  .filter(Boolean)
108
108
  }
109
109
  }
110
110
  return authorsByCommit
111
111
  }
112
112
 
113
- async #getPullRequestNumbersForCommits (commits) {
113
+ async #getPullRequestNumbersForCommits(commits) {
114
114
  const shas = commits
115
115
  .filter(c => !c.pullRequest?.number)
116
116
  .map(c => c.sha)
@@ -122,19 +122,20 @@ class ChangelogNotes {
122
122
 
123
123
  const pullRequestsByCommit = {}
124
124
  for (const sha of shas) {
125
- pullRequestsByCommit[sha] = await this.#rest.repos.listPullRequestsAssociatedWithCommit({
126
- owner: this.#owner,
127
- repo: this.#repo,
128
- commit_sha: sha,
129
- per_page: 1,
130
- })
131
- .then((r) => r.data[0].number)
125
+ pullRequestsByCommit[sha] = await this.#rest.repos
126
+ .listPullRequestsAssociatedWithCommit({
127
+ owner: this.#owner,
128
+ repo: this.#repo,
129
+ commit_sha: sha,
130
+ per_page: 1,
131
+ })
132
+ .then(r => r.data[0].number)
132
133
  .catch(() => null)
133
134
  }
134
135
  return pullRequestsByCommit
135
136
  }
136
137
 
137
- #buildEntry (commit) {
138
+ #buildEntry(commit) {
138
139
  const entry = []
139
140
 
140
141
  if (commit.sha) {
@@ -161,7 +162,7 @@ class ChangelogNotes {
161
162
  return entry.join(' ')
162
163
  }
163
164
 
164
- #filterCommits (commits) {
165
+ #filterCommits(commits) {
165
166
  const filteredCommits = []
166
167
  const keyedDuplicates = {}
167
168
 
@@ -186,8 +187,8 @@ class ChangelogNotes {
186
187
  // Sort all our duplicates so we get the latest verion (by PR number) of each type.
187
188
  // Then flatten so we can put them all back into the changelog
188
189
  const sortedDupes = Object.values(keyedDuplicates)
189
- .filter((items) => Boolean(items.length))
190
- .map((items) => items.sort((a, b) => b.pullRequestNumber - a.pullRequestNumber))
190
+ .filter(items => Boolean(items.length))
191
+ .map(items => items.sort((a, b) => b.pullRequestNumber - a.pullRequestNumber))
191
192
  .flatMap(items => items[0])
192
193
 
193
194
  // This moves them to the bottom of their changelog section which is not
@@ -199,7 +200,7 @@ class ChangelogNotes {
199
200
  return filteredCommits
200
201
  }
201
202
 
202
- async buildNotes (rawCommits, { version, previousTag, currentTag, changelogSections }) {
203
+ async buildNotes(rawCommits, { version, previousTag, currentTag, changelogSections }) {
203
204
  // get authors for commits for each sha
204
205
  const authors = await this.#getAuthorsForCommits(rawCommits)
205
206
 
@@ -208,7 +209,7 @@ class ChangelogNotes {
208
209
  // lookup commits without a pr number and find one if it exists
209
210
  const prNumbers = await this.#getPullRequestNumbersForCommits(rawCommits)
210
211
 
211
- const fullCommits = rawCommits.map((commit) => {
212
+ const fullCommits = rawCommits.map(commit => {
212
213
  commit.authors = authors[commit.sha] ?? []
213
214
  commit.pullRequestNumber = Number(commit.pullRequest?.number ?? prNumbers[commit.sha])
214
215
  return commit
@@ -216,9 +217,7 @@ class ChangelogNotes {
216
217
 
217
218
  const changelog = new Changelog({
218
219
  version,
219
- url: previousTag
220
- ? this.#ghUrl('compare', `${previousTag.toString()}...${currentTag.toString()}`)
221
- : null,
220
+ url: previousTag ? this.#ghUrl('compare', `${previousTag.toString()}...${currentTag.toString()}`) : null,
222
221
  sections: changelogSections,
223
222
  })
224
223
 
@@ -227,9 +226,7 @@ class ChangelogNotes {
227
226
  changelog.add(commit.type, this.#buildEntry(commit))
228
227
 
229
228
  // And breaking changes to its own section
230
- changelog.add(Changelog.BREAKING, ...commit.notes
231
- .filter(n => n.title === 'BREAKING CHANGE')
232
- .map(n => n.text))
229
+ changelog.add(Changelog.BREAKING, ...commit.notes.filter(n => n.title === 'BREAKING CHANGE').map(n => n.text))
233
230
  }
234
231
 
235
232
  return changelog.toString()