-
Notifications
You must be signed in to change notification settings - Fork 24
/
scripts_config.ts
163 lines (151 loc) · 3.62 KB
/
scripts_config.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
/**
* Script file model
*/
export interface ScriptsConfiguration extends ScriptOptions {
scripts: Scripts;
}
/**
* The scripts object.
* Keys are script identifiers, values are `ScriptDefinition`s.
*
* ```yaml
* # scripts.yaml
* scripts:
* start: deno run server.ts
* test: deno test
* ```
*/
export type Scripts = Record<string, ScriptDefinition>;
/**
* Either a script or a list of scripts
*/
export type ScriptDefinition = Script | CompositeScript;
/**
* Either a command string or an object representing the script
*/
export type Script = string | ScriptObject;
/**
* An object representing the script
*/
export interface ScriptObject extends ScriptOptions {
/**
* A command or list of commands
*/
cmd: string | CompositeScript;
/**
* A textual description of what this script does.
* This will be shown in the list of available scripts,
* when calling `vr` without arguments.
*
* **Note** nested `ScriptObject`'s `desc` are ignored
*/
desc?: string;
}
/**
* An array of scripts or an object representing script
* to be executed in parallel
*/
export type CompositeScript = ParallelScripts | Array<Script | ParallelScripts>;
/**
* An object representing scripts
* to be executed in parallel
*/
export interface ParallelScripts {
/**
* The list of script to be executed in parallel
*/
pll: Script[];
}
/**
* Additional script options
*
* These can be applied both in `ScriptObject`s and at top-level
* in which case they're applied to all the scripts defined in the file
*/
export interface ScriptOptions {
/**
* A map of environment variables to be passed to the script
*/
env?: EnvironmentVariables;
/**
* A list of boolean `--allow-*` deno cli options or
* a map of option names to values
*
* ```yaml
* # scripts.yaml
* scripts:
* start: deno run server.ts
* allow:
* - net
* - read
* ```
*/
allow?: Array<keyof AllowFlags> | AllowFlags;
/**
* A list of boolean V8 flags or
* a map of V8 option names to values
*
* ```yaml
* # scripts.yaml
* scripts:
* start: deno run server.ts
* v8Flags:
* - expose-gc
* - async-stack-trace
* ```
*/
v8Flags?: string[] | FlagsObject;
/**
* The path to an importmap json file,
* passed to deno cli's `--importmap` option.
*
* **Note** This currently requires the `--unstable` flag
*/
imap?: string;
/**
* The path to an _existing_ lockfile,
* passed to deno cli's `--lock` option.
*
* **Note** This doesn't create the lockfile, use `--lock-write` manually
* when appropriate
*/
lock?: string;
/**
* The log level, passed to deno cli's `--log-level` option.
*/
log?: string;
/**
* The path to a tsconfig json file,
* passed to deno cli's `--tsconfig` option.
*/
tsconfig?: string;
/**
* The path to a PEM certificate file,
* passed to deno cli's `--cert` option.
*/
cert?: string;
/**
* The hostname and port where to start the inspector,
* passed to deno cli's `--inspect` option.
*/
inspect?: string;
/**
* Same as `inspect`, but breaks at start of user script.
*/
inspectBrk?: string;
}
export interface AllowFlags {
all?: boolean;
env?: boolean;
hrtime?: boolean;
net?: string | boolean;
plugin?: boolean;
read?: string | boolean;
run?: boolean;
}
export type FlagsObject = Record<string, unknown>;
export type EnvironmentVariables = Record<string, string>;
export const isScriptObject = (script: object): script is ScriptObject =>
"cmd" in script;
export const isParallelScripts = (script: object): script is ParallelScripts =>
"pll" in script;