Skip to content

Commit f09f754

Browse files
authored
feat!: refactor to use @npmcli/template-oss (#31)
* feat!: refactor to use @npmcli/template-oss * move to index.ts file * disable coverage
1 parent 7f357f4 commit f09f754

36 files changed

+1453
-6313
lines changed

.clang-format

-3
This file was deleted.

.commitlintrc.cjs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* This file is automatically added by @npmcli/template-oss. Do not edit. */
2+
3+
module.exports = {
4+
extends: ['@commitlint/config-conventional'],
5+
rules: {
6+
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'deps', 'chore']],
7+
'header-max-length': [2, 'always', 80],
8+
'subject-case': [0],
9+
'body-max-line-length': [0],
10+
},
11+
}

.eslintignore

-1
This file was deleted.

.eslintrc.cjs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* This file is automatically added by @npmcli/template-oss. Do not edit. */
2+
3+
'use strict'
4+
5+
const { readdirSync: readdir } = require('fs')
6+
7+
const localConfigs = readdir(__dirname)
8+
.filter((file) => file.startsWith('.eslintrc.local.'))
9+
.map((file) => `./${file}`)
10+
11+
module.exports = {
12+
root: true,
13+
ignorePatterns: [
14+
'tap-testdir*/',
15+
'dist/',
16+
],
17+
parser: '@typescript-eslint/parser',
18+
settings: {
19+
'import/resolver': {
20+
typescript: {},
21+
},
22+
},
23+
extends: [
24+
'@npmcli',
25+
...localConfigs,
26+
],
27+
}

.eslintrc.json

-5
This file was deleted.

.github/CODEOWNERS

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
* @npm/cli-team

.github/ISSUE_TEMPLATE/bug.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: Bug
4+
description: File a bug/issue
5+
title: "[BUG] <title>"
6+
labels: [ Bug, Needs Triage ]
7+
8+
body:
9+
- type: checkboxes
10+
attributes:
11+
label: Is there an existing issue for this?
12+
description: Please [search here](./issues) to see if an issue already exists for your problem.
13+
options:
14+
- label: I have searched the existing issues
15+
required: true
16+
- type: textarea
17+
attributes:
18+
label: Current Behavior
19+
description: A clear & concise description of what you're experiencing.
20+
validations:
21+
required: false
22+
- type: textarea
23+
attributes:
24+
label: Expected Behavior
25+
description: A clear & concise description of what you expected to happen.
26+
validations:
27+
required: false
28+
- type: textarea
29+
attributes:
30+
label: Steps To Reproduce
31+
description: Steps to reproduce the behavior.
32+
value: |
33+
1. In this environment...
34+
2. With this config...
35+
3. Run '...'
36+
4. See error...
37+
validations:
38+
required: false
39+
- type: textarea
40+
attributes:
41+
label: Environment
42+
description: |
43+
examples:
44+
- **npm**: 7.6.3
45+
- **Node**: 13.14.0
46+
- **OS**: Ubuntu 20.04
47+
- **platform**: Macbook Pro
48+
value: |
49+
- npm:
50+
- Node:
51+
- OS:
52+
- platform:
53+
validations:
54+
required: false

.github/ISSUE_TEMPLATE/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
blank_issues_enabled: true
+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@v7
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,58 @@
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+
working-directory: ${{ runner.temp }}
33+
run: |
34+
MATCH=""
35+
SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
36+
37+
echo "node@$NODE_VERSION"
38+
39+
for SPEC in ${SPECS[@]}; do
40+
ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
41+
echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
42+
43+
if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
44+
MATCH=$SPEC
45+
echo "Found compatible version: npm@$MATCH"
46+
break
47+
fi
48+
done
49+
50+
if [ -z $MATCH ]; then
51+
echo "Could not find a compatible version of npm for node@$NODE_VERSION"
52+
exit 1
53+
fi
54+
55+
npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
56+
- name: npm Version
57+
shell: bash
58+
run: npm -v

.github/dependabot.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
version: 2
4+
5+
updates:

.github/matchers/tap.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"//@npmcli/template-oss": "This file is automatically added by @npmcli/template-oss. Do not edit.",
3+
"problemMatcher": [
4+
{
5+
"owner": "tap",
6+
"pattern": [
7+
{
8+
"regexp": "^\\s*not ok \\d+ - (.*)",
9+
"message": 1
10+
},
11+
{
12+
"regexp": "^\\s*---"
13+
},
14+
{
15+
"regexp": "^\\s*at:"
16+
},
17+
{
18+
"regexp": "^\\s*line:\\s*(\\d+)",
19+
"line": 1
20+
},
21+
{
22+
"regexp": "^\\s*column:\\s*(\\d+)",
23+
"column": 1
24+
},
25+
{
26+
"regexp": "^\\s*file:\\s*(.*)",
27+
"file": 1
28+
}
29+
]
30+
}
31+
]
32+
}

.github/settings.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
repository:
4+
allow_merge_commit: false
5+
allow_rebase_merge: true
6+
allow_squash_merge: true
7+
squash_merge_commit_title: PR_TITLE
8+
squash_merge_commit_message: PR_BODY
9+
delete_branch_on_merge: true
10+
enable_automated_security_fixes: true
11+
enable_vulnerability_alerts: true
12+
13+
branches:

.github/workflows/audit.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: Audit
4+
5+
on:
6+
workflow_dispatch:
7+
schedule:
8+
# "At 08:00 UTC (01:00 PT) on Monday" https://crontab.guru/#0_8_*_*_1
9+
- cron: "0 8 * * 1"
10+
11+
jobs:
12+
audit:
13+
name: Audit Dependencies
14+
if: github.repository_owner == 'npm'
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
shell: bash
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
- name: Setup Git User
23+
run: |
24+
git config --global user.email "[email protected]"
25+
git config --global user.name "npm CLI robot"
26+
- name: Setup Node
27+
uses: actions/setup-node@v4
28+
id: node
29+
with:
30+
node-version: 22.x
31+
check-latest: contains('22.x', '.x')
32+
- name: Install Latest npm
33+
uses: ./.github/actions/install-latest-npm
34+
with:
35+
node: ${{ steps.node.outputs.node-version }}
36+
- name: Install Dependencies
37+
run: npm i --ignore-scripts --no-audit --no-fund --package-lock
38+
- name: Run Production Audit
39+
run: npm audit --omit=dev
40+
- name: Run Full Audit
41+
run: npm audit --audit-level=none

0 commit comments

Comments
 (0)