Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

deps/validate npm package #4635

Merged
merged 3 commits into from
Mar 30, 2022
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
39 changes: 0 additions & 39 deletions node_modules/builtins/History.md

This file was deleted.

35 changes: 28 additions & 7 deletions node_modules/builtins/Readme.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@

# builtins

List of node.js [builtin modules](http://nodejs.org/api/).
[![CI](https://github.com/juliangruber/builtins/actions/workflows/ci.yml/badge.svg)](https://github.com/juliangruber/builtins/actions/workflows/ci.yml)

List of node.js [builtin modules](http://nodejs.org/api/).

## Usage

```js
const builtins = require('builtins')
```

Get list of core modules for current Node.js version:

```js
assert(builtins().includes('http'))
```

[![build status](https://secure.travis-ci.org/juliangruber/builtins.svg)](http://travis-ci.org/juliangruber/builtins)
Get list of core modules for specific Node.js version:

```js
assert(builtins({ version: '6.0.0' }).includes('http'))
```

## Example
Get list of core modules present in one or mode Node.js versions:

```js
var builtins = require('builtins');
assert(builtins({ version: '*' }).includes('worker_threads'))
```

assert(builtins.indexOf('http') > -1);
Add experimental modules to the list:

```js
assert(builtins({ experimental: true }).includes('wasi'))
```

## License

MIT
MIT
35 changes: 0 additions & 35 deletions node_modules/builtins/builtins.json

This file was deleted.

79 changes: 79 additions & 0 deletions node_modules/builtins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'use strict'

const semver = require('semver')

const permanentModules = [
'assert',
'buffer',
'child_process',
'cluster',
'console',
'constants',
'crypto',
'dgram',
'dns',
'domain',
'events',
'fs',
'http',
'https',
'module',
'net',
'os',
'path',
'punycode',
'querystring',
'readline',
'repl',
'stream',
'string_decoder',
'sys',
'timers',
'tls',
'tty',
'url',
'util',
'vm',
'zlib'
]

const versionLockedModules = {
freelist: '<6.0.0',
v8: '>=1.0.0',
process: '>=1.1.0',
inspector: '>=8.0.0',
async_hooks: '>=8.1.0',
http2: '>=8.4.0',
perf_hooks: '>=8.5.0',
trace_events: '>=10.0.0',
worker_threads: '>=12.0.0'
}

const experimentalModules = {
worker_threads: '>=10.5.0',
wasi: '>=12.16.0',
diagnostics_channel: '^14.17.0 || >=15.1.0'
}

module.exports = ({ version = process.version, experimental = false } = {}) => {
const builtins = [...permanentModules]

for (const [name, semverRange] of Object.entries(versionLockedModules)) {
if (version === '*' || semver.satisfies(version, semverRange)) {
builtins.push(name)
}
}

if (experimental) {
for (const [name, semverRange] of Object.entries(experimentalModules)) {
if (
!builtins.includes(name) &&
(version === '*' || semver.satisfies(version, semverRange))
) {
builtins.push(name)
}
}
}

return builtins
}
18 changes: 12 additions & 6 deletions node_modules/builtins/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
{
"name": "builtins",
"version": "1.0.3",
"version": "5.0.0",
"description": "List of node.js builtin modules",
"repository": "juliangruber/builtins",
"license": "MIT",
"main": "builtins.json",
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"main": "index.js",
"files": [],
"scripts": {
"test": "node test.js"
"test": "prettier-standard && standard && node test.js"
},
"dependencies": {
"semver": "^7.0.0"
},
"devDependencies": {
"node-core-test": "^1.1.1",
"prettier-standard": "^15.0.1",
"standard": "^14.3.4"
}
}
5 changes: 0 additions & 5 deletions node_modules/builtins/test.js

This file was deleted.

34 changes: 17 additions & 17 deletions node_modules/init-package-json/lib/default-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ function niceName (n) {

function readDeps (test, excluded) {
return function (cb) {
fs.readdir('node_modules', function (er, dir) {
if (er) {
fs.readdir('node_modules', function (readdirErr, dir) {
if (readdirErr) {
return cb()
}
var deps = {}
Expand All @@ -35,8 +35,8 @@ function readDeps (test, excluded) {
}

var dp = path.join(dirname, 'node_modules', d, 'package.json')
fs.readFile(dp, 'utf8', function (er, p) {
if (er) {
fs.readFile(dp, 'utf8', function (readFileErr, p) {
if (readFileErr) {
return next()
}
try {
Expand Down Expand Up @@ -108,11 +108,11 @@ var version = package.version ||
'1.0.0'
exports.version = yes ?
version :
prompt('version', version, function (version) {
if (semver.valid(version)) {
return version
prompt('version', version, function (promptedVersion) {
if (semver.valid(promptedVersion)) {
return promptedVersion
}
var er = new Error('Invalid version: "' + version + '"')
var er = new Error('Invalid version: "' + promptedVersion + '"')
er.notValid = true
return er
})
Expand All @@ -128,8 +128,8 @@ if (!package.main) {
f = []
}

f = f.filter(function (f) {
return f.match(/\.js$/)
f = f.filter(function (filtered) {
return filtered.match(/\.js$/)
})

if (f.indexOf('index.js') !== -1) {
Expand Down Expand Up @@ -261,17 +261,17 @@ if (!package.repository) {
}

if (!package.keywords) {
exports.keywords = yes ? '' : prompt('keywords', function (s) {
if (!s) {
exports.keywords = yes ? '' : prompt('keywords', function (promptedKeywords) {
if (!promptedKeywords) {
return undefined
}
if (Array.isArray(s)) {
s = s.join(' ')
if (Array.isArray(promptedKeywords)) {
promptedKeywords = promptedKeywords.join(' ')
}
if (typeof s !== 'string') {
return s
if (typeof promptedKeywords !== 'string') {
return promptedKeywords
}
return s.split(/[\s,]+/)
return promptedKeywords.split(/[\s,]+/)
})
}

Expand Down
54 changes: 27 additions & 27 deletions node_modules/init-package-json/lib/init-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,62 +74,62 @@ function init (dir, input, config, cb) {
var pz = new PZ(input, ctx)
pz.backupFile = def
pz.on('error', cb)
pz.on('data', function (data) {
Object.keys(data).forEach(function (k) {
if (data[k] !== undefined && data[k] !== null) {
pkg[k] = data[k]
pz.on('data', function (pzData) {
Object.keys(pzData).forEach(function (k) {
if (pzData[k] !== undefined && pzData[k] !== null) {
pkg[k] = pzData[k]
}
})

// only do a few of these.
// no need for mans or contributors if they're in the files
var es = readJson.extraSet
es = readJson.extraSet
readJson.extraSet = es.filter(function (fn) {
return fn.name !== 'authors' && fn.name !== 'mans'
})
readJson.extras(packageFile, pkg, function (er, pkg) {
if (er) {
return cb(er, pkg)
readJson.extras(packageFile, pkg, function (extrasErr, pkgWithExtras) {
if (extrasErr) {
return cb(extrasErr, pkgWithExtras)
}
readJson.extraSet = es
pkg = unParsePeople(pkg)
pkgWithExtras = unParsePeople(pkgWithExtras)
// no need for the readme now.
delete pkg.readme
delete pkg.readmeFilename
delete pkgWithExtras.readme
delete pkgWithExtras.readmeFilename

// really don't want to have this lying around in the file
delete pkg._id
delete pkgWithExtras._id

// ditto
delete pkg.gitHead
delete pkgWithExtras.gitHead

// if the repo is empty, remove it.
if (!pkg.repository) {
delete pkg.repository
if (!pkgWithExtras.repository) {
delete pkgWithExtras.repository
}

// readJson filters out empty descriptions, but init-package-json
// traditionally leaves them alone
if (!pkg.description) {
pkg.description = data.description
if (!pkgWithExtras.description) {
pkgWithExtras.description = pzData.description
}

var d = JSON.stringify(updateDeps(pkg), null, 2) + '\n'
function write (yes) {
fs.writeFile(packageFile, d, 'utf8', function (er) {
if (!er && yes && !config.get('silent')) {
console.log('Wrote to %s:\n\n%s\n', packageFile, d)
var stringified = JSON.stringify(updateDeps(pkgWithExtras), null, 2) + '\n'
function write (writeYes) {
fs.writeFile(packageFile, stringified, 'utf8', function (writeFileErr) {
if (!writeFileErr && writeYes && !config.get('silent')) {
console.log('Wrote to %s:\n\n%s\n', packageFile, stringified)
}
return cb(er, pkg)
return cb(writeFileErr, pkgWithExtras)
})
}
if (ctx.yes) {
return write(true)
}
console.log('About to write to %s:\n\n%s\n', packageFile, d)
read({ prompt: 'Is this OK? ', default: 'yes' }, function (er, ok) {
if (er) {
return cb(er)
console.log('About to write to %s:\n\n%s\n', packageFile, stringified)
read({ prompt: 'Is this OK? ', default: 'yes' }, function (promptErr, ok) {
if (promptErr) {
return cb(promptErr)
}
if (!ok || ok.toLowerCase().charAt(0) !== 'y') {
console.log('Aborted.')
Expand Down
Loading