From ac8e4ad18a6b726dd2c3abcb0f605701cca0ae2c Mon Sep 17 00:00:00 2001 From: Gar Date: Thu, 9 Sep 2021 14:05:14 -0700 Subject: [PATCH] deps: init-package-json@2.0.5 * fix: bin script path --- node_modules/init-package-json/LICENSE | 15 -- node_modules/init-package-json/LICENSE.md | 18 ++ .../{ => lib}/default-input.js | 177 ++++++++++++------ .../{ => lib}/init-package-json.js | 66 ++++--- node_modules/init-package-json/package.json | 34 ++-- package-lock.json | 24 ++- package.json | 2 +- 7 files changed, 207 insertions(+), 129 deletions(-) delete mode 100644 node_modules/init-package-json/LICENSE create mode 100644 node_modules/init-package-json/LICENSE.md rename node_modules/init-package-json/{ => lib}/default-input.js (64%) rename node_modules/init-package-json/{ => lib}/init-package-json.js (79%) diff --git a/node_modules/init-package-json/LICENSE b/node_modules/init-package-json/LICENSE deleted file mode 100644 index 05eeeb88c2ef4..0000000000000 --- a/node_modules/init-package-json/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter - -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. - -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. diff --git a/node_modules/init-package-json/LICENSE.md b/node_modules/init-package-json/LICENSE.md new file mode 100644 index 0000000000000..845be76f64e78 --- /dev/null +++ b/node_modules/init-package-json/LICENSE.md @@ -0,0 +1,18 @@ +ISC License + +Copyright npm, Inc. + +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. + +THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +EVENT SHALL NPM 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. diff --git a/node_modules/init-package-json/default-input.js b/node_modules/init-package-json/lib/default-input.js similarity index 64% rename from node_modules/init-package-json/default-input.js rename to node_modules/init-package-json/lib/default-input.js index d1f65841d6c5a..0003472975760 100644 --- a/node_modules/init-package-json/default-input.js +++ b/node_modules/init-package-json/lib/default-input.js @@ -1,5 +1,5 @@ +/* eslint-disable no-undef */ var fs = require('fs') -var glob = require('glob') var path = require('path') var validateLicense = require('validate-npm-package-license') var validateName = require('validate-npm-package-name') @@ -15,35 +15,57 @@ function niceName (n) { return n.replace(/^node-|[.-]js$/g, '').replace(/\s+/g, ' ').replace(/ /g, '-').toLowerCase() } -function readDeps (test, excluded) { return function (cb) { - fs.readdir('node_modules', function (er, dir) { - if (er) return cb() - var deps = {} - var n = dir.length - if (n === 0) return cb(null, deps) - dir.forEach(function (d) { - if (d.match(/^\./)) return next() - if (test !== isTestPkg(d) || excluded[d]) - return next() - - var dp = path.join(dirname, 'node_modules', d, 'package.json') - fs.readFile(dp, 'utf8', function (er, p) { - if (er) return next() - try { p = JSON.parse(p) } - catch (e) { return next() } - if (!p.version) return next() - if (p._requiredBy) { - if (!p._requiredBy.some(function (req) { return req === '#USER' })) return next() +function readDeps (test, excluded) { + return function (cb) { + fs.readdir('node_modules', function (er, dir) { + if (er) { + return cb() + } + var deps = {} + var n = dir.length + if (n === 0) { + return cb(null, deps) + } + dir.forEach(function (d) { + if (d.match(/^\./)) { + return next() + } + if (test !== isTestPkg(d) || excluded[d]) { + return next() } - deps[d] = config.get('save-exact') ? p.version : config.get('save-prefix') + p.version - return next() + + var dp = path.join(dirname, 'node_modules', d, 'package.json') + fs.readFile(dp, 'utf8', function (er, p) { + if (er) { + return next() + } + try { + p = JSON.parse(p) + } catch (e) { + return next() + } + if (!p.version) { + return next() + } + if (p._requiredBy) { + if (!p._requiredBy.some(function (req) { + return req === '#USER' + })) { + return next() + } + } + deps[d] = config.get('save-exact') ? p.version : config.get('save-prefix') + p.version + return next() + }) }) + function next () { + if (--n === 0) { + return cb(null, deps) + } + } }) - function next () { - if (--n === 0) return cb(null, deps) - } - }) -}} + } +} var name = niceName(package.name || basename) var spec @@ -54,16 +76,20 @@ try { } var scope = config.get('scope') if (scope) { - if (scope.charAt(0) !== '@') scope = '@' + scope + if (scope.charAt(0) !== '@') { + scope = '@' + scope + } if (spec.scope) { name = scope + '/' + spec.name.split('/')[1] } else { name = scope + '/' + name } } -exports.name = yes ? name : prompt('package name', name, function (data) { +exports.name = yes ? name : prompt('package name', name, function (data) { var its = validateName(data) - if (its.validForNewPackages) return data + if (its.validForNewPackages) { + return data + } var errors = (its.errors || []).concat(its.warnings || []) var er = new Error('Sorry, ' + errors.join(' and ') + '.') er.notValid = true @@ -83,7 +109,9 @@ var version = package.version || exports.version = yes ? version : prompt('version', version, function (version) { - if (semver.valid(version)) return version + if (semver.valid(version)) { + return version + } var er = new Error('Invalid version: "' + version + '"') er.notValid = true return er @@ -96,22 +124,25 @@ if (!package.description) { if (!package.main) { exports.main = function (cb) { fs.readdir(dirname, function (er, f) { - if (er) f = [] + if (er) { + f = [] + } f = f.filter(function (f) { return f.match(/\.js$/) }) - if (f.indexOf('index.js') !== -1) + if (f.indexOf('index.js') !== -1) { f = 'index.js' - else if (f.indexOf('main.js') !== -1) + } else if (f.indexOf('main.js') !== -1) { f = 'main.js' - else if (f.indexOf(basename + '.js') !== -1) + } else if (f.indexOf(basename + '.js') !== -1) { f = basename + '.js' - else + } else { f = f[0] + } - var index = f || 'index.js' + var index = f || 'index.js' return cb(null, yes ? index : prompt('entry point', index)) }) } @@ -121,18 +152,24 @@ if (!package.bin) { exports.bin = function (cb) { fs.readdir(path.resolve(dirname, 'bin'), function (er, d) { // no bins - if (er) return cb() + if (er) { + return cb() + } // just take the first js file we find there, or nada - return cb(null, d.filter(function (f) { - return f.match(/\.js$/) - })[0]) + let r = d.find(f => f.match(/\.js$/)) + if (r) { + r = `bin/${r}` + } + return cb(null, r) }) } } exports.directories = function (cb) { fs.readdir(dirname, function (er, dirs) { - if (er) return cb(er) + if (er) { + return cb(er) + } var res = {} dirs.forEach(function (d) { switch (d) { @@ -143,7 +180,9 @@ exports.directories = function (cb) { case 'lib': return res.lib = d } }) - if (Object.keys(res).length === 0) res = undefined + if (Object.keys(res).length === 0) { + res = undefined + } return cb(null, res) }) } @@ -173,13 +212,15 @@ function setupScripts (d, cb) { } if (!s.test || s.test === notest) { var commands = { - 'tap':'tap test/*.js' - , 'expresso':'expresso test' - , 'mocha':'mocha' + tap: 'tap test/*.js', + expresso: 'expresso test', + mocha: 'mocha', } var command Object.keys(commands).forEach(function (k) { - if (d.indexOf(k) !== -1) command = commands[k] + if (d.indexOf(k) !== -1) { + command = commands[k] + } }) var ps = 'test command' if (yes) { @@ -201,12 +242,18 @@ if (!package.repository) { var i = gconf.indexOf('[remote "origin"]') if (i !== -1) { var u = gconf[i + 1] - if (!u.match(/^\s*url =/)) u = gconf[i + 2] - if (!u.match(/^\s*url =/)) u = null - else u = u.replace(/^\s*url = /, '') + if (!u.match(/^\s*url =/)) { + u = gconf[i + 2] + } + if (!u.match(/^\s*url =/)) { + u = null + } else { + u = u.replace(/^\s*url = /, '') + } } - if (u && u.match(/^git@github.com:/)) + if (u && u.match(/^git@github.com:/)) { u = u.replace(/^git@github.com:/, 'https://github.com/') + } return cb(null, yes ? u : prompt('git repository', u)) }) @@ -215,9 +262,15 @@ if (!package.repository) { if (!package.keywords) { exports.keywords = yes ? '' : prompt('keywords', function (s) { - if (!s) return undefined - if (Array.isArray(s)) s = s.join(' ') - if (typeof s !== 'string') return s + if (!s) { + return undefined + } + if (Array.isArray(s)) { + s = s.join(' ') + } + if (typeof s !== 'string') { + return s + } return s.split(/[\s,]+/) }) } @@ -225,15 +278,15 @@ if (!package.keywords) { if (!package.author) { exports.author = config.get('init.author.name') || config.get('init-author-name') - ? { - "name" : config.get('init.author.name') || + ? { + name: config.get('init.author.name') || config.get('init-author-name'), - "email" : config.get('init.author.email') || + email: config.get('init.author.email') || config.get('init-author-email'), - "url" : config.get('init.author.url') || - config.get('init-author-url') + url: config.get('init.author.url') || + config.get('init-author-url'), } - : yes ? '' : prompt('author') + : yes ? '' : prompt('author') } const defaultDottedInitLicense = config && @@ -248,7 +301,9 @@ var license = package.license || 'ISC' exports.license = yes ? license : prompt('license', license, function (data) { var its = validateLicense(data) - if (its.validForNewPackages) return data + if (its.validForNewPackages) { + return data + } var errors = (its.errors || []).concat(its.warnings || []) var er = new Error('Sorry, ' + errors.join(' and ') + '.') er.notValid = true diff --git a/node_modules/init-package-json/init-package-json.js b/node_modules/init-package-json/lib/init-package-json.js similarity index 79% rename from node_modules/init-package-json/init-package-json.js rename to node_modules/init-package-json/lib/init-package-json.js index 83e7342d0aa4f..bee79351caab3 100644 --- a/node_modules/init-package-json/init-package-json.js +++ b/node_modules/init-package-json/lib/init-package-json.js @@ -12,7 +12,6 @@ var read = require('read') // to validate the data object at the end as a worthwhile package // and assign default values for things. -// readJson.extras(file, data, cb) var readJson = require('read-package-json') function yes (conf) { @@ -23,8 +22,10 @@ function yes (conf) { } function init (dir, input, config, cb) { - if (typeof config === 'function') - cb = config, config = {} + if (typeof config === 'function') { + cb = config + config = {} + } // accept either a plain-jane object, or a config object // with a "get" method. @@ -36,7 +37,7 @@ function init (dir, input, config, cb) { }, toJSON: function () { return data - } + }, } } @@ -52,14 +53,18 @@ function init (dir, input, config, cb) { readJson(packageFile, function (er, d) { readJson.extraSet = es - if (er) pkg = {} - else pkg = d + if (er) { + pkg = {} + } else { + pkg = d + } ctx.filename = packageFile ctx.dirname = path.dirname(packageFile) ctx.basename = path.basename(ctx.dirname) - if (!pkg.version || !semver.valid(pkg.version)) + if (!pkg.version || !semver.valid(pkg.version)) { delete pkg.version + } ctx.package = pkg ctx.config = config || {} @@ -71,7 +76,9 @@ function init (dir, input, config, cb) { 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] + if (data[k] !== undefined && data[k] !== null) { + pkg[k] = data[k] + } }) // only do a few of these. @@ -81,8 +88,10 @@ function init (dir, input, config, cb) { return fn.name !== 'authors' && fn.name !== 'mans' }) readJson.extras(packageFile, pkg, function (er, pkg) { + if (er) { + return cb(er, pkg) + } readJson.extraSet = es - if (er) return cb(er, pkg) pkg = unParsePeople(pkg) // no need for the readme now. delete pkg.readme @@ -95,13 +104,15 @@ function init (dir, input, config, cb) { delete pkg.gitHead // if the repo is empty, remove it. - if (!pkg.repository) + if (!pkg.repository) { delete pkg.repository + } // readJson filters out empty descriptions, but init-package-json // traditionally leaves them alone - if (!pkg.description) + if (!pkg.description) { pkg.description = data.description + } var d = JSON.stringify(updateDeps(pkg), null, 2) + '\n' function write (yes) { @@ -116,7 +127,7 @@ function init (dir, input, config, cb) { 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) { + read({prompt: 'Is this OK? ', default: 'yes'}, function (er, ok) { if (er) { return cb(er) } @@ -129,18 +140,19 @@ function init (dir, input, config, cb) { }) }) }) - } -function updateDeps(depsData) { +function updateDeps (depsData) { // optionalDependencies don't need to be repeated in two places if (depsData.dependencies) { if (depsData.optionalDependencies) { - for (const name of Object.keys(depsData.optionalDependencies)) + for (const name of Object.keys(depsData.optionalDependencies)) { delete depsData.dependencies[name] + } } - if (Object.keys(depsData.dependencies).length === 0) + if (Object.keys(depsData.dependencies).length === 0) { delete depsData.dependencies + } } return depsData @@ -148,21 +160,25 @@ function updateDeps(depsData) { // turn the objects into somewhat more humane strings. function unParsePeople (data) { - if (data.author) data.author = unParsePerson(data.author) - ;["maintainers", "contributors"].forEach(function (set) { - if (!Array.isArray(data[set])) return; + if (data.author) { + data.author = unParsePerson(data.author) + }['maintainers', 'contributors'].forEach(function (set) { + if (!Array.isArray(data[set])) { + return + } data[set] = data[set].map(unParsePerson) }) return data } function unParsePerson (person) { - if (typeof person === "string") return person - var name = person.name || "" + if (typeof person === 'string') { + return person + } + var name = person.name || '' var u = person.url || person.web - var url = u ? (" ("+u+")") : "" + var url = u ? (' (' + u + ')') : '' var e = person.email || person.mail - var email = e ? (" <"+e+">") : "" - return name+email+url + var email = e ? (' <' + e + '>') : '' + return name + email + url } - diff --git a/node_modules/init-package-json/package.json b/node_modules/init-package-json/package.json index 0e07f48f49746..6d642f6cf6879 100644 --- a/node_modules/init-package-json/package.json +++ b/node_modules/init-package-json/package.json @@ -1,41 +1,46 @@ { "name": "init-package-json", - "version": "2.0.4", - "main": "init-package-json.js", + "version": "2.0.5", + "main": "lib/init-package-json.js", "scripts": { "test": "tap", "preversion": "npm test", "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" + "prepublishOnly": "git push origin --follow-tags", + "lint": "eslint '**/*.js'", + "postlint": "npm-template-check", + "lintfix": "npm run lint -- --fix", + "snap": "tap", + "posttest": "npm run lint" }, "repository": { "type": "git", "url": "https://github.com/npm/init-package-json.git" }, - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", + "author": "GitHub Inc.", "license": "ISC", "description": "A node module to get your node module started", "dependencies": { - "glob": "^7.1.1", - "npm-package-arg": "^8.1.2", + "npm-package-arg": "^8.1.5", "promzard": "^0.3.0", "read": "~1.0.1", - "read-package-json": "^4.0.0", + "read-package-json": "^4.1.1", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", "validate-npm-package-name": "^3.0.0" }, "devDependencies": { "@npmcli/config": "^2.1.0", - "mkdirp": "^1.0.4", - "rimraf": "^3.0.2", - "tap": "^14.11.0" + "@npmcli/template-oss": "^1.0.3", + "tap": "^15.0.9" }, "engines": { "node": ">=10" }, "tap": { - "jobs": "1" + "statements": "94", + "branches": "83", + "lines": "94" }, "keywords": [ "init", @@ -48,7 +53,8 @@ "start" ], "files": [ - "default-input.js", - "init-package-json.js" - ] + "bin", + "lib" + ], + "templateVersion": "1.0.3" } diff --git a/package-lock.json b/package-lock.json index 852dc51752ea5..8f4a37801185a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -105,7 +105,7 @@ "graceful-fs": "^4.2.8", "hosted-git-info": "^4.0.2", "ini": "^2.0.0", - "init-package-json": "^2.0.4", + "init-package-json": "^2.0.5", "is-cidr": "^4.0.2", "json-parse-even-better-errors": "^2.3.1", "libnpmaccess": "^4.0.2", @@ -3877,16 +3877,15 @@ } }, "node_modules/init-package-json": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.4.tgz", - "integrity": "sha512-gUACSdZYka+VvnF90TsQorC+1joAVWNI724vBNj3RD0LLMeDss2IuzaeiQs0T4YzKs76BPHtrp/z3sn2p+KDTw==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.5.tgz", + "integrity": "sha512-u1uGAtEFu3VA6HNl/yUWw57jmKEMx8SKOxHhxjGnOFUiIlFnohKDFg4ZrPpv9wWqk44nDxGJAtqjdQFm+9XXQA==", "inBundle": true, "dependencies": { - "glob": "^7.1.1", - "npm-package-arg": "^8.1.2", + "npm-package-arg": "^8.1.5", "promzard": "^0.3.0", "read": "~1.0.1", - "read-package-json": "^4.0.0", + "read-package-json": "^4.1.1", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", "validate-npm-package-name": "^3.0.0" @@ -13318,15 +13317,14 @@ "integrity": "sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==" }, "init-package-json": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.4.tgz", - "integrity": "sha512-gUACSdZYka+VvnF90TsQorC+1joAVWNI724vBNj3RD0LLMeDss2IuzaeiQs0T4YzKs76BPHtrp/z3sn2p+KDTw==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.5.tgz", + "integrity": "sha512-u1uGAtEFu3VA6HNl/yUWw57jmKEMx8SKOxHhxjGnOFUiIlFnohKDFg4ZrPpv9wWqk44nDxGJAtqjdQFm+9XXQA==", "requires": { - "glob": "^7.1.1", - "npm-package-arg": "^8.1.2", + "npm-package-arg": "^8.1.5", "promzard": "^0.3.0", "read": "~1.0.1", - "read-package-json": "^4.0.0", + "read-package-json": "^4.1.1", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", "validate-npm-package-name": "^3.0.0" diff --git a/package.json b/package.json index 20b80c7ebe21c..8011f238ac2ff 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "graceful-fs": "^4.2.8", "hosted-git-info": "^4.0.2", "ini": "^2.0.0", - "init-package-json": "^2.0.4", + "init-package-json": "^2.0.5", "is-cidr": "^4.0.2", "json-parse-even-better-errors": "^2.3.1", "libnpmaccess": "^4.0.2",