UNPKG

4.03 kBTypeScriptView Raw
1import { PrimitiveType } from '@boost/args';
2import { Blueprint, Path, Predicates } from '@boost/common';
3import { ConcurrentEvent, Event } from '@boost/event';
4import { Plugin } from '@boost/plugin';
5import { ConfigContext } from './contexts/ConfigContext';
6import { DriverContext } from './contexts/DriverContext';
7import { Argv, BeemoTool, ConfigObject, Driverable, DriverCommandConfig, DriverCommandRegistration, DriverCommandRunner, DriverMetadata, DriverOptions, DriverOutput, DriverOutputStrategy, Execution } from './types';
8export declare abstract class Driver<Config extends object = {}, Options extends DriverOptions = DriverOptions> extends Plugin<BeemoTool, Options> implements Driverable {
9 commands: DriverCommandRegistration<any, any>[];
10 config: Config;
11 metadata: DriverMetadata;
12 tool: BeemoTool;
13 output: DriverOutput;
14 readonly onLoadProviderConfig: Event<[ConfigContext<{}>, Path, Config], string>;
15 readonly onLoadConsumerConfig: Event<[ConfigContext<{}>, Config], string>;
16 readonly onMergeConfig: Event<[ConfigContext<{}>, Config], string>;
17 readonly onCreateConfigFile: Event<[ConfigContext<{}>, Path, Config], string>;
18 readonly onCopyConfigFile: Event<[ConfigContext<{}>, Path, Config], string>;
19 readonly onReferenceConfigFile: Event<[ConfigContext<{}>, Path, Config], string>;
20 readonly onTemplateConfigFile: Event<[ConfigContext<{}>, Path, string | ConfigObject], string>;
21 readonly onDeleteConfigFile: Event<[ConfigContext<{}>, Path], string>;
22 readonly onBeforeExecute: ConcurrentEvent<[DriverContext<import("./contexts/DriverContext").DriverContextOptions>, Argv], string>;
23 readonly onAfterExecute: ConcurrentEvent<[DriverContext<import("./contexts/DriverContext").DriverContextOptions>, unknown], string>;
24 readonly onFailedExecute: ConcurrentEvent<[DriverContext<import("./contexts/DriverContext").DriverContextOptions>, Error], string>;
25 static validate(driver: Driver): void;
26 blueprint({ array, object, string, bool }: Predicates): Blueprint<DriverOptions>;
27 bootstrap(): void;
28 startup(tool: BeemoTool): void;
29 /**
30 * Special case for merging arrays.
31 */
32 doMerge(prevValue: unknown, nextValue: unknown): unknown;
33 /**
34 * Extract the error message when the driver fails to execute.
35 */
36 extractErrorMessage(error: {
37 message: string;
38 }): string;
39 /**
40 * Format the configuration file before it's written.
41 */
42 formatConfig(data: Config): string;
43 /**
44 * Return the module name without the Beemo namespace.
45 */
46 getName(): string;
47 /**
48 * Return a list of user defined arguments.
49 */
50 getArgs(): Argv;
51 /**
52 * Return a list of dependent drivers.
53 */
54 getDependencies(): string[];
55 /**
56 * Either return the tool override strategy, or the per-driver strategy.
57 */
58 getOutputStrategy(): DriverOutputStrategy;
59 /**
60 * Return a list of supported CLI options.
61 */
62 getSupportedOptions(): string[];
63 /**
64 * Extract the current version of the installed driver via its binary.
65 */
66 getVersion(): string;
67 /**
68 * Merge multiple configuration objects.
69 */
70 mergeConfig(prev: Config, next: Config): Config;
71 /**
72 * Handle command failures according to this driver.
73 */
74 processFailure(error: Execution): void;
75 /**
76 * Handle successful commands according to this driver.
77 */
78 processSuccess(response: Execution): void;
79 /**
80 * Register a sub-command within the CLI.
81 */
82 registerCommand<O extends object, P extends PrimitiveType[]>(path: string, config: DriverCommandConfig<O, P>, runner: DriverCommandRunner<O, P>): this;
83 /**
84 * Set metadata about the binary/executable in which this driver wraps.
85 */
86 setMetadata(metadata: Partial<DriverMetadata>): this;
87 /**
88 * Store the raw output of the driver's execution.
89 */
90 setOutput(type: keyof DriverOutput, value: string): this;
91}
92//# sourceMappingURL=Driver.d.ts.map
\No newline at end of file