@npmcli/template-oss 4.22.0 → 4.23.1
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/bin/apply.js +2 -5
- package/bin/check.js +2 -4
- package/bin/release-manager.js +1 -1
- package/bin/release-please.js +22 -18
- package/lib/apply/apply-files.js +14 -19
- package/lib/apply/apply-version.js +1 -5
- package/lib/apply/index.js +1 -4
- package/lib/check/check-apply.js +38 -38
- package/lib/check/check-changelog.js +1 -4
- package/lib/check/check-engines.js +5 -6
- package/lib/check/check-gitignore.js +14 -14
- package/lib/check/check-required.js +13 -15
- package/lib/check/check-unwanted.js +2 -3
- package/lib/check/index.js +9 -8
- package/lib/config.js +86 -35
- package/lib/content/SECURITY-md.hbs +1 -1
- package/lib/content/_job-release-integration-yml.hbs +2 -0
- package/lib/content/action-create-check-yml.hbs +1 -1
- package/lib/content/action-install-latest-npm-yml.hbs +1 -1
- package/lib/content/ci-release-yml.hbs +2 -2
- package/lib/content/eslintrc-js.hbs +4 -5
- package/lib/content/gitignore.hbs +0 -3
- package/lib/content/index.js +33 -32
- package/lib/content/package-json.hbs +12 -2
- package/lib/content/post-dependabot-yml.hbs +2 -3
- package/lib/content/prettier-js.hbs +6 -0
- package/lib/content/prettierignore.hbs +3 -0
- package/lib/index.js +3 -3
- package/lib/release/changelog.js +28 -31
- package/lib/release/node-workspace-format.js +12 -12
- package/lib/release/release-manager.js +61 -76
- package/lib/release/release-please.js +50 -58
- package/lib/release/util.js +11 -8
- package/lib/util/ci-versions.js +3 -3
- package/lib/util/dependabot.js +2 -2
- package/lib/util/files.js +25 -22
- package/lib/util/git.js +7 -4
- package/lib/util/gitignore.js +13 -11
- package/lib/util/has-package.js +7 -12
- package/lib/util/import-or-require.js +1 -1
- package/lib/util/json-diff.js +22 -21
- package/lib/util/merge.js +19 -16
- package/lib/util/output.js +8 -5
- package/lib/util/parser.js +77 -70
- package/lib/util/path.js +4 -4
- package/lib/util/template.js +11 -10
- package/package.json +12 -7
|
@@ -23,7 +23,7 @@ runs:
|
|
|
23
23
|
with:
|
|
24
24
|
result-encoding: string
|
|
25
25
|
script: |
|
|
26
|
-
const { repo: { owner, repo}, runId, serverUrl } = context
|
|
26
|
+
const { repo: { owner, repo}, runId, serverUrl } = context
|
|
27
27
|
const { JOB_NAME, SHA } = process.env
|
|
28
28
|
|
|
29
29
|
const job = await github.rest.actions.listJobsForWorkflowRun({
|
|
@@ -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
|
-
|
|
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
|
}
|
package/lib/content/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const { name: NAME, version: LATEST_VERSION } = require('../../package.json')
|
|
2
2
|
|
|
3
|
-
const isPublic =
|
|
3
|
+
const isPublic = p => p.config.isPublic
|
|
4
4
|
|
|
5
|
-
const sharedRootAdd =
|
|
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:
|
|
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:
|
|
27
|
+
parser: p => p.JsonMergeNoComment,
|
|
28
28
|
},
|
|
29
29
|
'tsconfig.json': {
|
|
30
30
|
file: 'tsconfig-json.hbs',
|
|
31
|
-
filter:
|
|
32
|
-
parser:
|
|
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:
|
|
45
|
+
filter: p => p.config.dependabot,
|
|
46
46
|
},
|
|
47
47
|
'.github/workflows/post-dependabot.yml': {
|
|
48
48
|
file: 'post-dependabot-yml.hbs',
|
|
49
|
-
filter:
|
|
49
|
+
filter: p => p.config.dependabot,
|
|
50
50
|
},
|
|
51
51
|
'.github/settings.yml': {
|
|
52
52
|
file: 'settings-yml.hbs',
|
|
53
|
-
filter:
|
|
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:
|
|
62
|
+
filter: p => p.config.allPrivate,
|
|
63
63
|
},
|
|
64
64
|
'.github/settings.yml': {
|
|
65
|
-
filter:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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
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,11 +196,7 @@ 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: [
|
|
@@ -3,10 +3,20 @@
|
|
|
3
3
|
"files": {{{ json distPaths }}},
|
|
4
4
|
"type": {{#if esm}}"module"{{else}}{{{ del }}}{{/if}},
|
|
5
5
|
"scripts": {
|
|
6
|
-
|
|
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",
|
|
@@ -26,7 +26,7 @@ jobs:
|
|
|
26
26
|
id: flags
|
|
27
27
|
run: |
|
|
28
28
|
dependabot_dir="$\{{ steps.metadata.outputs.directory }}"
|
|
29
|
-
if [[ "$dependabot_dir" == "/" ]]; then
|
|
29
|
+
if [[ "$dependabot_dir" == "/" || "$dependabot_dir" == "/{{ releaseBranch }}" ]]; then
|
|
30
30
|
echo "workspace=-iwr" >> $GITHUB_OUTPUT
|
|
31
31
|
else
|
|
32
32
|
# strip leading slash from directory so it works as a
|
|
@@ -64,7 +64,7 @@ jobs:
|
|
|
64
64
|
run: |
|
|
65
65
|
git commit -am "$\{{ steps.apply.outputs.message }}"
|
|
66
66
|
git push
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
# If the previous step failed, then reset the commit and remove any workflow changes
|
|
69
69
|
# and attempt to commit and push again. This is helpful because we will have a commit
|
|
70
70
|
# with the correct prefix that we can then --amend with @npmcli/stafftools later.
|
|
@@ -98,4 +98,3 @@ jobs:
|
|
|
98
98
|
echo "This PR has a breaking change. Run 'npx -p @npmcli/stafftools gh template-oss-fix'"
|
|
99
99
|
echo "for more information on how to fix this with a BREAKING CHANGE footer."
|
|
100
100
|
exit 1
|
|
101
|
-
|
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
|
|
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 =
|
|
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
|
|
46
|
+
const getPkgs = async root => {
|
|
47
47
|
log.verbose('get-pkgs', 'root', root)
|
|
48
48
|
|
|
49
49
|
const rootPkg = await getPkg(root)
|
package/lib/release/changelog.js
CHANGED
|
@@ -11,7 +11,7 @@ class Changelog {
|
|
|
11
11
|
[Changelog.BREAKING]: '⚠️ BREAKING CHANGES',
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
constructor
|
|
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
|
|
23
|
+
add(type, ...entries) {
|
|
24
24
|
if (!this.#types.has(type) || !entries.length) {
|
|
25
25
|
return
|
|
26
26
|
}
|
|
@@ -28,11 +28,11 @@ class Changelog {
|
|
|
28
28
|
this.#entries[type].push(...entries)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
#getEntries
|
|
31
|
+
#getEntries(type) {
|
|
32
32
|
return this.#entries[type].map(list).join('\n')
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
toString
|
|
35
|
+
toString() {
|
|
36
36
|
const body = [this.#title]
|
|
37
37
|
const includedTypes = []
|
|
38
38
|
|
|
@@ -47,7 +47,7 @@ class Changelog {
|
|
|
47
47
|
// empty string which will skip the release PR being created.
|
|
48
48
|
// We do this because we don't want PRs opened if they only contain
|
|
49
49
|
// chores but we do want to rebuild existing PRs if chores are added.
|
|
50
|
-
if (includedTypes.every(
|
|
50
|
+
if (includedTypes.every(type => this.#sections[type]?.hidden)) {
|
|
51
51
|
return ''
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -62,7 +62,7 @@ class ChangelogNotes {
|
|
|
62
62
|
#graphql
|
|
63
63
|
#ghUrl
|
|
64
64
|
|
|
65
|
-
constructor
|
|
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
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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
|
|
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
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
|
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
|
|
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(
|
|
190
|
-
.map(
|
|
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
|
|
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(
|
|
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()
|
|
@@ -12,7 +12,7 @@ module.exports = class extends ManifestPlugin {
|
|
|
12
12
|
#releasesByPackage = new Map()
|
|
13
13
|
#pathsByComponent = new Map()
|
|
14
14
|
|
|
15
|
-
async preconfigure
|
|
15
|
+
async preconfigure(strategiesByPath) {
|
|
16
16
|
// First build a list of all releases that will happen based on
|
|
17
17
|
// the conventional commits
|
|
18
18
|
for (const path in strategiesByPath) {
|
|
@@ -25,17 +25,19 @@ module.exports = class extends ManifestPlugin {
|
|
|
25
25
|
return strategiesByPath
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
run
|
|
28
|
+
run(candidates) {
|
|
29
29
|
this.#rewriteWorkspaceChangelogItems(candidates)
|
|
30
30
|
this.#sortReleases(candidates)
|
|
31
31
|
return candidates
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
#replaceWorkspace
|
|
34
|
+
#replaceWorkspace({ name, versionRange }) {
|
|
35
35
|
const version = versionRange.replace(/^[\^~]/, '')
|
|
36
36
|
const { path, component } = this.#releasesByPackage.get(name)
|
|
37
37
|
const { tagSeparator, includeVInTag } = this.repositoryConfig[path]
|
|
38
|
-
const {
|
|
38
|
+
const {
|
|
39
|
+
repository: { owner, repo },
|
|
40
|
+
} = this.github
|
|
39
41
|
const tag = new TagName(version, component, tagSeparator, includeVInTag).toString()
|
|
40
42
|
const url = `https://github.com/${owner}/${repo}/releases/tag/${tag}`
|
|
41
43
|
return list(`${link('workspace', url)}: ${wrapSpecs(`${name}@${version}`)}`)
|
|
@@ -46,7 +48,7 @@ module.exports = class extends ManifestPlugin {
|
|
|
46
48
|
// be part of the changelog plugin since they are written after that by the
|
|
47
49
|
// node-workspace plugin. A possible PR to release-please could add an option
|
|
48
50
|
// to customize these or run them through the changelog notes generator.
|
|
49
|
-
#rewriteWorkspaceChangelogItems
|
|
51
|
+
#rewriteWorkspaceChangelogItems(candidates) {
|
|
50
52
|
for (const candidate of candidates) {
|
|
51
53
|
for (const release of candidate.pullRequest.body.releaseData) {
|
|
52
54
|
// Update notes with a link to each workspaces release notes
|
|
@@ -57,13 +59,11 @@ module.exports = class extends ManifestPlugin {
|
|
|
57
59
|
.replace(/^\s{2}\* devDependencies\n/gm, '')
|
|
58
60
|
.replace(/^\s{2}\* peerDependencies\n/gm, '')
|
|
59
61
|
.replace(/^\s{2}\* optionalDependencies\n/gm, '')
|
|
60
|
-
.replace(
|
|
61
|
-
|
|
62
|
-
(...args) => this.#replaceWorkspace(args.at(-1))
|
|
62
|
+
.replace(/^\s{4}\* (?<name>[^\s]+) bumped to (?<versionRange>[^\s]+)/gm, (...args) =>
|
|
63
|
+
this.#replaceWorkspace(args.at(-1)),
|
|
63
64
|
)
|
|
64
|
-
.replace(
|
|
65
|
-
|
|
66
|
-
(...args) => this.#replaceWorkspace(args.at(-1))
|
|
65
|
+
.replace(/^\s{4}\* (?<name>[^\s]+) bumped from (?:[^\s]+) to (?<versionRange>[^\s]+)/gm, (...args) =>
|
|
66
|
+
this.#replaceWorkspace(args.at(-1)),
|
|
67
67
|
)
|
|
68
68
|
|
|
69
69
|
// Find the associated changelog and update that too
|
|
@@ -79,7 +79,7 @@ module.exports = class extends ManifestPlugin {
|
|
|
79
79
|
|
|
80
80
|
// Sort root release to the top of the pull request
|
|
81
81
|
// release please pre sorts based on graph order so
|
|
82
|
-
#sortReleases
|
|
82
|
+
#sortReleases(candidates) {
|
|
83
83
|
for (const candidate of candidates) {
|
|
84
84
|
candidate.pullRequest.body.releaseData.sort((a, b) => {
|
|
85
85
|
const aPath = this.#pathsByComponent.get(a.component)
|