@npmcli/template-oss 3.5.0 → 3.7.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.
@@ -1,5 +1,4 @@
1
1
  const fs = require('@npmcli/fs')
2
- const { EOL } = require('os')
3
2
  const { join, relative } = require('path')
4
3
 
5
4
  const run = async ({ root, path }) => {
@@ -10,13 +9,13 @@ const run = async ({ root, path }) => {
10
9
 
11
10
  if (await fs.exists(changelog)) {
12
11
  const content = await fs.readFile(changelog, { encoding: 'utf8' })
13
- const mustStart = `# Changelog${EOL}${EOL}#`
14
- if (!content.startsWith(mustStart)) {
12
+ const mustStart = /^#\s+Changelog\r?\n\r?\n#/
13
+ if (!mustStart.test(content)) {
15
14
  return {
16
15
  title: `The ${relative(root, changelog)} is incorrect:`,
17
16
  body: [
18
17
  'The changelog should start with',
19
- `"${mustStart}"`,
18
+ `"# Changelog\n\n#"`,
20
19
  ],
21
20
  solution: 'reformat the changelog to have the correct heading',
22
21
  }
@@ -1,5 +1,4 @@
1
1
  const log = require('proc-log')
2
- const { EOL } = require('os')
3
2
  const { resolve, relative, basename } = require('path')
4
3
  const fs = require('@npmcli/fs')
5
4
  const git = require('@npmcli/git')
@@ -48,7 +47,7 @@ const run = async ({ root, path, config }) => {
48
47
 
49
48
  const ignores = (await fs.readFile(ignoreFile))
50
49
  .toString()
51
- .split(EOL)
50
+ .split(/\r?\n/)
52
51
  .filter((l) => l && !l.trim().startsWith('#'))
53
52
 
54
53
  const relIgnore = relativeToRoot(ignoreFile)
@@ -3,8 +3,8 @@ name: Audit
3
3
  on:
4
4
  workflow_dispatch:
5
5
  schedule:
6
- # "At 01:00 on Monday" https://crontab.guru/#0_1_*_*_1
7
- - cron: "0 1 * * 1"
6
+ # "At 08:00 UTC (01:00 PT) on Monday" https://crontab.guru/#0_8_*_*_1
7
+ - cron: "0 8 * * 1"
8
8
 
9
9
  jobs:
10
10
  audit:
@@ -19,8 +19,8 @@ on:
19
19
  - {{pkgRelPath}}/**
20
20
  {{/if}}
21
21
  schedule:
22
- # "At 02:00 on Monday" https://crontab.guru/#0_2_*_*_1
23
- - cron: "0 2 * * 1"
22
+ # "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1
23
+ - cron: "0 9 * * 1"
24
24
 
25
25
  jobs:
26
26
  lint:
@@ -55,5 +55,7 @@ jobs:
55
55
  steps:
56
56
  {{> setupGit}}
57
57
  {{> setupNode useMatrix=true}}
58
+ - name: add tap problem matcher
59
+ run: echo "::add-matcher::.github/matchers/tap.json"
58
60
  - run: npm i --ignore-scripts --no-audit --no-fund
59
61
  - run: npm test --ignore-scripts {{~#if isWorkspace}} -w {{pkgName}}{{/if}}
@@ -13,8 +13,8 @@ on:
13
13
  - {{.}}
14
14
  {{/each}}
15
15
  schedule:
16
- # "At 03:00 on Monday" https://crontab.guru/#0_3_*_*_1
17
- - cron: "0 3 * * 1"
16
+ # "At 10:00 UTC (03:00 PT) on Monday" https://crontab.guru/#0_10_*_*_1
17
+ - cron: "0 10 * * 1"
18
18
 
19
19
  jobs:
20
20
  analyze:
@@ -1,5 +1,26 @@
1
1
  const { name: NAME, version: LATEST_VERSION } = require('../../package.json')
2
2
 
3
+ const releasePlease = () => ({
4
+ '.github/workflows/release-please.yml': {
5
+ file: 'release-please.yml',
6
+ filter: (o) => !o.pkg.private,
7
+ },
8
+ '.release-please-manifest.json': {
9
+ file: 'release-please-manifest.json',
10
+ filter: (o) => !o.pkg.private,
11
+ parser: (p) => class NoCommentJson extends p.JsonMerge {
12
+ comment = null
13
+ },
14
+ },
15
+ 'release-please-config.json': {
16
+ file: 'release-please-config.json',
17
+ filter: (o) => !o.pkg.private,
18
+ parser: (p) => class NoCommentJson extends p.JsonMerge {
19
+ comment = null
20
+ },
21
+ },
22
+ })
23
+
3
24
  // Changes applied to the root of the repo
4
25
  const rootRepo = {
5
26
  add: {
@@ -9,14 +30,12 @@ const rootRepo = {
9
30
  '.github/ISSUE_TEMPLATE/config.yml': 'config.yml',
10
31
  '.github/CODEOWNERS': 'CODEOWNERS',
11
32
  '.github/dependabot.yml': 'dependabot.yml',
33
+ '.github/matchers/tap.json': 'tap.json',
12
34
  '.github/workflows/audit.yml': 'audit.yml',
13
35
  '.github/workflows/codeql-analysis.yml': 'codeql-analysis.yml',
14
36
  '.github/workflows/post-dependabot.yml': 'post-dependabot.yml',
15
37
  '.github/workflows/pull-request.yml': 'pull-request.yml',
16
- '.github/workflows/release-please.yml': {
17
- file: 'release-please.yml',
18
- filter: (o) => !o.pkg.private,
19
- },
38
+ ...releasePlease(),
20
39
  },
21
40
  }
22
41
 
@@ -42,12 +61,14 @@ const rootModule = {
42
61
  // Changes for each workspace but applied to the root of the repo
43
62
  const workspaceRepo = {
44
63
  add: {
45
- '.github/workflows/release-please-{{pkgNameFs}}.yml': {
46
- file: 'release-please.yml',
47
- filter: (o) => !o.pkg.private,
48
- },
64
+ ...releasePlease(true),
65
+ '.github/matchers/tap.json': 'tap.json',
49
66
  '.github/workflows/ci-{{pkgNameFs}}.yml': 'ci.yml',
50
67
  },
68
+ rm: [
69
+ // These are the old release please files that should be removed now
70
+ '.github/workflows/release-please-{{pkgNameFs}}.yml',
71
+ ],
51
72
  }
52
73
 
53
74
  // Changes for each workspace but applied to the relative workspace dir
@@ -0,0 +1,15 @@
1
+ {
2
+ "separate-pull-requests": true,
3
+ "changelog-sections": [
4
+ {"type":"feat","section":"Features","hidden":false},
5
+ {"type":"fix","section":"Bug Fixes","hidden":false},
6
+ {"type":"docs","section":"Documentation","hidden":false},
7
+ {"type":"deps","section":"Dependencies","hidden":false},
8
+ {"type":"chore","hidden":true}
9
+ ],
10
+ "packages": {
11
+ "{{#unless pkgRelPath}}.{{/unless}}{{pkgRelPath}}": {
12
+ {{#unless pkgRelPath}}"package-name": ""{{/unless}}
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "{{#unless pkgRelPath}}.{{/unless}}{{pkgRelPath}}": "{{pkg.version}}"
3
+ }
@@ -1,56 +1,46 @@
1
- name: Release Please {{~#if isWorkspace}} - {{pkgName}}{{/if}}
1
+ name: Release Please
2
2
 
3
3
  on:
4
4
  push:
5
- {{#if pkgRelPath}}
6
- paths:
7
- - {{pkgRelPath}}/**
8
- {{/if}}
9
5
  branches:
10
6
  {{#each branches}}
11
7
  - {{.}}
12
8
  {{/each}}
13
9
 
14
- {{#if isWorkspace}}
15
10
  permissions:
16
11
  contents: write
17
12
  pull-requests: write
18
- {{/if}}
19
13
 
20
14
  jobs:
21
15
  release-please:
22
16
  runs-on: ubuntu-latest
17
+ outputs:
18
+ prs: $\{{ steps.release.outputs.prs }}
23
19
  steps:
24
20
  - uses: google-github-actions/release-please-action@v3
25
21
  id: release
26
22
  with:
27
- release-type: node
28
- {{#if pkgRelPath}}
29
- monorepo-tags: true
30
- path: {{pkgRelPath}}
31
- # name can be removed after this is merged
32
- # https://github.com/google-github-actions/release-please-action/pull/459
33
- package-name: "{{pkgName}}"
34
- {{/if}}
35
- changelog-types: >
36
- [
37
- {{#each changelogTypes}}
38
- {{{json .}}}{{#unless @last}},{{/unless}}
39
- {{/each}}
40
- ]
41
- {{#if isWorkspace}}
23
+ command: manifest
24
+
25
+ update-prs:
26
+ needs: release-please
27
+ if: needs.release-please.outputs.prs
28
+ runs-on: ubuntu-latest
29
+ strategy:
30
+ matrix:
31
+ pr: $\{{ fromJSON(needs.release-please.outputs.prs) }}
32
+ steps:
42
33
  {{> setupGit}}
43
34
  {{> setupNode}}
44
- - name: Update package-lock.json and commit
45
- if: steps.release.outputs.pr
35
+ - name: Update PR $\{{ matrix.pr.number }} dependencies and commit
46
36
  env:
47
37
  GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
48
38
  run: |
49
- gh pr checkout $\{{ fromJSON(steps.release.outputs.pr).number }}
39
+ gh pr checkout $\{{ matrix.pr.number }}
50
40
  npm run resetdeps
51
- title="$\{{ fromJSON(steps.release.outputs.pr).title }}"
52
- # get the version from the pr title
53
- # get everything after the last space
54
- git commit -am "deps: {{pkgName}}@${title##* }"
41
+ title="$\{{ matrix.pr.title }}"
42
+ # get the dependency spec from the pr title
43
+ # get everything after ': release ' + replace space with @
44
+ dep_spec=$(echo "${title##*: release }" | tr ' ' @)
45
+ git commit -am "deps: $dep_spec"
55
46
  git push
56
- {{/if}}
@@ -0,0 +1,28 @@
1
+ {
2
+ "problemMatcher": [{
3
+ "owner": "tap",
4
+ "pattern" : [
5
+ {
6
+ "regexp": "^\\s*not ok \\d+ - (.*)",
7
+ "message": 1
8
+ },
9
+ {
10
+ "regexp": "^\\s*---"
11
+ },
12
+ {
13
+ "regexp": "^\\s*at:"
14
+ },
15
+ {
16
+ "regexp": "^\\s*line:\\s*(\\d+)",
17
+ "line": 1
18
+ },
19
+ {
20
+ "regexp": "^\\s*column:\\s*(\\d+)",
21
+ "column": 1
22
+ }, {
23
+ "regexp": "^\\s*file:\\s*(.*)",
24
+ "file": 1
25
+ }
26
+ ]
27
+ }]
28
+ }
@@ -18,7 +18,9 @@ const getRepo = async (path) => {
18
18
  const url = new URL(`https://${domain}`)
19
19
  url.pathname = `/${user}/${project}.git`
20
20
  return url.toString()
21
- } catch {}
21
+ } catch {
22
+ // errors are ignored
23
+ }
22
24
  }
23
25
 
24
26
  module.exports = getRepo
@@ -1,5 +1,4 @@
1
1
  const fs = require('@npmcli/fs')
2
- const { EOL } = require('os')
3
2
  const { basename, extname, dirname } = require('path')
4
3
  const yaml = require('yaml')
5
4
  const NpmPackageJson = require('@npmcli/package-json')
@@ -56,7 +55,7 @@ class Base {
56
55
 
57
56
  prepare (s) {
58
57
  const header = this.header()
59
- return header ? header + EOL + EOL + s : s
58
+ return header ? `${header}\n\n${s}` : s
60
59
  }
61
60
 
62
61
  prepareTarget (s) {
@@ -199,7 +198,7 @@ class Json extends Base {
199
198
  comment = (c) => ({ [`//${this.options.config.__NAME__}`]: c })
200
199
 
201
200
  toString (s) {
202
- return JSON.stringify(s, (_, v) => v === this.DELETE ? undefined : v, 2)
201
+ return JSON.stringify(s, (_, v) => v === this.DELETE ? undefined : v, 2).trim() + '\n'
203
202
  }
204
203
 
205
204
  parse (s) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npmcli/template-oss",
3
- "version": "3.5.0",
3
+ "version": "3.7.1",
4
4
  "description": "templated files used in npm CLI team oss projects",
5
5
  "main": "lib/content/index.js",
6
6
  "bin": {
@@ -45,7 +45,7 @@
45
45
  "npm-package-arg": "^9.0.1",
46
46
  "proc-log": "^2.0.0",
47
47
  "semver": "^7.3.5",
48
- "yaml": "^2.0.0-11"
48
+ "yaml": "2.0.0-11"
49
49
  },
50
50
  "files": [
51
51
  "bin/",