-
Notifications
You must be signed in to change notification settings - Fork 21
/
tusk.schema.json
641 lines (641 loc) · 15.5 KB
/
tusk.schema.json
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
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
{
"$defs": {
"argClause": {
"additionalProperties": false,
"description": "A command-line argument definition for the task.",
"properties": {
"type": {
"$ref": "#/$defs/type",
"title": "type"
},
"usage": {
"description": "A one-line summary of the argument.",
"title": "usage",
"type": "string"
},
"values": {
"description": "A predefined set of acceptable values to provide for the argument.",
"items": {
"$ref": "#/$defs/value"
},
"title": "values",
"type": "array"
}
},
"type": "object"
},
"argsClause": {
"additionalProperties": {
"$ref": "#/$defs/argClause"
},
"description": "The set of command-line arguments that must be provided to the task.",
"type": "object"
},
"commandClause": {
"description": "The command or commands to execute using the global interpreter.",
"oneOf": [
{
"$ref": "#/$defs/commandItem"
},
{
"items": {
"$ref": "#/$defs/commandItem"
},
"type": "array"
}
]
},
"commandItem": {
"description": "The command to execute using the global interpreter.",
"oneOf": [
{
"type": "string"
},
{
"additionalProperties": false,
"properties": {
"dir": {
"title": "dir",
"type": "string"
},
"exec": {
"description": "The command to execute using the global interpreter.",
"title": "exec",
"type": "string"
},
"print": {
"description": "The text that will be printed when the command is executed.",
"title": "print",
"type": "string"
},
"quiet": {
"default": false,
"description": "Whether to silence the text/hint before execution.\nCommand output will still be printed.\n",
"title": "quiet",
"type": "boolean"
}
},
"required": [
"exec"
],
"type": "object"
}
]
},
"defaultClause": {
"description": "The default value to use if the value is not otherwise set.\nIf 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.\n",
"oneOf": [
{
"$ref": "#/$defs/defaultItem"
},
{
"items": {
"$ref": "#/$defs/defaultItem"
},
"type": "array"
}
],
"title": "default"
},
"defaultItem": {
"description": "A default value to use if the value is not otherwise set.\nIf a `when` clause is provided, the value will be used if and only if the condition evaluates to true.\n",
"oneOf": [
{
"$ref": "#/$defs/value"
},
{
"additionalProperties": false,
"oneOf": [
{
"required": [
"command"
]
},
{
"required": [
"value"
]
}
],
"properties": {
"command": {
"description": "A command to run via the global interpreter.\nThe value of stdout will be used as the value.\n",
"title": "command",
"type": "string"
},
"value": {
"$ref": "#/$defs/value",
"title": "value"
},
"when": {
"$ref": "#/$defs/whenClause",
"title": "when"
}
},
"type": "object"
}
]
},
"envFile": {
"description": "A file to load environment variables from.\nFile paths specified are relative to the configuration file.\n",
"oneOf": [
{
"type": "string"
},
{
"additionalProperties": false,
"properties": {
"path": {
"description": "The path to an environment file relative to the configuration file.\n",
"type": "string"
},
"required": {
"default": true,
"description": "Whether the file is required to exist.",
"type": "boolean"
}
},
"required": [
"path"
],
"type": "object"
}
]
},
"envFileClause": {
"description": "The files to load environment variables from.\nIf no value is specified, environment variables will be read from an optional `.env` file automatically.\n",
"oneOf": [
{
"$ref": "#/$defs/envFile"
},
{
"items": {
"$ref": "#/$defs/envFile"
},
"type": "array"
}
]
},
"option": {
"additionalProperties": false,
"allOf": [
{
"not": {
"required": [
"private",
"environment"
]
}
},
{
"not": {
"required": [
"private",
"required"
]
}
},
{
"not": {
"required": [
"private",
"short"
]
}
},
{
"not": {
"required": [
"private",
"values"
]
}
},
{
"not": {
"required": [
"required",
"default"
]
}
}
],
"description": "A command-line option for the task.\nOptions may be set by CLI flag, environment variable, or a configured default value, in that order.\n",
"properties": {
"default": {
"$ref": "#/$defs/defaultClause",
"title": "default"
},
"environment": {
"description": "An environment variable that can be used to set the value.",
"title": "environment",
"type": "string"
},
"private": {
"default": false,
"description": "Whether the option is configurable by CLI or environment variable.",
"title": "private",
"type": "boolean"
},
"required": {
"default": false,
"title": "required",
"type": "boolean"
},
"rewrite": {
"description": "The text to use for interpolation for boolean values.",
"title": "rewrite",
"type": "string"
},
"short": {
"description": "The one-letter option name.\nShort flags can be passed using a single hyphen (e.g., -a) or combined with other short flags (e.g., -abc).\n",
"maxLength": 1,
"minLength": 1,
"title": "short",
"type": "string"
},
"type": {
"$ref": "#/$defs/type",
"title": "type"
},
"usage": {
"description": "A one-line summary of the option.",
"title": "usage",
"type": "string"
},
"values": {
"description": "A predefined set of acceptable values to provide for the option.",
"items": {
"$ref": "#/$defs/value"
},
"title": "values",
"type": "array"
}
},
"type": "object"
},
"optionsClause": {
"additionalProperties": {
"$ref": "#/$defs/option"
},
"description": "The set of command-line options that may be provided to the task.",
"type": "object"
},
"runClause": {
"anyOf": [
{
"$ref": "#/$defs/runItem"
},
{
"items": {
"$ref": "#/$defs/runItem"
},
"type": "array"
}
],
"description": "The behavior of the task."
},
"runItem": {
"oneOf": [
{
"$ref": "#/$defs/commandClause"
},
{
"additionalProperties": false,
"oneOf": [
{
"required": [
"command"
]
},
{
"required": [
"set-environment"
]
},
{
"required": [
"task"
]
}
],
"properties": {
"command": {
"$ref": "#/$defs/commandClause",
"title": "run command"
},
"set-environment": {
"$ref": "#/$defs/setEnvironmentClause",
"title": "run set environment"
},
"task": {
"$ref": "#/$defs/subTaskClause",
"title": "run sub-task"
},
"when": {
"$ref": "#/$defs/whenClause",
"title": "run when"
}
},
"type": "object"
}
]
},
"setEnvironmentClause": {
"additionalProperties": {
"type": [
"string",
"null"
]
},
"description": "The environment variables to either set or unset.",
"type": "object"
},
"stringOrArray": {
"oneOf": [
{
"type": "string"
},
{
"items": {
"type": "string"
},
"type": "array"
}
]
},
"subTaskClause": {
"description": "A sub-task to run as a part of the outer task definition.",
"oneOf": [
{
"type": "string"
},
{
"additionalProperties": false,
"properties": {
"args": {
"description": "The argument values to pass to the sub-task.",
"items": {
"$ref": "#/$defs/value"
},
"title": "sub-task args",
"type": "array"
},
"name": {
"description": "The name of the sub-task to run.",
"title": "sub-task name",
"type": "string"
},
"options": {
"additionalProperties": {
"$ref": "#/$defs/value"
},
"description": "The option values to pass to the sub-task.",
"title": "sub-task options",
"type": "object"
}
},
"required": [
"name"
],
"type": "object"
}
]
},
"taskClause": {
"description": "The task definition.",
"oneOf": [
{
"$ref": "#/$defs/taskInclude"
},
{
"$ref": "#/$defs/taskItem"
}
]
},
"taskInclude": {
"additionalProperties": false,
"properties": {
"include": {
"description": "The relative file path to the yaml task definition.\n",
"title": "task include",
"type": "string"
}
},
"required": [
"include"
],
"type": "object"
},
"taskItem": {
"additionalProperties": false,
"properties": {
"args": {
"$ref": "#/$defs/argsClause",
"title": "task args"
},
"description": {
"description": "The full description of the task. This may be a multi-line value.\n",
"title": "task description",
"type": "string"
},
"finally": {
"$ref": "#/$defs/runClause",
"description": "Logic to execute after a task's run logic has completed, whether or not that task was successful.\n",
"title": "task finally"
},
"options": {
"$ref": "#/$defs/optionsClause",
"title": "task options"
},
"private": {
"default": false,
"description": "Whether the task can be ran directly.",
"title": "task private",
"type": "boolean"
},
"quiet": {
"default": false,
"description": "Whether to silence the text/hint before execution.\nCommand output will still be printed.",
"title": "task quiet",
"type": "boolean"
},
"run": {
"$ref": "#/$defs/runClause",
"title": "task run"
},
"usage": {
"description": "A one-line summary of the task.",
"title": "task usage",
"type": "string"
}
},
"required": [
"run"
],
"type": "object"
},
"tasksClause": {
"additionalProperties": {
"$ref": "#/$defs/taskClause"
},
"description": "The list of defined tasks available.",
"type": "object"
},
"type": {
"description": "The type of the value.\n",
"enum": [
"int",
"integer",
"float",
"float64",
"double",
"bool",
"boolean",
"string"
]
},
"value": {
"description": "The value of an arg or option.",
"oneOf": [
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "string"
}
]
},
"valueList": {
"description": "A set of possible values for an arg or option.",
"oneOf": [
{
"$ref": "#/$defs/value"
},
{
"items": {
"$ref": "#/$defs/value"
},
"type": "array"
}
]
},
"whenClause": {
"description": "A condition that controls whether its outer clause runs or not.\nEach individual item in the list of when clauses must pass for the check to be considered successful.\n",
"oneOf": [
{
"$ref": "#/$defs/whenItem"
},
{
"items": {
"$ref": "#/$defs/whenItem"
},
"type": "array"
}
]
},
"whenItem": {
"oneOf": [
{
"$ref": "#/$defs/value"
},
{
"additionalProperties": false,
"minProperties": 1,
"properties": {
"command": {
"$ref": "#/$defs/stringOrArray",
"description": "A command to run via the global interpreter.\nThe when clause will be considered a success if any of the commands exit with a status code of 0.\n",
"title": "when command"
},
"environment": {
"additionalProperties": {
"$ref": "#/$defs/stringOrArray"
},
"description": "A set of environment variable values to check.\nThe when clause will be considered a success if any environment variable matches any of the provided values.\n",
"title": "when environment",
"type": "object"
},
"equal": {
"additionalProperties": {
"$ref": "#/$defs/valueList"
},
"description": "A set of arg or option values to check.\nThe when clause will be considered a success if any arg or option matches any of the provided values.\n",
"title": "when equal",
"type": "object"
},
"exists": {
"$ref": "#/$defs/stringOrArray",
"description": "A set of files to check for existence.\nThe when clause will be considered a success if any of the files exist.\n",
"title": "when exists"
},
"not-equal": {
"additionalProperties": {
"$ref": "#/$defs/valueList"
},
"description": "A set of arg or option values to check negatively.\nThe when clause will be considered a success if any of the arg or option values do not match any of the provided values.\n",
"title": "when not equal",
"type": "object"
},
"not-exists": {
"$ref": "#/$defs/stringOrArray",
"description": "A set of files to check for non-existence.\nThe when clause will be considered a success if any of the files do not exist.\n",
"title": "when not exists"
},
"os": {
"$ref": "#/$defs/stringOrArray",
"description": "A set of operating systems to check against.\nThe when clause will be considered a success if the current OS matches any of the provided operating systems.\n",
"title": "when os"
}
},
"type": "object"
}
]
}
},
"$id": "https://github.com/rliebz/tusk/blob/main/tusk.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"env-file": {
"$ref": "#/$defs/envFileClause",
"title": "env-file"
},
"interpreter": {
"default": "sh -c",
"description": "The interpreter to use for commands.\nThe 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.\nThe commands specified in individual tasks will be passed as the final argument.\n",
"examples": [
"node -e",
"python3 -c"
],
"title": "interpreter",
"type": "string"
},
"name": {
"default": "tusk",
"description": "The alias name to display in help text when using shell aliases to create a custom named CLI application.\n",
"title": "name",
"type": "string"
},
"options": {
"$ref": "#/$defs/optionsClause",
"description": "Shared options available to all tasks.\nAny 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.\nTasks 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.\n",
"title": "shared options"
},
"tasks": {
"$ref": "#/$defs/tasksClause",
"title": "tasks"
},
"usage": {
"default": "the modern task runner",
"description": "The usage text to display in help text when using shell aliases to create a custom named CLI application.\n",
"title": "usage",
"type": "string"
}
},
"title": "JSON schema for tusk configuration files",
"type": "object"
}