修改后台权限
This commit is contained in:
1
node_modules/validate-npm-package-name/lib/builtin-modules.json
generated
vendored
Normal file
1
node_modules/validate-npm-package-name/lib/builtin-modules.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
["_http_agent","_http_client","_http_common","_http_incoming","_http_outgoing","_http_server","_stream_duplex","_stream_passthrough","_stream_readable","_stream_transform","_stream_wrap","_stream_writable","_tls_common","_tls_wrap","assert","assert/strict","async_hooks","buffer","child_process","cluster","console","constants","crypto","dgram","diagnostics_channel","dns","dns/promises","domain","events","fs","fs/promises","http","http2","https","inspector","inspector/promises","module","net","os","path","path/posix","path/win32","perf_hooks","process","punycode","querystring","readline","readline/promises","repl","stream","stream/consumers","stream/promises","stream/web","string_decoder","sys","timers","timers/promises","tls","trace_events","tty","url","util","util/types","v8","vm","wasi","worker_threads","zlib","node:sea","node:sqlite","node:test","node:test/reporters"]
|
||||
114
node_modules/validate-npm-package-name/lib/index.js
generated
vendored
Normal file
114
node_modules/validate-npm-package-name/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
'use strict'
|
||||
const builtins = require('./builtin-modules.json')
|
||||
|
||||
var scopedPackagePattern = new RegExp('^(?:@([^/]+?)[/])?([^/]+?)$')
|
||||
var exclusionList = [
|
||||
'node_modules',
|
||||
'favicon.ico',
|
||||
]
|
||||
|
||||
function validate (name) {
|
||||
var warnings = []
|
||||
var errors = []
|
||||
|
||||
if (name === null) {
|
||||
errors.push('name cannot be null')
|
||||
return done(warnings, errors)
|
||||
}
|
||||
|
||||
if (name === undefined) {
|
||||
errors.push('name cannot be undefined')
|
||||
return done(warnings, errors)
|
||||
}
|
||||
|
||||
if (typeof name !== 'string') {
|
||||
errors.push('name must be a string')
|
||||
return done(warnings, errors)
|
||||
}
|
||||
|
||||
if (!name.length) {
|
||||
errors.push('name length must be greater than zero')
|
||||
}
|
||||
|
||||
if (name.startsWith('.')) {
|
||||
errors.push('name cannot start with a period')
|
||||
}
|
||||
|
||||
if (name.startsWith('-')) {
|
||||
errors.push('name cannot start with a hyphen')
|
||||
}
|
||||
|
||||
if (name.match(/^_/)) {
|
||||
errors.push('name cannot start with an underscore')
|
||||
}
|
||||
|
||||
if (name.trim() !== name) {
|
||||
errors.push('name cannot contain leading or trailing spaces')
|
||||
}
|
||||
|
||||
// No funny business
|
||||
exclusionList.forEach(function (excludedName) {
|
||||
if (name.toLowerCase() === excludedName) {
|
||||
errors.push(excludedName + ' is not a valid package name')
|
||||
}
|
||||
})
|
||||
|
||||
// Generate warnings for stuff that used to be allowed
|
||||
|
||||
// core module names like http, events, util, etc
|
||||
if (builtins.includes(name.toLowerCase())) {
|
||||
warnings.push(name + ' is a core module name')
|
||||
}
|
||||
|
||||
if (name.length > 214) {
|
||||
warnings.push('name can no longer contain more than 214 characters')
|
||||
}
|
||||
|
||||
// mIxeD CaSe nAMEs
|
||||
if (name.toLowerCase() !== name) {
|
||||
warnings.push('name can no longer contain capital letters')
|
||||
}
|
||||
|
||||
if (/[~'!()*]/.test(name.split('/').slice(-1)[0])) {
|
||||
warnings.push('name can no longer contain special characters ("~\'!()*")')
|
||||
}
|
||||
|
||||
if (encodeURIComponent(name) !== name) {
|
||||
// Maybe it's a scoped package name, like @user/package
|
||||
var nameMatch = name.match(scopedPackagePattern)
|
||||
if (nameMatch) {
|
||||
var user = nameMatch[1]
|
||||
var pkg = nameMatch[2]
|
||||
|
||||
if (pkg.startsWith('.')) {
|
||||
errors.push('name cannot start with a period')
|
||||
}
|
||||
|
||||
if (encodeURIComponent(user) === user && encodeURIComponent(pkg) === pkg) {
|
||||
return done(warnings, errors)
|
||||
}
|
||||
}
|
||||
|
||||
errors.push('name can only contain URL-friendly characters')
|
||||
}
|
||||
|
||||
return done(warnings, errors)
|
||||
}
|
||||
|
||||
var done = function (warnings, errors) {
|
||||
var result = {
|
||||
validForNewPackages: errors.length === 0 && warnings.length === 0,
|
||||
validForOldPackages: errors.length === 0,
|
||||
warnings: warnings,
|
||||
errors: errors,
|
||||
}
|
||||
if (!result.warnings.length) {
|
||||
delete result.warnings
|
||||
}
|
||||
if (!result.errors.length) {
|
||||
delete result.errors
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = validate
|
||||
Reference in New Issue
Block a user