Skip to content

Commit 7ce491b

Browse files
committed
chore: use @npmcli/template-oss
This adds `@npmcli/template-oss` to manage GitHub Actions, linting, and other chores. This surfaced a few bugs which I opted to fix in separate issues: - #432 - #434
1 parent 9a3064c commit 7ce491b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+680
-8038
lines changed

Diff for: .commitlintrc.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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, 'always', ['lower-case', 'sentence-case', 'start-case']],
9+
},
10+
}

Diff for: .eslintrc.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* This file is automatically added by @npmcli/template-oss. Do not edit. */
2+
3+
const { readdirSync: readdir } = require('fs')
4+
5+
const localConfigs = readdir(__dirname)
6+
.filter((file) => file.startsWith('.eslintrc.local.'))
7+
.map((file) => `./${file}`)
8+
9+
module.exports = {
10+
extends: [
11+
'@npmcli',
12+
...localConfigs,
13+
],
14+
}

Diff for: .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

Diff for: .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

Diff for: .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

Diff for: .github/dependabot.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
version: 2
4+
5+
updates:
6+
- package-ecosystem: npm
7+
directory: "/"
8+
schedule:
9+
interval: daily
10+
allow:
11+
- dependency-type: direct
12+
versioning-strategy: increase-if-necessary
13+
commit-message:
14+
prefix: deps
15+
prefix-development: chore
16+
labels:
17+
- "Dependencies"

Diff for: .github/workflows/audit.yml

+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+
name: Audit
4+
5+
on:
6+
workflow_dispatch:
7+
schedule:
8+
# "At 01:00 on Monday" https://crontab.guru/#0_1_*_*_1
9+
- cron: "0 1 * * 1"
10+
11+
jobs:
12+
audit:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Setup git user
17+
run: |
18+
git config --global user.email "[email protected]"
19+
git config --global user.name "npm cli ops bot"
20+
- uses: actions/setup-node@v3
21+
with:
22+
node-version: 16.x
23+
- name: Update npm to latest
24+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
25+
- run: npm -v
26+
- run: npm i --ignore-scripts --package-lock
27+
- run: npm audit

Diff for: .github/workflows/ci.yml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: CI
4+
5+
on:
6+
workflow_dispatch:
7+
pull_request:
8+
branches:
9+
- '*'
10+
push:
11+
branches:
12+
- main
13+
- latest
14+
schedule:
15+
# "At 02:00 on Monday" https://crontab.guru/#0_2_*_*_1
16+
- cron: "0 2 * * 1"
17+
18+
jobs:
19+
lint:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Setup git user
24+
run: |
25+
git config --global user.email "[email protected]"
26+
git config --global user.name "npm cli ops bot"
27+
- uses: actions/setup-node@v3
28+
with:
29+
node-version: 16.x
30+
- name: Update npm to latest
31+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
32+
- run: npm -v
33+
- run: npm i --ignore-scripts
34+
- run: npm run lint
35+
36+
test:
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
node-version:
41+
- 10.x
42+
- 12.x
43+
- 14.x
44+
- 16.x
45+
platform:
46+
- os: ubuntu-latest
47+
shell: bash
48+
- os: macos-latest
49+
shell: bash
50+
- os: windows-latest
51+
shell: cmd
52+
runs-on: ${{ matrix.platform.os }}
53+
defaults:
54+
run:
55+
shell: ${{ matrix.platform.shell }}
56+
steps:
57+
- uses: actions/checkout@v3
58+
- name: Setup git user
59+
run: |
60+
git config --global user.email "[email protected]"
61+
git config --global user.name "npm cli ops bot"
62+
- uses: actions/setup-node@v3
63+
with:
64+
node-version: ${{ matrix.node-version }}
65+
- name: Update to workable npm (windows)
66+
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
67+
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
68+
run: |
69+
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
70+
tar xf npm-7.5.4.tgz
71+
cd package
72+
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
73+
cd ..
74+
rmdir /s /q package
75+
- name: Update npm to 7
76+
# If we do test on npm 10 it needs npm7
77+
if: startsWith(matrix.node-version, '10.')
78+
run: npm i --prefer-online --no-fund --no-audit -g npm@7
79+
- name: Update npm to latest
80+
if: ${{ !startsWith(matrix.node-version, '10.') }}
81+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
82+
- run: npm -v
83+
- run: npm i --ignore-scripts
84+
- run: npm test --ignore-scripts

Diff for: .github/workflows/codeql-analysis.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: "CodeQL"
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
- latest
10+
pull_request:
11+
# The branches below must be a subset of the branches above
12+
branches:
13+
- main
14+
- latest
15+
schedule:
16+
# "At 03:00 on Monday" https://crontab.guru/#0_3_*_*_1
17+
- cron: "0 3 * * 1"
18+
19+
jobs:
20+
analyze:
21+
name: Analyze
22+
runs-on: ubuntu-latest
23+
permissions:
24+
actions: read
25+
contents: read
26+
security-events: write
27+
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
language: [ javascript ]
32+
33+
steps:
34+
- uses: actions/checkout@v3
35+
- name: Setup git user
36+
run: |
37+
git config --global user.email "[email protected]"
38+
git config --global user.name "npm cli ops bot"
39+
- name: Initialize CodeQL
40+
uses: github/codeql-action/init@v1
41+
with:
42+
languages: ${{ matrix.language }}
43+
- name: Perform CodeQL Analysis
44+
uses: github/codeql-action/analyze@v1

Diff for: .github/workflows/post-dependabot.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: Post Dependabot Actions
4+
5+
on: pull_request
6+
7+
# https://docs.github.com/en/rest/overview/permissions-required-for-github-apps
8+
permissions:
9+
actions: write
10+
contents: write
11+
12+
jobs:
13+
Install:
14+
runs-on: ubuntu-latest
15+
if: github.actor == 'dependabot[bot]'
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Setup git user
19+
run: |
20+
git config --global user.email "[email protected]"
21+
git config --global user.name "npm cli ops bot"
22+
- uses: actions/setup-node@v3
23+
with:
24+
node-version: 16.x
25+
- name: Update npm to latest
26+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
27+
- run: npm -v
28+
- name: Dependabot metadata
29+
id: metadata
30+
uses: dependabot/[email protected]
31+
with:
32+
github-token: "${{ secrets.GITHUB_TOKEN }}"
33+
- name: npm install and commit
34+
if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
gh pr checkout ${{ github.event.pull_request.number }}
39+
npm install --ignore-scripts
40+
npm run template-oss-apply
41+
git add .
42+
git commit -am "chore: postinstall for dependabot template-oss PR"
43+
git push

Diff for: .github/workflows/pull-request.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: Pull Request Linting
4+
5+
on:
6+
pull_request:
7+
types:
8+
- opened
9+
- reopened
10+
- edited
11+
- synchronize
12+
13+
jobs:
14+
check:
15+
name: Check PR Title or Commits
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- name: Setup git user
22+
run: |
23+
git config --global user.email "[email protected]"
24+
git config --global user.name "npm cli ops bot"
25+
- uses: actions/setup-node@v3
26+
with:
27+
node-version: 16.x
28+
- name: Update npm to latest
29+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
30+
- run: npm -v
31+
- name: Install deps
32+
run: npm i -D @commitlint/cli @commitlint/config-conventional
33+
- name: Check commits OR PR title
34+
env:
35+
PR_TITLE: ${{ github.event.pull_request.title }}
36+
run: |
37+
npx --offline commitlint -V --from origin/main --to ${{ github.event.pull_request.head.sha }} \
38+
|| echo $PR_TITLE | npx --offline commitlint -V

Diff for: .github/workflows/release-please.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: Release Please
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
- latest
10+
11+
jobs:
12+
release-please:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: google-github-actions/release-please-action@v3
16+
id: release
17+
with:
18+
release-type: node
19+
changelog-types: >
20+
[
21+
{"type":"feat","section":"Features","hidden":false},
22+
{"type":"fix","section":"Bug Fixes","hidden":false},
23+
{"type":"docs","section":"Documentation","hidden":false},
24+
{"type":"deps","section":"Dependencies","hidden":false},
25+
{"type":"chore","hidden":true}
26+
]

0 commit comments

Comments
 (0)