@teambit/pnpm 1.0.1123 → 1.0.1125
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/.npmignore +18 -0
- package/dist/get-proxy-config.d.ts +2 -7
- package/dist/get-proxy-config.js +4 -7
- package/dist/get-proxy-config.js.map +1 -1
- package/dist/get-registries.d.ts +2 -2
- package/dist/get-registries.js +23 -93
- package/dist/get-registries.js.map +1 -1
- package/dist/load-pnpm-esm.cjs +19 -0
- package/dist/lockfile-deps-graph-converter.d.ts +17 -1
- package/dist/lockfile-deps-graph-converter.js +101 -32
- package/dist/lockfile-deps-graph-converter.js.map +1 -1
- package/dist/lockfile-deps-graph-converter.spec.js +200 -5
- package/dist/lockfile-deps-graph-converter.spec.js.map +1 -1
- package/dist/lynx.d.ts +53 -5
- package/dist/lynx.js +378 -322
- package/dist/lynx.js.map +1 -1
- package/dist/lynx.spec.d.ts +1 -0
- package/dist/lynx.spec.js +55 -0
- package/dist/lynx.spec.js.map +1 -0
- package/dist/pnpm-error-to-bit-error.d.ts +17 -2
- package/dist/pnpm-error-to-bit-error.js +7 -0
- package/dist/pnpm-error-to-bit-error.js.map +1 -1
- package/dist/pnpm-error-to-bit-error.spec.js +10 -11
- package/dist/pnpm-error-to-bit-error.spec.js.map +1 -1
- package/dist/pnpm-prune-modules.js +18 -8
- package/dist/pnpm-prune-modules.js.map +1 -1
- package/dist/pnpm.package-manager.d.ts +3 -4
- package/dist/pnpm.package-manager.js +168 -60
- package/dist/pnpm.package-manager.js.map +1 -1
- package/dist/pnpm.package-manager.spec.d.ts +1 -0
- package/dist/pnpm.package-manager.spec.js +48 -0
- package/dist/pnpm.package-manager.spec.js.map +1 -0
- package/dist/{preview-1785446962235.js → preview-1785493814568.js} +2 -2
- package/dist/read-config.d.ts +7 -1
- package/dist/read-config.js +22 -14
- package/dist/read-config.js.map +1 -1
- package/load-pnpm-esm.cjs +19 -0
- package/package.json +21 -33
package/.npmignore
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
dist/tsconfig.tsbuildinfo
|
|
2
|
+
dist/tsconfig.json
|
|
3
|
+
/tsconfig.json
|
|
4
|
+
|
|
5
|
+
package-tar/
|
|
6
|
+
.bit-capsule-ready
|
|
7
|
+
/*.ts
|
|
8
|
+
artifacts/*
|
|
9
|
+
!artifacts/env-template
|
|
10
|
+
!artifacts/ui-bundle
|
|
11
|
+
!artifacts/preview-bundle
|
|
12
|
+
package-tar/
|
|
13
|
+
.bit-capsule-ready
|
|
14
|
+
/*.ts
|
|
15
|
+
artifacts/*
|
|
16
|
+
!artifacts/env-template
|
|
17
|
+
!artifacts/ui-bundle
|
|
18
|
+
!artifacts/preview-bundle
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import type { PackageManagerProxyConfig } from '@teambit/dependency-resolver';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function getProxyConfig(config:
|
|
4
|
-
export type ProxyConfig = {
|
|
5
|
-
httpProxy?: string;
|
|
6
|
-
httpsProxy?: string;
|
|
7
|
-
noProxy?: boolean | string;
|
|
8
|
-
};
|
|
2
|
+
import type { ResolvedConfig } from '@pnpm/napi';
|
|
3
|
+
export declare function getProxyConfig(config: ResolvedConfig): PackageManagerProxyConfig;
|
package/dist/get-proxy-config.js
CHANGED
|
@@ -5,14 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getProxyConfig = getProxyConfig;
|
|
7
7
|
function getProxyConfig(config) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
httpsProxy,
|
|
13
|
-
noProxy: config.rawConfig.noproxy
|
|
8
|
+
return {
|
|
9
|
+
httpProxy: config.httpProxy,
|
|
10
|
+
httpsProxy: config.httpsProxy ?? config.httpProxy,
|
|
11
|
+
noProxy: config.noProxy
|
|
14
12
|
};
|
|
15
|
-
return proxyConfig;
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
//# sourceMappingURL=get-proxy-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getProxyConfig","config","httpProxy","httpsProxy","
|
|
1
|
+
{"version":3,"names":["getProxyConfig","config","httpProxy","httpsProxy","noProxy"],"sources":["get-proxy-config.ts"],"sourcesContent":["import type { PackageManagerProxyConfig } from '@teambit/dependency-resolver';\nimport type { ResolvedConfig } from '@pnpm/napi';\n\nexport function getProxyConfig(config: ResolvedConfig): PackageManagerProxyConfig {\n return {\n httpProxy: config.httpProxy,\n httpsProxy: config.httpsProxy ?? config.httpProxy,\n noProxy: config.noProxy,\n };\n}\n"],"mappings":";;;;;;AAGO,SAASA,cAAcA,CAACC,MAAsB,EAA6B;EAChF,OAAO;IACLC,SAAS,EAAED,MAAM,CAACC,SAAS;IAC3BC,UAAU,EAAEF,MAAM,CAACE,UAAU,IAAIF,MAAM,CAACC,SAAS;IACjDE,OAAO,EAAEH,MAAM,CAACG;EAClB,CAAC;AACH","ignoreList":[]}
|
package/dist/get-registries.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RegistriesMap } from '@teambit/dependency-resolver';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function getRegistries(config:
|
|
2
|
+
import type { ResolvedConfig } from '@pnpm/napi';
|
|
3
|
+
export declare function getRegistries(config: ResolvedConfig): RegistriesMap;
|
package/dist/get-registries.js
CHANGED
|
@@ -4,35 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getRegistries = getRegistries;
|
|
7
|
-
function _credentialsByUri() {
|
|
8
|
-
const data = _interopRequireDefault(require("credentials-by-uri"));
|
|
9
|
-
_credentialsByUri = function () {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _toolboxString() {
|
|
15
|
-
const data = require("@teambit/toolbox.string.strip-trailing-char");
|
|
16
|
-
_toolboxString = function () {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
function _lodash() {
|
|
22
|
-
const data = require("lodash");
|
|
23
|
-
_lodash = function () {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
function _nerfDart() {
|
|
29
|
-
const data = _interopRequireDefault(require("nerf-dart"));
|
|
30
|
-
_nerfDart = function () {
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
36
7
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
37
8
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
38
9
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -40,71 +11,36 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
40
11
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
41
12
|
function getRegistries(config) {
|
|
42
13
|
const registriesMap = {};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
authHeaderValue: credentials.authHeaderValue
|
|
55
|
-
}, originalAuthConfig);
|
|
56
|
-
});
|
|
14
|
+
for (const {
|
|
15
|
+
name,
|
|
16
|
+
url,
|
|
17
|
+
authHeader
|
|
18
|
+
} of config.registries) {
|
|
19
|
+
registriesMap[name] = _objectSpread({
|
|
20
|
+
uri: url,
|
|
21
|
+
alwaysAuth: !!authHeader,
|
|
22
|
+
authHeaderValue: authHeader
|
|
23
|
+
}, originalAuthFromHeader(authHeader));
|
|
24
|
+
}
|
|
57
25
|
return registriesMap;
|
|
58
26
|
}
|
|
59
27
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
originalAuthType: creds.originalAuthType || defaultCredentials.originalAuthType,
|
|
69
|
-
originalAuthValue: creds.originalAuthValue || defaultCredentials.originalAuthValue
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function getScopedCredentials(nerfed, scope, config) {
|
|
73
|
-
const token = config[`${scope}_authToken`];
|
|
74
|
-
// Check for bearer token
|
|
75
|
-
if (token) {
|
|
76
|
-
return {
|
|
77
|
-
originalAuthType: `authToken`,
|
|
78
|
-
originalAuthValue: token
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
const auth = config[`${scope}_auth`];
|
|
82
|
-
|
|
83
|
-
// Check for basic auth token
|
|
84
|
-
if (auth) {
|
|
28
|
+
/**
|
|
29
|
+
* Reconstruct the npmrc-style credential a header came from, for consumers
|
|
30
|
+
* that regenerate `.npmrc` entries from Bit's registry model: `Bearer` is an
|
|
31
|
+
* `_authToken` credential and `Basic` an `_auth` (base64 `user:password`) one.
|
|
32
|
+
*/
|
|
33
|
+
function originalAuthFromHeader(authHeader) {
|
|
34
|
+
if (authHeader?.startsWith('Bearer ')) {
|
|
85
35
|
return {
|
|
86
|
-
originalAuthType:
|
|
87
|
-
originalAuthValue:
|
|
36
|
+
originalAuthType: 'authToken',
|
|
37
|
+
originalAuthValue: authHeader.slice('Bearer '.length)
|
|
88
38
|
};
|
|
89
39
|
}
|
|
90
|
-
|
|
91
|
-
// Check for username/password auth
|
|
92
|
-
let username;
|
|
93
|
-
let password;
|
|
94
|
-
if (config[`${scope}username`]) {
|
|
95
|
-
username = config[`${scope}username`];
|
|
96
|
-
}
|
|
97
|
-
if (config[`${scope}_password`]) {
|
|
98
|
-
if (scope === '') {
|
|
99
|
-
password = config[`${scope}_password`];
|
|
100
|
-
} else {
|
|
101
|
-
password = Buffer.from(config[`${scope}_password`], 'base64').toString('utf8');
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (username && password) {
|
|
40
|
+
if (authHeader?.startsWith('Basic ')) {
|
|
105
41
|
return {
|
|
106
|
-
originalAuthType:
|
|
107
|
-
originalAuthValue:
|
|
42
|
+
originalAuthType: 'auth',
|
|
43
|
+
originalAuthValue: authHeader.slice('Basic '.length)
|
|
108
44
|
};
|
|
109
45
|
}
|
|
110
46
|
return {
|
|
@@ -112,11 +48,5 @@ function getScopedCredentials(nerfed, scope, config) {
|
|
|
112
48
|
originalAuthValue: ''
|
|
113
49
|
};
|
|
114
50
|
}
|
|
115
|
-
function switchTrailingSlash(uri) {
|
|
116
|
-
if (!uri.endsWith('/')) {
|
|
117
|
-
return `${uri}/`;
|
|
118
|
-
}
|
|
119
|
-
return (0, _toolboxString().stripTrailingChar)(uri, '/');
|
|
120
|
-
}
|
|
121
51
|
|
|
122
52
|
//# sourceMappingURL=get-registries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getRegistries","config","registriesMap","name","url","authHeader","registries","_objectSpread","uri","alwaysAuth","authHeaderValue","originalAuthFromHeader","startsWith","originalAuthType","originalAuthValue","slice","length"],"sources":["get-registries.ts"],"sourcesContent":["import type { RegistriesMap } from '@teambit/dependency-resolver';\nimport type { ResolvedConfig } from '@pnpm/napi';\n\nexport function getRegistries(config: ResolvedConfig): RegistriesMap {\n const registriesMap: RegistriesMap = {};\n for (const { name, url, authHeader } of config.registries) {\n registriesMap[name] = {\n uri: url,\n alwaysAuth: !!authHeader,\n authHeaderValue: authHeader,\n ...originalAuthFromHeader(authHeader),\n };\n }\n return registriesMap;\n}\n\n/**\n * Reconstruct the npmrc-style credential a header came from, for consumers\n * that regenerate `.npmrc` entries from Bit's registry model: `Bearer` is an\n * `_authToken` credential and `Basic` an `_auth` (base64 `user:password`) one.\n */\nfunction originalAuthFromHeader(authHeader: string | undefined): {\n originalAuthType: string;\n originalAuthValue: string;\n} {\n if (authHeader?.startsWith('Bearer ')) {\n return { originalAuthType: 'authToken', originalAuthValue: authHeader.slice('Bearer '.length) };\n }\n if (authHeader?.startsWith('Basic ')) {\n return { originalAuthType: 'auth', originalAuthValue: authHeader.slice('Basic '.length) };\n }\n return { originalAuthType: '', originalAuthValue: '' };\n}\n"],"mappings":";;;;;;;;;;;AAGO,SAASA,aAAaA,CAACC,MAAsB,EAAiB;EACnE,MAAMC,aAA4B,GAAG,CAAC,CAAC;EACvC,KAAK,MAAM;IAAEC,IAAI;IAAEC,GAAG;IAAEC;EAAW,CAAC,IAAIJ,MAAM,CAACK,UAAU,EAAE;IACzDJ,aAAa,CAACC,IAAI,CAAC,GAAAI,aAAA;MACjBC,GAAG,EAAEJ,GAAG;MACRK,UAAU,EAAE,CAAC,CAACJ,UAAU;MACxBK,eAAe,EAAEL;IAAU,GACxBM,sBAAsB,CAACN,UAAU,CAAC,CACtC;EACH;EACA,OAAOH,aAAa;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASS,sBAAsBA,CAACN,UAA8B,EAG5D;EACA,IAAIA,UAAU,EAAEO,UAAU,CAAC,SAAS,CAAC,EAAE;IACrC,OAAO;MAAEC,gBAAgB,EAAE,WAAW;MAAEC,iBAAiB,EAAET,UAAU,CAACU,KAAK,CAAC,SAAS,CAACC,MAAM;IAAE,CAAC;EACjG;EACA,IAAIX,UAAU,EAAEO,UAAU,CAAC,QAAQ,CAAC,EAAE;IACpC,OAAO;MAAEC,gBAAgB,EAAE,MAAM;MAAEC,iBAAiB,EAAET,UAAU,CAACU,KAAK,CAAC,QAAQ,CAACC,MAAM;IAAE,CAAC;EAC3F;EACA,OAAO;IAAEH,gBAAgB,EAAE,EAAE;IAAEC,iBAAiB,EAAE;EAAG,CAAC;AACxD","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Native CJS so Babel's modules-commonjs transform leaves the import() alone.
|
|
4
|
+
// @pnpm/deps.path, @pnpm/lockfile.fs, and @pnpm/installing.modules-yaml are
|
|
5
|
+
// ESM-only and must go through Node's ESM loader.
|
|
6
|
+
let esmPromise;
|
|
7
|
+
exports.loadEsm = async () => {
|
|
8
|
+
esmPromise ??= Promise.all([
|
|
9
|
+
import('@pnpm/deps.path'),
|
|
10
|
+
import('@pnpm/lockfile.fs'),
|
|
11
|
+
import('@pnpm/installing.modules-yaml'),
|
|
12
|
+
]).then(([dp, lockfileFs, modulesYaml]) => ({
|
|
13
|
+
dp,
|
|
14
|
+
lockfileFs,
|
|
15
|
+
modulesYaml,
|
|
16
|
+
getLockfileImporterId: lockfileFs.getLockfileImporterId,
|
|
17
|
+
}));
|
|
18
|
+
return esmPromise;
|
|
19
|
+
};
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { type ProjectManifest } from '@pnpm/types';
|
|
2
|
-
import { type ResolveFunction } from '@pnpm/client';
|
|
3
2
|
import { DependenciesGraph } from '@teambit/objects';
|
|
4
3
|
import { type CalcDepsGraphOptions, type CalcDepsGraphForComponentOptions } from '@teambit/dependency-resolver';
|
|
5
4
|
import { type BitLockfileFile } from './lynx';
|
|
5
|
+
/**
|
|
6
|
+
* Minimal structural signature of the `resolve` function returned by
|
|
7
|
+
* `generateResolverAndFetcher` in `./lynx` (backed by `@pnpm/napi`'s
|
|
8
|
+
* `resolveDependency`). Only the parts this module consumes are typed.
|
|
9
|
+
*/
|
|
10
|
+
type ResolveFunction = (wantedDependency: {
|
|
11
|
+
alias?: string;
|
|
12
|
+
bareSpecifier?: string;
|
|
13
|
+
}, opts: {
|
|
14
|
+
lockfileDir?: string;
|
|
15
|
+
projectDir?: string;
|
|
16
|
+
preferredVersions?: Record<string, unknown>;
|
|
17
|
+
}) => Promise<{
|
|
18
|
+
resolution?: Record<string, unknown>;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function init(): Promise<void>;
|
|
6
21
|
export declare function convertLockfileToGraph(lockfile: BitLockfileFile, { pkgName, componentRootDir, componentRelativeDir, componentIdByPkgName, }: Omit<CalcDepsGraphOptions & CalcDepsGraphForComponentOptions, 'rootDir' | 'components' | 'component'>): DependenciesGraph;
|
|
7
22
|
export declare function convertGraphToLockfile(_graph: DependenciesGraph, { manifests, rootDir, resolve, }: {
|
|
8
23
|
manifests: Record<string, ProjectManifest>;
|
|
9
24
|
rootDir: string;
|
|
10
25
|
resolve: ResolveFunction;
|
|
11
26
|
}): Promise<BitLockfileFile>;
|
|
27
|
+
export {};
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.convertGraphToLockfile = convertGraphToLockfile;
|
|
7
7
|
exports.convertLockfileToGraph = convertLockfileToGraph;
|
|
8
|
+
exports.init = init;
|
|
8
9
|
function _path() {
|
|
9
10
|
const data = _interopRequireDefault(require("path"));
|
|
10
11
|
_path = function () {
|
|
@@ -12,13 +13,6 @@ function _path() {
|
|
|
12
13
|
};
|
|
13
14
|
return data;
|
|
14
15
|
}
|
|
15
|
-
function dp() {
|
|
16
|
-
const data = _interopRequireWildcard(require("@pnpm/dependency-path"));
|
|
17
|
-
dp = function () {
|
|
18
|
-
return data;
|
|
19
|
-
};
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
16
|
function _lodash() {
|
|
23
17
|
const data = require("lodash");
|
|
24
18
|
_lodash = function () {
|
|
@@ -47,13 +41,6 @@ function _objects() {
|
|
|
47
41
|
};
|
|
48
42
|
return data;
|
|
49
43
|
}
|
|
50
|
-
function _lockfile() {
|
|
51
|
-
const data = require("@pnpm/lockfile.fs");
|
|
52
|
-
_lockfile = function () {
|
|
53
|
-
return data;
|
|
54
|
-
};
|
|
55
|
-
return data;
|
|
56
|
-
}
|
|
57
44
|
function _normalizePath() {
|
|
58
45
|
const data = _interopRequireDefault(require("normalize-path"));
|
|
59
46
|
_normalizePath = function () {
|
|
@@ -61,13 +48,41 @@ function _normalizePath() {
|
|
|
61
48
|
};
|
|
62
49
|
return data;
|
|
63
50
|
}
|
|
64
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
65
51
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
66
52
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
67
53
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
68
54
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
69
55
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
70
56
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
57
|
+
/**
|
|
58
|
+
* Minimal structural signature of the `resolve` function returned by
|
|
59
|
+
* `generateResolverAndFetcher` in `./lynx` (backed by `@pnpm/napi`'s
|
|
60
|
+
* `resolveDependency`). Only the parts this module consumes are typed.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
// @pnpm/deps.path and @pnpm/lockfile.fs are ESM-only; load them through a .cjs
|
|
64
|
+
// shim so the require() chain in the build capsule's mocha runner doesn't trip
|
|
65
|
+
// on the transitive ESM import. Call `init()` once before invoking the public
|
|
66
|
+
// converters; helpers reach for these module-level slots synchronously.
|
|
67
|
+
let dp;
|
|
68
|
+
let getLockfileImporterId;
|
|
69
|
+
let loading;
|
|
70
|
+
function ensureInitialized() {
|
|
71
|
+
if (!dp || !getLockfileImporterId) {
|
|
72
|
+
throw new Error('lockfile-deps-graph-converter: await init() before calling the converters');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function init() {
|
|
76
|
+
loading ??= (async () => {
|
|
77
|
+
const {
|
|
78
|
+
loadEsm
|
|
79
|
+
} = require('./load-pnpm-esm.cjs');
|
|
80
|
+
const m = await loadEsm();
|
|
81
|
+
dp = m.dp;
|
|
82
|
+
getLockfileImporterId = m.getLockfileImporterId;
|
|
83
|
+
})();
|
|
84
|
+
return loading;
|
|
85
|
+
}
|
|
71
86
|
function convertLockfileToGraphFromCapsule(lockfile, {
|
|
72
87
|
componentRelativeDir,
|
|
73
88
|
componentIdByPkgName
|
|
@@ -92,7 +107,10 @@ function importerDepsToNeighbours(importerDependencies, lifecycle, optional) {
|
|
|
92
107
|
version,
|
|
93
108
|
specifier
|
|
94
109
|
}] of Object.entries(importerDependencies)) {
|
|
95
|
-
|
|
110
|
+
// `refToRelative` yields null for non-registry refs (`link:` and
|
|
111
|
+
// friends) — those are workspace wiring, not graph nodes.
|
|
112
|
+
const id = dp.refToRelative(version, name);
|
|
113
|
+
if (id == null) continue;
|
|
96
114
|
neighbours.push({
|
|
97
115
|
name,
|
|
98
116
|
specifier,
|
|
@@ -109,6 +127,7 @@ function convertLockfileToGraph(lockfile, {
|
|
|
109
127
|
componentRelativeDir,
|
|
110
128
|
componentIdByPkgName
|
|
111
129
|
}) {
|
|
130
|
+
ensureInitialized();
|
|
112
131
|
if (componentRootDir == null || pkgName == null) {
|
|
113
132
|
return convertLockfileToGraphFromCapsule(lockfile, {
|
|
114
133
|
componentRelativeDir,
|
|
@@ -125,7 +144,8 @@ function convertLockfileToGraph(lockfile, {
|
|
|
125
144
|
for (const depType of ['dependencies', 'optionalDependencies']) {
|
|
126
145
|
const optional = depType === 'optionalDependencies';
|
|
127
146
|
for (const [name, version] of Object.entries(lockedPkg[depType] ?? {})) {
|
|
128
|
-
const id = dp
|
|
147
|
+
const id = dp.refToRelative(version, name);
|
|
148
|
+
if (id == null) continue;
|
|
129
149
|
directDependencies.push({
|
|
130
150
|
name,
|
|
131
151
|
specifier: componentDevImporter[depType]?.[name]?.specifier ?? '*',
|
|
@@ -136,7 +156,7 @@ function convertLockfileToGraph(lockfile, {
|
|
|
136
156
|
}
|
|
137
157
|
}
|
|
138
158
|
delete lockfile.snapshots[lockedPkgDepPath];
|
|
139
|
-
delete lockfile.packages[dp
|
|
159
|
+
delete lockfile.packages[dp.removeSuffix(lockedPkgDepPath)];
|
|
140
160
|
// Scrub back-edges from a circular workspace dep (another workspace
|
|
141
161
|
// component depending on the one we're processing). Otherwise the
|
|
142
162
|
// back-edge survives buildEdges but its target — the just-deleted
|
|
@@ -188,7 +208,7 @@ function buildEdges(lockfile, {
|
|
|
188
208
|
id: replacedDepPath,
|
|
189
209
|
neighbours
|
|
190
210
|
};
|
|
191
|
-
const pkgId = dp
|
|
211
|
+
const pkgId = dp.removeSuffix(replacedDepPath);
|
|
192
212
|
if (pkgId !== replacedDepPath) {
|
|
193
213
|
edge.attr = {
|
|
194
214
|
pkgId
|
|
@@ -225,7 +245,7 @@ function extractDependenciesFromSnapshot(snapshot, replaceFileVersion) {
|
|
|
225
245
|
optional: true
|
|
226
246
|
}]) {
|
|
227
247
|
for (const [name, ref] of Object.entries(snapshot[depTypeField] ?? {})) {
|
|
228
|
-
const subDepPath = dp
|
|
248
|
+
const subDepPath = dp.refToRelative(ref, name);
|
|
229
249
|
if (subDepPath != null) {
|
|
230
250
|
dependencies.push({
|
|
231
251
|
id: replaceFileVersion(subDepPath),
|
|
@@ -249,7 +269,7 @@ function buildPackages(lockfile, {
|
|
|
249
269
|
delete graphPkg.resolution;
|
|
250
270
|
}
|
|
251
271
|
const replacedPkgId = replaceFileVersion(pkgId);
|
|
252
|
-
const parsed = dp
|
|
272
|
+
const parsed = dp.parse(replacedPkgId);
|
|
253
273
|
if (parsed.name && componentIdByPkgName.has(parsed.name)) {
|
|
254
274
|
const compId = componentIdByPkgName.get(parsed.name);
|
|
255
275
|
graphPkg.component = {
|
|
@@ -283,6 +303,7 @@ async function convertGraphToLockfile(_graph, {
|
|
|
283
303
|
rootDir,
|
|
284
304
|
resolve
|
|
285
305
|
}) {
|
|
306
|
+
await init();
|
|
286
307
|
const graphString = _graph.serialize();
|
|
287
308
|
const graph = _objects().DependenciesGraph.deserialize(graphString);
|
|
288
309
|
dropOrphanFilePkgs(graph);
|
|
@@ -336,7 +357,7 @@ async function convertGraphToLockfile(_graph, {
|
|
|
336
357
|
const rootEdge = graph.findRootEdge();
|
|
337
358
|
if (rootEdge) {
|
|
338
359
|
for (const [projectDir, manifest] of Object.entries(manifests)) {
|
|
339
|
-
const projectId =
|
|
360
|
+
const projectId = getLockfileImporterId(rootDir, projectDir);
|
|
340
361
|
lockfile.importers[projectId] = {
|
|
341
362
|
dependencies: {},
|
|
342
363
|
devDependencies: {},
|
|
@@ -351,9 +372,9 @@ async function convertGraphToLockfile(_graph, {
|
|
|
351
372
|
specifier
|
|
352
373
|
};
|
|
353
374
|
} else {
|
|
354
|
-
const edgeId = rootEdge.neighbours.find(directDep => directDep.name === name && (directDep.specifier === specifier || dp
|
|
375
|
+
const edgeId = rootEdge.neighbours.find(directDep => directDep.name === name && (directDep.specifier === specifier || dp.removeSuffix(directDep.id) === `${name}@${specifier}`))?.id;
|
|
355
376
|
if (edgeId) {
|
|
356
|
-
const parsed = dp
|
|
377
|
+
const parsed = dp.parse(edgeId);
|
|
357
378
|
const ref = depPathToRef(parsed);
|
|
358
379
|
lockfile.importers[projectId][depType][name] = {
|
|
359
380
|
version: ref,
|
|
@@ -375,8 +396,8 @@ async function convertGraphToLockfile(_graph, {
|
|
|
375
396
|
alias: pkgToResolve.name,
|
|
376
397
|
bareSpecifier: pkgToResolve.version
|
|
377
398
|
}, {
|
|
378
|
-
lockfileDir:
|
|
379
|
-
projectDir:
|
|
399
|
+
lockfileDir: rootDir,
|
|
400
|
+
projectDir: rootDir,
|
|
380
401
|
preferredVersions: {}
|
|
381
402
|
});
|
|
382
403
|
} catch (err) {
|
|
@@ -397,7 +418,7 @@ async function convertGraphToLockfile(_graph, {
|
|
|
397
418
|
const {
|
|
398
419
|
resolution
|
|
399
420
|
} = resolveResult;
|
|
400
|
-
if ('integrity' in resolution && resolution.integrity) {
|
|
421
|
+
if (resolution != null && 'integrity' in resolution && resolution.integrity) {
|
|
401
422
|
lockfile.packages[pkgToResolve.pkgId].resolution = {
|
|
402
423
|
integrity: resolution.integrity
|
|
403
424
|
};
|
|
@@ -426,6 +447,7 @@ async function convertGraphToLockfile(_graph, {
|
|
|
426
447
|
if (failedWorkspaceComponentPkgs.size > 0) {
|
|
427
448
|
scrubPkgsFromLockfile(lockfile, failedWorkspaceComponentPkgs);
|
|
428
449
|
}
|
|
450
|
+
dropUnreachableLockfileEntries(lockfile);
|
|
429
451
|
// Validate the generated lockfile
|
|
430
452
|
for (const [depPath, pkg] of Object.entries(lockfile.packages)) {
|
|
431
453
|
if (pkg.resolution == null || Object.keys(pkg.resolution).length === 0) {
|
|
@@ -438,7 +460,7 @@ async function convertGraphToLockfile(_graph, {
|
|
|
438
460
|
for (const {
|
|
439
461
|
id
|
|
440
462
|
} of neighbours) {
|
|
441
|
-
const parsed = dp
|
|
463
|
+
const parsed = dp.parse(id);
|
|
442
464
|
deps[parsed.name] = depPathToRef(parsed);
|
|
443
465
|
if (!allEdgeIds.has(id)) {
|
|
444
466
|
snapshots[id] = {};
|
|
@@ -461,7 +483,7 @@ function getPkgsToResolve(lockfile, manifests) {
|
|
|
461
483
|
}
|
|
462
484
|
for (const [pkgId, pkg] of Object.entries(lockfile.packages ?? {})) {
|
|
463
485
|
if (pkg.resolution == null || 'type' in pkg.resolution && pkg.resolution.type === 'directory') {
|
|
464
|
-
const parsed = dp
|
|
486
|
+
const parsed = dp.parse(pkgId);
|
|
465
487
|
if (parsed.name && parsed.version && (!pkgsInTheWorkspaces.has(parsed.name) || pkgsInTheWorkspaces.get(parsed.name) !== parsed.version)) {
|
|
466
488
|
pkgsToResolve.push({
|
|
467
489
|
name: parsed.name,
|
|
@@ -473,11 +495,58 @@ function getPkgsToResolve(lockfile, manifests) {
|
|
|
473
495
|
}
|
|
474
496
|
return pkgsToResolve;
|
|
475
497
|
}
|
|
498
|
+
function dropUnreachableLockfileEntries(lockfile) {
|
|
499
|
+
const reachablePackages = new Set();
|
|
500
|
+
const reachableSnapshots = new Set();
|
|
501
|
+
// An explicit stack: deep dependency chains would overflow the call
|
|
502
|
+
// stack with a recursive walk.
|
|
503
|
+
const stack = [];
|
|
504
|
+
const visit = depPath => {
|
|
505
|
+
stack.push(depPath);
|
|
506
|
+
while (stack.length > 0) {
|
|
507
|
+
const current = stack.pop();
|
|
508
|
+
if (reachableSnapshots.has(current)) continue;
|
|
509
|
+
reachableSnapshots.add(current);
|
|
510
|
+
reachablePackages.add(dp.removeSuffix(current));
|
|
511
|
+
const snapshot = lockfile.snapshots?.[current];
|
|
512
|
+
if (!snapshot) continue;
|
|
513
|
+
for (const depType of ['dependencies', 'optionalDependencies']) {
|
|
514
|
+
for (const [name, ref] of Object.entries(snapshot[depType] ?? {})) {
|
|
515
|
+
if (ref.startsWith('link:') || ref.startsWith('file:')) continue;
|
|
516
|
+
stack.push(`${name}@${ref}`);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
for (const importer of Object.values(lockfile.importers ?? {})) {
|
|
522
|
+
for (const depType of ['dependencies', 'devDependencies', 'optionalDependencies']) {
|
|
523
|
+
for (const [name, {
|
|
524
|
+
version
|
|
525
|
+
}] of Object.entries(importer[depType] ?? {})) {
|
|
526
|
+
if (version.startsWith('link:') || version.startsWith('file:')) continue;
|
|
527
|
+
visit(`${name}@${version}`);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
for (const pkgId of Object.keys(lockfile.packages ?? {})) {
|
|
532
|
+
if (!reachablePackages.has(pkgId)) {
|
|
533
|
+
delete lockfile.packages[pkgId];
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
for (const depPath of Object.keys(lockfile.snapshots ?? {})) {
|
|
537
|
+
if (!reachableSnapshots.has(depPath)) {
|
|
538
|
+
delete lockfile.snapshots[depPath];
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (lockfile.bit?.depsRequiringBuild) {
|
|
542
|
+
lockfile.bit.depsRequiringBuild = lockfile.bit.depsRequiringBuild.filter(depPath => reachablePackages.has(dp.removeSuffix(depPath)));
|
|
543
|
+
}
|
|
544
|
+
}
|
|
476
545
|
function depPathToRef(depPath) {
|
|
477
546
|
return `${depPath.version}${depPath.patchHash ?? ''}${depPath.peerDepGraphHash ?? ''}`;
|
|
478
547
|
}
|
|
479
548
|
function isFilePkgId(pkgId) {
|
|
480
|
-
return dp
|
|
549
|
+
return dp.parse(pkgId).nonSemverVersion?.startsWith('file:') ?? false;
|
|
481
550
|
}
|
|
482
551
|
|
|
483
552
|
/**
|
|
@@ -539,7 +608,7 @@ function dropOrphanFilePkgs(graph) {
|
|
|
539
608
|
*/
|
|
540
609
|
function dropOrphanNeighbours(graph) {
|
|
541
610
|
const edgeIds = new Set(graph.edges.map(edge => edge.id));
|
|
542
|
-
const isOrphan = n => !edgeIds.has(n.id) && !graph.packages.has(dp
|
|
611
|
+
const isOrphan = n => !edgeIds.has(n.id) && !graph.packages.has(dp.removeSuffix(n.id));
|
|
543
612
|
graph.edges = graph.edges.map(edge => {
|
|
544
613
|
if (!edge.neighbours.some(isOrphan)) return edge;
|
|
545
614
|
return _objectSpread(_objectSpread({}, edge), {}, {
|
|
@@ -557,7 +626,7 @@ function dropOrphanNeighbours(graph) {
|
|
|
557
626
|
* specifier, which is the same path as a graph-less install for that one dep.
|
|
558
627
|
*/
|
|
559
628
|
function scrubPkgsFromLockfile(lockfile, pkgIds) {
|
|
560
|
-
const matches = depPath => pkgIds.has(dp
|
|
629
|
+
const matches = depPath => pkgIds.has(dp.removeSuffix(depPath));
|
|
561
630
|
for (const pkgId of pkgIds) {
|
|
562
631
|
delete lockfile.packages[pkgId];
|
|
563
632
|
}
|