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