@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.
@@ -6,7 +6,7 @@ pull_request:
6
6
  {{/if}}
7
7
  {{#if isRootMono}}
8
8
  paths-ignore:
9
- {{#each workspaceGlob}}
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 workspaceGlob}}
24
+ {{#each workspaceGlobs}}
25
25
  - {{ . }}
26
26
  {{/each}}
27
27
  {{/if}}
@@ -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 }}
@@ -33,7 +33,7 @@
33
33
  "standard": {{{ del }}},
34
34
  "tap": {
35
35
  {{#if workspacePaths}}
36
- "test-ignore": "^({{ join workspacePaths "|" }})/**",
36
+ "test-ignore": "^({{ join workspacePaths "|" }})/",
37
37
  {{/if}}
38
38
  "nyc-arg": [
39
39
  {{#each workspaceGlobs}}
@@ -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 "chore: postinstall for dependabot template-oss PR"
62
+ git commit -am "$\{{ steps.apply.outputs.message }}"
54
63
  git push
55
-
56
- - name: Push All Changes Except Workflows
57
- if: steps.push.outcome == 'failure'
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 "chore: postinstall for dependabot template-oss PR"
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
+
@@ -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 setupHandlebars = (...partialDirs) => {
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
- // Load all files as camelcase partial names.
23
- // all other content dirs only get special underscore leading
24
- // files as partials. this prevents recursion loops when overwriting
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npmcli/template-oss",
3
- "version": "4.3.2",
3
+ "version": "4.4.0",
4
4
  "description": "templated files used in npm CLI team oss projects",
5
5
  "main": "lib/content/index.js",
6
6
  "bin": {