@pnpm/config.package-is-installable 1000.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +13 -0
- package/lib/checkEngine.d.ts +13 -0
- package/lib/checkEngine.js +32 -0
- package/lib/checkPlatform.d.ts +14 -0
- package/lib/checkPlatform.js +69 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.js +43 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
|
|
4
|
+
Copyright (c) 2016-2026 Zoltan Kochan and other contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
export declare class UnsupportedEngineError extends PnpmError {
|
|
3
|
+
wanted: WantedEngine;
|
|
4
|
+
current: Engine;
|
|
5
|
+
packageId: string;
|
|
6
|
+
constructor(packageId: string, wanted: WantedEngine, current: Engine);
|
|
7
|
+
}
|
|
8
|
+
export declare function checkEngine(packageId: string, wantedEngine: WantedEngine, currentEngine: Engine): UnsupportedEngineError | null;
|
|
9
|
+
export interface Engine {
|
|
10
|
+
node: string;
|
|
11
|
+
pnpm?: string;
|
|
12
|
+
}
|
|
13
|
+
export type WantedEngine = Partial<Engine>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
export class UnsupportedEngineError extends PnpmError {
|
|
4
|
+
wanted;
|
|
5
|
+
current;
|
|
6
|
+
packageId;
|
|
7
|
+
constructor(packageId, wanted, current) {
|
|
8
|
+
super('UNSUPPORTED_ENGINE', `Unsupported engine for ${packageId}: wanted: ${JSON.stringify(wanted)} (current: ${JSON.stringify(current)})`);
|
|
9
|
+
this.packageId = packageId;
|
|
10
|
+
this.wanted = wanted;
|
|
11
|
+
this.current = current;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function checkEngine(packageId, wantedEngine, currentEngine) {
|
|
15
|
+
if (!wantedEngine)
|
|
16
|
+
return null;
|
|
17
|
+
const unsatisfiedWanted = {};
|
|
18
|
+
if (wantedEngine.node && !semver.satisfies(currentEngine.node, wantedEngine.node, { includePrerelease: true })) {
|
|
19
|
+
if (!semver.valid(currentEngine.node)) {
|
|
20
|
+
throw new PnpmError('INVALID_NODE_VERSION', `The nodeVersion setting is "${currentEngine.node}", which is not exact semver version`);
|
|
21
|
+
}
|
|
22
|
+
unsatisfiedWanted.node = wantedEngine.node;
|
|
23
|
+
}
|
|
24
|
+
if (currentEngine.pnpm && wantedEngine.pnpm && !semver.satisfies(currentEngine.pnpm, wantedEngine.pnpm, { includePrerelease: true })) {
|
|
25
|
+
unsatisfiedWanted.pnpm = wantedEngine.pnpm;
|
|
26
|
+
}
|
|
27
|
+
if (Object.keys(unsatisfiedWanted).length > 0) {
|
|
28
|
+
return new UnsupportedEngineError(packageId, unsatisfiedWanted, currentEngine);
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=checkEngine.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
import type { SupportedArchitectures } from '@pnpm/types';
|
|
3
|
+
export declare class UnsupportedPlatformError extends PnpmError {
|
|
4
|
+
wanted: WantedPlatform;
|
|
5
|
+
current: Platform;
|
|
6
|
+
constructor(packageId: string, wanted: WantedPlatform, current: Platform);
|
|
7
|
+
}
|
|
8
|
+
export declare function checkPlatform(packageId: string, wantedPlatform: WantedPlatform, supportedArchitectures?: SupportedArchitectures): UnsupportedPlatformError | null;
|
|
9
|
+
export interface Platform {
|
|
10
|
+
cpu: string | string[];
|
|
11
|
+
os: string | string[];
|
|
12
|
+
libc: string | string[];
|
|
13
|
+
}
|
|
14
|
+
export type WantedPlatform = Partial<Platform>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
import { familySync as getLibcFamilySync } from 'detect-libc';
|
|
3
|
+
const currentLibc = getLibcFamilySync() ?? 'unknown';
|
|
4
|
+
export class UnsupportedPlatformError extends PnpmError {
|
|
5
|
+
wanted;
|
|
6
|
+
current;
|
|
7
|
+
constructor(packageId, wanted, current) {
|
|
8
|
+
super('UNSUPPORTED_PLATFORM', `Unsupported platform for ${packageId}: wanted ${JSON.stringify(wanted)} (current: ${JSON.stringify(current)})`);
|
|
9
|
+
this.wanted = wanted;
|
|
10
|
+
this.current = current;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function checkPlatform(packageId, wantedPlatform, supportedArchitectures) {
|
|
14
|
+
const current = {
|
|
15
|
+
os: dedupeCurrent(process.platform, supportedArchitectures?.os ?? ['current']),
|
|
16
|
+
cpu: dedupeCurrent(process.arch, supportedArchitectures?.cpu ?? ['current']),
|
|
17
|
+
libc: dedupeCurrent(currentLibc, supportedArchitectures?.libc ?? ['current']),
|
|
18
|
+
};
|
|
19
|
+
const { platform, arch } = process;
|
|
20
|
+
let osOk = true;
|
|
21
|
+
let cpuOk = true;
|
|
22
|
+
let libcOk = true;
|
|
23
|
+
if (wantedPlatform.os) {
|
|
24
|
+
osOk = checkList(current.os, wantedPlatform.os);
|
|
25
|
+
}
|
|
26
|
+
if (wantedPlatform.cpu) {
|
|
27
|
+
cpuOk = checkList(current.cpu, wantedPlatform.cpu);
|
|
28
|
+
}
|
|
29
|
+
if (wantedPlatform.libc && currentLibc !== 'unknown') {
|
|
30
|
+
libcOk = checkList(current.libc, wantedPlatform.libc);
|
|
31
|
+
}
|
|
32
|
+
if (!osOk || !cpuOk || !libcOk) {
|
|
33
|
+
return new UnsupportedPlatformError(packageId, wantedPlatform, { os: platform, cpu: arch, libc: currentLibc });
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function checkList(value, list) {
|
|
38
|
+
let tmp;
|
|
39
|
+
let match = false;
|
|
40
|
+
let blc = 0;
|
|
41
|
+
if (typeof list === 'string') {
|
|
42
|
+
list = [list];
|
|
43
|
+
}
|
|
44
|
+
list = list.filter((value) => typeof value === 'string');
|
|
45
|
+
if (list.length === 1 && list[0] === 'any') {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
const values = Array.isArray(value) ? value : [value];
|
|
49
|
+
for (const value of values) {
|
|
50
|
+
for (let i = 0; i < list.length; ++i) {
|
|
51
|
+
tmp = list[i];
|
|
52
|
+
if (tmp[0] === '!') {
|
|
53
|
+
tmp = tmp.slice(1);
|
|
54
|
+
if (tmp === value) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
++blc;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
match = match || tmp === value;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return match || blc === list.length;
|
|
65
|
+
}
|
|
66
|
+
function dedupeCurrent(current, supported) {
|
|
67
|
+
return supported.map((supported) => supported === 'current' ? current : supported);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=checkPlatform.js.map
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SupportedArchitectures } from '@pnpm/types';
|
|
2
|
+
import { UnsupportedEngineError, type WantedEngine } from './checkEngine.js';
|
|
3
|
+
import { UnsupportedPlatformError } from './checkPlatform.js';
|
|
4
|
+
export type { Engine } from './checkEngine.js';
|
|
5
|
+
export type { Platform, WantedPlatform } from './checkPlatform.js';
|
|
6
|
+
export { UnsupportedEngineError, UnsupportedPlatformError, type WantedEngine, };
|
|
7
|
+
export declare function packageIsInstallable(pkgId: string, pkg: {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
engines?: WantedEngine;
|
|
11
|
+
cpu?: string[];
|
|
12
|
+
os?: string[];
|
|
13
|
+
libc?: string[];
|
|
14
|
+
}, options: {
|
|
15
|
+
engineStrict?: boolean;
|
|
16
|
+
nodeVersion?: string;
|
|
17
|
+
optional: boolean;
|
|
18
|
+
pnpmVersion?: string;
|
|
19
|
+
lockfileDir: string;
|
|
20
|
+
supportedArchitectures?: SupportedArchitectures;
|
|
21
|
+
}): boolean | null;
|
|
22
|
+
export declare function checkPackage(pkgId: string, manifest: {
|
|
23
|
+
engines?: WantedEngine;
|
|
24
|
+
cpu?: string[];
|
|
25
|
+
os?: string[];
|
|
26
|
+
libc?: string[];
|
|
27
|
+
}, options: {
|
|
28
|
+
nodeVersion?: string;
|
|
29
|
+
pnpmVersion?: string;
|
|
30
|
+
supportedArchitectures?: SupportedArchitectures;
|
|
31
|
+
}): null | UnsupportedEngineError | UnsupportedPlatformError;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { installCheckLogger, skippedOptionalDependencyLogger, } from '@pnpm/core-loggers';
|
|
2
|
+
import { getSystemNodeVersion } from '@pnpm/engine.runtime.system-node-version';
|
|
3
|
+
import { checkEngine, UnsupportedEngineError } from './checkEngine.js';
|
|
4
|
+
import { checkPlatform, UnsupportedPlatformError } from './checkPlatform.js';
|
|
5
|
+
export { UnsupportedEngineError, UnsupportedPlatformError, };
|
|
6
|
+
export function packageIsInstallable(pkgId, pkg, options) {
|
|
7
|
+
const warn = checkPackage(pkgId, pkg, options);
|
|
8
|
+
if (warn == null)
|
|
9
|
+
return true;
|
|
10
|
+
installCheckLogger.warn({
|
|
11
|
+
message: warn.message,
|
|
12
|
+
prefix: options.lockfileDir,
|
|
13
|
+
});
|
|
14
|
+
if (options.optional) {
|
|
15
|
+
skippedOptionalDependencyLogger.debug({
|
|
16
|
+
details: warn.toString(),
|
|
17
|
+
package: {
|
|
18
|
+
id: pkgId,
|
|
19
|
+
name: pkg.name,
|
|
20
|
+
version: pkg.version,
|
|
21
|
+
},
|
|
22
|
+
prefix: options.lockfileDir,
|
|
23
|
+
reason: warn.code === 'ERR_PNPM_UNSUPPORTED_ENGINE' ? 'unsupported_engine' : 'unsupported_platform',
|
|
24
|
+
});
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
if (options.engineStrict)
|
|
28
|
+
throw warn;
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
export function checkPackage(pkgId, manifest, options) {
|
|
32
|
+
return checkPlatform(pkgId, {
|
|
33
|
+
cpu: manifest.cpu ?? ['any'],
|
|
34
|
+
os: manifest.os ?? ['any'],
|
|
35
|
+
libc: manifest.libc ?? ['any'],
|
|
36
|
+
}, options.supportedArchitectures) ?? ((manifest.engines == null)
|
|
37
|
+
? null
|
|
38
|
+
: checkEngine(pkgId, manifest.engines, {
|
|
39
|
+
node: options.nodeVersion ?? getSystemNodeVersion() ?? process.version,
|
|
40
|
+
pnpm: options.pnpmVersion,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pnpm/config.package-is-installable",
|
|
3
|
+
"version": "1000.0.15",
|
|
4
|
+
"description": "Checks if a package is installable on the current system",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pnpm",
|
|
7
|
+
"pnpm11"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"funding": "https://opencollective.com/pnpm",
|
|
11
|
+
"repository": "https://github.com/pnpm/pnpm/tree/main/config/package-is-installable",
|
|
12
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/config/package-is-installable#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "lib/index.js",
|
|
18
|
+
"types": "lib/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./lib/index.js"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"lib",
|
|
24
|
+
"!*.map"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"detect-libc": "^2.0.3",
|
|
28
|
+
"execa": "npm:safe-execa@0.3.0",
|
|
29
|
+
"memoize": "^10.2.0",
|
|
30
|
+
"semver": "^7.7.2",
|
|
31
|
+
"@pnpm/engine.runtime.system-node-version": "1000.0.11",
|
|
32
|
+
"@pnpm/core-loggers": "1001.0.4",
|
|
33
|
+
"@pnpm/types": "1000.9.0",
|
|
34
|
+
"@pnpm/error": "1000.0.5",
|
|
35
|
+
"@pnpm/cli.meta": "1000.0.11"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@pnpm/logger": ">=1001.0.0 <1002.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@jest/globals": "30.0.5",
|
|
42
|
+
"@types/semver": "7.7.1",
|
|
43
|
+
"@pnpm/logger": "1001.0.1",
|
|
44
|
+
"@pnpm/config.package-is-installable": "1000.0.15"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=22.13"
|
|
48
|
+
},
|
|
49
|
+
"jest": {
|
|
50
|
+
"preset": "@pnpm/jest-config"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"start": "tsgo --watch",
|
|
54
|
+
"_test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest",
|
|
55
|
+
"test": "pnpm run compile && pnpm run _test",
|
|
56
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
57
|
+
"compile": "tsgo --build && pnpm run lint --fix"
|
|
58
|
+
}
|
|
59
|
+
}
|