From 7fbf6f7825f76906ecdec79ab15595f9e2f7b784 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Thu, 25 Aug 2022 12:45:11 -0700 Subject: [PATCH] deps: bin-links@3.0.3 --- .../npm-normalize-package-bin/LICENSE | 15 +++++ .../npm-normalize-package-bin/lib/index.js | 64 +++++++++++++++++++ .../npm-normalize-package-bin/package.json | 41 ++++++++++++ node_modules/bin-links/package.json | 4 +- package-lock.json | 20 ++++-- workspaces/arborist/package.json | 2 +- workspaces/libnpmexec/package.json | 2 +- 7 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 node_modules/bin-links/node_modules/npm-normalize-package-bin/LICENSE create mode 100644 node_modules/bin-links/node_modules/npm-normalize-package-bin/lib/index.js create mode 100644 node_modules/bin-links/node_modules/npm-normalize-package-bin/package.json diff --git a/node_modules/bin-links/node_modules/npm-normalize-package-bin/LICENSE b/node_modules/bin-links/node_modules/npm-normalize-package-bin/LICENSE new file mode 100644 index 000000000000..19cec97b1846 --- /dev/null +++ b/node_modules/bin-links/node_modules/npm-normalize-package-bin/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) 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 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/bin-links/node_modules/npm-normalize-package-bin/lib/index.js b/node_modules/bin-links/node_modules/npm-normalize-package-bin/lib/index.js new file mode 100644 index 000000000000..d6f0a581b9e6 --- /dev/null +++ b/node_modules/bin-links/node_modules/npm-normalize-package-bin/lib/index.js @@ -0,0 +1,64 @@ +// pass in a manifest with a 'bin' field here, and it'll turn it +// into a properly santized bin object +const { join, basename } = require('path') + +const normalize = pkg => + !pkg.bin ? removeBin(pkg) + : typeof pkg.bin === 'string' ? normalizeString(pkg) + : Array.isArray(pkg.bin) ? normalizeArray(pkg) + : typeof pkg.bin === 'object' ? normalizeObject(pkg) + : removeBin(pkg) + +const normalizeString = pkg => { + if (!pkg.name) { + return removeBin(pkg) + } + pkg.bin = { [pkg.name]: pkg.bin } + return normalizeObject(pkg) +} + +const normalizeArray = pkg => { + pkg.bin = pkg.bin.reduce((acc, k) => { + acc[basename(k)] = k + return acc + }, {}) + return normalizeObject(pkg) +} + +const removeBin = pkg => { + delete pkg.bin + return pkg +} + +const normalizeObject = pkg => { + const orig = pkg.bin + const clean = {} + let hasBins = false + Object.keys(orig).forEach(binKey => { + const base = join('/', basename(binKey.replace(/\\|:/g, '/'))).slice(1) + + if (typeof orig[binKey] !== 'string' || !base) { + return + } + + const binTarget = join('/', orig[binKey]) + .replace(/\\/g, '/').slice(1) + + if (!binTarget) { + return + } + + clean[base] = binTarget + hasBins = true + }) + + if (hasBins) { + pkg.bin = clean + } else { + delete pkg.bin + } + + return pkg +} + +module.exports = normalize diff --git a/node_modules/bin-links/node_modules/npm-normalize-package-bin/package.json b/node_modules/bin-links/node_modules/npm-normalize-package-bin/package.json new file mode 100644 index 000000000000..02de808d9b70 --- /dev/null +++ b/node_modules/bin-links/node_modules/npm-normalize-package-bin/package.json @@ -0,0 +1,41 @@ +{ + "name": "npm-normalize-package-bin", + "version": "2.0.0", + "description": "Turn any flavor of allowable package.json bin into a normalized object", + "main": "lib/index.js", + "repository": { + "type": "git", + "url": "https://github.com/npm/npm-normalize-package-bin.git" + }, + "author": "GitHub Inc.", + "license": "ISC", + "scripts": { + "test": "tap", + "snap": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "postpublish": "git push origin --follow-tags", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force", + "lintfix": "npm run lint -- --fix", + "prepublishOnly": "git push origin --follow-tags", + "posttest": "npm run lint" + }, + "devDependencies": { + "@npmcli/eslint-config": "^3.1.0", + "@npmcli/template-oss": "3.5.0", + "tap": "^16.3.0" + }, + "files": [ + "bin/", + "lib/" + ], + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.5.0" + } +} diff --git a/node_modules/bin-links/package.json b/node_modules/bin-links/package.json index aba3d8f6c090..ff240c227622 100644 --- a/node_modules/bin-links/package.json +++ b/node_modules/bin-links/package.json @@ -1,6 +1,6 @@ { "name": "bin-links", - "version": "3.0.2", + "version": "3.0.3", "description": "JavaScript package binary linker", "main": "./lib/index.js", "scripts": { @@ -28,7 +28,7 @@ "dependencies": { "cmd-shim": "^5.0.0", "mkdirp-infer-owner": "^2.0.0", - "npm-normalize-package-bin": "^1.0.0", + "npm-normalize-package-bin": "^2.0.0", "read-cmd-shim": "^3.0.0", "rimraf": "^3.0.0", "write-file-atomic": "^4.0.0" diff --git a/package-lock.json b/package-lock.json index 20a69b395690..4046930c930e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1544,13 +1544,13 @@ } }, "node_modules/bin-links": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-3.0.2.tgz", - "integrity": "sha512-+oSWBdbCUK6X4LOCSrU36fWRzZNaK7/evX7GozR9xwl2dyiVi3UOUwTyyOVYI1FstgugfsM9QESRrWo7gjCYbg==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-3.0.3.tgz", + "integrity": "sha512-zKdnMPWEdh4F5INR07/eBrodC7QrF5JKvqskjz/ZZRXg5YSAZIbn8zGhbhUrElzHBZ2fvEQdOU59RHcTG3GiwA==", "dependencies": { "cmd-shim": "^5.0.0", "mkdirp-infer-owner": "^2.0.0", - "npm-normalize-package-bin": "^1.0.0", + "npm-normalize-package-bin": "^2.0.0", "read-cmd-shim": "^3.0.0", "rimraf": "^3.0.0", "write-file-atomic": "^4.0.0" @@ -1559,6 +1559,14 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/bin-links/node_modules/npm-normalize-package-bin": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-2.0.0.tgz", + "integrity": "sha512-awzfKUO7v0FscrSpRoogyNm0sajikhBWpU0QMrW09AMi9n1PoKU6WaIqUzuJSQnpciZZmJ/jMZ2Egfmb/9LiWQ==", + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "license": "MIT", @@ -10510,7 +10518,7 @@ "@npmcli/package-json": "^2.0.0", "@npmcli/query": "^1.2.0", "@npmcli/run-script": "^4.1.3", - "bin-links": "^3.0.0", + "bin-links": "^3.0.3", "cacache": "^16.1.3", "common-ancestor-path": "^1.0.1", "json-parse-even-better-errors": "^2.3.1", @@ -10617,7 +10625,7 @@ "devDependencies": { "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", - "bin-links": "^3.0.0", + "bin-links": "^3.0.3", "minify-registry-metadata": "^2.2.0", "mkdirp": "^1.0.4", "tap": "^16.0.1" diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json index 77a7c71b99d2..db997e1fa3f8 100644 --- a/workspaces/arborist/package.json +++ b/workspaces/arborist/package.json @@ -13,7 +13,7 @@ "@npmcli/package-json": "^2.0.0", "@npmcli/query": "^1.2.0", "@npmcli/run-script": "^4.1.3", - "bin-links": "^3.0.0", + "bin-links": "^3.0.3", "cacache": "^16.1.3", "common-ancestor-path": "^1.0.1", "json-parse-even-better-errors": "^2.3.1", diff --git a/workspaces/libnpmexec/package.json b/workspaces/libnpmexec/package.json index e7640d66f099..f9ccd7d3bff1 100644 --- a/workspaces/libnpmexec/package.json +++ b/workspaces/libnpmexec/package.json @@ -51,7 +51,7 @@ "devDependencies": { "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", - "bin-links": "^3.0.0", + "bin-links": "^3.0.3", "minify-registry-metadata": "^2.2.0", "mkdirp": "^1.0.4", "tap": "^16.0.1"