Skip to content

Commit 6b1fbe1

Browse files
committed
1 parent aa1d486 commit 6b1fbe1

File tree

10 files changed

+173
-213
lines changed

10 files changed

+173
-213
lines changed

node_modules/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
!/npm-package-arg
143143
!/npm-package-arg/node_modules/
144144
/npm-package-arg/node_modules/*
145-
!/npm-package-arg/node_modules/proc-log
145+
!/npm-package-arg/node_modules/validate-npm-package-name
146146
!/npm-packlist
147147
!/npm-pick-manifest
148148
!/npm-profile

node_modules/npm-package-arg/lib/npa.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ function isFileSpec (spec) {
6666
if (isWindows) {
6767
return isWindowsFile.test(spec)
6868
}
69-
// We never hit this in windows tests, obviously
70-
/* istanbul ignore next */
7169
return isPosixFile.test(spec)
7270
}
7371

node_modules/npm-package-arg/node_modules/proc-log/LICENSE

Lines changed: 0 additions & 15 deletions
This file was deleted.

node_modules/npm-package-arg/node_modules/proc-log/lib/index.js

Lines changed: 0 additions & 153 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Copyright (c) 2015, npm, Inc
2+
3+
4+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
5+
6+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
'use strict'
2+
const { builtinModules: builtins } = require('module')
3+
4+
var scopedPackagePattern = new RegExp('^(?:@([^/]+?)[/])?([^/]+?)$')
5+
var exclusionList = [
6+
'node_modules',
7+
'favicon.ico',
8+
]
9+
10+
function validate (name) {
11+
var warnings = []
12+
var errors = []
13+
14+
if (name === null) {
15+
errors.push('name cannot be null')
16+
return done(warnings, errors)
17+
}
18+
19+
if (name === undefined) {
20+
errors.push('name cannot be undefined')
21+
return done(warnings, errors)
22+
}
23+
24+
if (typeof name !== 'string') {
25+
errors.push('name must be a string')
26+
return done(warnings, errors)
27+
}
28+
29+
if (!name.length) {
30+
errors.push('name length must be greater than zero')
31+
}
32+
33+
if (name.startsWith('.')) {
34+
errors.push('name cannot start with a period')
35+
}
36+
37+
if (name.match(/^_/)) {
38+
errors.push('name cannot start with an underscore')
39+
}
40+
41+
if (name.trim() !== name) {
42+
errors.push('name cannot contain leading or trailing spaces')
43+
}
44+
45+
// No funny business
46+
exclusionList.forEach(function (excludedName) {
47+
if (name.toLowerCase() === excludedName) {
48+
errors.push(excludedName + ' is not a valid package name')
49+
}
50+
})
51+
52+
// Generate warnings for stuff that used to be allowed
53+
54+
// core module names like http, events, util, etc
55+
if (builtins.includes(name.toLowerCase())) {
56+
warnings.push(name + ' is a core module name')
57+
}
58+
59+
if (name.length > 214) {
60+
warnings.push('name can no longer contain more than 214 characters')
61+
}
62+
63+
// mIxeD CaSe nAMEs
64+
if (name.toLowerCase() !== name) {
65+
warnings.push('name can no longer contain capital letters')
66+
}
67+
68+
if (/[~'!()*]/.test(name.split('/').slice(-1)[0])) {
69+
warnings.push('name can no longer contain special characters ("~\'!()*")')
70+
}
71+
72+
if (encodeURIComponent(name) !== name) {
73+
// Maybe it's a scoped package name, like @user/package
74+
var nameMatch = name.match(scopedPackagePattern)
75+
if (nameMatch) {
76+
var user = nameMatch[1]
77+
var pkg = nameMatch[2]
78+
79+
if (pkg.startsWith('.')) {
80+
errors.push('name cannot start with a period')
81+
}
82+
83+
if (encodeURIComponent(user) === user && encodeURIComponent(pkg) === pkg) {
84+
return done(warnings, errors)
85+
}
86+
}
87+
88+
errors.push('name can only contain URL-friendly characters')
89+
}
90+
91+
return done(warnings, errors)
92+
}
93+
94+
var done = function (warnings, errors) {
95+
var result = {
96+
validForNewPackages: errors.length === 0 && warnings.length === 0,
97+
validForOldPackages: errors.length === 0,
98+
warnings: warnings,
99+
errors: errors,
100+
}
101+
if (!result.warnings.length) {
102+
delete result.warnings
103+
}
104+
if (!result.errors.length) {
105+
delete result.errors
106+
}
107+
return result
108+
}
109+
110+
module.exports = validate

node_modules/npm-package-arg/node_modules/proc-log/package.json renamed to node_modules/npm-package-arg/node_modules/validate-npm-package-name/package.json

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
11
{
2-
"name": "proc-log",
3-
"version": "5.0.0",
4-
"files": [
5-
"bin/",
6-
"lib/"
7-
],
8-
"main": "lib/index.js",
9-
"description": "just emit 'log' events on the process object",
10-
"repository": {
11-
"type": "git",
12-
"url": "git+https://github.com/npm/proc-log.git"
2+
"name": "validate-npm-package-name",
3+
"version": "7.0.0",
4+
"description": "Give me a string and I'll tell you if it's a valid npm package name",
5+
"main": "lib/",
6+
"directories": {
7+
"test": "test"
8+
},
9+
"devDependencies": {
10+
"@npmcli/eslint-config": "^5.0.0",
11+
"@npmcli/template-oss": "4.27.1",
12+
"tap": "^16.0.1"
1313
},
14-
"author": "GitHub Inc.",
15-
"license": "ISC",
1614
"scripts": {
15+
"cov:test": "TAP_FLAGS='--cov' npm run test:code",
16+
"test:code": "tap ${TAP_FLAGS:-'--'} test/*.js",
17+
"test:style": "standard",
1718
"test": "tap",
18-
"snap": "tap",
19-
"posttest": "npm run lint",
20-
"postsnap": "eslint index.js test/*.js --fix",
2119
"lint": "npm run eslint",
2220
"postlint": "template-oss-check",
23-
"lintfix": "npm run eslint -- --fix",
2421
"template-oss-apply": "template-oss-apply --force",
22+
"lintfix": "npm run eslint -- --fix",
23+
"snap": "tap",
24+
"posttest": "npm run lint",
2525
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
2626
},
27-
"devDependencies": {
28-
"@npmcli/eslint-config": "^5.0.0",
29-
"@npmcli/template-oss": "4.23.3",
30-
"tap": "^16.0.1"
27+
"repository": {
28+
"type": "git",
29+
"url": "git+https://github.com/npm/validate-npm-package-name.git"
3130
},
31+
"keywords": [
32+
"npm",
33+
"package",
34+
"names",
35+
"validation"
36+
],
37+
"author": "GitHub Inc.",
38+
"license": "ISC",
39+
"bugs": {
40+
"url": "https://github.com/npm/validate-npm-package-name/issues"
41+
},
42+
"homepage": "https://github.com/npm/validate-npm-package-name",
43+
"files": [
44+
"bin/",
45+
"lib/"
46+
],
3247
"engines": {
33-
"node": "^18.17.0 || >=20.5.0"
48+
"node": "^20.17.0 || >=22.9.0"
3449
},
3550
"templateOSS": {
3651
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
37-
"version": "4.23.3",
52+
"version": "4.27.1",
3853
"publish": true
3954
},
4055
"tap": {

0 commit comments

Comments
 (0)