@npmcli/template-oss 4.9.0 → 4.10.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/bin/release-manager.js +7 -1
- package/lib/content/_step-node.yml +3 -3
- package/lib/content/index.js +1 -0
- package/lib/content/release.yml +4 -4
- package/lib/release-please/index.js +28 -23
- package/lib/util/parser.js +28 -2
- package/package.json +4 -2
package/bin/release-manager.js
CHANGED
|
@@ -10,13 +10,19 @@ const log = (...logs) => console.error('LOG', ...logs)
|
|
|
10
10
|
const ROOT = process.cwd()
|
|
11
11
|
const pkg = require(join(ROOT, 'package.json'))
|
|
12
12
|
|
|
13
|
+
const args = process.argv.slice(2).reduce((acc, a) => {
|
|
14
|
+
const [k, v] = a.replace(/^--/g, '').split('=')
|
|
15
|
+
acc[k] = v === 'true'
|
|
16
|
+
return acc
|
|
17
|
+
}, {})
|
|
18
|
+
|
|
13
19
|
/* eslint-disable max-len */
|
|
14
20
|
const DEFAULT_RELEASE_PROCESS = `
|
|
15
21
|
1. Checkout the release branch and test
|
|
16
22
|
|
|
17
23
|
\`\`\`sh
|
|
18
24
|
gh pr checkout <PR-NUMBER> --force
|
|
19
|
-
npm
|
|
25
|
+
npm ${args.lockfile ? 'ci' : 'update'}
|
|
20
26
|
npm test
|
|
21
27
|
gh pr checks --watch
|
|
22
28
|
\`\`\`
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
- name: Install npm@7
|
|
21
21
|
if: startsWith(matrix.node-version, '10.')
|
|
22
22
|
run: npm i --prefer-online --no-fund --no-audit -g npm@7
|
|
23
|
-
- name: Install npm@
|
|
23
|
+
- name: Install npm@{{ npmSpec }}
|
|
24
24
|
if: $\{{ !startsWith(matrix.node-version, '10.') }}
|
|
25
25
|
{{else}}
|
|
26
|
-
- name: Install npm@
|
|
26
|
+
- name: Install npm@{{ npmSpec }}
|
|
27
27
|
{{/if}}
|
|
28
|
-
run: npm i --prefer-online --no-fund --no-audit -g npm@
|
|
28
|
+
run: npm i --prefer-online --no-fund --no-audit -g npm@{{ npmSpec }}
|
|
29
29
|
- name: npm Version
|
|
30
30
|
run: npm -v
|
|
31
31
|
{{/if}}
|
package/lib/content/index.js
CHANGED
package/lib/content/release.yml
CHANGED
|
@@ -51,9 +51,9 @@ jobs:
|
|
|
51
51
|
const comments = await github.paginate(github.rest.issues.listComments, issue)
|
|
52
52
|
let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id
|
|
53
53
|
|
|
54
|
-
body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to
|
|
55
|
-
body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`
|
|
56
|
-
body += `To force CI to
|
|
54
|
+
body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to Update This Release\n\n`
|
|
55
|
+
body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`{{ defaultBranch }}\`. `
|
|
56
|
+
body += `To force CI to update this PR, run this command:\n\n`
|
|
57
57
|
body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME}\n\`\`\``
|
|
58
58
|
|
|
59
59
|
if (commentId) {
|
|
@@ -82,7 +82,7 @@ jobs:
|
|
|
82
82
|
RELEASE_COMMENT_ID: $\{{ needs.release.outputs.comment-id }}
|
|
83
83
|
GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
|
|
84
84
|
run: |
|
|
85
|
-
{{ rootNpmPath }} exec --offline -- template-oss-release-manager
|
|
85
|
+
{{ rootNpmPath }} exec --offline -- template-oss-release-manager --lockfile={{ lockfile }}
|
|
86
86
|
{{ rootNpmPath }} run rp-pull-request --ignore-scripts {{~#if allFlags}} {{ allFlags }}{{else}} --if-present{{/if}}
|
|
87
87
|
- name: Commit
|
|
88
88
|
id: commit
|
|
@@ -29,42 +29,47 @@ const main = async ({ repo: fullRepo, token, dryRun, branch, force }) => {
|
|
|
29
29
|
.filter(([k, v]) => k.startsWith('RELEASE_PLEASE_') && v != null)
|
|
30
30
|
.map(([k, v]) => [k.replace('RELEASE_PLEASE_', ''), v])
|
|
31
31
|
|
|
32
|
+
const baseBranch = branch ?? github.repository.defaultBranch
|
|
33
|
+
|
|
32
34
|
const manifest = await RP.Manifest.fromManifest(
|
|
33
35
|
github,
|
|
34
|
-
|
|
36
|
+
baseBranch,
|
|
35
37
|
undefined,
|
|
36
38
|
undefined,
|
|
37
39
|
Object.fromEntries(manifestOverrides)
|
|
38
40
|
)
|
|
39
41
|
|
|
40
|
-
let pullRequests = []
|
|
41
|
-
let allReleases = []
|
|
42
42
|
if (force) {
|
|
43
|
-
|
|
44
|
-
// the release PR from the repo and return it, which will trigger
|
|
45
|
-
// the rest of the steps in the workflow to run
|
|
46
|
-
const prNumber = await github.octokit.issues.listForRepo({
|
|
43
|
+
const { data: releasePrs } = await github.octokit.pulls.list({
|
|
47
44
|
owner,
|
|
48
45
|
repo,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
owner,
|
|
55
|
-
repo,
|
|
56
|
-
pull_number: prNumber,
|
|
57
|
-
}).then(res => [{
|
|
58
|
-
...res.data,
|
|
59
|
-
headBranchName: res.data.head.ref,
|
|
60
|
-
updates: [],
|
|
61
|
-
}])
|
|
46
|
+
head: `release-please--branches--${baseBranch}`,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
if (releasePrs.length !== 1) {
|
|
50
|
+
throw new Error(`Found ${releasePrs.length} matching PRs, expected 1`)
|
|
62
51
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
|
|
53
|
+
const [releasePr] = releasePrs
|
|
54
|
+
const id = process.env.GITHUB_RUN_ID
|
|
55
|
+
? `by https://github.com/${owner}/${repo}/actions/runs/${process.env.GITHUB_RUN_ID}`
|
|
56
|
+
: `manually starting at ${new Date().toJSON()}`
|
|
57
|
+
|
|
58
|
+
// XXX(hack): to get release please to recreate a pull request it needs
|
|
59
|
+
// to have a different body string so we append a message a message that CI
|
|
60
|
+
// is running. This will force release-please to rebase the PR but it
|
|
61
|
+
// wont update the body again, so we only append to it.
|
|
62
|
+
await github.octokit.pulls.update({
|
|
63
|
+
owner,
|
|
64
|
+
repo,
|
|
65
|
+
pull_number: releasePr.number,
|
|
66
|
+
body: `${releasePr.body.trim()}\n- This PR is being recreated ${id}`,
|
|
67
|
+
})
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
const pullRequests = await (dryRun ? manifest.buildPullRequests() : manifest.createPullRequests())
|
|
71
|
+
const allReleases = await (dryRun ? manifest.buildReleases() : manifest.createReleases())
|
|
72
|
+
|
|
68
73
|
// We only ever get a single pull request with our current release-please settings
|
|
69
74
|
const rootPr = pullRequests.filter(Boolean)?.[0]
|
|
70
75
|
if (rootPr?.number) {
|
package/lib/util/parser.js
CHANGED
|
@@ -5,6 +5,7 @@ const NpmPackageJson = require('@npmcli/package-json')
|
|
|
5
5
|
const jsonParse = require('json-parse-even-better-errors')
|
|
6
6
|
const Diff = require('diff')
|
|
7
7
|
const { unset } = require('lodash')
|
|
8
|
+
const ini = require('ini')
|
|
8
9
|
const template = require('./template.js')
|
|
9
10
|
const jsonDiff = require('./json-diff')
|
|
10
11
|
const merge = require('./merge.js')
|
|
@@ -176,9 +177,33 @@ class Js extends Base {
|
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
class Ini extends Base {
|
|
179
|
-
|
|
180
|
-
static types = ['npmrc']
|
|
180
|
+
static types = ['ini']
|
|
181
181
|
comment = (c) => `; ${c}`
|
|
182
|
+
|
|
183
|
+
toString (s) {
|
|
184
|
+
return typeof s === 'string' ? s : ini.stringify(s)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
parse (s) {
|
|
188
|
+
return typeof s === 'string' ? ini.parse(s) : s
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
prepare (s, t) {
|
|
192
|
+
let source = s
|
|
193
|
+
if (typeof this.merge === 'function' && t) {
|
|
194
|
+
source = this.merge(t, s)
|
|
195
|
+
}
|
|
196
|
+
return super.prepare(this.toString(source))
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
diff (t, s) {
|
|
200
|
+
return jsonDiff(this.parse(t), this.parse(s), this.DELETE)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
class IniMerge extends Ini {
|
|
205
|
+
static types = ['npmrc']
|
|
206
|
+
merge = (t, s) => merge(t, s)
|
|
182
207
|
}
|
|
183
208
|
|
|
184
209
|
class Markdown extends Base {
|
|
@@ -314,6 +339,7 @@ const Parsers = {
|
|
|
314
339
|
Gitignore,
|
|
315
340
|
Js,
|
|
316
341
|
Ini,
|
|
342
|
+
IniMerge,
|
|
317
343
|
Markdown,
|
|
318
344
|
Yml,
|
|
319
345
|
YmlMerge,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npmcli/template-oss",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "templated files used in npm CLI team oss projects",
|
|
5
5
|
"main": "lib/content/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"glob": "^8.0.1",
|
|
46
46
|
"handlebars": "^4.7.7",
|
|
47
47
|
"hosted-git-info": "^6.0.0",
|
|
48
|
+
"ini": "^3.0.1",
|
|
48
49
|
"json-parse-even-better-errors": "^3.0.0",
|
|
49
50
|
"just-deep-map-values": "^1.1.1",
|
|
50
51
|
"just-diff": "^5.0.1",
|
|
@@ -75,7 +76,8 @@
|
|
|
75
76
|
"test-ignore": "^(workspace/test-workspace)/"
|
|
76
77
|
},
|
|
77
78
|
"templateOSS": {
|
|
78
|
-
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten."
|
|
79
|
+
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
80
|
+
"npmSpec": "8"
|
|
79
81
|
},
|
|
80
82
|
"engines": {
|
|
81
83
|
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
|