Skip to content

Commit c92869f

Browse files
authored
fix: conform to @npmcli/template-oss (#117)
Updates this repo to use @npmcli/template-oss, with all the linting, CI, etc that goes along with it. Tests were refactored to solely use tap.testdir so that jobs didn't have to be limited to 1. No more collisions, yay.
1 parent 4c30406 commit c92869f

29 files changed

+4962
-2891
lines changed

.eslintrc.js

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

.github/workflows/ci.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- latest
9+
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v2
16+
with:
17+
node-version: '16'
18+
cache: npm
19+
- run: npm i --prefer-online -g npm@latest
20+
- run: npm ci
21+
- run: npm run lint
22+
23+
test:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
node-version: [10.0.x, 10.x, 12.0.x, 12.x, 14.0.x, 14.x, 15.x, 16.x]
28+
platform:
29+
- os: ubuntu-latest
30+
shell: bash
31+
- os: macos-latest
32+
shell: bash
33+
- os: windows-latest
34+
shell: bash
35+
- os: windows-latest
36+
shell: cmd
37+
- os: windows-latest
38+
shell: powershell
39+
runs-on: ${{ matrix.platform.os }}
40+
defaults:
41+
run:
42+
shell: ${{ matrix.platform.shell }}
43+
steps:
44+
- uses: actions/checkout@v2
45+
- uses: actions/setup-node@v2
46+
with:
47+
node-version: ${{ matrix.node-version }}
48+
cache: npm
49+
- run: npm i --prefer-online -g npm@latest
50+
- run: npm ci
51+
- run: npm test --ignore-scripts
52+
- run: npm ls -a

.gitignore

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1-
node_modules/
2-
.eslintrc
3-
.nyc_output
1+
# ignore everything in the root
2+
/*
3+
4+
# keep these
5+
!/.eslintrc*
6+
!/.github
7+
!**/.gitignore
8+
!/package.json
9+
!/package-lock.json
10+
!/bin
11+
!/lib
12+
!/map.js
13+
!/tap-snapshots
14+
!/test
15+
!/README*
16+
!/LICENSE*

.travis.yml

-6
This file was deleted.

LICENSE

-15
This file was deleted.

LICENSE.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
ISC License
2+
3+
Copyright npm, Inc.
4+
5+
Permission to use, copy, modify, and/or distribute this
6+
software for any purpose with or without fee is hereby
7+
granted, provided that the above copyright notice and this
8+
permission notice appear in all copies.
9+
10+
THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
11+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
12+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
13+
EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
14+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
16+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
18+
USE OR PERFORMANCE OF THIS SOFTWARE.

example/example-basic.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ var dir = process.cwd()
33
var initFile = require.resolve('./init/basic-init.js')
44

55
init(dir, initFile, function (err, data) {
6-
if (!err) console.log('written successfully')
6+
if (!err) {
7+
console.log('written successfully')
8+
}
79
})

example/example-default.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ var init = require('../init-package-json.js')
22
var dir = process.cwd()
33

44
init(dir, 'file that does not exist', function (err, data) {
5-
if (!err) console.log('written successfully')
5+
if (!err) {
6+
console.log('written successfully')
7+
}
68
})

example/example-npm.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ var dir = process.cwd()
33
var npm = require('npm')
44

55
npm.load(function (er, npm) {
6-
if (er) throw er
6+
if (er) {
7+
throw er
8+
}
79
init(dir, npm.config.get('init-module'), npm.config, function (er, data) {
8-
if (er) throw er
10+
if (er) {
11+
throw er
12+
}
913
console.log('written successfully')
1014
})
1115
})

example/init/basic-init.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
exports.flavor = prompt("what's your favorite flavor of ice cream buddy?", "I LIKE THEM ALL")
1+
/* eslint-disable no-undef */
2+
exports.flavor = prompt("what's your favorite flavor of ice cream buddy?", 'I LIKE THEM ALL')

0 commit comments

Comments
 (0)