-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
204 additions
and
21 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
node_modules/npm-pick-manifest/node_modules/npm-install-checks/LICENSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright (c) Robert Kowalski and Isaac Z. Schlueter ("Authors") | ||
All rights reserved. | ||
|
||
The BSD License | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS | ||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | ||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
78 changes: 78 additions & 0 deletions
78
node_modules/npm-pick-manifest/node_modules/npm-install-checks/lib/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
const semver = require('semver') | ||
|
||
const checkEngine = (target, npmVer, nodeVer, force = false) => { | ||
const nodev = force ? null : nodeVer | ||
const eng = target.engines | ||
const opt = { includePrerelease: true } | ||
if (!eng) { | ||
return | ||
} | ||
|
||
const nodeFail = nodev && eng.node && !semver.satisfies(nodev, eng.node, opt) | ||
const npmFail = npmVer && eng.npm && !semver.satisfies(npmVer, eng.npm, opt) | ||
if (nodeFail || npmFail) { | ||
throw Object.assign(new Error('Unsupported engine'), { | ||
pkgid: target._id, | ||
current: { node: nodeVer, npm: npmVer }, | ||
required: eng, | ||
code: 'EBADENGINE', | ||
}) | ||
} | ||
} | ||
|
||
const checkPlatform = (target, force = false) => { | ||
if (force) { | ||
return | ||
} | ||
|
||
const platform = process.platform | ||
const arch = process.arch | ||
const osOk = target.os ? checkList(platform, target.os) : true | ||
const cpuOk = target.cpu ? checkList(arch, target.cpu) : true | ||
|
||
if (!osOk || !cpuOk) { | ||
throw Object.assign(new Error('Unsupported platform'), { | ||
pkgid: target._id, | ||
current: { | ||
os: platform, | ||
cpu: arch, | ||
}, | ||
required: { | ||
os: target.os, | ||
cpu: target.cpu, | ||
}, | ||
code: 'EBADPLATFORM', | ||
}) | ||
} | ||
} | ||
|
||
const checkList = (value, list) => { | ||
if (typeof list === 'string') { | ||
list = [list] | ||
} | ||
if (list.length === 1 && list[0] === 'any') { | ||
return true | ||
} | ||
// match none of the negated values, and at least one of the | ||
// non-negated values, if any are present. | ||
let negated = 0 | ||
let match = false | ||
for (const entry of list) { | ||
const negate = entry.charAt(0) === '!' | ||
const test = negate ? entry.slice(1) : entry | ||
if (negate) { | ||
negated++ | ||
if (value === test) { | ||
return false | ||
} | ||
} else { | ||
match = match || value === test | ||
} | ||
} | ||
return match || negated === list.length | ||
} | ||
|
||
module.exports = { | ||
checkEngine, | ||
checkPlatform, | ||
} |
48 changes: 48 additions & 0 deletions
48
node_modules/npm-pick-manifest/node_modules/npm-install-checks/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "npm-install-checks", | ||
"version": "5.0.0", | ||
"description": "Check the engines and platform fields in package.json", | ||
"main": "lib/index.js", | ||
"dependencies": { | ||
"semver": "^7.1.1" | ||
}, | ||
"devDependencies": { | ||
"@npmcli/eslint-config": "^3.0.1", | ||
"@npmcli/template-oss": "3.2.2", | ||
"tap": "^16.0.1" | ||
}, | ||
"scripts": { | ||
"test": "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", | ||
"snap": "tap", | ||
"posttest": "npm run lint" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/npm/npm-install-checks.git" | ||
}, | ||
"keywords": [ | ||
"npm,", | ||
"install" | ||
], | ||
"license": "BSD-2-Clause", | ||
"files": [ | ||
"bin/", | ||
"lib/" | ||
], | ||
"engines": { | ||
"node": "^12.13.0 || ^14.15.0 || >=16.0.0" | ||
}, | ||
"author": "GitHub Inc.", | ||
"templateOSS": { | ||
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", | ||
"version": "3.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters