@pnpm/config.package-is-installable 1100.0.13 → 1100.0.14

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @pnpm/package-is-installable
2
2
 
3
+ ## 1100.0.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @pnpm/core-loggers@1100.2.3
9
+
3
10
  ## 1100.0.13
4
11
 
5
12
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/config.package-is-installable",
3
- "version": "1100.0.13",
3
+ "version": "1100.0.14",
4
4
  "description": "Checks if a package is installable on the current system",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "@pnpm/cli.meta": "1100.0.9",
31
- "@pnpm/core-loggers": "1100.2.2",
31
+ "@pnpm/core-loggers": "1100.2.3",
32
32
  "@pnpm/engine.runtime.system-version": "1100.0.4",
33
33
  "@pnpm/error": "1100.0.1",
34
34
  "@pnpm/types": "1101.4.0",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@jest/globals": "30.4.1",
45
- "@pnpm/config.package-is-installable": "1100.0.13",
45
+ "@pnpm/config.package-is-installable": "1100.0.14",
46
46
  "@pnpm/logger": "1100.0.0",
47
47
  "@types/semver": "7.7.1"
48
48
  },
@@ -1,13 +0,0 @@
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>;
@@ -1,32 +0,0 @@
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
@@ -1,14 +0,0 @@
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>;
@@ -1,69 +0,0 @@
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
- if (typeof list === 'string') {
41
- list = [list];
42
- }
43
- list = list.filter((value) => typeof value === 'string');
44
- if (list.length === 1 && list[0] === 'any') {
45
- return true;
46
- }
47
- const values = Array.isArray(value) ? value : [value];
48
- for (const value of values) {
49
- for (let i = 0; i < list.length; ++i) {
50
- tmp = list[i];
51
- if (tmp[0] === '!') {
52
- tmp = tmp.slice(1);
53
- if (tmp === value) {
54
- return false;
55
- }
56
- }
57
- else {
58
- match = match || tmp === value;
59
- }
60
- }
61
- }
62
- // No negation rejected any value. Accept if a positive entry matched, or if the list
63
- // contains only negations (no positive constraints to satisfy).
64
- return match || list.every(entry => entry[0] === '!');
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 DELETED
@@ -1,32 +0,0 @@
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 { inferPlatformFromPackageName } from './inferPlatformFromPackageName.js';
7
- export { UnsupportedEngineError, UnsupportedPlatformError, type WantedEngine, };
8
- export declare function packageIsInstallable(pkgId: string, pkg: {
9
- name: string;
10
- version: string;
11
- engines?: WantedEngine;
12
- cpu?: string[];
13
- os?: string[];
14
- libc?: string[];
15
- }, options: {
16
- engineStrict?: boolean;
17
- nodeVersion?: string;
18
- optional: boolean;
19
- pnpmVersion?: string;
20
- lockfileDir: string;
21
- supportedArchitectures?: SupportedArchitectures;
22
- }): boolean | null;
23
- export declare function checkPackage(pkgId: string, manifest: {
24
- engines?: WantedEngine;
25
- cpu?: string[];
26
- os?: string[];
27
- libc?: string[];
28
- }, options: {
29
- nodeVersion?: string;
30
- pnpmVersion?: string;
31
- supportedArchitectures?: SupportedArchitectures;
32
- }): null | UnsupportedEngineError | UnsupportedPlatformError;
@@ -1,13 +0,0 @@
1
- export interface PlatformInferredFromPackageName {
2
- os?: string[];
3
- cpu?: string[];
4
- libc?: string[];
5
- }
6
- /**
7
- * Infers the supported platforms of a package from the tokens of its name,
8
- * e.g. `@nx/nx-win32-arm64-msvc` → `{ os: ['win32'], cpu: ['arm64'] }`.
9
- * Platform-specific binary packages follow this naming convention, which is
10
- * the only platform signal left when their os/cpu/libc manifest fields are
11
- * absent. Returns null when no platform token is recognized in the name.
12
- */
13
- export declare function inferPlatformFromPackageName(name: string): PlatformInferredFromPackageName | null;
@@ -1,71 +0,0 @@
1
- const OS_BY_TOKEN = new Map([
2
- ['aix', 'aix'],
3
- ['android', 'android'],
4
- ['darwin', 'darwin'],
5
- ['macos', 'darwin'],
6
- ['osx', 'darwin'],
7
- ['freebsd', 'freebsd'],
8
- ['linux', 'linux'],
9
- ['netbsd', 'netbsd'],
10
- ['openbsd', 'openbsd'],
11
- ['openharmony', 'openharmony'],
12
- ['sunos', 'sunos'],
13
- ['win32', 'win32'],
14
- ['windows', 'win32'],
15
- ]);
16
- const CPU_BY_TOKEN = new Map([
17
- ['arm', 'arm'],
18
- ['armv6', 'arm'],
19
- ['armv7', 'arm'],
20
- ['arm64', 'arm64'],
21
- ['aarch64', 'arm64'],
22
- ['ia32', 'ia32'],
23
- ['loong64', 'loong64'],
24
- ['mips64el', 'mips64el'],
25
- ['ppc64', 'ppc64'],
26
- ['ppc64le', 'ppc64'],
27
- ['riscv64', 'riscv64'],
28
- ['s390x', 's390x'],
29
- ['x64', 'x64'],
30
- ['amd64', 'x64'],
31
- ['wasm32', 'wasm32'],
32
- ]);
33
- const LIBC_BY_TOKEN = new Map([
34
- ['glibc', 'glibc'],
35
- ['gnu', 'glibc'],
36
- ['gnueabihf', 'glibc'],
37
- ['musl', 'musl'],
38
- ['musleabihf', 'musl'],
39
- ]);
40
- /**
41
- * Infers the supported platforms of a package from the tokens of its name,
42
- * e.g. `@nx/nx-win32-arm64-msvc` → `{ os: ['win32'], cpu: ['arm64'] }`.
43
- * Platform-specific binary packages follow this naming convention, which is
44
- * the only platform signal left when their os/cpu/libc manifest fields are
45
- * absent. Returns null when no platform token is recognized in the name.
46
- */
47
- export function inferPlatformFromPackageName(name) {
48
- const nameWithoutScope = name.includes('/') ? name.slice(name.indexOf('/') + 1) : name;
49
- const tokens = nameWithoutScope.toLowerCase().split(/[-_.]/);
50
- const os = pickTokenValues(tokens, OS_BY_TOKEN);
51
- const cpu = pickTokenValues(tokens, CPU_BY_TOKEN);
52
- const libc = pickTokenValues(tokens, LIBC_BY_TOKEN);
53
- if (os == null && cpu == null && libc == null)
54
- return null;
55
- return {
56
- ...(os != null ? { os } : {}),
57
- ...(cpu != null ? { cpu } : {}),
58
- ...(libc != null ? { libc } : {}),
59
- };
60
- }
61
- function pickTokenValues(tokens, valueByToken) {
62
- const values = new Set();
63
- for (const token of tokens) {
64
- const value = valueByToken.get(token);
65
- if (value != null) {
66
- values.add(value);
67
- }
68
- }
69
- return values.size > 0 ? Array.from(values) : undefined;
70
- }
71
- //# sourceMappingURL=inferPlatformFromPackageName.js.map