Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
uses: actions/setup-node@v4
id: node
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
node-version: 24.x
check-latest: contains('24.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
uses: actions/setup-node@v4
id: node
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
node-version: 24.x
check-latest: contains('24.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
Expand Down Expand Up @@ -95,6 +95,7 @@ jobs:
- 20.x
- 22.9.0
- 22.x
- 24.x
exclude:
- platform: { name: macOS, os: macos-13, shell: bash }
node-version: 20.17.0
Expand All @@ -104,6 +105,8 @@ jobs:
node-version: 22.9.0
- platform: { name: macOS, os: macos-13, shell: bash }
node-version: 22.x
- platform: { name: macOS, os: macos-13, shell: bash }
node-version: 24.x
runs-on: ${{ matrix.platform.os }}
defaults:
run:
Expand Down Expand Up @@ -137,9 +140,14 @@ jobs:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test (with coverage on Node >= 24)
if: ${{ startsWith(matrix.node-version, '24') }}
run: npm run test:cover --ignore-scripts
- name: Test (on Node 20 with globbing workaround)
if: ${{ startsWith(matrix.node-version, '20') }}
run: npm run test:node20 --ignore-scripts
- name: Test
if: ${{ !startsWith(matrix.node-version, '24') && !startsWith(matrix.node-version, '20') }}
run: npm test --ignore-scripts
- name: Conclude Check
uses: LouisBrunner/[email protected]
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
uses: actions/setup-node@v4
id: node
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
node-version: 24.x
check-latest: contains('24.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
Expand Down Expand Up @@ -71,6 +71,7 @@ jobs:
- 20.x
- 22.9.0
- 22.x
- 24.x
exclude:
- platform: { name: macOS, os: macos-13, shell: bash }
node-version: 20.17.0
Expand All @@ -80,6 +81,8 @@ jobs:
node-version: 22.9.0
- platform: { name: macOS, os: macos-13, shell: bash }
node-version: 22.x
- platform: { name: macOS, os: macos-13, shell: bash }
node-version: 24.x
runs-on: ${{ matrix.platform.os }}
defaults:
run:
Expand All @@ -103,7 +106,12 @@ jobs:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test (with coverage on Node >= 24)
if: ${{ startsWith(matrix.node-version, '24') }}
run: npm run test:cover --ignore-scripts
- name: Test (on Node 20 with globbing workaround)
if: ${{ startsWith(matrix.node-version, '20') }}
run: npm run test:node20 --ignore-scripts
- name: Test
if: ${{ !startsWith(matrix.node-version, '24') && !startsWith(matrix.node-version, '20') }}
run: npm test --ignore-scripts
4 changes: 2 additions & 2 deletions .github/workflows/post-dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
uses: actions/setup-node@v4
id: node
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
node-version: 24.x
check-latest: contains('24.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
uses: actions/setup-node@v4
id: node
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
node-version: 24.x
check-latest: contains('24.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:
uses: actions/setup-node@v4
id: node
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
node-version: 24.x
check-latest: contains('24.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
uses: actions/setup-node@v4
id: node
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
node-version: 24.x
check-latest: contains('24.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
Expand Down Expand Up @@ -119,8 +119,8 @@ jobs:
uses: actions/setup-node@v4
id: node
with:
node-version: 22.x
check-latest: contains('22.x', '.x')
node-version: 24.x
check-latest: contains('24.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
Expand Down
21 changes: 9 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
"main": "lib/index.js",
"devDependencies": {
"@npmcli/eslint-config": "^6.0.0",
"@npmcli/template-oss": "4.28.1",
"tap": "^16.3.2"
"@npmcli/template-oss": "4.28.1"
},
"scripts": {
"test": "tap",
"test": "node --test './test/**/*.js'",
"lint": "npm run eslint",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force",
"lintfix": "npm run eslint -- --fix",
"snap": "tap",
"snap": "node --test --test-update-snapshots './test/**/*.js'",
"posttest": "npm run lint",
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"test:cover": "node --test --experimental-test-coverage --test-timeout=3000 --test-coverage-lines=100 --test-coverage-functions=100 --test-coverage-branches=100 './test/**/*.js'",
"test:node20": "node --test test"
},
"repository": {
"type": "git",
Expand All @@ -39,12 +40,8 @@
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.28.1",
"publish": true
},
"tap": {
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
"publish": true,
"testRunner": "node:test",
"latestCiVersion": 24
}
}
42 changes: 19 additions & 23 deletions test/email.test.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
var test = require('tap').test
var v = require('../').email
const { test } = require('node:test')
const assert = require('node:assert')
const v = require('../').email

test('email misses an @', function (t) {
var err = v('namedomain')
t.type(err, 'object')
t.end()
test('email misses an @', function () {
const err = v('namedomain')
assert.strictEqual(typeof err, 'object')
})

test('email is longer then 254 characters', function (t) {
var str = '@'.repeat(255)
var err = v(str)
t.type(err, 'object')
t.end()
test('email is longer then 254 characters', function () {
const str = '@'.repeat(255)
const err = v(str)
assert.strictEqual(typeof err, 'object')
})

test('email misses a dot', function (t) {
var err = v('name@domain')
t.type(err, 'object')
t.end()
test('email misses a dot', function () {
const err = v('name@domain')
assert.strictEqual(typeof err, 'object')
})

test('email misses a string before the @', function (t) {
var err = v('@domain')
t.type(err, 'object')
t.end()
test('email misses a string before the @', function () {
const err = v('@domain')
assert.strictEqual(typeof err, 'object')
})

test('email is ok', function (t) {
var err = v('[email protected]')
t.type(err, 'null')
t.end()
test('email is ok', function () {
const err = v('[email protected]')
assert.strictEqual(err, null)
})
40 changes: 18 additions & 22 deletions test/pw.test.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
var test = require('tap').test
var v = require('../').pw
const { test } = require('node:test')
const assert = require('node:assert')
const v = require('../').pw

test('pw contains a \'', function (t) {
var err = v('\'')
t.type(err, 'null')
t.end()
test('pw contains a \'', function () {
const err = v('\'')
assert.strictEqual(err, null)
})

test('pw contains a :', function (t) {
var err = v(':')
t.type(err, 'null')
t.end()
test('pw contains a :', function () {
const err = v(':')
assert.strictEqual(err, null)
})

test('pw contains a @', function (t) {
var err = v('@')
t.notOk(err, 'null')
t.end()
test('pw contains a @', function () {
const err = v('@')
assert.strictEqual(err, null)
})

test('pw contains a "', function (t) {
var err = v('"')
t.type(err, 'null')
t.end()
test('pw contains a "', function () {
const err = v('"')
assert.strictEqual(err, null)
})

test('pw is ok', function (t) {
var err = v('duck')
t.type(err, 'null')
t.end()
test('pw is ok', function () {
const err = v('duck')
assert.strictEqual(err, null)
})
64 changes: 29 additions & 35 deletions test/username.test.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
var test = require('tap').test
var v = require('../').username
const { test } = require('node:test')
const assert = require('node:assert')
const v = require('../').username

test('username must be lowercase', function (t) {
var err = v('ERRR')
t.type(err, 'object')
t.match(err.message, /lowercase/)
t.end()
test('username must be lowercase', function () {
const err = v('ERRR')
assert.strictEqual(typeof err, 'object')
assert.match(err.message, /lowercase/)
})

test('username may not contain non-url-safe chars', function (t) {
var err = v('f ')
t.type(err, 'object')
t.match(err.message, /url-safe/)
t.end()
test('username may not contain non-url-safe chars', function () {
const err = v('f ')
assert.strictEqual(typeof err, 'object')
assert.match(err.message, /url-safe/)
})

test('username may not contain illegal characters', function (t) {
var err = v("ben's")
t.type(err, 'object')
t.match(err.message, /illegal character "'"/)
t.end()
test('username may not contain illegal characters', function () {
const err = v("ben's")
assert.strictEqual(typeof err, 'object')
assert.match(err.message, /illegal character "'"/)
})

test('username may not start with "."', function (t) {
var err = v('.username')
t.type(err, 'object')
t.match(err.message, /start with.*\./)
t.end()
test('username may not start with "."', function () {
const err = v('.username')
assert.strictEqual(typeof err, 'object')
assert.match(err.message, /start with.*\./)
})

test('username may not be longer than 214 characters', function (t) {
test('username may not be longer than 214 characters', function () {
// eslint-disable-next-line max-len
var err = v('bacon-ipsum-dolor-amet-tongue-short-loin-landjaeger-tenderloin-ball-tip-pork-loin-porchetta-pig-pork-chop-beef-ribs-pork-belly--shankle-t-bone-turducken-tongue-landjaeger-pork-loin-beef-chicken-short-loin-and-pickle')
t.type(err, 'object')
t.match(err.message, /less than or equal to 214/)
t.end()
const err = v('bacon-ipsum-dolor-amet-tongue-short-loin-landjaeger-tenderloin-ball-tip-pork-loin-porchetta-pig-pork-chop-beef-ribs-pork-belly--shankle-t-bone-turducken-tongue-landjaeger-pork-loin-beef-chicken-short-loin-and-pickle')
assert.strictEqual(typeof err, 'object')
assert.match(err.message, /less than or equal to 214/)
})

test('username may be as long as 214 characters', function (t) {
test('username may be as long as 214 characters', function () {
// eslint-disable-next-line max-len
var err = v('bacon-ipsum-dolor-amet-tongue-short-loin-landjaeger-tenderloin-ball-tip-pork-loin-porchetta-pig-pork-chop-beef-ribs-pork-belly--shankle-t-bone-turducken-tongue-landjaeger-pork-loin-beef-chicken-short-loin-porchetta')
t.type(err, 'null')
t.end()
const err = v('bacon-ipsum-dolor-amet-tongue-short-loin-landjaeger-tenderloin-ball-tip-pork-loin-porchetta-pig-pork-chop-beef-ribs-pork-belly--shankle-t-bone-turducken-tongue-landjaeger-pork-loin-beef-chicken-short-loin-porchetta')
assert.strictEqual(err, null)
})

test('username is ok', function (t) {
var err = v('ente')
t.type(err, 'null')
t.end()
test('username is ok', function () {
const err = v('ente')
assert.strictEqual(err, null)
})