UNPKG

4.69 kBTypeScriptView Raw
1import { PortablePath } from '@yarnpkg/fslib';
2import { Cache } from './Cache';
3import { Configuration } from './Configuration';
4import { Fetcher } from './Fetcher';
5import { DependencyMeta } from './Manifest';
6import { MessageName } from './MessageName';
7import { Report } from './Report';
8import { Resolver } from './Resolver';
9import { Workspace } from './Workspace';
10import { IdentHash, DescriptorHash, LocatorHash } from './types';
11import { Descriptor, Ident, Locator, Package } from './types';
12export declare type InstallOptions = {
13 cache: Cache;
14 fetcher?: Fetcher;
15 resolver?: Resolver;
16 report: Report;
17 immutable?: boolean;
18 lockfileOnly?: boolean;
19 persistProject?: boolean;
20};
21export declare class Project {
22 readonly configuration: Configuration;
23 readonly cwd: PortablePath;
24 /**
25 * Is meant to be populated by the consumer. Should the descriptor referenced
26 * by the key be requested, the descriptor referenced in the value will be
27 * resolved instead. The resolved data will then be used as final resolution
28 * for the initial descriptor.
29 *
30 * Note that the lockfile will contain the second descriptor but not the
31 * first one (meaning that if you remove the alias during a subsequent
32 * install, it'll be lost and the real package will be resolved / installed).
33 */
34 resolutionAliases: Map<DescriptorHash, DescriptorHash>;
35 workspaces: Array<Workspace>;
36 workspacesByCwd: Map<PortablePath, Workspace>;
37 workspacesByIdent: Map<IdentHash, Workspace>;
38 storedResolutions: Map<DescriptorHash, LocatorHash>;
39 storedDescriptors: Map<DescriptorHash, Descriptor>;
40 storedPackages: Map<LocatorHash, Package>;
41 storedChecksums: Map<LocatorHash, string>;
42 accessibleLocators: Set<LocatorHash>;
43 originalPackages: Map<LocatorHash, Package>;
44 optionalBuilds: Set<LocatorHash>;
45 lockFileChecksum: string | null;
46 static find(configuration: Configuration, startingCwd: PortablePath): Promise<{
47 project: Project;
48 workspace: Workspace | null;
49 locator: Locator;
50 }>;
51 static generateBuildStateFile(buildState: Map<LocatorHash, string>, locatorStore: Map<LocatorHash, Locator>): string;
52 constructor(projectCwd: PortablePath, { configuration }: {
53 configuration: Configuration;
54 });
55 private setupResolutions;
56 private setupWorkspaces;
57 private addWorkspace;
58 get topLevelWorkspace(): Workspace;
59 tryWorkspaceByCwd(workspaceCwd: PortablePath): Workspace | null;
60 getWorkspaceByCwd(workspaceCwd: PortablePath): Workspace;
61 tryWorkspaceByFilePath(filePath: PortablePath): Workspace | null;
62 getWorkspaceByFilePath(filePath: PortablePath): Workspace;
63 tryWorkspaceByIdent(ident: Ident): Workspace | null;
64 getWorkspaceByIdent(ident: Ident): Workspace;
65 tryWorkspaceByDescriptor(descriptor: Descriptor): Workspace | null;
66 getWorkspaceByDescriptor(descriptor: Descriptor): Workspace;
67 tryWorkspaceByLocator(locator: Locator): Workspace | null;
68 getWorkspaceByLocator(locator: Locator): Workspace;
69 /**
70 * Import the dependencies of each resolved workspace into their own
71 * `Workspace` instance.
72 */
73 private refreshWorkspaceDependencies;
74 forgetResolution(descriptor: Descriptor): void;
75 forgetResolution(locator: Locator): void;
76 forgetTransientResolutions(): void;
77 forgetVirtualResolutions(): void;
78 getDependencyMeta(ident: Ident, version: string | null): DependencyMeta;
79 findLocatorForLocation(cwd: PortablePath, { strict }?: {
80 strict?: boolean;
81 }): Promise<Locator | null>;
82 validateEverything(opts: {
83 validationWarnings: Array<{
84 name: MessageName;
85 text: string;
86 }>;
87 validationErrors: Array<{
88 name: MessageName;
89 text: string;
90 }>;
91 report: Report;
92 }): Promise<void>;
93 resolveEverything(opts: {
94 report: Report;
95 lockfileOnly: true;
96 resolver?: Resolver;
97 } | {
98 report: Report;
99 lockfileOnly?: boolean;
100 cache: Cache;
101 resolver?: Resolver;
102 }): Promise<void>;
103 fetchEverything({ cache, report, fetcher: userFetcher }: InstallOptions): Promise<void>;
104 linkEverything({ cache, report, fetcher: optFetcher }: InstallOptions): Promise<void>;
105 install(opts: InstallOptions): Promise<void>;
106 generateLockfile(): string;
107 persistLockfile(): Promise<void>;
108 persistInstallStateFile(): Promise<void>;
109 restoreInstallState(): Promise<void>;
110 applyLightResolution(): Promise<void>;
111 persist(): Promise<void>;
112 cacheCleanup({ cache, report }: InstallOptions): Promise<void>;
113}