Skip to content

Commit ec4d3a9

Browse files
committed
chore: postinstall for dependabot template-oss PR
1 parent b2c47e3 commit ec4d3a9

13 files changed

+369
-721
lines changed

.eslintrc.js

+3
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,
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: 'Create Check'
4+
inputs:
5+
name:
6+
required: true
7+
token:
8+
required: true
9+
sha:
10+
required: true
11+
check-name:
12+
default: ''
13+
outputs:
14+
check-id:
15+
value: ${{ steps.create-check.outputs.check_id }}
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Get Workflow Job
20+
uses: actions/github-script@v6
21+
id: workflow
22+
env:
23+
JOB_NAME: "${{ inputs.name }}"
24+
SHA: "${{ inputs.sha }}"
25+
with:
26+
result-encoding: string
27+
script: |
28+
const { repo: { owner, repo}, runId, serverUrl } = context
29+
const { JOB_NAME, SHA } = process.env
30+
31+
const job = await github.rest.actions.listJobsForWorkflowRun({
32+
owner,
33+
repo,
34+
run_id: runId,
35+
per_page: 100
36+
}).then(r => r.data.jobs.find(j => j.name.endsWith(JOB_NAME)))
37+
38+
return [
39+
`This check is assosciated with ${serverUrl}/${owner}/${repo}/commit/${SHA}.`,
40+
'Run logs:',
41+
job?.html_url || `could not be found for a job ending with: "${JOB_NAME}"`,
42+
].join(' ')
43+
- name: Create Check
44+
uses: LouisBrunner/[email protected]
45+
id: create-check
46+
with:
47+
token: ${{ inputs.token }}
48+
sha: ${{ inputs.sha }}
49+
status: in_progress
50+
name: ${{ inputs.check-name || inputs.name }}
51+
output: |
52+
{"summary":"${{ steps.workflow.outputs.result }}"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: 'Install Latest npm'
4+
description: 'Install the latest version of npm compatible with the Node version'
5+
inputs:
6+
node:
7+
description: 'Current Node version'
8+
required: true
9+
runs:
10+
using: "composite"
11+
steps:
12+
# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
13+
- name: Update Windows npm
14+
if: |
15+
runner.os == 'Windows' && (
16+
startsWith(inputs.node, 'v10.') ||
17+
startsWith(inputs.node, 'v12.') ||
18+
startsWith(inputs.node, 'v14.')
19+
)
20+
shell: cmd
21+
run: |
22+
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
23+
tar xf npm-7.5.4.tgz
24+
cd package
25+
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
26+
cd ..
27+
rmdir /s /q package
28+
- name: Install Latest npm
29+
shell: bash
30+
env:
31+
NODE_VERSION: ${{ inputs.node }}
32+
run: |
33+
MATCH=""
34+
SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
35+
36+
echo "node@$NODE_VERSION"
37+
38+
for SPEC in ${SPECS[@]}; do
39+
ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
40+
echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
41+
42+
if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
43+
MATCH=$SPEC
44+
echo "Found compatible version: npm@$MATCH"
45+
break
46+
fi
47+
done
48+
49+
if [ -z $MATCH ]; then
50+
echo "Could not find a compatible version of npm for node@$NODE_VERSION"
51+
exit 1
52+
fi
53+
54+
npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
55+
- name: npm Version
56+
shell: bash
57+
run: npm -v

.github/workflows/audit.yml

+4-46
Original file line numberDiff line numberDiff line change
@@ -29,52 +29,10 @@ jobs:
2929
with:
3030
node-version: 20.x
3131
check-latest: contains('20.x', '.x')
32-
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
49-
shell: bash
50-
if: startsWith(steps.node.outputs.node-version, 'v10.')
51-
id: npm-7
52-
run: |
53-
npm i --prefer-online --no-fund --no-audit -g npm@7
54-
echo "updated=true" >> "$GITHUB_OUTPUT"
55-
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"
63-
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"
71-
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
75-
76-
- name: npm Version
77-
run: npm -v
32+
- name: Install Latest npm
33+
uses: ./.github/actions/install-latest-npm
34+
with:
35+
node: ${{ steps.node.outputs.node-version }}
7836
- name: Install Dependencies
7937
run: npm i --ignore-scripts --no-audit --no-fund --package-lock
8038
- name: Run Production Audit

0 commit comments

Comments
 (0)