-
Notifications
You must be signed in to change notification settings - Fork 21
/
tusk.schema.yaml
510 lines (464 loc) · 14.2 KB
/
tusk.schema.yaml
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# yaml-language-server: $schema=http://json-schema.org/draft-07/schema#
---
$schema: "http://json-schema.org/draft-07/schema#"
$id: "https://github.com/rliebz/tusk/blob/main/tusk.schema.json"
title: JSON schema for tusk configuration files
type: object
additionalProperties: false
properties:
name:
title: name
type: string
description: >
The alias name to display in help text when using shell aliases to create
a custom named CLI application.
default: tusk
usage:
title: usage
type: string
description: >
The usage text to display in help text when using shell aliases to create
a custom named CLI application.
default: the modern task runner
env-file:
title: env-file
$ref: "#/$defs/envFileClause"
interpreter:
title: interpreter
type: string
default: sh -c
description: >
The interpreter to use for commands.
The interpreter is specified as an executable, which can either be an
absolute path or available on the user's PATH, followed by a series of
optional arguments.
The commands specified in individual tasks will be passed as the final
argument.
examples:
- node -e
- python3 -c
options:
title: shared options
description: >
Shared options available to all tasks.
Any shared variables referenced by a task will be exposed by command-line
when invoking that task. Shared variables referenced by a sub-task will
be evaluated as needed, but not exposed by command-line.
Tasks that define an argument or option with the same name as a shared
task will overwrite the value of the shared option for the length of that
task, not including sub-tasks.
$ref: "#/$defs/optionsClause"
tasks:
title: tasks
$ref: "#/$defs/tasksClause"
$defs:
argClause:
description: A command-line argument definition for the task.
type: object
additionalProperties: false
properties:
type:
title: type
$ref: "#/$defs/type"
usage:
title: usage
description: A one-line summary of the argument.
type: string
values:
title: values
description: A predefined set of acceptable values to provide for the argument.
type: array
items:
$ref: "#/$defs/value"
argsClause:
description: The set of command-line arguments that must be provided to the task.
type: object
additionalProperties:
$ref: "#/$defs/argClause"
commandClause:
description: The command or commands to execute using the global interpreter.
oneOf:
- $ref: "#/$defs/commandItem"
- type: array
items:
$ref: "#/$defs/commandItem"
commandItem:
description: The command to execute using the global interpreter.
oneOf:
- type: string
- type: object
additionalProperties: false
required:
- exec
properties:
exec:
title: exec
description: The command to execute using the global interpreter.
type: string
dir:
title: dir
type: string
print:
title: print
description: The text that will be printed when the command is executed.
type: string
quiet:
title: quiet
description: >
Whether to silence the text/hint before execution.
Command output will still be printed.
type: boolean
default: false
defaultClause:
title: default
description: >
The default value to use if the value is not otherwise set.
If multiple values are provided, the first `when` that evaluates to true
will be used as the default value, with an omitted `when` always
considered true.
oneOf:
- $ref: "#/$defs/defaultItem"
- type: array
items:
$ref: "#/$defs/defaultItem"
defaultItem:
description: >
A default value to use if the value is not otherwise set.
If a `when` clause is provided, the value will be used if and only if
the condition evaluates to true.
oneOf:
- $ref: "#/$defs/value"
- type: object
additionalProperties: false
properties:
command:
title: command
description: >
A command to run via the global interpreter.
The value of stdout will be used as the value.
type: string
value:
title: value
$ref: "#/$defs/value"
when:
title: when
$ref: "#/$defs/whenClause"
oneOf:
- required: [command]
- required: [value]
envFile:
description: >
A file to load environment variables from.
File paths specified are relative to the configuration file.
oneOf:
- type: string
- type: object
additionalProperties: false
required:
- path
properties:
path:
description: >
The path to an environment file relative to the configuration file.
type: string
required:
description: Whether the file is required to exist.
type: boolean
default: true
envFileClause:
description: >
The files to load environment variables from.
If no value is specified, environment variables will be read from an
optional `.env` file automatically.
oneOf:
- $ref: "#/$defs/envFile"
- type: array
items:
$ref: "#/$defs/envFile"
type:
description: >
The type of the value.
enum:
- int
- integer
- float
- float64
- double
- bool
- boolean
- string
option:
description: >
A command-line option for the task.
Options may be set by CLI flag, environment variable, or a configured
default value, in that order.
type: object
additionalProperties: false
properties:
default:
title: default
$ref: "#/$defs/defaultClause"
environment:
title: environment
description: An environment variable that can be used to set the value.
type: string
private:
title: private
description: Whether the option is configurable by CLI or environment variable.
type: boolean
default: false
required:
title: required
type: boolean
default: false
rewrite:
title: rewrite
description: The text to use for interpolation for boolean values.
type: string
short:
title: short
description: >
The one-letter option name.
Short flags can be passed using a single hyphen (e.g., -a) or
combined with other short flags (e.g., -abc).
type: string
minLength: 1
maxLength: 1
type:
title: type
$ref: "#/$defs/type"
usage:
title: usage
description: A one-line summary of the option.
type: string
values:
title: values
description: A predefined set of acceptable values to provide for the option.
type: array
items:
$ref: "#/$defs/value"
allOf:
- not: { required: [private, environment] }
- not: { required: [private, required] }
- not: { required: [private, short] }
- not: { required: [private, values] }
- not: { required: [required, default] }
optionsClause:
description: The set of command-line options that may be provided to the task.
type: object
additionalProperties:
$ref: "#/$defs/option"
runClause:
description: The behavior of the task.
anyOf:
- $ref: "#/$defs/runItem"
- type: array
items:
$ref: "#/$defs/runItem"
runItem:
oneOf:
- $ref: "#/$defs/commandClause"
- type: object
additionalProperties: false
properties:
command:
title: run command
$ref: "#/$defs/commandClause"
set-environment:
title: run set environment
$ref: "#/$defs/setEnvironmentClause"
task:
title: run sub-task
$ref: "#/$defs/subTaskClause"
when:
title: run when
$ref: "#/$defs/whenClause"
oneOf:
- required: [command]
- required: [set-environment]
- required: [task]
setEnvironmentClause:
description: The environment variables to either set or unset.
type: object
additionalProperties:
type:
- string
- "null"
stringOrArray:
oneOf:
- type: string
- type: array
items:
type: string
subTaskClause:
description: A sub-task to run as a part of the outer task definition.
oneOf:
- type: string
- type: object
additionalProperties: false
required:
- name
properties:
name:
title: sub-task name
description: The name of the sub-task to run.
type: string
args:
title: sub-task args
description: The argument values to pass to the sub-task.
type: array
items:
$ref: "#/$defs/value"
options:
title: sub-task options
description: The option values to pass to the sub-task.
type: object
additionalProperties:
$ref: "#/$defs/value"
taskClause:
description: The task definition.
oneOf:
- $ref: "#/$defs/taskInclude"
- $ref: "#/$defs/taskItem"
taskInclude:
type: object
additionalProperties: false
required:
- include
properties:
include:
title: task include
description: >
The relative file path to the yaml task definition.
type: string
taskItem:
type: object
additionalProperties: false
required:
- run
properties:
run:
title: task run
$ref: "#/$defs/runClause"
args:
title: task args
$ref: "#/$defs/argsClause"
description:
title: task description
description: >
The full description of the task. This may be a multi-line value.
type: string
finally:
title: task finally
description: >
Logic to execute after a task's run logic has completed, whether or
not that task was successful.
$ref: "#/$defs/runClause"
options:
title: task options
$ref: "#/$defs/optionsClause"
private:
title: task private
description: Whether the task can be ran directly.
type: boolean
default: false
quiet:
title: task quiet
description: Whether to silence the text/hint before execution.
Command output will still be printed.
type: boolean
default: false
usage:
title: task usage
description: A one-line summary of the task.
type: string
tasksClause:
description: The list of defined tasks available.
type: object
additionalProperties:
$ref: "#/$defs/taskClause"
whenClause:
description: >
A condition that controls whether its outer clause runs or not.
Each individual item in the list of when clauses must pass for the check
to be considered successful.
oneOf:
- $ref: "#/$defs/whenItem"
- type: array
items:
$ref: "#/$defs/whenItem"
whenItem:
oneOf:
- $ref: "#/$defs/value"
- type: object
additionalProperties: false
properties:
command:
title: when command
description: >
A command to run via the global interpreter.
The when clause will be considered a success if any of the
commands exit with a status code of 0.
$ref: "#/$defs/stringOrArray"
equal:
title: when equal
description: >
A set of arg or option values to check.
The when clause will be considered a success if any arg or option
matches any of the provided values.
type: object
additionalProperties:
$ref: "#/$defs/valueList"
environment:
title: when environment
description: >
A set of environment variable values to check.
The when clause will be considered a success if any environment
variable matches any of the provided values.
type: object
additionalProperties:
$ref: "#/$defs/stringOrArray"
exists:
title: when exists
description: >
A set of files to check for existence.
The when clause will be considered a success if any of the files
exist.
$ref: "#/$defs/stringOrArray"
not-equal:
title: when not equal
description: >
A set of arg or option values to check negatively.
The when clause will be considered a success if any of the arg
or option values do not match any of the provided values.
type: object
additionalProperties:
$ref: "#/$defs/valueList"
not-exists:
title: when not exists
description: >
A set of files to check for non-existence.
The when clause will be considered a success if any of the files
do not exist.
$ref: "#/$defs/stringOrArray"
os:
title: when os
description: >
A set of operating systems to check against.
The when clause will be considered a success if the current OS
matches any of the provided operating systems.
$ref: "#/$defs/stringOrArray"
minProperties: 1
valueList:
description: A set of possible values for an arg or option.
oneOf:
- $ref: "#/$defs/value"
- type: array
items:
$ref: "#/$defs/value"
value:
description: The value of an arg or option.
oneOf:
- type: number
- type: boolean
- type: string