diff options
author | Luke Karrys <luke@lukekarrys.com> | 2022-04-07 20:47:28 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2022-04-07 20:47:28 +0300 |
commit | ed7a421d291652097c6c1eb41c72cdee61ca7eda (patch) | |
tree | c6a4f0b80e15cc913a59211cd24318568c28f920 | |
parent | 80131e2a7015f9877826b54a7f98ce5e8e6f8239 (diff) |
resetdeps
-rw-r--r-- | node_modules/.gitignore | 2 | ||||
-rw-r--r-- | node_modules/minify-registry-metadata/LICENSE | 21 | ||||
-rw-r--r-- | node_modules/minify-registry-metadata/index.js | 104 | ||||
-rw-r--r-- | node_modules/minify-registry-metadata/package.json | 34 | ||||
-rw-r--r-- | package-lock.json | 16 | ||||
-rw-r--r-- | smoke-tests/package.json | 1 |
6 files changed, 162 insertions, 16 deletions
diff --git a/node_modules/.gitignore b/node_modules/.gitignore index 508199997..5eb851151 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -281,7 +281,6 @@ readme* /mime-db /mime-types /mimic-response -/minify-registry-metadata /minimist /mkdirp-classic /napi-build-utils @@ -351,6 +350,7 @@ readme* /side-channel /simple-concat /simple-get +/smoke-tests /source-map /source-map-support /space-separated-tokens diff --git a/node_modules/minify-registry-metadata/LICENSE b/node_modules/minify-registry-metadata/LICENSE new file mode 100644 index 000000000..05c8f9301 --- /dev/null +++ b/node_modules/minify-registry-metadata/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) npm, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/minify-registry-metadata/index.js b/node_modules/minify-registry-metadata/index.js new file mode 100644 index 000000000..698de6670 --- /dev/null +++ b/node_modules/minify-registry-metadata/index.js @@ -0,0 +1,104 @@ +'use strict' + +// take metadata and remove anything the cli doesnt need to install it. +const keep = [ + 'name', + 'dist-tags' +] + +const manifestKeep = [ + 'name', + 'version', + 'dependencies', + 'optionalDependencies', + 'devDependencies', + 'bundleDependencies', + 'peerDependencies', + 'acceptDependencies', + 'bin', + '_hasShrinkwrap', + 'directories', + 'dist', + 'engines', + 'deprecated', + 'peerDependenciesMeta', + 'funding', + 'os', + 'cpu' +] + +const manifestSets = [ + 'versions', + 'policyRestrictions', + 'stagedVersions' +] + +const isEmpty = val => { + return !val || + (typeof val === 'object' && Object.keys(val).length === 0) +} + +const minifyManifests = (doc, out, type) => { + if (!doc[type]) + return + + // policyRestrictions and staging have other metadata, and a versions obj + if (doc[type].versions) { + out[type] = {} + Object.keys(doc[type]).filter(k => k !== 'versions').forEach(k => { + out[type][k] = doc[type][k] + }) + // ok, now minify the actual manifests on that object. + return minifyManifests(doc[type], out[type], 'versions') + } + + // minify all the manifests + const smallVersions = {} + Object.keys(doc[type]).forEach(v => { + const manifest = doc[type][v] + const smallVersion = {} + if (manifest.bundledDependencies && !manifest.bundleDependencies) { + manifest.bundleDependencies = manifest.bundledDependencies + } + manifestKeep.forEach(field => { + if (!isEmpty(manifest[field])) { + smallVersion[field] = manifest[field] + } + }) + + if (manifest.scripts && ( + manifest.scripts.preinstall || + manifest.scripts.install || + manifest.scripts.postinstall)) { + smallVersion.hasInstallScript = true + } + + smallVersions[v] = smallVersion + }) + + out[type] = smallVersions +} + +module.exports = doc => { + // not registry metadata + if (!doc) { + return false + } + + const out = {} + + for (let i = 0; i < keep.length; ++i) { + if (doc[keep[i]] !== undefined) { + out[keep[i]] = doc[keep[i]] + } + } + + manifestSets.forEach(type => minifyManifests(doc, out, type)) + + const mtime = (doc.time || {}).modified + if (mtime) { + out.modified = mtime + } + + return out +} diff --git a/node_modules/minify-registry-metadata/package.json b/node_modules/minify-registry-metadata/package.json new file mode 100644 index 000000000..eea2bdd07 --- /dev/null +++ b/node_modules/minify-registry-metadata/package.json @@ -0,0 +1,34 @@ +{ + "name": "minify-registry-metadata", + "description": "minimal regsitry packuments. :corgi:", + "version": "2.2.0", + "devDependencies": { + "changes-stream": "^2.2.0", + "concurrent-couch-follower": "^1.2.0", + "normalize-registry-metadata": "^1.1.2", + "request": "^2.80.0", + "tap": "^14.10.6" + }, + "license": "ISC", + "main": "index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/minify-registry-metadata.git" + }, + "scripts": { + "test": "tap test/fixtures/*.js", + "snap": "tap test/fixtures/*.js", + "preversion": "npm test", + "postversion": "npm publish", + "postpublish": "git push origin --follow-tags" + }, + "tap": { + "node-arg": [ + "test/test.js" + ], + "check-coverage": true + }, + "files": [ + "index.js" + ] +} diff --git a/package-lock.json b/package-lock.json index 09879d002..ba6ddb98c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9751,7 +9751,6 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "abbrev": "1.0.4", "minify-registry-metadata": "^2.2.0" }, "devDependencies": { @@ -9763,11 +9762,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, - "smoke-tests/node_modules/abbrev": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz", - "integrity": "sha1-vVWuXkE7oXIu5Mq6H26hBBSlns0=" - }, "workspaces/arborist": { "name": "@npmcli/arborist", "version": "5.0.4", @@ -14232,17 +14226,9 @@ "version": "file:smoke-tests", "requires": { "@npmcli/template-oss": "3.3.2", - "abbrev": "1.0.4", "minify-registry-metadata": "^2.2.0", - "rimraf": "*", + "rimraf": "^3.0.2", "tap": "^16.0.1" - }, - "dependencies": { - "abbrev": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz", - "integrity": "sha1-vVWuXkE7oXIu5Mq6H26hBBSlns0=" - } } }, "socks": { diff --git a/smoke-tests/package.json b/smoke-tests/package.json index 1dc9410ab..b4d97ea80 100644 --- a/smoke-tests/package.json +++ b/smoke-tests/package.json @@ -24,6 +24,7 @@ }, "devDependencies": { "@npmcli/template-oss": "3.3.2", + "rimraf": "^3.0.2", "tap": "^16.0.1" }, "author": "GitHub Inc.", |