@thegetty/quire-cli 1.0.0-rc.33 → 1.0.0-rc.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/schemas/config.schema.json +194 -0
- package/schemas/figures.schema.json +56 -0
- package/schemas/layout.schema.json +5 -0
- package/schemas/objects.schema.json +88 -0
- package/schemas/publication.schema.json +162 -0
- package/schemas/references.schema.json +30 -0
- package/src/commands/validate.js +64 -0
- package/src/errors/validation/validation-error.js +13 -0
- package/src/errors/validation/yaml-duplicate-error.js +11 -0
- package/src/errors/validation/yaml-parse-error.js +11 -0
- package/src/errors/validation/yaml-validation-error.js +11 -0
- package/src/validators/utils.js +98 -0
- package/src/validators/validate-yaml.js +38 -0
- package/patches/.DS_Store +0 -0
- package/patches/README.md +0 -19
- package/patches/install-npm-version+1.0.9.patch +0 -12119
- package/src/.DS_Store +0 -0
- package/src/helpers/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegetty/quire-cli",
|
|
3
3
|
"description": "Quire command-line interface",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.35",
|
|
5
5
|
"author": "Getty Digital",
|
|
6
6
|
"license": "SEE LICENSE IN https://github.com/thegetty/quire/blob/main/LICENSE",
|
|
7
7
|
"bugs": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"files": [
|
|
21
21
|
"bin/",
|
|
22
22
|
"patches/",
|
|
23
|
+
"schemas/",
|
|
23
24
|
"scripts/",
|
|
24
25
|
"src/",
|
|
25
26
|
"CHANGELOG.md",
|
|
@@ -58,7 +59,6 @@
|
|
|
58
59
|
"execa": "^6.1.0",
|
|
59
60
|
"fs-extra": "^11.1.0",
|
|
60
61
|
"hosted-git-info": "^6.1.1",
|
|
61
|
-
"i18next": "^22.4.9",
|
|
62
62
|
"inquirer": "^9.1.4",
|
|
63
63
|
"js-yaml": "^4.1.0",
|
|
64
64
|
"loglevel": "^1.8.1",
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Quire Config Schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"accordion": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"controls": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"enum": ["arrow", "plus-minus"]
|
|
12
|
+
},
|
|
13
|
+
"copyButton": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"properties": {
|
|
16
|
+
"ariaLabel": { "type": "string" },
|
|
17
|
+
"successText": { "type": "string" },
|
|
18
|
+
"symbol": { "type": "string" }
|
|
19
|
+
},
|
|
20
|
+
"required": ["ariaLabel", "successText", "symbol"]
|
|
21
|
+
},
|
|
22
|
+
"globalControls": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"properties": {
|
|
25
|
+
"collapseText": { "type": "string" },
|
|
26
|
+
"expandText": { "type": "string" }
|
|
27
|
+
},
|
|
28
|
+
"required": ["collapseText", "expandText"]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"required": ["controls", "copyButton", "globalControls"]
|
|
32
|
+
},
|
|
33
|
+
"analytics": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"properties": {
|
|
36
|
+
"googleId": { "type": "string" }
|
|
37
|
+
},
|
|
38
|
+
"required": ["googleId"]
|
|
39
|
+
},
|
|
40
|
+
"bylineFormat": {
|
|
41
|
+
"oneOf": [
|
|
42
|
+
{ "type": "string", "enum": ["name", "name-title"] },
|
|
43
|
+
{ "type": "boolean", "enum": [false] }
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"bibliography": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"properties": {
|
|
49
|
+
"displayOnPage": { "type": "boolean" },
|
|
50
|
+
"displayShort": { "type": "boolean" },
|
|
51
|
+
"heading": { "type": "string" }
|
|
52
|
+
},
|
|
53
|
+
"required": ["displayOnPage", "displayShort", "heading"]
|
|
54
|
+
},
|
|
55
|
+
"citations": {
|
|
56
|
+
"type": "object",
|
|
57
|
+
"properties": {
|
|
58
|
+
"divider": { "type": "string" },
|
|
59
|
+
"popupStyle": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"enum": ["text", "icon"]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": ["divider", "popupStyle"]
|
|
65
|
+
},
|
|
66
|
+
"entryPage": {
|
|
67
|
+
"type": "object",
|
|
68
|
+
"properties": {
|
|
69
|
+
"sideBySide": { "type": "boolean" },
|
|
70
|
+
"objectLinkText": { "type": "string" }
|
|
71
|
+
},
|
|
72
|
+
"required": ["sideBySide", "objectLinkText"]
|
|
73
|
+
},
|
|
74
|
+
"epub": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"properties": {
|
|
77
|
+
"defaultCoverImage": { "type": "string" },
|
|
78
|
+
"outputDir": { "type": "string" }
|
|
79
|
+
},
|
|
80
|
+
"required": ["defaultCoverImage", "outputDir"]
|
|
81
|
+
},
|
|
82
|
+
"footnotes": {
|
|
83
|
+
"type": "object",
|
|
84
|
+
"properties": {
|
|
85
|
+
"backlinkSymbol": { "type": "string" }
|
|
86
|
+
},
|
|
87
|
+
"required": ["backlinkSymbol"]
|
|
88
|
+
},
|
|
89
|
+
"figures": {
|
|
90
|
+
"type": "object",
|
|
91
|
+
"properties": {
|
|
92
|
+
"assetDir": { "type": "string" },
|
|
93
|
+
"enableModal": { "type": "boolean" },
|
|
94
|
+
"imageDir": { "type": "string" }
|
|
95
|
+
},
|
|
96
|
+
"required": ["assetDir", "enableModal", "imageDir"]
|
|
97
|
+
},
|
|
98
|
+
"licenseIcons": { "type": "boolean" },
|
|
99
|
+
"localization": {
|
|
100
|
+
"type": "object",
|
|
101
|
+
"properties": {
|
|
102
|
+
"defaultLocale": { "type": "string" }
|
|
103
|
+
},
|
|
104
|
+
"required": ["defaultLocale"]
|
|
105
|
+
},
|
|
106
|
+
"menuType": {
|
|
107
|
+
"type": "string",
|
|
108
|
+
"enum": ["full", "brief"]
|
|
109
|
+
},
|
|
110
|
+
"navigation": {
|
|
111
|
+
"type": "object",
|
|
112
|
+
"properties": {
|
|
113
|
+
"nextButtonText": { "type": "string" },
|
|
114
|
+
"prevButtonText": { "type": "string" }
|
|
115
|
+
},
|
|
116
|
+
"required": ["nextButtonText", "prevButtonText"]
|
|
117
|
+
},
|
|
118
|
+
"pageTitle": {
|
|
119
|
+
"type": "object",
|
|
120
|
+
"properties": {
|
|
121
|
+
"labelDivider": { "type": "string" }
|
|
122
|
+
},
|
|
123
|
+
"required": ["labelDivider"]
|
|
124
|
+
},
|
|
125
|
+
"pdf": {
|
|
126
|
+
"type": "object",
|
|
127
|
+
"properties": {
|
|
128
|
+
"filename": { "type": "string" },
|
|
129
|
+
"outputDir": { "type": "string" },
|
|
130
|
+
"pagePDF": {
|
|
131
|
+
"type": "object",
|
|
132
|
+
"properties": {
|
|
133
|
+
"accessLinks": {
|
|
134
|
+
"type": "array",
|
|
135
|
+
"items": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"properties": {
|
|
138
|
+
"header": { "type": "boolean" },
|
|
139
|
+
"footer": { "type": "boolean" },
|
|
140
|
+
"label": { "type": "string" }
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"coverPage": { "type": "boolean" },
|
|
145
|
+
"output": { "type": "boolean" }
|
|
146
|
+
},
|
|
147
|
+
"required": ["accessLinks", "coverPage", "output"]
|
|
148
|
+
},
|
|
149
|
+
"publicationPDF": {
|
|
150
|
+
"type": "object",
|
|
151
|
+
"properties": {
|
|
152
|
+
"output": { "type": "boolean" }
|
|
153
|
+
},
|
|
154
|
+
"required": ["output"]
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"required": ["filename", "outputDir", "pagePDF", "publicationPDF"]
|
|
158
|
+
},
|
|
159
|
+
"ref": {
|
|
160
|
+
"type": "object",
|
|
161
|
+
"properties": {
|
|
162
|
+
"sequenceTransition": { "type": "number" }
|
|
163
|
+
},
|
|
164
|
+
"required": ["sequenceTransition"]
|
|
165
|
+
},
|
|
166
|
+
"searchEnabled": { "type": "boolean" },
|
|
167
|
+
"tableOfContents": {
|
|
168
|
+
"type": "object",
|
|
169
|
+
"properties": {
|
|
170
|
+
"contributorDivider": { "type": "string" }
|
|
171
|
+
},
|
|
172
|
+
"required": ["contributorDivider"]
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"required": [
|
|
176
|
+
"accordion",
|
|
177
|
+
"bylineFormat",
|
|
178
|
+
"bibliography",
|
|
179
|
+
"citations",
|
|
180
|
+
"entryPage",
|
|
181
|
+
"epub",
|
|
182
|
+
"footnotes",
|
|
183
|
+
"figures",
|
|
184
|
+
"licenseIcons",
|
|
185
|
+
"localization",
|
|
186
|
+
"menuType",
|
|
187
|
+
"navigation",
|
|
188
|
+
"pageTitle",
|
|
189
|
+
"pdf",
|
|
190
|
+
"ref",
|
|
191
|
+
"searchEnabled",
|
|
192
|
+
"tableOfContents"
|
|
193
|
+
]
|
|
194
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Figures YAML Schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"figure_list": {
|
|
7
|
+
"type": "array",
|
|
8
|
+
"items": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"required": ["id"],
|
|
11
|
+
"properties": {
|
|
12
|
+
"id": { "type": "string" },
|
|
13
|
+
"label": { "type": "string" },
|
|
14
|
+
"src": { "type": "string" },
|
|
15
|
+
"caption": { "type": "string" },
|
|
16
|
+
"credit": { "type": ["string", "null"] },
|
|
17
|
+
"alt": { "type": ["string", "null"] },
|
|
18
|
+
"poster": { "type": "string" },
|
|
19
|
+
"download": { "type": "boolean" },
|
|
20
|
+
"zoom": { "type": "boolean" },
|
|
21
|
+
"media_id": { "type": "string" },
|
|
22
|
+
"media_type": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"enum": ["youtube", "soundcloud", "table"]
|
|
25
|
+
},
|
|
26
|
+
"annotations": {
|
|
27
|
+
"type": "array",
|
|
28
|
+
"items": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"required": ["input", "items"],
|
|
31
|
+
"properties": {
|
|
32
|
+
"input": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"enum": ["radio", "checkbox"]
|
|
35
|
+
},
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"items": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"properties": {
|
|
41
|
+
"src": { "type": "string" },
|
|
42
|
+
"label": { "type": "string" },
|
|
43
|
+
"selected": { "type": "boolean" }
|
|
44
|
+
},
|
|
45
|
+
"required": ["src"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"required": ["figure_list"]
|
|
56
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Objects Schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
|
|
6
|
+
"required": [
|
|
7
|
+
"object_card",
|
|
8
|
+
"object_display_order",
|
|
9
|
+
"object_filters",
|
|
10
|
+
"object_list"
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"object_filters": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"items": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"minItems": 0
|
|
19
|
+
},
|
|
20
|
+
"object_card": {
|
|
21
|
+
"type": "array",
|
|
22
|
+
"items": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"minItems": 0
|
|
26
|
+
},
|
|
27
|
+
"object_display_order": {
|
|
28
|
+
"type": "array",
|
|
29
|
+
"items": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
},
|
|
32
|
+
"minItems": 0
|
|
33
|
+
},
|
|
34
|
+
"object_list": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"id": {
|
|
40
|
+
"type": "string"
|
|
41
|
+
},
|
|
42
|
+
"title": {
|
|
43
|
+
"type": "string"
|
|
44
|
+
},
|
|
45
|
+
"artist": {
|
|
46
|
+
"type": "string"
|
|
47
|
+
},
|
|
48
|
+
"year": {
|
|
49
|
+
"type": "integer"
|
|
50
|
+
},
|
|
51
|
+
"medium": {
|
|
52
|
+
"type": "string"
|
|
53
|
+
},
|
|
54
|
+
"dimensions": {
|
|
55
|
+
"type": "string"
|
|
56
|
+
},
|
|
57
|
+
"location": {
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"link": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"format": "uri"
|
|
63
|
+
},
|
|
64
|
+
"figure": {
|
|
65
|
+
"type": "array",
|
|
66
|
+
"items": {
|
|
67
|
+
"type": "object",
|
|
68
|
+
"properties": {
|
|
69
|
+
"id": {
|
|
70
|
+
"type": "string"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"required": [
|
|
74
|
+
"id"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
"minItems": 0
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"required": [
|
|
81
|
+
"id",
|
|
82
|
+
"title"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"minItems": 0
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Publication Schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
|
|
6
|
+
"required": [
|
|
7
|
+
"url",
|
|
8
|
+
"title",
|
|
9
|
+
"subtitle",
|
|
10
|
+
"description",
|
|
11
|
+
"pub_date",
|
|
12
|
+
"language",
|
|
13
|
+
"pub_type",
|
|
14
|
+
"identifier",
|
|
15
|
+
"publisher",
|
|
16
|
+
"contributor",
|
|
17
|
+
"copyright",
|
|
18
|
+
"license",
|
|
19
|
+
"resource_link",
|
|
20
|
+
"subject",
|
|
21
|
+
"revision_history",
|
|
22
|
+
"promo_image"
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
"properties": {
|
|
26
|
+
"url": { "type": "string" },
|
|
27
|
+
"title": { "type": "string" },
|
|
28
|
+
"subtitle": { "type": "string" },
|
|
29
|
+
|
|
30
|
+
"reading_line": { "type": ["string", "null"] },
|
|
31
|
+
"short_title": { "type": ["string", "null"] },
|
|
32
|
+
|
|
33
|
+
"description": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"required": ["full"],
|
|
36
|
+
"properties": {
|
|
37
|
+
"one_line": { "type": ["string", "null"] },
|
|
38
|
+
"full": { "type": "string" }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
"pub_date": {
|
|
43
|
+
"oneOf": [
|
|
44
|
+
{ "type": "string" },
|
|
45
|
+
{ "type": "object" }
|
|
46
|
+
] },
|
|
47
|
+
"language": { "type": "string" },
|
|
48
|
+
"pub_type": { "type": "string" },
|
|
49
|
+
|
|
50
|
+
"identifier": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"properties": {
|
|
53
|
+
"isbn": { "type": ["string", "null"] }
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
"publisher": {
|
|
58
|
+
"type": "array",
|
|
59
|
+
"items": { "$ref": "#/definitions/publisher" }
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
"contributor_as_it_appears": { "type": ["string", "null"] },
|
|
63
|
+
|
|
64
|
+
"contributor": {
|
|
65
|
+
"type": "array",
|
|
66
|
+
"items": { "$ref": "#/definitions/contributor" }
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
"copyright": { "type": "string" },
|
|
70
|
+
|
|
71
|
+
"license": { "$ref": "#/definitions/license" },
|
|
72
|
+
|
|
73
|
+
"resource_link": {
|
|
74
|
+
"type": "array",
|
|
75
|
+
"items": { "$ref": "#/definitions/resourceLink" }
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
"subject": {
|
|
79
|
+
"type": "array",
|
|
80
|
+
"items": { "$ref": "#/definitions/subject" }
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
"revision_history": {
|
|
84
|
+
"type": "array",
|
|
85
|
+
"items": { "$ref": "#/definitions/revision" }
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
"repository_url": { "type": ["string", "null"] },
|
|
89
|
+
|
|
90
|
+
"promo_image": { "type": "string" }
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
"definitions": {
|
|
94
|
+
"publisher": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"required": ["name"],
|
|
97
|
+
"properties": {
|
|
98
|
+
"name": { "type": "string" },
|
|
99
|
+
"location": { "type": ["string", "null"] },
|
|
100
|
+
"url": { "type": ["string", "null"] },
|
|
101
|
+
"logo": { "type": ["string", "null"] }
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
"contributor": {
|
|
106
|
+
"type": "object",
|
|
107
|
+
"required": ["id", "type", "first_name", "last_name"],
|
|
108
|
+
"properties": {
|
|
109
|
+
"id": { "type": "string" },
|
|
110
|
+
"type": { "type": "string" },
|
|
111
|
+
"first_name": { "type": "string" },
|
|
112
|
+
"last_name": { "type": "string" },
|
|
113
|
+
"title": { "type": ["string", "null"] },
|
|
114
|
+
"affiliation": { "type": ["string", "null"] },
|
|
115
|
+
"bio": { "type": ["string", "null"] },
|
|
116
|
+
"url": { "type": ["string", "null"] },
|
|
117
|
+
"image": { "type": ["string", "null"] }
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
"license": {
|
|
122
|
+
"type": "object",
|
|
123
|
+
"required": ["name", "abbreviation", "url", "scope"],
|
|
124
|
+
"properties": {
|
|
125
|
+
"name": { "type": "string" },
|
|
126
|
+
"abbreviation": { "type": "string" },
|
|
127
|
+
"url": { "type": "string" },
|
|
128
|
+
"scope": { "type": "string" }
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
"resourceLink": {
|
|
133
|
+
"type": "object",
|
|
134
|
+
"required": ["type", "name", "link_relation"],
|
|
135
|
+
"properties": {
|
|
136
|
+
"type": { "type": "string" },
|
|
137
|
+
"name": { "type": "string" },
|
|
138
|
+
"media_type": { "type": ["string", "null"] },
|
|
139
|
+
"link_relation": { "type": "string" },
|
|
140
|
+
"url": { "type": ["string", "null"] }
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
"subject": {
|
|
145
|
+
"type": "object",
|
|
146
|
+
"required": ["type", "name"],
|
|
147
|
+
"properties": {
|
|
148
|
+
"type": { "type": "string" },
|
|
149
|
+
"name": { "type": "string" },
|
|
150
|
+
"identifier": { "type": ["string", "null"] }
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
"revision": {
|
|
155
|
+
"type": "object",
|
|
156
|
+
"properties": {
|
|
157
|
+
"date": { "type": ["string", "null"] },
|
|
158
|
+
"summary": { "type": ["string", "null"] }
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "References Schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
|
|
6
|
+
"required": [
|
|
7
|
+
"entries"
|
|
8
|
+
],
|
|
9
|
+
"properties": {
|
|
10
|
+
"entries": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"items": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"id": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"full": {
|
|
19
|
+
"type": "string"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"required": [
|
|
23
|
+
"full",
|
|
24
|
+
"id"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"minItems": 0
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Command from '#src/Command.js'
|
|
2
|
+
import { YAMLException } from 'js-yaml'
|
|
3
|
+
import YamlValidationError from '../errors/validation/yaml-validation-error.js'
|
|
4
|
+
import fs from 'fs-extra'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
import { projectRoot } from '#lib/11ty/index.js'
|
|
7
|
+
import testcwd from '../helpers/test-cwd.js'
|
|
8
|
+
import yamlValidation from '../validators/validate-yaml.js'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Quire CLI `validate` Command
|
|
13
|
+
*
|
|
14
|
+
* @class ValidateCommand
|
|
15
|
+
* @extends {Command}
|
|
16
|
+
*/
|
|
17
|
+
export default class ValidateCommand extends Command {
|
|
18
|
+
static definition = {
|
|
19
|
+
name: 'validate',
|
|
20
|
+
description: 'Validate configuration files',
|
|
21
|
+
summary: 'run validation',
|
|
22
|
+
version: '1.0.0',
|
|
23
|
+
options: [
|
|
24
|
+
[ '--debug', 'run validate with debug output to console' ],
|
|
25
|
+
],
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
constructor() {
|
|
29
|
+
super(ValidateCommand.definition)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
action(options, command){
|
|
33
|
+
if(options.debug) {
|
|
34
|
+
console.debug('[CLI] Command \'%s\' called with options %o', this.name(), options)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const dataPath = path.join(projectRoot, 'content', '_data')
|
|
38
|
+
const files = fs.readdirSync(dataPath)
|
|
39
|
+
.filter(file => file.endsWith('.yaml') || file.endsWith('.yml'))
|
|
40
|
+
.map(file => path.join(dataPath, file)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
let errorList = []
|
|
44
|
+
console.log('Validating YAML files..')
|
|
45
|
+
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
try {
|
|
48
|
+
yamlValidation(file)
|
|
49
|
+
} catch (error){
|
|
50
|
+
errorList.push(error)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if(errorList.length > 0) {
|
|
55
|
+
errorList.forEach(err => { console.error(`${err.reason}`) })
|
|
56
|
+
} else {
|
|
57
|
+
console.log('Validation complete.')
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
preAction(options, command) {
|
|
62
|
+
testcwd(command)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default class ValidationError extends Error {
|
|
2
|
+
constructor(message, {filePath, reason, code} = {}) {
|
|
3
|
+
super(message)
|
|
4
|
+
this.name = this.constructor.name
|
|
5
|
+
this.filePath = filePath
|
|
6
|
+
this.reason = reason
|
|
7
|
+
this.code = code
|
|
8
|
+
|
|
9
|
+
if ('captureStackTrace' in Error) {
|
|
10
|
+
Error.captureStackTrace(this, this.constructor)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ValidationError from './validation-error.js'
|
|
2
|
+
|
|
3
|
+
export default class YamlDuplicateIdError extends ValidationError {
|
|
4
|
+
constructor(filePath, reason) {
|
|
5
|
+
super('Duplicate ID found in YAML file', {
|
|
6
|
+
filePath,
|
|
7
|
+
reason: reason,
|
|
8
|
+
code: 'YAML_DUPLICATE_ID_ERROR',
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ValidationError from './validation-error.js'
|
|
2
|
+
|
|
3
|
+
export default class YamlParseError extends ValidationError {
|
|
4
|
+
constructor(filePath, reason) {
|
|
5
|
+
super('Error parsing YAML file', {
|
|
6
|
+
filePath,
|
|
7
|
+
reason: reason,
|
|
8
|
+
code: 'YAML_PARSE_ERROR',
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ValidationError from './validation-error.js'
|
|
2
|
+
|
|
3
|
+
export default class YamlValidationError extends ValidationError {
|
|
4
|
+
constructor(filePath, reason) {
|
|
5
|
+
super('Error validating YAML file', {
|
|
6
|
+
filePath,
|
|
7
|
+
reason: reason,
|
|
8
|
+
code: 'YAML_VALIDATION_ERROR',
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
}
|