@pnpm/core 15.3.12 → 16.0.0

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 (40) hide show
  1. package/lib/api.d.ts +0 -1
  2. package/lib/api.js +0 -1
  3. package/lib/api.js.map +1 -1
  4. package/lib/index.d.ts +3 -1
  5. package/lib/index.js +4 -3
  6. package/lib/index.js.map +1 -1
  7. package/lib/install/checkCompatibility/BreakingChangeError.d.ts +12 -0
  8. package/lib/install/checkCompatibility/BreakingChangeError.js +14 -0
  9. package/lib/install/checkCompatibility/BreakingChangeError.js.map +1 -0
  10. package/lib/install/checkCompatibility/ErrorRelatedSources.d.ts +5 -0
  11. package/lib/install/checkCompatibility/ErrorRelatedSources.js +3 -0
  12. package/lib/install/checkCompatibility/ErrorRelatedSources.js.map +1 -0
  13. package/lib/install/checkCompatibility/ModulesBreakingChangeError.d.ts +9 -0
  14. package/lib/install/checkCompatibility/ModulesBreakingChangeError.js +18 -0
  15. package/lib/install/checkCompatibility/ModulesBreakingChangeError.js.map +1 -0
  16. package/lib/install/checkCompatibility/UnexpectedStoreError.d.ts +11 -0
  17. package/lib/install/checkCompatibility/UnexpectedStoreError.js +14 -0
  18. package/lib/install/checkCompatibility/UnexpectedStoreError.js.map +1 -0
  19. package/lib/install/checkCompatibility/UnexpectedVirtualStoreDirError.d.ts +11 -0
  20. package/lib/install/checkCompatibility/UnexpectedVirtualStoreDirError.js +14 -0
  21. package/lib/install/checkCompatibility/UnexpectedVirtualStoreDirError.js.map +1 -0
  22. package/lib/install/checkCompatibility/index.d.ts +6 -0
  23. package/lib/install/checkCompatibility/index.js +38 -0
  24. package/lib/install/checkCompatibility/index.js.map +1 -0
  25. package/lib/install/index.d.ts +2 -9
  26. package/lib/install/index.js +29 -104
  27. package/lib/install/index.js.map +1 -1
  28. package/lib/install/validateModules.d.ts +26 -0
  29. package/lib/install/validateModules.js +138 -0
  30. package/lib/install/validateModules.js.map +1 -0
  31. package/package.json +49 -49
  32. package/lib/install/index.test.d.ts +0 -1
  33. package/lib/install/index.test.js +0 -57
  34. package/lib/install/index.test.js.map +0 -1
  35. package/lib/link/index.d.ts +0 -11
  36. package/lib/link/index.js +0 -144
  37. package/lib/link/index.js.map +0 -1
  38. package/lib/link/options.d.ts +0 -32
  39. package/lib/link/options.js +0 -38
  40. package/lib/link/options.js.map +0 -1
package/lib/api.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './install';
2
2
  export { PeerDependencyIssuesError } from './install/reportPeerDependencyIssues';
3
- export * from './link';
4
3
  export * from './getPeerDependencyIssues';
package/lib/api.js CHANGED
@@ -18,6 +18,5 @@ exports.PeerDependencyIssuesError = void 0;
18
18
  __exportStar(require("./install"), exports);
19
19
  var reportPeerDependencyIssues_1 = require("./install/reportPeerDependencyIssues");
20
20
  Object.defineProperty(exports, "PeerDependencyIssuesError", { enumerable: true, get: function () { return reportPeerDependencyIssues_1.PeerDependencyIssuesError; } });
21
- __exportStar(require("./link"), exports);
22
21
  __exportStar(require("./getPeerDependencyIssues"), exports);
23
22
  //# sourceMappingURL=api.js.map
package/lib/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,mFAAgF;AAAvE,uIAAA,yBAAyB,OAAA;AAClC,yCAAsB;AACtB,4DAAyC"}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,mFAAgF;AAAvE,uIAAA,yBAAyB,OAAA;AAClC,4DAAyC"}
package/lib/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export type { BadPeerDependencyIssue, MissingPeerDependencyIssue, MissingPeerIssuesByPeerName, PackageManifest, PeerDependencyIssues, PeerDependencyIssuesByProjects, } from '@pnpm/types';
2
2
  export type { HoistingLimits } from '@pnpm/headless';
3
3
  export * from './api';
4
- export { type ProjectOptions, UnexpectedStoreError, UnexpectedVirtualStoreDirError } from '@pnpm/get-context';
4
+ export { type ProjectOptions } from '@pnpm/get-context';
5
+ export { UnexpectedStoreError } from './install/checkCompatibility/UnexpectedStoreError';
6
+ export { UnexpectedVirtualStoreDirError } from './install/checkCompatibility/UnexpectedVirtualStoreDirError';
5
7
  export type { InstallOptions } from './install/extendInstallOptions';
6
8
  export type { WorkspacePackages } from '@pnpm/resolver-base';
7
9
  export type { UpdateMatchingFunction } from '@pnpm/resolve-dependencies';
package/lib/index.js CHANGED
@@ -16,7 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.UnexpectedVirtualStoreDirError = exports.UnexpectedStoreError = void 0;
18
18
  __exportStar(require("./api"), exports);
19
- var get_context_1 = require("@pnpm/get-context");
20
- Object.defineProperty(exports, "UnexpectedStoreError", { enumerable: true, get: function () { return get_context_1.UnexpectedStoreError; } });
21
- Object.defineProperty(exports, "UnexpectedVirtualStoreDirError", { enumerable: true, get: function () { return get_context_1.UnexpectedVirtualStoreDirError; } });
19
+ var UnexpectedStoreError_1 = require("./install/checkCompatibility/UnexpectedStoreError");
20
+ Object.defineProperty(exports, "UnexpectedStoreError", { enumerable: true, get: function () { return UnexpectedStoreError_1.UnexpectedStoreError; } });
21
+ var UnexpectedVirtualStoreDirError_1 = require("./install/checkCompatibility/UnexpectedVirtualStoreDirError");
22
+ Object.defineProperty(exports, "UnexpectedVirtualStoreDirError", { enumerable: true, get: function () { return UnexpectedVirtualStoreDirError_1.UnexpectedVirtualStoreDirError; } });
22
23
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AASA,wCAAqB;AAErB,iDAA6G;AAA/E,mHAAA,oBAAoB,OAAA;AAAE,6HAAA,8BAA8B,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AASA,wCAAqB;AAGrB,0FAAwF;AAA/E,4HAAA,oBAAoB,OAAA;AAC7B,8GAA4G;AAAnG,gJAAA,8BAA8B,OAAA"}
@@ -0,0 +1,12 @@
1
+ import { PnpmError } from '@pnpm/error';
2
+ import { type ErrorRelatedSources } from './ErrorRelatedSources';
3
+ export type BreakingChangeErrorOptions = ErrorRelatedSources & {
4
+ code: string;
5
+ message: string;
6
+ };
7
+ export declare class BreakingChangeError extends PnpmError {
8
+ relatedIssue?: number;
9
+ relatedPR?: number;
10
+ additionalInformation?: string;
11
+ constructor(opts: BreakingChangeErrorOptions);
12
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BreakingChangeError = void 0;
4
+ const error_1 = require("@pnpm/error");
5
+ class BreakingChangeError extends error_1.PnpmError {
6
+ constructor(opts) {
7
+ super(opts.code, opts.message);
8
+ this.relatedIssue = opts.relatedIssue;
9
+ this.relatedPR = opts.relatedPR;
10
+ this.additionalInformation = opts.additionalInformation;
11
+ }
12
+ }
13
+ exports.BreakingChangeError = BreakingChangeError;
14
+ //# sourceMappingURL=BreakingChangeError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BreakingChangeError.js","sourceRoot":"","sources":["../../../src/install/checkCompatibility/BreakingChangeError.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AAQvC,MAAa,mBAAoB,SAAQ,iBAAS;IAIhD,YAAa,IAAgC;QAC3C,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAA;QACrC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAA;IACzD,CAAC;CACF;AAVD,kDAUC"}
@@ -0,0 +1,5 @@
1
+ export interface ErrorRelatedSources {
2
+ additionalInformation?: string;
3
+ relatedIssue?: number;
4
+ relatedPR?: number;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ErrorRelatedSources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorRelatedSources.js","sourceRoot":"","sources":["../../../src/install/checkCompatibility/ErrorRelatedSources.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { BreakingChangeError } from './BreakingChangeError';
2
+ import { type ErrorRelatedSources } from './ErrorRelatedSources';
3
+ export type ModulesBreakingChangeErrorOptions = ErrorRelatedSources & {
4
+ modulesPath: string;
5
+ };
6
+ export declare class ModulesBreakingChangeError extends BreakingChangeError {
7
+ modulesPath: string;
8
+ constructor(opts: ModulesBreakingChangeErrorOptions);
9
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModulesBreakingChangeError = void 0;
4
+ const BreakingChangeError_1 = require("./BreakingChangeError");
5
+ class ModulesBreakingChangeError extends BreakingChangeError_1.BreakingChangeError {
6
+ constructor(opts) {
7
+ super({
8
+ additionalInformation: opts.additionalInformation,
9
+ code: 'MODULES_BREAKING_CHANGE',
10
+ message: `The node_modules structure at "${opts.modulesPath}" is not compatible with the current pnpm version. Run "pnpm install --force" to recreate node_modules.`,
11
+ relatedIssue: opts.relatedIssue,
12
+ relatedPR: opts.relatedPR,
13
+ });
14
+ this.modulesPath = opts.modulesPath;
15
+ }
16
+ }
17
+ exports.ModulesBreakingChangeError = ModulesBreakingChangeError;
18
+ //# sourceMappingURL=ModulesBreakingChangeError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModulesBreakingChangeError.js","sourceRoot":"","sources":["../../../src/install/checkCompatibility/ModulesBreakingChangeError.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAO3D,MAAa,0BAA2B,SAAQ,yCAAmB;IAEjE,YAAa,IAAuC;QAClD,KAAK,CAAC;YACJ,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;YACjD,IAAI,EAAE,yBAAyB;YAC/B,OAAO,EAAE,kCAAkC,IAAI,CAAC,WAAW,yGAAyG;YACpK,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAA;QACF,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;IACrC,CAAC;CACF;AAZD,gEAYC"}
@@ -0,0 +1,11 @@
1
+ import { PnpmError } from '@pnpm/error';
2
+ export declare class UnexpectedStoreError extends PnpmError {
3
+ expectedStorePath: string;
4
+ actualStorePath: string;
5
+ modulesDir: string;
6
+ constructor(opts: {
7
+ expectedStorePath: string;
8
+ actualStorePath: string;
9
+ modulesDir: string;
10
+ });
11
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnexpectedStoreError = void 0;
4
+ const error_1 = require("@pnpm/error");
5
+ class UnexpectedStoreError extends error_1.PnpmError {
6
+ constructor(opts) {
7
+ super('UNEXPECTED_STORE', 'Unexpected store location');
8
+ this.expectedStorePath = opts.expectedStorePath;
9
+ this.actualStorePath = opts.actualStorePath;
10
+ this.modulesDir = opts.modulesDir;
11
+ }
12
+ }
13
+ exports.UnexpectedStoreError = UnexpectedStoreError;
14
+ //# sourceMappingURL=UnexpectedStoreError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnexpectedStoreError.js","sourceRoot":"","sources":["../../../src/install/checkCompatibility/UnexpectedStoreError.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AAEvC,MAAa,oBAAqB,SAAQ,iBAAS;IAIjD,YACE,IAIC;QAED,KAAK,CAAC,kBAAkB,EAAE,2BAA2B,CAAC,CAAA;QACtD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAA;QAC/C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAA;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;IACnC,CAAC;CACF;AAhBD,oDAgBC"}
@@ -0,0 +1,11 @@
1
+ import { PnpmError } from '@pnpm/error';
2
+ export declare class UnexpectedVirtualStoreDirError extends PnpmError {
3
+ expected: string;
4
+ actual: string;
5
+ modulesDir: string;
6
+ constructor(opts: {
7
+ expected: string;
8
+ actual: string;
9
+ modulesDir: string;
10
+ });
11
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnexpectedVirtualStoreDirError = void 0;
4
+ const error_1 = require("@pnpm/error");
5
+ class UnexpectedVirtualStoreDirError extends error_1.PnpmError {
6
+ constructor(opts) {
7
+ super('UNEXPECTED_VIRTUAL_STORE', 'Unexpected virtual store location');
8
+ this.expected = opts.expected;
9
+ this.actual = opts.actual;
10
+ this.modulesDir = opts.modulesDir;
11
+ }
12
+ }
13
+ exports.UnexpectedVirtualStoreDirError = UnexpectedVirtualStoreDirError;
14
+ //# sourceMappingURL=UnexpectedVirtualStoreDirError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnexpectedVirtualStoreDirError.js","sourceRoot":"","sources":["../../../src/install/checkCompatibility/UnexpectedVirtualStoreDirError.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AAEvC,MAAa,8BAA+B,SAAQ,iBAAS;IAI3D,YACE,IAIC;QAED,KAAK,CAAC,0BAA0B,EAAE,mCAAmC,CAAC,CAAA;QACtE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QACzB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;IACnC,CAAC;CACF;AAhBD,wEAgBC"}
@@ -0,0 +1,6 @@
1
+ import { type Modules } from '@pnpm/modules-yaml';
2
+ export declare function checkCompatibility(modules: Modules, opts: {
3
+ storeDir: string;
4
+ modulesDir: string;
5
+ virtualStoreDir: string;
6
+ }): void;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.checkCompatibility = checkCompatibility;
7
+ const path_1 = __importDefault(require("path"));
8
+ const constants_1 = require("@pnpm/constants");
9
+ const ModulesBreakingChangeError_1 = require("./ModulesBreakingChangeError");
10
+ const UnexpectedStoreError_1 = require("./UnexpectedStoreError");
11
+ const UnexpectedVirtualStoreDirError_1 = require("./UnexpectedVirtualStoreDirError");
12
+ function checkCompatibility(modules, opts) {
13
+ if (!modules.layoutVersion || modules.layoutVersion !== constants_1.LAYOUT_VERSION) {
14
+ throw new ModulesBreakingChangeError_1.ModulesBreakingChangeError({
15
+ modulesPath: opts.modulesDir,
16
+ });
17
+ }
18
+ // Important: comparing paths with path.relative()
19
+ // is the only way to compare paths correctly on Windows
20
+ // as of Node.js 4-9
21
+ // See related issue: https://github.com/pnpm/pnpm/issues/996
22
+ if (!modules.storeDir ||
23
+ path_1.default.relative(modules.storeDir, opts.storeDir) !== '' && path_1.default.relative(modules.storeDir, path_1.default.join(opts.storeDir, '../v3')) !== '') {
24
+ throw new UnexpectedStoreError_1.UnexpectedStoreError({
25
+ actualStorePath: opts.storeDir,
26
+ expectedStorePath: modules.storeDir,
27
+ modulesDir: opts.modulesDir,
28
+ });
29
+ }
30
+ if (modules.virtualStoreDir && path_1.default.relative(modules.virtualStoreDir, opts.virtualStoreDir) !== '') {
31
+ throw new UnexpectedVirtualStoreDirError_1.UnexpectedVirtualStoreDirError({
32
+ actual: opts.virtualStoreDir,
33
+ expected: modules.virtualStoreDir,
34
+ modulesDir: opts.modulesDir,
35
+ });
36
+ }
37
+ }
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/install/checkCompatibility/index.ts"],"names":[],"mappings":";;;;;AAOA,gDAkCC;AAzCD,gDAAuB;AACvB,+CAAgD;AAEhD,6EAAyE;AACzE,iEAA6D;AAC7D,qFAAiF;AAEjF,SAAgB,kBAAkB,CAChC,OAAgB,EAChB,IAIC;IAED,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,aAAa,KAAK,0BAAc,EAAE,CAAC;QACvE,MAAM,IAAI,uDAA0B,CAAC;YACnC,WAAW,EAAE,IAAI,CAAC,UAAU;SAC7B,CAAC,CAAA;IACJ,CAAC;IACD,kDAAkD;IAClD,wDAAwD;IACxD,oBAAoB;IACpB,6DAA6D;IAC7D,IACE,CAAC,OAAO,CAAC,QAAQ;QACjB,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,EAClI,CAAC;QACD,MAAM,IAAI,2CAAoB,CAAC;YAC7B,eAAe,EAAE,IAAI,CAAC,QAAQ;YAC9B,iBAAiB,EAAE,OAAO,CAAC,QAAQ;YACnC,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,OAAO,CAAC,eAAe,IAAI,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,CAAC;QACnG,MAAM,IAAI,+DAA8B,CAAC;YACvC,MAAM,EAAE,IAAI,CAAC,eAAe;YAC5B,QAAQ,EAAE,OAAO,CAAC,eAAe;YACjC,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}
@@ -26,17 +26,11 @@ export interface UninstallSomeDepsMutation {
26
26
  dependencyNames: string[];
27
27
  targetDependenciesField?: DependenciesField;
28
28
  }
29
- export interface UnlinkDepsMutation {
30
- mutation: 'unlink';
31
- }
32
- export interface UnlinkSomeDepsMutation {
33
- mutation: 'unlinkSome';
34
- dependencyNames: string[];
35
- }
36
- export type DependenciesMutation = InstallDepsMutation | InstallSomeDepsMutation | UninstallSomeDepsMutation | UnlinkDepsMutation | UnlinkSomeDepsMutation;
29
+ export type DependenciesMutation = InstallDepsMutation | InstallSomeDepsMutation | UninstallSomeDepsMutation;
37
30
  type Opts = Omit<InstallOptions, 'allProjects'> & {
38
31
  preferredVersions?: PreferredVersions;
39
32
  pruneDirectDependencies?: boolean;
33
+ binsDir?: string;
40
34
  } & InstallMutationOptions;
41
35
  export declare function install(manifest: ProjectManifest, opts: Opts): Promise<ProjectManifest>;
42
36
  export type MutatedProject = DependenciesMutation & {
@@ -60,7 +54,6 @@ export interface MutateModulesResult {
60
54
  depsRequiringBuild?: DepPath[];
61
55
  }
62
56
  export declare function mutateModules(projects: MutatedProject[], maybeOpts: MutateModulesOptions): Promise<MutateModulesResult>;
63
- export declare function createObjectChecksum(obj: Record<string, unknown>): string;
64
57
  export declare function addDependenciesToPackage(manifest: ProjectManifest, dependencySelectors: string[], opts: Omit<InstallOptions, 'allProjects'> & {
65
58
  bin?: string;
66
59
  allowNew?: boolean;
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
@@ -29,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
6
  exports.install = install;
30
7
  exports.mutateModulesInSingleProject = mutateModulesInSingleProject;
31
8
  exports.mutateModules = mutateModules;
32
- exports.createObjectChecksum = createObjectChecksum;
33
9
  exports.addDependenciesToPackage = addDependenciesToPackage;
34
10
  const path_1 = __importDefault(require("path"));
35
11
  const build_modules_1 = require("@pnpm/build-modules");
@@ -37,7 +13,7 @@ const builder_policy_1 = require("@pnpm/builder.policy");
37
13
  const catalogs_protocol_parser_1 = require("@pnpm/catalogs.protocol-parser");
38
14
  const constants_1 = require("@pnpm/constants");
39
15
  const core_loggers_1 = require("@pnpm/core-loggers");
40
- const crypto = __importStar(require("@pnpm/crypto.polyfill"));
16
+ const crypto_object_hasher_1 = require("@pnpm/crypto.object-hasher");
41
17
  const lockfile_settings_checker_1 = require("@pnpm/lockfile.settings-checker");
42
18
  const error_1 = require("@pnpm/error");
43
19
  const get_context_1 = require("@pnpm/get-context");
@@ -52,26 +28,22 @@ const lockfile_preferred_versions_1 = require("@pnpm/lockfile.preferred-versions
52
28
  const logger_1 = require("@pnpm/logger");
53
29
  const manifest_utils_1 = require("@pnpm/manifest-utils");
54
30
  const modules_yaml_1 = require("@pnpm/modules-yaml");
55
- const read_modules_dir_1 = require("@pnpm/read-modules-dir");
56
31
  const read_project_manifest_1 = require("@pnpm/read-project-manifest");
57
- const remove_bins_1 = require("@pnpm/remove-bins");
58
32
  const resolve_dependencies_1 = require("@pnpm/resolve-dependencies");
59
- const rimraf_1 = __importDefault(require("@zkochan/rimraf"));
60
- const is_inner_link_1 = __importDefault(require("is-inner-link"));
61
33
  const is_subdir_1 = __importDefault(require("is-subdir"));
62
- const p_filter_1 = __importDefault(require("p-filter"));
63
34
  const p_limit_1 = __importDefault(require("p-limit"));
64
35
  const map_1 = __importDefault(require("ramda/src/map"));
65
36
  const clone_1 = __importDefault(require("ramda/src/clone"));
66
37
  const isEmpty_1 = __importDefault(require("ramda/src/isEmpty"));
67
38
  const pipeWith_1 = __importDefault(require("ramda/src/pipeWith"));
68
39
  const props_1 = __importDefault(require("ramda/src/props"));
69
- const sort_keys_1 = __importDefault(require("sort-keys"));
70
40
  const parseWantedDependencies_1 = require("../parseWantedDependencies");
71
41
  const removeDeps_1 = require("../uninstall/removeDeps");
72
42
  const extendInstallOptions_1 = require("./extendInstallOptions");
73
43
  const link_1 = require("./link");
74
44
  const reportPeerDependencyIssues_1 = require("./reportPeerDependencyIssues");
45
+ const validateModules_1 = require("./validateModules");
46
+ const ci_info_1 = require("ci-info");
75
47
  class LockfileConfigMismatchError extends error_1.PnpmError {
76
48
  constructor(outdatedLockfileSettingName) {
77
49
  super('LOCKFILE_CONFIG_MISMATCH', `Cannot proceed with the frozen installation. The current "${outdatedLockfileSettingName}" configuration doesn't match the value found in the lockfile`, {
@@ -101,6 +73,7 @@ async function install(manifest, opts) {
101
73
  buildIndex: 0,
102
74
  manifest,
103
75
  rootDir,
76
+ binsDir: opts.binsDir,
104
77
  }],
105
78
  });
106
79
  return projects[0].manifest;
@@ -134,13 +107,34 @@ async function mutateModules(projects, maybeOpts) {
134
107
  const installsOnly = allMutationsAreInstalls(projects);
135
108
  if (!installsOnly)
136
109
  opts.strictPeerDependencies = false;
137
- // @ts-expect-error
138
- opts['forceNewModules'] = installsOnly;
139
110
  const rootProjectManifest = opts.allProjects.find(({ rootDir }) => rootDir === opts.lockfileDir)?.manifest ??
140
111
  // When running install/update on a subset of projects, the root project might not be included,
141
112
  // so reading its manifest explicitly here.
142
113
  await (0, read_project_manifest_1.safeReadProjectManifestOnly)(opts.lockfileDir);
143
- const ctx = await (0, get_context_1.getContext)(opts);
114
+ let ctx = await (0, get_context_1.getContext)(opts);
115
+ if (!opts.lockfileOnly && ctx.modulesFile != null) {
116
+ const { purged } = await (0, validateModules_1.validateModules)(ctx.modulesFile, Object.values(ctx.projects), {
117
+ forceNewModules: installsOnly,
118
+ include: opts.include,
119
+ lockfileDir: opts.lockfileDir,
120
+ modulesDir: opts.modulesDir ?? 'node_modules',
121
+ registries: opts.registries,
122
+ storeDir: opts.storeDir,
123
+ virtualStoreDir: ctx.virtualStoreDir,
124
+ virtualStoreDirMaxLength: opts.virtualStoreDirMaxLength,
125
+ confirmModulesPurge: opts.confirmModulesPurge && !ci_info_1.isCI,
126
+ forceHoistPattern: opts.forceHoistPattern,
127
+ hoistPattern: opts.hoistPattern,
128
+ currentHoistPattern: ctx.currentHoistPattern,
129
+ forcePublicHoistPattern: opts.forcePublicHoistPattern,
130
+ publicHoistPattern: opts.publicHoistPattern,
131
+ currentPublicHoistPattern: ctx.currentPublicHoistPattern,
132
+ global: opts.global,
133
+ });
134
+ if (purged) {
135
+ ctx = await (0, get_context_1.getContext)(opts);
136
+ }
137
+ }
144
138
  if (opts.hooks.preResolution) {
145
139
  await opts.hooks.preResolution({
146
140
  currentLockfile: ctx.currentLockfile,
@@ -203,7 +197,7 @@ async function mutateModules(projects, maybeOpts) {
203
197
  rootModulesDir: ctx.rootModulesDir,
204
198
  });
205
199
  }
206
- const packageExtensionsChecksum = (0, isEmpty_1.default)(opts.packageExtensions ?? {}) ? undefined : createObjectChecksum(opts.packageExtensions);
200
+ const packageExtensionsChecksum = (0, crypto_object_hasher_1.hashObjectNullableWithPrefix)(opts.packageExtensions);
207
201
  const pnpmfileChecksum = await opts.hooks.calculatePnpmfileChecksum?.();
208
202
  const patchedDependencies = opts.ignorePackageManifest
209
203
  ? ctx.wantedLockfile.patchedDependencies
@@ -426,67 +420,6 @@ Note that in CI environments, this setting is enabled by default.`,
426
420
  });
427
421
  break;
428
422
  }
429
- case 'unlink': {
430
- const packageDirs = await (0, read_modules_dir_1.readModulesDir)(projectOpts.modulesDir);
431
- const externalPackages = await (0, p_filter_1.default)(packageDirs, async (packageDir) => isExternalLink(ctx.storeDir, projectOpts.modulesDir, packageDir));
432
- const allDeps = (0, manifest_utils_1.getAllDependenciesFromManifest)(projectOpts.manifest);
433
- const packagesToInstall = [];
434
- for (const pkgName of externalPackages) {
435
- await (0, rimraf_1.default)(path_1.default.join(projectOpts.modulesDir, pkgName));
436
- if (allDeps[pkgName]) {
437
- packagesToInstall.push(pkgName);
438
- }
439
- }
440
- if (packagesToInstall.length === 0) {
441
- return {
442
- updatedProjects: projects.map((mutatedProject) => ctx.projects[mutatedProject.rootDir]),
443
- };
444
- }
445
- // TODO: install only those that were unlinked
446
- // but don't update their version specs in package.json
447
- await installCase({ ...projectOpts, mutation: 'install' });
448
- break;
449
- }
450
- case 'unlinkSome': {
451
- if (projectOpts.manifest?.name && opts.globalBin) {
452
- await (0, remove_bins_1.removeBin)(path_1.default.join(opts.globalBin, projectOpts.manifest?.name));
453
- }
454
- const packagesToInstall = [];
455
- const allDeps = (0, manifest_utils_1.getAllDependenciesFromManifest)(projectOpts.manifest);
456
- for (const depName of project.dependencyNames) {
457
- try {
458
- if (!await isExternalLink(ctx.storeDir, projectOpts.modulesDir, depName)) {
459
- logger_1.logger.warn({
460
- message: `${depName} is not an external link`,
461
- prefix: project.rootDir,
462
- });
463
- continue;
464
- }
465
- }
466
- catch (err) { // eslint-disable-line
467
- if (err['code'] !== 'ENOENT')
468
- throw err;
469
- }
470
- await (0, rimraf_1.default)(path_1.default.join(projectOpts.modulesDir, depName));
471
- if (allDeps[depName]) {
472
- packagesToInstall.push(depName);
473
- }
474
- }
475
- if (packagesToInstall.length === 0) {
476
- return {
477
- updatedProjects: projects.map((mutatedProject) => ctx.projects[mutatedProject.rootDir]),
478
- };
479
- }
480
- // TODO: install only those that were unlinked
481
- // but don't update their version specs in package.json
482
- await installSome({
483
- ...projectOpts,
484
- dependencySelectors: packagesToInstall,
485
- mutation: 'installSome',
486
- updatePackageManifest: false,
487
- });
488
- break;
489
- }
490
423
  }
491
424
  }
492
425
  /* eslint-enable no-await-in-loop */
@@ -583,17 +516,9 @@ Note that in CI environments, this setting is enabled by default.`,
583
516
  };
584
517
  }
585
518
  }
586
- function createObjectChecksum(obj) {
587
- const s = JSON.stringify((0, sort_keys_1.default)(obj, { deep: true }));
588
- return crypto.hash('md5', s, 'hex');
589
- }
590
519
  function cacheExpired(prunedAt, maxAgeInMinutes) {
591
520
  return ((Date.now() - new Date(prunedAt).valueOf()) / (1000 * 60)) > maxAgeInMinutes;
592
521
  }
593
- async function isExternalLink(storeDir, modules, pkgName) {
594
- const link = await (0, is_inner_link_1.default)(modules, pkgName);
595
- return !link.isInner;
596
- }
597
522
  function pkgHasDependencies(manifest) {
598
523
  return Boolean((Object.keys(manifest.dependencies ?? {}).length > 0) ||
599
524
  Object.keys(manifest.devDependencies ?? {}).length ||