@npmcli/template-oss 2.5.0 → 2.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.
- package/README.md +6 -0
- package/lib/config.js +3 -0
- package/lib/content/ci-workspace.yml +26 -39
- package/lib/content/ci.yml +14 -6
- package/lib/content/codeql-analysis.yml +38 -0
- package/lib/content/commitlintrc.js +1 -1
- package/lib/content/dependabot.yml +2 -2
- package/lib/content/post-dependabot.yml +31 -0
- package/lib/content/release-please.yml +1 -1
- package/lib/postinstall/copy-content.js +6 -1
- package/lib/postinstall/update-package.js +5 -1
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -41,6 +41,7 @@ These fields will be set in the project's `package.json`:
|
|
|
41
41
|
lint: `eslint '**/*.js'`,
|
|
42
42
|
postlint: 'npm-template-check',
|
|
43
43
|
lintfix: 'npm run lint -- --fix',
|
|
44
|
+
'template-copy': 'npm-template-copy --force',
|
|
44
45
|
preversion: 'npm test',
|
|
45
46
|
postversion: 'npm publish',
|
|
46
47
|
prepublishOnly: 'git push origin --follow-tags',
|
|
@@ -99,6 +100,11 @@ your new file. The object keys are destination paths, and values are source.
|
|
|
99
100
|
`npm-template-check` is run by `postlint` and will error if the `package.json`
|
|
100
101
|
is not configured properly, with steps to run to correct any problems.
|
|
101
102
|
|
|
103
|
+
### Manual copy
|
|
104
|
+
|
|
105
|
+
Template files will be copied automatically when `template-oss` is updated.
|
|
106
|
+
You can force an update with `npm run template-copy`.
|
|
107
|
+
|
|
102
108
|
#### Extending
|
|
103
109
|
|
|
104
110
|
Add any unwanted packages to `unwantedPackages` in `lib/check.js`. Currently
|
package/lib/config.js
CHANGED
|
@@ -7,6 +7,7 @@ const defaultConfig = {
|
|
|
7
7
|
applyRootModuleFiles: true,
|
|
8
8
|
workspaces: [],
|
|
9
9
|
paths: [],
|
|
10
|
+
force: false,
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
module.exports = async (root) => {
|
|
@@ -44,5 +45,7 @@ module.exports = async (root) => {
|
|
|
44
45
|
|
|
45
46
|
config.paths.push(root)
|
|
46
47
|
|
|
48
|
+
config.force = process.argv.indexOf('--force') !== -1
|
|
49
|
+
|
|
47
50
|
return config
|
|
48
51
|
}
|
|
@@ -4,8 +4,6 @@ on:
|
|
|
4
4
|
pull_request:
|
|
5
5
|
paths:
|
|
6
6
|
- %%pkgpath%%/**
|
|
7
|
-
branches:
|
|
8
|
-
- '*'
|
|
9
7
|
push:
|
|
10
8
|
paths:
|
|
11
9
|
- %%pkgpath%%/**
|
|
@@ -20,57 +18,46 @@ jobs:
|
|
|
20
18
|
steps:
|
|
21
19
|
# Checkout the npm/cli repo
|
|
22
20
|
- uses: actions/checkout@v2
|
|
23
|
-
-
|
|
24
|
-
uses: actions/setup-node@v2
|
|
21
|
+
- uses: actions/setup-node@v2
|
|
25
22
|
with:
|
|
26
|
-
node-version: 16
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
node ./bin/npm-cli.js install --ignore-scripts --no-audit
|
|
31
|
-
node ./bin/npm-cli.js rebuild
|
|
32
|
-
- name: Run linting
|
|
33
|
-
run: node ./bin/npm-cli.js run posttest -w %%pkgpath%%
|
|
34
|
-
env:
|
|
35
|
-
DEPLOY_VERSION: testing
|
|
23
|
+
node-version: '16'
|
|
24
|
+
- run: npm i --prefer-online -g npm@latest
|
|
25
|
+
- run: npm i
|
|
26
|
+
- run: npm run lint -w %%pkgpath%%
|
|
36
27
|
|
|
37
28
|
test:
|
|
38
29
|
strategy:
|
|
39
30
|
fail-fast: false
|
|
40
31
|
matrix:
|
|
41
|
-
node-version: [
|
|
32
|
+
node-version: [12.13.0, 12.x, 14.15.0, 14.x, 16.13.0, 16.x]
|
|
42
33
|
platform:
|
|
43
34
|
- os: ubuntu-latest
|
|
44
35
|
shell: bash
|
|
45
36
|
- os: macos-latest
|
|
46
37
|
shell: bash
|
|
47
38
|
- os: windows-latest
|
|
48
|
-
shell:
|
|
49
|
-
- os: windows-latest
|
|
50
|
-
shell: powershell
|
|
51
|
-
|
|
39
|
+
shell: cmd
|
|
52
40
|
runs-on: ${{ matrix.platform.os }}
|
|
53
41
|
defaults:
|
|
54
42
|
run:
|
|
55
43
|
shell: ${{ matrix.platform.shell }}
|
|
56
|
-
|
|
57
44
|
steps:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
run:
|
|
45
|
+
- uses: actions/checkout@v2
|
|
46
|
+
- uses: actions/setup-node@v2
|
|
47
|
+
with:
|
|
48
|
+
node-version: ${{ matrix.node-version }}
|
|
49
|
+
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
|
|
50
|
+
- name: Update to workable npm (windows)
|
|
51
|
+
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12') || startsWith(matrix.node-version, '14'))
|
|
52
|
+
run: |
|
|
53
|
+
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
|
|
54
|
+
tar xf npm-7.5.4.tgz
|
|
55
|
+
cd package
|
|
56
|
+
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
|
|
57
|
+
cd ..
|
|
58
|
+
rmdir /s /q package
|
|
59
|
+
- name: Update npm
|
|
60
|
+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
|
|
61
|
+
- run: npm -v
|
|
62
|
+
- run: npm i
|
|
63
|
+
- run: npm test --ignore-scripts -w %%pkgpath%%
|
package/lib/content/ci.yml
CHANGED
|
@@ -9,7 +9,7 @@ on:
|
|
|
9
9
|
- main
|
|
10
10
|
- latest
|
|
11
11
|
schedule:
|
|
12
|
-
# "At 02:00 on Monday" https://crontab.guru/#
|
|
12
|
+
# "At 02:00 on Monday" https://crontab.guru/#0_2_*_*_1
|
|
13
13
|
- cron: "0 2 * * 1"
|
|
14
14
|
|
|
15
15
|
jobs:
|
|
@@ -34,12 +34,8 @@ jobs:
|
|
|
34
34
|
shell: bash
|
|
35
35
|
- os: macos-latest
|
|
36
36
|
shell: bash
|
|
37
|
-
- os: windows-latest
|
|
38
|
-
shell: bash
|
|
39
37
|
- os: windows-latest
|
|
40
38
|
shell: cmd
|
|
41
|
-
- os: windows-latest
|
|
42
|
-
shell: powershell
|
|
43
39
|
runs-on: ${{ matrix.platform.os }}
|
|
44
40
|
defaults:
|
|
45
41
|
run:
|
|
@@ -49,6 +45,18 @@ jobs:
|
|
|
49
45
|
- uses: actions/setup-node@v2
|
|
50
46
|
with:
|
|
51
47
|
node-version: ${{ matrix.node-version }}
|
|
52
|
-
|
|
48
|
+
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
|
|
49
|
+
- name: Update to workable npm (windows)
|
|
50
|
+
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12') || startsWith(matrix.node-version, '14'))
|
|
51
|
+
run: |
|
|
52
|
+
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
|
|
53
|
+
tar xf npm-7.5.4.tgz
|
|
54
|
+
cd package
|
|
55
|
+
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
|
|
56
|
+
cd ..
|
|
57
|
+
rmdir /s /q package
|
|
58
|
+
- name: Update npm
|
|
59
|
+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
|
|
60
|
+
- run: npm -v
|
|
53
61
|
- run: npm i
|
|
54
62
|
- run: npm test --ignore-scripts
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# This file is automatically added by @npmcli/template-oss. Do not edit.
|
|
2
|
+
|
|
3
|
+
name: "CodeQL"
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
pull_request:
|
|
9
|
+
# The branches below must be a subset of the branches above
|
|
10
|
+
branches: [ main ]
|
|
11
|
+
schedule:
|
|
12
|
+
# "At 03:00 on Monday" https://crontab.guru/#0_3_*_*_1
|
|
13
|
+
- cron: "0 3 * * 1"
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
analyze:
|
|
17
|
+
name: Analyze
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
permissions:
|
|
20
|
+
actions: read
|
|
21
|
+
contents: read
|
|
22
|
+
security-events: write
|
|
23
|
+
|
|
24
|
+
strategy:
|
|
25
|
+
fail-fast: false
|
|
26
|
+
matrix:
|
|
27
|
+
language: [ 'javascript' ]
|
|
28
|
+
|
|
29
|
+
steps:
|
|
30
|
+
- name: Checkout repository
|
|
31
|
+
uses: actions/checkout@v2
|
|
32
|
+
|
|
33
|
+
- name: Initialize CodeQL
|
|
34
|
+
uses: github/codeql-action/init@v1
|
|
35
|
+
with:
|
|
36
|
+
languages: ${{ matrix.language }}
|
|
37
|
+
- name: Perform CodeQL Analysis
|
|
38
|
+
uses: github/codeql-action/analyze@v1
|
|
@@ -6,6 +6,6 @@ module.exports = {
|
|
|
6
6
|
rules: {
|
|
7
7
|
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'chore', 'deps']],
|
|
8
8
|
'header-max-length': [2, 'always', 80],
|
|
9
|
-
'subject-case': [
|
|
9
|
+
'subject-case': [0, 'always', ['lower-case', 'sentence-case', 'start-case']],
|
|
10
10
|
},
|
|
11
11
|
}
|
|
@@ -8,9 +8,9 @@ updates:
|
|
|
8
8
|
interval: daily
|
|
9
9
|
allow:
|
|
10
10
|
- dependency-type: direct
|
|
11
|
-
versioning-strategy: increase
|
|
11
|
+
versioning-strategy: increase
|
|
12
12
|
commit-message:
|
|
13
13
|
prefix: deps
|
|
14
14
|
prefix-development: chore
|
|
15
15
|
labels:
|
|
16
|
-
- "
|
|
16
|
+
- "Dependencies"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# This file is automatically added by @npmcli/template-oss. Do not edit.
|
|
2
|
+
|
|
3
|
+
name: "Post Dependabot Actions"
|
|
4
|
+
on: pull_request
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
Install:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
if: ${{ github.actor == 'dependabot[bot]' }}
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v2
|
|
12
|
+
- uses: actions/setup-node@v2
|
|
13
|
+
with:
|
|
14
|
+
node-version: '16'
|
|
15
|
+
- name: Dependabot metadata
|
|
16
|
+
id: metadata
|
|
17
|
+
uses: dependabot/fetch-metadata@v1.1.1
|
|
18
|
+
with:
|
|
19
|
+
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
20
|
+
- name: npm install and commit
|
|
21
|
+
if: ${{contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')}}
|
|
22
|
+
env:
|
|
23
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
24
|
+
run: |
|
|
25
|
+
git config --local user.email "ops+npm-cli@npmjs.com"
|
|
26
|
+
git config --local user.name "npm cli ops bot"
|
|
27
|
+
gh pr checkout ${{ github.event.pull_request.number }}
|
|
28
|
+
npm install
|
|
29
|
+
git add .
|
|
30
|
+
git commit -am "chore: postinstall for dependabot template-oss PR"
|
|
31
|
+
git push origin ${{github.ref_name}}
|
|
@@ -21,5 +21,5 @@ jobs:
|
|
|
21
21
|
[{"type":"feat","section":"Features","hidden":false},
|
|
22
22
|
{"type":"fix","section":"Bug Fixes","hidden":false},
|
|
23
23
|
{"type":"docs","section":"Documentation","hidden":false},
|
|
24
|
-
{"type":"deps","section":"
|
|
24
|
+
{"type":"deps","section":"Dependencies","hidden":false},
|
|
25
25
|
{"type":"chore","hidden":true}]
|
|
@@ -21,6 +21,8 @@ const repoFiles = {
|
|
|
21
21
|
'.github/CODEOWNERS': './CODEOWNERS',
|
|
22
22
|
'.github/dependabot.yml': './dependabot.yml',
|
|
23
23
|
'.github/workflows/audit.yml': './audit.yml',
|
|
24
|
+
'.github/workflows/codeql-analysis.yml': './codeql-analysis.yml',
|
|
25
|
+
'.github/workflows/post-dependabot.yml': './post-dependabot.yml',
|
|
24
26
|
'.github/workflows/pull-request.yml': './pull-request.yml',
|
|
25
27
|
'.github/workflows/release-please.yml': './release-please.yml',
|
|
26
28
|
}
|
|
@@ -81,7 +83,10 @@ const copyContent = async (path, rootPath, config) => {
|
|
|
81
83
|
await copyFiles(rootPath, repoFiles)
|
|
82
84
|
if (!config.windowsCI) {
|
|
83
85
|
// copyFiles already did the mkdir so we can just fs.copyFile now
|
|
84
|
-
await fs.copyFile(
|
|
86
|
+
await fs.copyFile(
|
|
87
|
+
join(contentDir, 'ci-no-windows.yml'),
|
|
88
|
+
join(rootPath, '.github', 'workflows', 'ci.yml')
|
|
89
|
+
)
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
return
|
|
@@ -11,6 +11,7 @@ const changes = {
|
|
|
11
11
|
scripts: {
|
|
12
12
|
lint: `eslint '**/*.js'`,
|
|
13
13
|
postlint: 'npm-template-check',
|
|
14
|
+
'template-copy': 'npm-template-copy --force',
|
|
14
15
|
lintfix: 'npm run lint -- --fix',
|
|
15
16
|
preversion: 'npm test',
|
|
16
17
|
postversion: 'npm publish',
|
|
@@ -26,6 +27,7 @@ const changes = {
|
|
|
26
27
|
|
|
27
28
|
const patchPackage = async (path, root, config) => {
|
|
28
29
|
const pkg = await PackageJson.load(path)
|
|
30
|
+
config = config || {}
|
|
29
31
|
|
|
30
32
|
// If we are running this on itself, we always run the script.
|
|
31
33
|
// We also don't set templateVersion in package.json because
|
|
@@ -38,7 +40,9 @@ const patchPackage = async (path, root, config) => {
|
|
|
38
40
|
// if the target package.json has a templateVersion field matching our own
|
|
39
41
|
// current version, we return false here so the postinstall script knows to
|
|
40
42
|
// exit early instead of running everything again
|
|
41
|
-
if (
|
|
43
|
+
if (!config.force
|
|
44
|
+
&& currentVersion === TEMPLATE_VERSION
|
|
45
|
+
&& !isDogfood) {
|
|
42
46
|
return false
|
|
43
47
|
}
|
|
44
48
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npmcli/template-oss",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "templated files used in npm CLI team oss projects",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"npm-template-check": "bin/npm-template-check.js"
|
|
7
|
+
"npm-template-check": "bin/npm-template-check.js",
|
|
8
|
+
"npm-template-copy": "bin/postinstall.js"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
|
10
11
|
"lint": "eslint '**/*.js'",
|
|
@@ -16,7 +17,8 @@
|
|
|
16
17
|
"prepublishOnly": "git push origin --follow-tags",
|
|
17
18
|
"preversion": "npm test",
|
|
18
19
|
"snap": "tap",
|
|
19
|
-
"test": "tap"
|
|
20
|
+
"test": "tap",
|
|
21
|
+
"template-copy": "npm-template-copy --force"
|
|
20
22
|
},
|
|
21
23
|
"repository": {
|
|
22
24
|
"type": "git",
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
"author": "GitHub Inc.",
|
|
30
32
|
"license": "ISC",
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"@npmcli/fs": "^1.
|
|
34
|
+
"@npmcli/fs": "^1.1.0",
|
|
33
35
|
"@npmcli/map-workspaces": "^2.0.0",
|
|
34
36
|
"@npmcli/package-json": "^1.0.1",
|
|
35
37
|
"json-parse-even-better-errors": "^2.3.1",
|
|
@@ -43,7 +45,7 @@
|
|
|
43
45
|
"@npmcli/eslint-config": "*",
|
|
44
46
|
"@npmcli/promise-spawn": "^2.0.0",
|
|
45
47
|
"@npmcli/template-oss": "file:./",
|
|
46
|
-
"eslint": "^8.
|
|
48
|
+
"eslint": "^8.8.0",
|
|
47
49
|
"eslint-plugin-node": "^11.1.0",
|
|
48
50
|
"tap": "*"
|
|
49
51
|
},
|