Skip to content

Commit 977736c

Browse files
committed
chore: @npmcli/[email protected]
1 parent 1e54107 commit 977736c

File tree

9 files changed

+235
-347
lines changed

9 files changed

+235
-347
lines changed

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const localConfigs = readdir(__dirname)
1010

1111
module.exports = {
1212
root: true,
13+
ignorePatterns: [
14+
'tap-testdir*/',
15+
],
1316
extends: [
1417
'@npmcli',
1518
...localConfigs,

.github/workflows/audit.yml

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,48 +30,33 @@ jobs:
3030
node-version: 20.x
3131
check-latest: contains('20.x', '.x')
3232

33-
# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
34-
- name: Update Windows npm
35-
if: |
36-
matrix.platform.os == 'windows-latest' && (
37-
startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
38-
)
39-
run: |
40-
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
41-
tar xf npm-7.5.4.tgz
42-
cd package
43-
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
44-
cd ..
45-
rmdir /s /q package
46-
47-
# Start on Node 10 because we dont test on anything lower
48-
- name: Install npm@7 on Node 10
33+
- name: Install Latest npm
4934
shell: bash
50-
if: startsWith(steps.node.outputs.node-version, 'v10.')
51-
id: npm-7
35+
env:
36+
NODE_VERSION: ${{ steps.node.outputs.node-version }}
5237
run: |
53-
npm i --prefer-online --no-fund --no-audit -g npm@7
54-
echo "updated=true" >> "$GITHUB_OUTPUT"
38+
MATCH=""
39+
SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
5540
56-
- name: Install npm@8 on Node 12
57-
shell: bash
58-
if: startsWith(steps.node.outputs.node-version, 'v12.')
59-
id: npm-8
60-
run: |
61-
npm i --prefer-online --no-fund --no-audit -g npm@8
62-
echo "updated=true" >> "$GITHUB_OUTPUT"
41+
echo "node@$NODE_VERSION"
6342
64-
- name: Install npm@9 on Node 14/16/18.0
65-
shell: bash
66-
if: startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
67-
id: npm-9
68-
run: |
69-
npm i --prefer-online --no-fund --no-audit -g npm@9
70-
echo "updated=true" >> "$GITHUB_OUTPUT"
43+
for SPEC in ${SPECS[@]}; do
44+
ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
45+
echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
46+
47+
if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
48+
MATCH=$SPEC
49+
echo "Found compatible version: npm@$MATCH"
50+
break
51+
fi
52+
done
53+
54+
if [ -z $MATCH ]; then
55+
echo "Could not find a compatible version of npm for node@$NODE_VERSION"
56+
exit 1
57+
fi
7158
72-
- name: Install npm@latest on Node
73-
if: ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
74-
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
59+
npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
7560
7661
- name: npm Version
7762
run: npm -v

.github/workflows/ci-release.yml

Lines changed: 47 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -85,48 +85,33 @@ jobs:
8585
node-version: 20.x
8686
check-latest: contains('20.x', '.x')
8787

88-
# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
89-
- name: Update Windows npm
90-
if: |
91-
matrix.platform.os == 'windows-latest' && (
92-
startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
93-
)
94-
run: |
95-
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
96-
tar xf npm-7.5.4.tgz
97-
cd package
98-
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
99-
cd ..
100-
rmdir /s /q package
101-
102-
# Start on Node 10 because we dont test on anything lower
103-
- name: Install npm@7 on Node 10
88+
- name: Install Latest npm
10489
shell: bash
105-
if: startsWith(steps.node.outputs.node-version, 'v10.')
106-
id: npm-7
90+
env:
91+
NODE_VERSION: ${{ steps.node.outputs.node-version }}
10792
run: |
108-
npm i --prefer-online --no-fund --no-audit -g npm@7
109-
echo "updated=true" >> "$GITHUB_OUTPUT"
93+
MATCH=""
94+
SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
11095
111-
- name: Install npm@8 on Node 12
112-
shell: bash
113-
if: startsWith(steps.node.outputs.node-version, 'v12.')
114-
id: npm-8
115-
run: |
116-
npm i --prefer-online --no-fund --no-audit -g npm@8
117-
echo "updated=true" >> "$GITHUB_OUTPUT"
96+
echo "node@$NODE_VERSION"
11897
119-
- name: Install npm@9 on Node 14/16/18.0
120-
shell: bash
121-
if: startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
122-
id: npm-9
123-
run: |
124-
npm i --prefer-online --no-fund --no-audit -g npm@9
125-
echo "updated=true" >> "$GITHUB_OUTPUT"
98+
for SPEC in ${SPECS[@]}; do
99+
ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
100+
echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
126101
127-
- name: Install npm@latest on Node
128-
if: ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
129-
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
102+
if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
103+
MATCH=$SPEC
104+
echo "Found compatible version: npm@$MATCH"
105+
break
106+
fi
107+
done
108+
109+
if [ -z $MATCH ]; then
110+
echo "Could not find a compatible version of npm for node@$NODE_VERSION"
111+
exit 1
112+
fi
113+
114+
npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
130115
131116
- name: npm Version
132117
run: npm -v
@@ -235,7 +220,9 @@ jobs:
235220
- name: Update Windows npm
236221
if: |
237222
matrix.platform.os == 'windows-latest' && (
238-
startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
223+
startsWith(steps.node.outputs.node-version, 'v10.') ||
224+
startsWith(steps.node.outputs.node-version, 'v12.') ||
225+
startsWith(steps.node.outputs.node-version, 'v14.')
239226
)
240227
run: |
241228
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
@@ -245,34 +232,33 @@ jobs:
245232
cd ..
246233
rmdir /s /q package
247234
248-
# Start on Node 10 because we dont test on anything lower
249-
- name: Install npm@7 on Node 10
235+
- name: Install Latest npm
250236
shell: bash
251-
if: startsWith(steps.node.outputs.node-version, 'v10.')
252-
id: npm-7
237+
env:
238+
NODE_VERSION: ${{ steps.node.outputs.node-version }}
253239
run: |
254-
npm i --prefer-online --no-fund --no-audit -g npm@7
255-
echo "updated=true" >> "$GITHUB_OUTPUT"
240+
MATCH=""
241+
SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
256242
257-
- name: Install npm@8 on Node 12
258-
shell: bash
259-
if: startsWith(steps.node.outputs.node-version, 'v12.')
260-
id: npm-8
261-
run: |
262-
npm i --prefer-online --no-fund --no-audit -g npm@8
263-
echo "updated=true" >> "$GITHUB_OUTPUT"
243+
echo "node@$NODE_VERSION"
264244
265-
- name: Install npm@9 on Node 14/16/18.0
266-
shell: bash
267-
if: startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
268-
id: npm-9
269-
run: |
270-
npm i --prefer-online --no-fund --no-audit -g npm@9
271-
echo "updated=true" >> "$GITHUB_OUTPUT"
245+
for SPEC in ${SPECS[@]}; do
246+
ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
247+
echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
248+
249+
if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
250+
MATCH=$SPEC
251+
echo "Found compatible version: npm@$MATCH"
252+
break
253+
fi
254+
done
255+
256+
if [ -z $MATCH ]; then
257+
echo "Could not find a compatible version of npm for node@$NODE_VERSION"
258+
exit 1
259+
fi
272260
273-
- name: Install npm@latest on Node
274-
if: ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
275-
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
261+
npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
276262
277263
- name: npm Version
278264
run: npm -v

.github/workflows/ci.yml

Lines changed: 47 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -34,48 +34,33 @@ jobs:
3434
node-version: 20.x
3535
check-latest: contains('20.x', '.x')
3636

37-
# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
38-
- name: Update Windows npm
39-
if: |
40-
matrix.platform.os == 'windows-latest' && (
41-
startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
42-
)
43-
run: |
44-
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
45-
tar xf npm-7.5.4.tgz
46-
cd package
47-
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
48-
cd ..
49-
rmdir /s /q package
50-
51-
# Start on Node 10 because we dont test on anything lower
52-
- name: Install npm@7 on Node 10
37+
- name: Install Latest npm
5338
shell: bash
54-
if: startsWith(steps.node.outputs.node-version, 'v10.')
55-
id: npm-7
39+
env:
40+
NODE_VERSION: ${{ steps.node.outputs.node-version }}
5641
run: |
57-
npm i --prefer-online --no-fund --no-audit -g npm@7
58-
echo "updated=true" >> "$GITHUB_OUTPUT"
42+
MATCH=""
43+
SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
5944
60-
- name: Install npm@8 on Node 12
61-
shell: bash
62-
if: startsWith(steps.node.outputs.node-version, 'v12.')
63-
id: npm-8
64-
run: |
65-
npm i --prefer-online --no-fund --no-audit -g npm@8
66-
echo "updated=true" >> "$GITHUB_OUTPUT"
45+
echo "node@$NODE_VERSION"
6746
68-
- name: Install npm@9 on Node 14/16/18.0
69-
shell: bash
70-
if: startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
71-
id: npm-9
72-
run: |
73-
npm i --prefer-online --no-fund --no-audit -g npm@9
74-
echo "updated=true" >> "$GITHUB_OUTPUT"
47+
for SPEC in ${SPECS[@]}; do
48+
ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
49+
echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
50+
51+
if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
52+
MATCH=$SPEC
53+
echo "Found compatible version: npm@$MATCH"
54+
break
55+
fi
56+
done
57+
58+
if [ -z $MATCH ]; then
59+
echo "Could not find a compatible version of npm for node@$NODE_VERSION"
60+
exit 1
61+
fi
7562
76-
- name: Install npm@latest on Node
77-
if: ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
78-
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
63+
npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
7964
8065
- name: npm Version
8166
run: npm -v
@@ -132,7 +117,9 @@ jobs:
132117
- name: Update Windows npm
133118
if: |
134119
matrix.platform.os == 'windows-latest' && (
135-
startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
120+
startsWith(steps.node.outputs.node-version, 'v10.') ||
121+
startsWith(steps.node.outputs.node-version, 'v12.') ||
122+
startsWith(steps.node.outputs.node-version, 'v14.')
136123
)
137124
run: |
138125
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
@@ -142,34 +129,33 @@ jobs:
142129
cd ..
143130
rmdir /s /q package
144131
145-
# Start on Node 10 because we dont test on anything lower
146-
- name: Install npm@7 on Node 10
132+
- name: Install Latest npm
147133
shell: bash
148-
if: startsWith(steps.node.outputs.node-version, 'v10.')
149-
id: npm-7
134+
env:
135+
NODE_VERSION: ${{ steps.node.outputs.node-version }}
150136
run: |
151-
npm i --prefer-online --no-fund --no-audit -g npm@7
152-
echo "updated=true" >> "$GITHUB_OUTPUT"
137+
MATCH=""
138+
SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
153139
154-
- name: Install npm@8 on Node 12
155-
shell: bash
156-
if: startsWith(steps.node.outputs.node-version, 'v12.')
157-
id: npm-8
158-
run: |
159-
npm i --prefer-online --no-fund --no-audit -g npm@8
160-
echo "updated=true" >> "$GITHUB_OUTPUT"
140+
echo "node@$NODE_VERSION"
161141
162-
- name: Install npm@9 on Node 14/16/18.0
163-
shell: bash
164-
if: startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
165-
id: npm-9
166-
run: |
167-
npm i --prefer-online --no-fund --no-audit -g npm@9
168-
echo "updated=true" >> "$GITHUB_OUTPUT"
142+
for SPEC in ${SPECS[@]}; do
143+
ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
144+
echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
145+
146+
if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
147+
MATCH=$SPEC
148+
echo "Found compatible version: npm@$MATCH"
149+
break
150+
fi
151+
done
152+
153+
if [ -z $MATCH ]; then
154+
echo "Could not find a compatible version of npm for node@$NODE_VERSION"
155+
exit 1
156+
fi
169157
170-
- name: Install npm@latest on Node
171-
if: ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
172-
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
158+
npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
173159
174160
- name: npm Version
175161
run: npm -v

0 commit comments

Comments
 (0)