1 |
|
2 | import { PortablePath } from '@yarnpkg/fslib';
|
3 | import { CommandClass } from 'clipanion';
|
4 | import { Writable, Readable } from 'stream';
|
5 | import { PluginConfiguration, Configuration, ConfigurationDefinitionMap } from './Configuration';
|
6 | import { Fetcher } from './Fetcher';
|
7 | import { Linker } from './Linker';
|
8 | import { MessageName } from './MessageName';
|
9 | import { Project, InstallOptions } from './Project';
|
10 | import { Resolver, ResolveOptions } from './Resolver';
|
11 | import { Workspace } from './Workspace';
|
12 | import { Locator, Descriptor } from './types';
|
13 | declare type ProcessEnvironment = {
|
14 | [key: string]: string;
|
15 | };
|
16 | export declare type CommandContext = {
|
17 | cwd: PortablePath;
|
18 | plugins: PluginConfiguration;
|
19 | quiet: boolean;
|
20 | stdin: Readable;
|
21 | stdout: Writable;
|
22 | stderr: Writable;
|
23 | };
|
24 | export interface FetcherPlugin {
|
25 | new (): Fetcher;
|
26 | }
|
27 | export interface LinkerPlugin {
|
28 | new (): Linker;
|
29 | }
|
30 | export interface ResolverPlugin {
|
31 | new (): Resolver;
|
32 | }
|
33 | export declare type Hooks = {
|
34 | registerPackageExtensions?: (configuration: Configuration, registerPackageExtension: (descriptor: Descriptor, extensionData: any) => void) => Promise<void>;
|
35 | setupScriptEnvironment?: (project: Project, env: ProcessEnvironment, makePathWrapper: (name: string, argv0: string, args: Array<string>) => Promise<void>) => Promise<void>;
|
36 | wrapScriptExecution?: (executor: () => Promise<number>, project: Project, locator: Locator, scriptName: string, extra: {
|
37 | script: string;
|
38 | args: Array<string>;
|
39 | cwd: PortablePath;
|
40 | env: ProcessEnvironment;
|
41 | stdin: Readable | null;
|
42 | stdout: Writable;
|
43 | stderr: Writable;
|
44 | }) => Promise<() => Promise<number>>;
|
45 | globalHashGeneration?: (project: Project, contributeHash: (data: string | Buffer) => void) => Promise<void>;
|
46 | reduceDependency?: (dependency: Descriptor, project: Project, locator: Locator, initialDependency: Descriptor, extra: {
|
47 | resolver: Resolver;
|
48 | resolveOptions: ResolveOptions;
|
49 | }) => Promise<Descriptor>;
|
50 | afterAllInstalled?: (project: Project, options: InstallOptions) => void;
|
51 | validateProject?: (project: Project, report: {
|
52 | reportWarning: (name: MessageName, text: string) => void;
|
53 | reportError: (name: MessageName, text: string) => void;
|
54 | }) => void;
|
55 | validateWorkspace?: (workspace: Workspace, report: {
|
56 | reportWarning: (name: MessageName, text: string) => void;
|
57 | reportError: (name: MessageName, text: string) => void;
|
58 | }) => void;
|
59 | populateYarnPaths?: (project: Project, definePath: (path: PortablePath | null) => void) => Promise<void>;
|
60 | };
|
61 | export declare type Plugin<PluginHooks = any> = {
|
62 | configuration?: Partial<ConfigurationDefinitionMap>;
|
63 | commands?: Array<CommandClass<CommandContext>>;
|
64 | fetchers?: Array<FetcherPlugin>;
|
65 | linkers?: Array<LinkerPlugin>;
|
66 | resolvers?: Array<ResolverPlugin>;
|
67 | hooks?: PluginHooks;
|
68 | };
|
69 | export {};
|