1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.LockfileResolver = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 | const structUtils = tslib_1.__importStar(require("./structUtils"));
|
6 | class LockfileResolver {
|
7 | supportsDescriptor(descriptor, opts) {
|
8 | const resolution = opts.project.storedResolutions.get(descriptor.descriptorHash);
|
9 | if (resolution)
|
10 | return true;
|
11 |
|
12 |
|
13 | if (opts.project.originalPackages.has(structUtils.convertDescriptorToLocator(descriptor).locatorHash))
|
14 | return true;
|
15 | return false;
|
16 | }
|
17 | supportsLocator(locator, opts) {
|
18 | if (opts.project.originalPackages.has(locator.locatorHash))
|
19 | return true;
|
20 | return false;
|
21 | }
|
22 | shouldPersistResolution(locator, opts) {
|
23 | throw new Error(`The shouldPersistResolution method shouldn't be called on the lockfile resolver, which would always answer yes`);
|
24 | }
|
25 | bindDescriptor(descriptor, fromLocator, opts) {
|
26 | return descriptor;
|
27 | }
|
28 | getResolutionDependencies(descriptor, opts) {
|
29 | return [];
|
30 | }
|
31 | async getCandidates(descriptor, dependencies, opts) {
|
32 | let pkg = opts.project.originalPackages.get(structUtils.convertDescriptorToLocator(descriptor).locatorHash);
|
33 | if (pkg)
|
34 | return [pkg];
|
35 | const resolution = opts.project.storedResolutions.get(descriptor.descriptorHash);
|
36 | if (!resolution)
|
37 | throw new Error(`Expected the resolution to have been successful - resolution not found`);
|
38 | pkg = opts.project.originalPackages.get(resolution);
|
39 | if (!pkg)
|
40 | throw new Error(`Expected the resolution to have been successful - package not found`);
|
41 | return [pkg];
|
42 | }
|
43 | async getSatisfying(descriptor, references, opts) {
|
44 | return null;
|
45 | }
|
46 | async resolve(locator, opts) {
|
47 | const pkg = opts.project.originalPackages.get(locator.locatorHash);
|
48 | if (!pkg)
|
49 | throw new Error(`The lockfile resolver isn't meant to resolve packages - they should already have been stored into a cache`);
|
50 | return pkg;
|
51 | }
|
52 | }
|
53 | exports.LockfileResolver = LockfileResolver;
|