@npmcli/template-oss 4.3.2 → 4.4.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/lib/content/_on-ci.yml +2 -2
- package/lib/content/ci.yml +9 -0
- package/lib/content/pkg.json +1 -1
- package/lib/content/post-dependabot.yml +33 -5
- package/lib/util/template.js +19 -16
- package/package.json +1 -1
package/lib/content/_on-ci.yml
CHANGED
|
@@ -6,7 +6,7 @@ pull_request:
|
|
|
6
6
|
{{/if}}
|
|
7
7
|
{{#if isRootMono}}
|
|
8
8
|
paths-ignore:
|
|
9
|
-
{{#each
|
|
9
|
+
{{#each workspaceGlobs}}
|
|
10
10
|
- {{ . }}
|
|
11
11
|
{{/each}}
|
|
12
12
|
{{/if}}
|
|
@@ -21,7 +21,7 @@ push:
|
|
|
21
21
|
{{/if}}
|
|
22
22
|
{{#if isRootMono}}
|
|
23
23
|
paths-ignore:
|
|
24
|
-
{{#each
|
|
24
|
+
{{#each workspaceGlobs}}
|
|
25
25
|
- {{ . }}
|
|
26
26
|
{{/each}}
|
|
27
27
|
{{/if}}
|
package/lib/content/ci.yml
CHANGED
|
@@ -4,6 +4,15 @@ on:
|
|
|
4
4
|
{{> onCi }}
|
|
5
5
|
|
|
6
6
|
jobs:
|
|
7
|
+
engines:
|
|
8
|
+
{{> jobMatrix
|
|
9
|
+
jobName="Engines"
|
|
10
|
+
jobDepFlags="--engines-strict"
|
|
11
|
+
macCI=false
|
|
12
|
+
windowsCI=false
|
|
13
|
+
ciVersions=(reject ciVersions '\.x$')
|
|
14
|
+
}}
|
|
15
|
+
|
|
7
16
|
lint:
|
|
8
17
|
{{> job jobName="Lint" }}
|
|
9
18
|
{{> stepLint jobRunFlags=pkgFlags }}
|
package/lib/content/pkg.json
CHANGED
|
@@ -39,6 +39,15 @@ jobs:
|
|
|
39
39
|
if [[ `git status --porcelain` ]]; then
|
|
40
40
|
echo "::set-output name=changes::true"
|
|
41
41
|
fi
|
|
42
|
+
# This only sets the conventional commit prefix. This workflow can't reliably determine
|
|
43
|
+
# what the breaking change is though. If a BREAKING CHANGE message is required then
|
|
44
|
+
# this PR check will fail and the commit will be amended with stafftools
|
|
45
|
+
if [[ "$\{{ steps.dependabot-metadata.outputs.update-type }}" == "version-update:semver-major" ]]; then
|
|
46
|
+
prefix='feat!'
|
|
47
|
+
else
|
|
48
|
+
prefix='chore!'
|
|
49
|
+
fi
|
|
50
|
+
echo "::set-output name=message::$prefix: postinstall for dependabot template-oss PR"
|
|
42
51
|
|
|
43
52
|
# This step will fail if template-oss has made any workflow updates. It is impossible
|
|
44
53
|
# for a workflow to update other workflows. In the case it does fail, we continue
|
|
@@ -50,21 +59,40 @@ jobs:
|
|
|
50
59
|
env:
|
|
51
60
|
GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
|
|
52
61
|
run: |
|
|
53
|
-
git commit -am "
|
|
62
|
+
git commit -am "$\{{ steps.apply.outputs.message }}"
|
|
54
63
|
git push
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
|
|
65
|
+
# If the previous step failed, then reset the commit and remove any workflow changes
|
|
66
|
+
# and attempt to commit and push again. This is helpful because we will have a commit
|
|
67
|
+
# with the correct prefix that we can then --amend with @npmcli/stafftools later.
|
|
68
|
+
- name: Commit and push all changes except workflows
|
|
69
|
+
if: steps.apply.outputs.changes && steps.push-all.outcome == 'failure'
|
|
58
70
|
env:
|
|
59
71
|
GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
|
|
60
72
|
run: |
|
|
61
73
|
git reset HEAD~
|
|
62
74
|
git checkout HEAD -- .github/workflows/
|
|
63
75
|
git clean -fd .github/workflows/
|
|
64
|
-
git commit -am "
|
|
76
|
+
git commit -am "$\{{ steps.apply.outputs.message }}"
|
|
65
77
|
git push
|
|
66
78
|
|
|
79
|
+
# Check if all the necessary template-oss changes were applied. Since we continued
|
|
80
|
+
# on errors in one of the previous steps, this check will fail if our follow up
|
|
81
|
+
# only applied a portion of the changes and we need to followup manually.
|
|
82
|
+
#
|
|
83
|
+
# Note that this used to run `lint` and `postlint` but that will fail this action
|
|
84
|
+
# if we've also shipped any linting changes separate from template-oss. We do
|
|
85
|
+
# linting in another action, so we want to fail this one only if there are
|
|
86
|
+
# template-oss changes that could not be applied.
|
|
67
87
|
- name: Check Changes
|
|
68
88
|
if: steps.apply.outputs.changes
|
|
69
89
|
run: |
|
|
70
90
|
{{ rootNpmPath }} exec --offline $\{{ steps.flags.outputs.workspace }} -- template-oss-check
|
|
91
|
+
|
|
92
|
+
- name: Fail on Breaking Change
|
|
93
|
+
if: steps.apply.outputs.changes && startsWith(steps.apply.outputs.message, 'feat!')
|
|
94
|
+
run: |
|
|
95
|
+
echo "This PR has a breaking change. Run 'npx -p @npmcli/stafftools gh template-oss-fix'"
|
|
96
|
+
echo "for more information on how to fix this with a BREAKING CHANGE footer."
|
|
97
|
+
exit 1
|
|
98
|
+
|
package/lib/util/template.js
CHANGED
|
@@ -10,30 +10,33 @@ const partialName = (s) => basename(s, extname(s)) // remove extension
|
|
|
10
10
|
.replace(/^_/, '') // remove leading underscore
|
|
11
11
|
.replace(/-([a-z])/g, (_, g) => g.toUpperCase()) // camelcase
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const makePartials = (dir, setDefault) => {
|
|
14
|
+
const partials = fs.readdirSync(dir).reduce((acc, f) => {
|
|
15
|
+
const partial = fs.readFileSync(join(dir, f)).toString()
|
|
16
|
+
const name = partialName(f)
|
|
17
|
+
acc[name] = partial
|
|
18
|
+
if (setDefault && f.startsWith('_')) {
|
|
19
|
+
acc[partialName(`default-${name}`)] = partial
|
|
20
|
+
}
|
|
21
|
+
return acc
|
|
22
|
+
}, {})
|
|
23
|
+
|
|
24
|
+
Handlebars.registerPartial(partials)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const setupHandlebars = (baseDir, ...otherDirs) => {
|
|
14
28
|
Handlebars.registerHelper('obj', ({ hash }) => Object.fromEntries(safeValues(hash)))
|
|
15
29
|
Handlebars.registerHelper('join', (arr, sep) => arr.join(typeof sep === 'string' ? sep : ', '))
|
|
16
30
|
Handlebars.registerHelper('pluck', (arr, key) => arr.map(a => a[key]))
|
|
31
|
+
Handlebars.registerHelper('reject', (arr, re) => arr.filter(a => !new RegExp(re).test(a)))
|
|
17
32
|
Handlebars.registerHelper('quote', (arr) => arr.map(a => `'${a}'`))
|
|
18
33
|
Handlebars.registerHelper('last', (arr) => arr[arr.length - 1])
|
|
19
34
|
Handlebars.registerHelper('json', (c) => JSON.stringify(c))
|
|
20
35
|
Handlebars.registerHelper('del', () => JSON.stringify(DELETE))
|
|
21
36
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// a filename to use as a enw file
|
|
26
|
-
let isBase = true
|
|
27
|
-
for (const dir of partialDirs) {
|
|
28
|
-
for (const f of fs.readdirSync(dir)) {
|
|
29
|
-
if (f.startsWith('_') || isBase) {
|
|
30
|
-
Handlebars.registerPartial(
|
|
31
|
-
partialName(f),
|
|
32
|
-
fs.readFileSync(join(dir, f)).toString()
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
isBase = false
|
|
37
|
+
makePartials(baseDir, true)
|
|
38
|
+
for (const dir of otherDirs) {
|
|
39
|
+
makePartials(dir)
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
|