From 033e948c95b3455812e03a860ad1bd96a635e7eb Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 1 Sep 2021 14:32:47 -0700 Subject: [PATCH] deps: read-package-json@4.1.1 * feat: add types lookup * fix(man): don't lose relative man path --- node_modules/read-package-json/package.json | 10 +++- node_modules/read-package-json/read-json.js | 51 +++++++++++++++++++-- package-lock.json | 14 +++--- package.json | 2 +- 4 files changed, 62 insertions(+), 15 deletions(-) diff --git a/node_modules/read-package-json/package.json b/node_modules/read-package-json/package.json index 5ca535cfd14ad..fb263fd711ee7 100644 --- a/node_modules/read-package-json/package.json +++ b/node_modules/read-package-json/package.json @@ -1,6 +1,6 @@ { "name": "read-package-json", - "version": "4.0.1", + "version": "4.1.1", "author": "Isaac Z. Schlueter (http://blog.izs.me/)", "description": "The thing npm uses to read package.json files with semantics and defaults and validation", "repository": { @@ -12,7 +12,7 @@ "prerelease": "npm t", "postrelease": "npm publish && git push --follow-tags", "release": "standard-version -s", - "test": "tap --nyc-arg=--all --coverage test/*.js --branches 68 --functions 83 --lines 76 --statements 77", + "test": "tap --nyc-arg=--all --coverage test/*.js", "npmclilint": "npmcli-lint", "lint": "npm run npmclilint -- --ignore-pattern test/fixtures \"*.*js\" \"test/**/*.*js\"", "lintfix": "npm run lint -- --fix", @@ -36,5 +36,11 @@ ], "engines": { "node": ">=10" + }, + "tap": { + "branches": 68, + "functions": 83, + "lines": 76, + "statements": 77 } } diff --git a/node_modules/read-package-json/read-json.js b/node_modules/read-package-json/read-json.js index 04d22e3af7e21..468a33e397774 100644 --- a/node_modules/read-package-json/read-json.js +++ b/node_modules/read-package-json/read-json.js @@ -21,6 +21,7 @@ readJson.extraSet = [ mans, bins, githead, + fillTypes, ] var typoWarned = {} @@ -339,16 +340,17 @@ function readme_ (file, data, rm, cb) { } function mans (file, data, cb) { - var m = data.directories && data.directories.man - if (data.man || !m) { + let cwd = data.directories && data.directories.man + if (data.man || !cwd) { return cb(null, data) } - m = path.resolve(path.dirname(file), m) - glob('**/*.[0-9]', { cwd: m }, function (er, mans) { + const dirname = path.dirname(file) + cwd = path.resolve(path.dirname(file), cwd) + glob('**/*.[0-9]', { cwd }, function (er, mans) { if (er) { return cb(er) } - data.man = mans + data.man = mans.map(man => path.relative(dirname, path.join(cwd, man))) return cb(null, data) }) } @@ -517,6 +519,45 @@ function final (file, data, log, strict, cb) { }) } +function fillTypes (file, data, cb) { + var index = data.main ? data.main : 'index.js' + + // TODO exports is much more complicated than this in verbose format + // We need to support for instance + + // "exports": { + // ".": [ + // { + // "default": "./lib/npm.js" + // }, + // "./lib/npm.js" + // ], + // "./package.json": "./package.json" + // }, + // as well as conditional exports + + // if (data.exports && typeof data.exports === 'string') { + // index = data.exports + // } + + // if (data.exports && data.exports['.']) { + // index = data.exports['.'] + // if (typeof index !== 'string') { + // } + // } + + var extless = + path.join(path.dirname(index), path.basename(index, path.extname(index))) + var dts = `./${extless}.d.ts` + var dtsPath = path.join(path.dirname(file), dts) + var hasDTSFields = 'types' in data || 'typings' in data + if (!hasDTSFields && fs.existsSync(dtsPath)) { + data.types = dts + } + + cb(null, data) +} + function makePackageId (data) { var name = cleanString(data.name) var ver = cleanString(data.version) diff --git a/package-lock.json b/package-lock.json index ef2bf71959f6b..1d4f7b360a6e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -138,7 +138,7 @@ "parse-conflict-json": "^1.1.1", "qrcode-terminal": "^0.12.0", "read": "~1.0.7", - "read-package-json": "^4.0.1", + "read-package-json": "^4.1.1", "read-package-json-fast": "^2.0.3", "readdir-scoped-modules": "^1.1.0", "rimraf": "^3.0.2", @@ -6444,9 +6444,9 @@ "inBundle": true }, "node_modules/read-package-json": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-4.0.1.tgz", - "integrity": "sha512-czqCcYfkEl6sIFJVOND/5/Goseu7cVw1rcDUATq6ED0jLGjMm9/HOPmFmEZMvRu9yl272YERaMUcOlvcNU9InQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-4.1.1.tgz", + "integrity": "sha512-P82sbZJ3ldDrWCOSKxJT0r/CXMWR0OR3KRh55SgKo3p91GSIEEC32v3lSHAvO/UcH3/IoL7uqhOFBduAnwdldw==", "inBundle": true, "dependencies": { "glob": "^7.1.1", @@ -15193,9 +15193,9 @@ "integrity": "sha512-HJpV9bQpkl6KwjxlJcBoqu9Ba0PQg8TqSNIOrulGt54a0uup0HtevreFHzYzkm0lpnleRdNBzXznKrgxglEHQw==" }, "read-package-json": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-4.0.1.tgz", - "integrity": "sha512-czqCcYfkEl6sIFJVOND/5/Goseu7cVw1rcDUATq6ED0jLGjMm9/HOPmFmEZMvRu9yl272YERaMUcOlvcNU9InQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-4.1.1.tgz", + "integrity": "sha512-P82sbZJ3ldDrWCOSKxJT0r/CXMWR0OR3KRh55SgKo3p91GSIEEC32v3lSHAvO/UcH3/IoL7uqhOFBduAnwdldw==", "requires": { "glob": "^7.1.1", "json-parse-even-better-errors": "^2.3.0", diff --git a/package.json b/package.json index 30877f8de75c5..f769d346ea47e 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "parse-conflict-json": "^1.1.1", "qrcode-terminal": "^0.12.0", "read": "~1.0.7", - "read-package-json": "^4.0.1", + "read-package-json": "^4.1.1", "read-package-json-fast": "^2.0.3", "readdir-scoped-modules": "^1.1.0", "rimraf": "^3.0.2",