@teambit/pnpm 1.0.1124 → 1.0.1126

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.
Files changed (38) hide show
  1. package/.npmignore +18 -0
  2. package/dist/get-proxy-config.d.ts +2 -7
  3. package/dist/get-proxy-config.js +4 -7
  4. package/dist/get-proxy-config.js.map +1 -1
  5. package/dist/get-registries.d.ts +2 -2
  6. package/dist/get-registries.js +23 -93
  7. package/dist/get-registries.js.map +1 -1
  8. package/dist/load-pnpm-esm.cjs +19 -0
  9. package/dist/lockfile-deps-graph-converter.d.ts +17 -1
  10. package/dist/lockfile-deps-graph-converter.js +101 -32
  11. package/dist/lockfile-deps-graph-converter.js.map +1 -1
  12. package/dist/lockfile-deps-graph-converter.spec.js +200 -5
  13. package/dist/lockfile-deps-graph-converter.spec.js.map +1 -1
  14. package/dist/lynx.d.ts +53 -5
  15. package/dist/lynx.js +378 -322
  16. package/dist/lynx.js.map +1 -1
  17. package/dist/lynx.spec.d.ts +1 -0
  18. package/dist/lynx.spec.js +55 -0
  19. package/dist/lynx.spec.js.map +1 -0
  20. package/dist/pnpm-error-to-bit-error.d.ts +17 -2
  21. package/dist/pnpm-error-to-bit-error.js +7 -0
  22. package/dist/pnpm-error-to-bit-error.js.map +1 -1
  23. package/dist/pnpm-error-to-bit-error.spec.js +10 -11
  24. package/dist/pnpm-error-to-bit-error.spec.js.map +1 -1
  25. package/dist/pnpm-prune-modules.js +18 -8
  26. package/dist/pnpm-prune-modules.js.map +1 -1
  27. package/dist/pnpm.package-manager.d.ts +3 -4
  28. package/dist/pnpm.package-manager.js +168 -60
  29. package/dist/pnpm.package-manager.js.map +1 -1
  30. package/dist/pnpm.package-manager.spec.d.ts +1 -0
  31. package/dist/pnpm.package-manager.spec.js +48 -0
  32. package/dist/pnpm.package-manager.spec.js.map +1 -0
  33. package/dist/{preview-1785466791445.js → preview-1785520628900.js} +2 -2
  34. package/dist/read-config.d.ts +7 -1
  35. package/dist/read-config.js +22 -14
  36. package/dist/read-config.js.map +1 -1
  37. package/load-pnpm-esm.cjs +19 -0
  38. 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 { Config } from '@pnpm/config';
3
- export declare function getProxyConfig(config: Config): PackageManagerProxyConfig;
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;
@@ -5,14 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getProxyConfig = getProxyConfig;
7
7
  function getProxyConfig(config) {
8
- const httpProxy = config.httpProxy;
9
- const httpsProxy = config.httpsProxy || httpProxy;
10
- const proxyConfig = {
11
- httpProxy,
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","proxyConfig","noProxy","rawConfig","noproxy"],"sources":["get-proxy-config.ts"],"sourcesContent":["import type { PackageManagerProxyConfig } from '@teambit/dependency-resolver';\nimport type { Config } from '@pnpm/config';\n\nexport function getProxyConfig(config: Config): PackageManagerProxyConfig {\n const httpProxy = config.httpProxy;\n const httpsProxy = config.httpsProxy || httpProxy;\n const proxyConfig: PackageManagerProxyConfig = {\n httpProxy,\n httpsProxy,\n noProxy: config.rawConfig.noproxy,\n };\n return proxyConfig;\n}\n\nexport type ProxyConfig = {\n httpProxy?: string;\n httpsProxy?: string;\n noProxy?: boolean | string;\n};\n"],"mappings":";;;;;;AAGO,SAASA,cAAcA,CAACC,MAAc,EAA6B;EACxE,MAAMC,SAAS,GAAGD,MAAM,CAACC,SAAS;EAClC,MAAMC,UAAU,GAAGF,MAAM,CAACE,UAAU,IAAID,SAAS;EACjD,MAAME,WAAsC,GAAG;IAC7CF,SAAS;IACTC,UAAU;IACVE,OAAO,EAAEJ,MAAM,CAACK,SAAS,CAACC;EAC5B,CAAC;EACD,OAAOH,WAAW;AACpB","ignoreList":[]}
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":[]}
@@ -1,3 +1,3 @@
1
1
  import type { RegistriesMap } from '@teambit/dependency-resolver';
2
- import type { Config } from '@pnpm/config';
3
- export declare function getRegistries(config: Config): RegistriesMap;
2
+ import type { ResolvedConfig } from '@pnpm/napi';
3
+ export declare function getRegistries(config: ResolvedConfig): RegistriesMap;
@@ -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
- Object.keys(config.registries).forEach(regName => {
44
- const uri = config.registries[regName];
45
- let credentials = (0, _credentialsByUri().default)(config.rawConfig, uri);
46
- let originalAuthConfig = getOriginalAuthConfigByUri(config.rawConfig, uri);
47
- if ((0, _lodash().isEmpty)(credentials)) {
48
- credentials = (0, _credentialsByUri().default)(config.rawConfig, switchTrailingSlash(uri));
49
- originalAuthConfig = getOriginalAuthConfigByUri(config.rawConfig, switchTrailingSlash(uri));
50
- }
51
- registriesMap[regName] = _objectSpread({
52
- uri,
53
- alwaysAuth: !!credentials.alwaysAuth,
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
- // based on https://github.com/pnpm/credentials-by-uri/blob/master/index.js
61
- function getOriginalAuthConfigByUri(config, uri) {
62
- const nerfed = (0, _nerfDart().default)(uri);
63
- const defnerf = (0, _nerfDart().default)(config.registry);
64
- const creds = getScopedCredentials(nerfed, `${nerfed}:`, config);
65
- if (nerfed !== defnerf) return creds;
66
- const defaultCredentials = getScopedCredentials(nerfed, '', config);
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: `auth`,
87
- originalAuthValue: auth
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: `auth`,
107
- originalAuthValue: Buffer.from(`${username}:${password}`).toString('base64')
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":["_credentialsByUri","data","_interopRequireDefault","require","_toolboxString","_lodash","_nerfDart","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","getRegistries","config","registriesMap","registries","regName","uri","credentials","getCredentialsByURI","rawConfig","originalAuthConfig","getOriginalAuthConfigByUri","isEmpty","switchTrailingSlash","alwaysAuth","authHeaderValue","nerfed","toNerfDart","defnerf","registry","creds","getScopedCredentials","defaultCredentials","originalAuthType","originalAuthValue","scope","token","auth","username","password","Buffer","from","toString","endsWith","stripTrailingChar"],"sources":["get-registries.ts"],"sourcesContent":["import getCredentialsByURI from 'credentials-by-uri';\nimport type { RegistriesMap } from '@teambit/dependency-resolver';\nimport { stripTrailingChar } from '@teambit/toolbox.string.strip-trailing-char';\nimport type { Config } from '@pnpm/config';\nimport { isEmpty } from 'lodash';\nimport toNerfDart from 'nerf-dart';\n\ntype OriginalAuthConfig = {\n originalAuthType: string;\n originalAuthValue: string;\n};\n\nexport function getRegistries(config: Config): RegistriesMap {\n const registriesMap: RegistriesMap = {};\n\n Object.keys(config.registries).forEach((regName) => {\n const uri = config.registries[regName];\n let credentials = getCredentialsByURI(config.rawConfig, uri);\n let originalAuthConfig = getOriginalAuthConfigByUri(config.rawConfig, uri);\n if (isEmpty(credentials)) {\n credentials = getCredentialsByURI(config.rawConfig, switchTrailingSlash(uri));\n originalAuthConfig = getOriginalAuthConfigByUri(config.rawConfig, switchTrailingSlash(uri));\n }\n registriesMap[regName] = {\n uri,\n alwaysAuth: !!credentials.alwaysAuth,\n authHeaderValue: credentials.authHeaderValue,\n ...originalAuthConfig,\n };\n });\n return registriesMap;\n}\n\n// based on https://github.com/pnpm/credentials-by-uri/blob/master/index.js\nfunction getOriginalAuthConfigByUri(config: Record<string, any>, uri: string): OriginalAuthConfig {\n const nerfed = toNerfDart(uri);\n const defnerf = toNerfDart(config.registry);\n\n const creds = getScopedCredentials(nerfed, `${nerfed}:`, config);\n if (nerfed !== defnerf) return creds;\n const defaultCredentials = getScopedCredentials(nerfed, '', config);\n return {\n originalAuthType: creds.originalAuthType || defaultCredentials.originalAuthType,\n originalAuthValue: creds.originalAuthValue || defaultCredentials.originalAuthValue,\n };\n}\n\nfunction getScopedCredentials(nerfed: string, scope: string, config: Record<string, any>): OriginalAuthConfig {\n const token = config[`${scope}_authToken`];\n // Check for bearer token\n if (token) {\n return {\n originalAuthType: `authToken`,\n originalAuthValue: token,\n };\n }\n\n const auth = config[`${scope}_auth`];\n\n // Check for basic auth token\n if (auth) {\n return {\n originalAuthType: `auth`,\n originalAuthValue: auth,\n };\n }\n\n // Check for username/password auth\n let username;\n let password;\n if (config[`${scope}username`]) {\n username = config[`${scope}username`];\n }\n if (config[`${scope}_password`]) {\n if (scope === '') {\n password = config[`${scope}_password`];\n } else {\n password = Buffer.from(config[`${scope}_password`], 'base64').toString('utf8');\n }\n }\n\n if (username && password) {\n return {\n originalAuthType: `auth`,\n originalAuthValue: Buffer.from(`${username}:${password}`).toString('base64'),\n };\n }\n\n return {\n originalAuthType: '',\n originalAuthValue: '',\n };\n}\n\nfunction switchTrailingSlash(uri: string): string {\n if (!uri.endsWith('/')) {\n return `${uri}/`;\n }\n return stripTrailingChar(uri, '/');\n}\n"],"mappings":";;;;;;AAAA,SAAAA,kBAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,iBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,eAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,cAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,UAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,SAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAA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AAEG;IACrB,CAAC;EACH;;EAEA;EACA,IAAIC,QAAQ;EACZ,IAAIC,QAAQ;EACZ,IAAI3B,MAAM,CAAC,GAAGuB,KAAK,UAAU,CAAC,EAAE;IAC9BG,QAAQ,GAAG1B,MAAM,CAAC,GAAGuB,KAAK,UAAU,CAAC;EACvC;EACA,IAAIvB,MAAM,CAAC,GAAGuB,KAAK,WAAW,CAAC,EAAE;IAC/B,IAAIA,KAAK,KAAK,EAAE,EAAE;MAChBI,QAAQ,GAAG3B,MAAM,CAAC,GAAGuB,KAAK,WAAW,CAAC;IACxC,CAAC,MAAM;MACLI,QAAQ,GAAGC,MAAM,CAACC,IAAI,CAAC7B,MAAM,CAAC,GAAGuB,KAAK,WAAW,CAAC,EAAE,QAAQ,CAAC,CAACO,QAAQ,CAAC,MAAM,CAAC;IAChF;EACF;EAEA,IAAIJ,QAAQ,IAAIC,QAAQ,EAAE;IACxB,OAAO;MACLN,gBAAgB,EAAE,MAAM;MACxBC,iBAAiB,EAAEM,MAAM,CAACC,IAAI,CAAC,GAAGH,QAAQ,IAAIC,QAAQ,EAAE,CAAC,CAACG,QAAQ,CAAC,QAAQ;IAC7E,CAAC;EACH;EAEA,OAAO;IACLT,gBAAgB,EAAE,EAAE;IACpBC,iBAAiB,EAAE;EACrB,CAAC;AACH;AAEA,SAASX,mBAAmBA,CAACP,GAAW,EAAU;EAChD,IAAI,CAACA,GAAG,CAAC2B,QAAQ,CAAC,GAAG,CAAC,EAAE;IACtB,OAAO,GAAG3B,GAAG,GAAG;EAClB;EACA,OAAO,IAAA4B,kCAAiB,EAAC5B,GAAG,EAAE,GAAG,CAAC;AACpC","ignoreList":[]}
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
- const id = dp().refToRelative(version, name);
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().refToRelative(version, name);
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().removeSuffix(lockedPkgDepPath)];
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().removeSuffix(replacedDepPath);
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().refToRelative(ref, name);
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().parse(replacedPkgId);
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 = (0, _lockfile().getLockfileImporterId)(rootDir, projectDir);
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().removeSuffix(directDep.id) === `${name}@${specifier}`))?.id;
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().parse(edgeId);
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().parse(id);
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().parse(pkgId);
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().parse(pkgId).nonSemverVersion?.startsWith('file:') ?? false;
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().removeSuffix(n.id));
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().removeSuffix(depPath));
629
+ const matches = depPath => pkgIds.has(dp.removeSuffix(depPath));
561
630
  for (const pkgId of pkgIds) {
562
631
  delete lockfile.packages[pkgId];
563
632
  }