-
Notifications
You must be signed in to change notification settings - Fork 20
/
taqueria-types.ts
84 lines (71 loc) · 2.06 KB
/
taqueria-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
import type { i18n } from '@taqueria/protocol/i18n';
import * as LoadedConfig from '@taqueria/protocol/LoadedConfig';
import * as SanitizedArgs from '@taqueria/protocol/SanitizedArgs';
import * as Settings from '@taqueria/protocol/Settings';
import yargs from 'deno-yargs';
// TODO: There should be an ActionResponse type that we're extending here.
// This probably exists already in the taqueria-sdk and should be moved to the
// taqueria-protocol package so that the type can be shared between the CLI
// and SDK
export type PluginResponseValidator = <T extends { success: boolean; stdout?: string; stderr?: string }>(
json: Record<string, unknown>,
) => T;
export interface Builder {
[key: string]: Record<string, unknown>;
plugin: {
choices: string[];
default: string;
};
}
export interface CLICommand {
original: string;
description: string;
handler: (yargs: CLIConfig) => unknown;
builder: Builder;
middlewares: (yargs: CLIConfig) => CLIConfig[];
demanded: string[];
optional: string[];
}
export type DenoArgs = typeof Deno.args;
export type MachineInfo = {
arch: string;
os: string;
target: string;
vendor: string;
};
export interface UsageAnalyticsDeps {
readonly parsedArgs: SanitizedArgs.t;
readonly env: EnvVars;
readonly machineInfo: MachineInfo;
}
export type EnvKey =
| 'TAQ_COLUMNS'
| 'TAQ_CONFIG_DIR'
| 'TAQ_MAX_CONCURRENCY'
| 'TAQ_PROJECT_DIR'
| 'TAQ_ENV'
| 'TAQ_DISABLE_STATE'
| 'TAQ_VERSION'
| 'HOME'
| 'CI'
| 'TEST';
export interface EnvVars {
get: (key: EnvKey) => undefined | string;
}
export type CLIConfig = ReturnType<typeof yargs> & {
handled?: boolean;
};
export type PluginRequestArgs = (string | number | boolean)[];
// Common dependencies before we retrieved the config
export interface PreExtendDeps {
readonly parsedArgs: SanitizedArgs.t;
readonly env: EnvVars;
readonly i18n: i18n;
readonly stdout: typeof Deno.stdout;
readonly stderr: typeof Deno.stderr;
}
// Common dependencies after we retrieved the config
export interface PluginDeps extends PreExtendDeps {
readonly config: LoadedConfig.t;
}
export { LoadedConfig };