@npmcli/template-oss 2.5.1 → 2.6.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/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
- - name: Use Node.js 16.x
24
- uses: actions/setup-node@v2
21
+ - uses: actions/setup-node@v2
25
22
  with:
26
- node-version: 16.x
27
- cache: npm
28
- - name: Install dependencies
29
- run: |
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: ['12.13.0', 12.x, '14.15.0', 14.x, '16.0.0', 16.x]
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: bash
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
- # Checkout the npm/cli repo
59
- - uses: actions/checkout@v2
60
-
61
- # Installs the specific version of Node.js
62
- - name: Use Node.js ${{ matrix.node-version }}
63
- uses: actions/setup-node@v2
64
- with:
65
- node-version: ${{ matrix.node-version }}
66
- cache: npm
67
-
68
- # Run the installer script
69
- - name: Install dependencies
70
- run: |
71
- node ./bin/npm-cli.js install --ignore-scripts --no-audit
72
- node ./bin/npm-cli.js rebuild
73
-
74
- # Run the tests, but not if we're just gonna do coveralls later anyway
75
- - name: Run Tap tests
76
- run: node ./bin/npm-cli.js run -w %%pkgpath%% --ignore-scripts test -- -t600 -Rbase -c
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%%
@@ -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
- - run: npm i --prefer-online -g npm@latest
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
@@ -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 (currentVersion === TEMPLATE_VERSION && !isDogfood) {
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.5.1",
3
+ "version": "2.6.0",
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",