1 | import { ExecaError, ExecaReturnValue } from 'execa';
|
2 | import {
|
3 | Arguments,
|
4 | Argv,
|
5 | Command,
|
6 | MapOptionConfig,
|
7 | MapParamConfig,
|
8 | OptionConfigMap,
|
9 | ParserOptions,
|
10 | PrimitiveType,
|
11 | } from '@boost/args';
|
12 | import { Path, PortablePath } from '@boost/common';
|
13 | import { PluginsSetting } from '@boost/config';
|
14 | import { Pluggable } from '@boost/plugin';
|
15 | import type { Context } from './contexts/Context';
|
16 | import type { ScriptContext } from './contexts/ScriptContext';
|
17 | import type { Tool } from './Tool';
|
18 |
|
19 | export type { Arguments, Argv, ParserOptions };
|
20 |
|
21 | export type BeemoTool = Tool;
|
22 |
|
23 | export interface BeemoProcess<C extends Context = Context> {
|
24 | context: C;
|
25 | tool: BeemoTool;
|
26 | }
|
27 |
|
28 | export type UnknownSettings = Record<string, unknown>;
|
29 |
|
30 | export interface BootstrapFile {
|
31 | (tool: BeemoTool): Promise<void> | void;
|
32 | bootstrap?: (tool: BeemoTool) => Promise<void> | void;
|
33 | default?: (tool: BeemoTool) => Promise<void> | void;
|
34 | }
|
35 |
|
36 | export type Execution = ExecaReturnValue;
|
37 |
|
38 | export type ExecutionError = ExecaError;
|
39 |
|
40 |
|
41 |
|
42 | export type DriverConfigStrategy = 'copy' | 'create' | 'native' | 'none' | 'reference' | 'template';
|
43 |
|
44 | export type DriverOutputStrategy = 'buffer' | 'none' | 'pipe' | 'stream';
|
45 |
|
46 | export interface DriverOptions {
|
47 | args?: string[];
|
48 | configStrategy?: DriverConfigStrategy;
|
49 | dependencies?: string[];
|
50 | env?: Record<string, string>;
|
51 | expandGlobs?: boolean;
|
52 | outputStrategy?: DriverOutputStrategy;
|
53 | template?: string;
|
54 | }
|
55 |
|
56 | export interface DriverMetadata {
|
57 | bin: string;
|
58 | commandOptions: OptionConfigMap;
|
59 | configName: string;
|
60 | configOption: string;
|
61 | configStrategy: 'copy' | 'create' | 'reference' | 'template';
|
62 | dependencies: string[];
|
63 | description: string;
|
64 | filterOptions: boolean;
|
65 | helpOption: string;
|
66 | title: string;
|
67 | useConfigOption: boolean;
|
68 | versionOption: string;
|
69 | watchOptions: string[];
|
70 | workspaceStrategy: 'copy' | 'reference';
|
71 | }
|
72 |
|
73 | export interface DriverOutput {
|
74 | stderr: string;
|
75 | stdout: string;
|
76 | }
|
77 |
|
78 | export interface Driverable extends Pluggable<BeemoTool> {
|
79 | metadata: DriverMetadata;
|
80 | }
|
81 |
|
82 |
|
83 |
|
84 | export interface DriverCommandConfig<O extends object, P extends PrimitiveType[]>
|
85 | extends Omit<Command, 'category'> {
|
86 | allowUnknownOptions?: boolean;
|
87 | allowVariadicParams?: boolean | string;
|
88 | options?: MapOptionConfig<O>;
|
89 | params?: MapParamConfig<P>;
|
90 | }
|
91 |
|
92 | export type DriverCommandRunner<O extends object, P extends PrimitiveType[]> = (
|
93 | tool: Tool,
|
94 | options: O,
|
95 | params: P,
|
96 | rest: string[],
|
97 | ) => Promise<string | undefined | void> | string | undefined | void;
|
98 |
|
99 | export interface DriverCommandRegistration<O extends object, P extends PrimitiveType[]> {
|
100 | path: string;
|
101 | config: DriverCommandConfig<O, P>;
|
102 | runner: DriverCommandRunner<O, P>;
|
103 | }
|
104 |
|
105 |
|
106 |
|
107 | export interface Scriptable<O extends object> extends Pluggable<BeemoTool> {
|
108 | parse: () => ParserOptions<O>;
|
109 | execute: (context: ScriptContext, args: Arguments<O>) => Promise<unknown>;
|
110 | }
|
111 |
|
112 |
|
113 |
|
114 | export interface RoutineOptions {
|
115 | tool: BeemoTool;
|
116 | }
|
117 |
|
118 |
|
119 |
|
120 | export type ConfigExecuteStrategy = DriverOutputStrategy | '';
|
121 |
|
122 | export interface ConfigFile<T extends object = UnknownSettings> {
|
123 | configure: {
|
124 | cleanup: boolean;
|
125 | parallel: boolean;
|
126 | };
|
127 | debug: boolean;
|
128 | drivers: PluginsSetting;
|
129 | execute: {
|
130 | concurrency: number;
|
131 | graph: boolean;
|
132 | output: ConfigExecuteStrategy;
|
133 | };
|
134 | module: string;
|
135 | scripts: PluginsSetting;
|
136 | settings: T;
|
137 | }
|
138 |
|
139 | export interface BeemoConfig<T extends object = UnknownSettings> {
|
140 | configure?: {
|
141 | cleanup?: boolean;
|
142 | parallel?: boolean;
|
143 | };
|
144 | debug?: boolean;
|
145 | drivers?: PluginsSetting;
|
146 | execute?: {
|
147 | concurrency?: number;
|
148 | graph?: boolean;
|
149 | output?: ConfigExecuteStrategy;
|
150 | };
|
151 | module?: string;
|
152 | scripts?: PluginsSetting;
|
153 | settings?: T;
|
154 | }
|
155 |
|
156 | export type ConfigObject = Record<string, unknown>;
|
157 |
|
158 | export interface ConfigTemplateOptions {
|
159 | configModule: string;
|
160 | consumerConfigPath: Path | null;
|
161 | context: Context;
|
162 | driver: Driverable;
|
163 | driverConfigPath: Path;
|
164 | driverName: string;
|
165 | providerConfigPath: Path | null;
|
166 | templatePath: Path;
|
167 | tool: BeemoTool;
|
168 | }
|
169 |
|
170 | export interface ConfigTemplateResult {
|
171 | config: ConfigObject | string;
|
172 | path?: PortablePath;
|
173 | }
|
174 |
|
175 | export type ConfigTemplate = (
|
176 | configs: ConfigObject[],
|
177 | options: ConfigTemplateOptions,
|
178 | ) => ConfigTemplateResult;
|
179 |
|
180 |
|
181 |
|
182 | declare global {
|
183 | namespace NodeJS {
|
184 | interface Process {
|
185 | beemo: BeemoProcess;
|
186 | }
|
187 | }
|
188 | }
|