5etools-utils 0.5.13 → 0.5.15
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/lib/TestJson.js +19 -9
- package/package.json +3 -2
- package/schema/brew/decks.json +28 -1
- package/schema/brew-fast/decks.json +28 -1
- package/schema/site/decks.json +28 -1
- package/schema/site-fast/decks.json +28 -1
package/lib/TestJson.js
CHANGED
|
@@ -33,10 +33,10 @@ class JsonTester {
|
|
|
33
33
|
if (isBrew && dirSchema) throw new Error(`"isBrew" and "dirSchema" are mutually exclusive!`);
|
|
34
34
|
if (!fnGetSchemaId) throw new Error(`"fnGetSchemaId" is required!`);
|
|
35
35
|
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
this._dirSchemaSite = path.join(__dirname, "..", "schema", "site");
|
|
37
|
+
this._dirSchemaBrew = path.join(__dirname, "..", "schema", "brew");
|
|
38
|
+
|
|
39
|
+
this._dirSchema = dirSchema ?? (isBrew ? this._dirSchemaBrew : this._dirSchemaSite);
|
|
40
40
|
this._tagLog = tagLog;
|
|
41
41
|
this._fnGetSchemaId = fnGetSchemaId;
|
|
42
42
|
|
|
@@ -112,30 +112,40 @@ class JsonTester {
|
|
|
112
112
|
return out;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
doLoadSchema (type, relativeFilePath) {
|
|
116
|
+
if (!["site", "brew"].includes(type)) throw new Error(`Unknown schema type "${type}"`);
|
|
117
|
+
|
|
118
|
+
const dir = type === "site" ? this._dirSchemaSite : this._dirSchemaBrew;
|
|
119
|
+
|
|
120
|
+
this._ajv.addSchema(
|
|
121
|
+
Uf.readJSON(path.join(dir, relativeFilePath)),
|
|
122
|
+
relativeFilePath,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_doLoadSchemas () {
|
|
116
127
|
if (this._isSchemaLoaded) return;
|
|
117
128
|
|
|
118
129
|
Uf.listJsonFiles(this._dirSchema)
|
|
119
130
|
.forEach(filePath => {
|
|
120
131
|
filePath = path.normalize(filePath);
|
|
121
|
-
const contents = Uf.readJSON(filePath);
|
|
122
132
|
|
|
123
133
|
const relativeFilePath = path.relative(this._dirSchema, filePath)
|
|
124
134
|
.replace(/\\/g, "/");
|
|
125
135
|
|
|
126
|
-
this._ajv.addSchema(
|
|
136
|
+
this._ajv.addSchema(Uf.readJSON(filePath), relativeFilePath);
|
|
127
137
|
});
|
|
128
138
|
|
|
129
139
|
this._isSchemaLoaded = true;
|
|
130
140
|
}
|
|
131
141
|
|
|
132
142
|
_hasSchema (schemaId) {
|
|
133
|
-
this.
|
|
143
|
+
this._doLoadSchemas();
|
|
134
144
|
return !!this._ajv.schemas[schemaId];
|
|
135
145
|
}
|
|
136
146
|
|
|
137
147
|
getFileErrors ({filePath} = {}) {
|
|
138
|
-
this.
|
|
148
|
+
this._doLoadSchemas();
|
|
139
149
|
|
|
140
150
|
Um.info(this._tagLog, `\tValidating "${filePath}"...`);
|
|
141
151
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5etools-utils",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.15",
|
|
4
4
|
"description": "Shared utilities for the 5etools ecosystem.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/Api.js",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"build": "node node/compile-schemas.js",
|
|
16
16
|
"test": "npm run lint:js && npm run test:js",
|
|
17
17
|
"test:js": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
18
|
-
"lint:js": "eslint lib node test --fix"
|
|
18
|
+
"lint:js": "eslint lib node test --fix",
|
|
19
|
+
"preversion": "npm t"
|
|
19
20
|
},
|
|
20
21
|
"repository": {
|
|
21
22
|
"type": "git",
|
package/schema/brew/decks.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "decks.json",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"$defs": {
|
|
7
7
|
"deckData": {
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"name": {
|
|
11
11
|
"type": "string"
|
|
12
12
|
},
|
|
13
|
+
"alias": {
|
|
14
|
+
"$ref": "util.json#/$defs/alias"
|
|
15
|
+
},
|
|
13
16
|
"source": {
|
|
14
17
|
"type": "string"
|
|
15
18
|
},
|
|
@@ -74,6 +77,9 @@
|
|
|
74
77
|
"name": {
|
|
75
78
|
"type": "string"
|
|
76
79
|
},
|
|
80
|
+
"alias": {
|
|
81
|
+
"$ref": "util.json#/$defs/alias"
|
|
82
|
+
},
|
|
77
83
|
"source": {
|
|
78
84
|
"type": "string"
|
|
79
85
|
},
|
|
@@ -141,6 +147,9 @@
|
|
|
141
147
|
"name": {
|
|
142
148
|
"type": "string"
|
|
143
149
|
},
|
|
150
|
+
"alias": {
|
|
151
|
+
"$ref": "util.json#/$defs/alias"
|
|
152
|
+
},
|
|
144
153
|
"source": {
|
|
145
154
|
"type": "string"
|
|
146
155
|
},
|
|
@@ -266,6 +275,9 @@
|
|
|
266
275
|
"name": {
|
|
267
276
|
"type": "string"
|
|
268
277
|
},
|
|
278
|
+
"alias": {
|
|
279
|
+
"$ref": "util.json#/$defs/alias"
|
|
280
|
+
},
|
|
269
281
|
"source": {
|
|
270
282
|
"type": "string"
|
|
271
283
|
},
|
|
@@ -295,6 +307,9 @@
|
|
|
295
307
|
},
|
|
296
308
|
"value": {
|
|
297
309
|
"type": "integer"
|
|
310
|
+
},
|
|
311
|
+
"valueName": {
|
|
312
|
+
"type": "string"
|
|
298
313
|
}
|
|
299
314
|
},
|
|
300
315
|
"additionalProperties": false
|
|
@@ -307,6 +322,9 @@
|
|
|
307
322
|
"name": {
|
|
308
323
|
"type": "string"
|
|
309
324
|
},
|
|
325
|
+
"alias": {
|
|
326
|
+
"$ref": "util.json#/$defs/alias"
|
|
327
|
+
},
|
|
310
328
|
"source": {
|
|
311
329
|
"type": "string"
|
|
312
330
|
},
|
|
@@ -336,6 +354,9 @@
|
|
|
336
354
|
},
|
|
337
355
|
"value": {
|
|
338
356
|
"type": "integer"
|
|
357
|
+
},
|
|
358
|
+
"valueName": {
|
|
359
|
+
"type": "string"
|
|
339
360
|
}
|
|
340
361
|
},
|
|
341
362
|
"additionalProperties": false,
|
|
@@ -351,6 +372,9 @@
|
|
|
351
372
|
"name": {
|
|
352
373
|
"type": "string"
|
|
353
374
|
},
|
|
375
|
+
"alias": {
|
|
376
|
+
"$ref": "util.json#/$defs/alias"
|
|
377
|
+
},
|
|
354
378
|
"source": {
|
|
355
379
|
"type": "string"
|
|
356
380
|
},
|
|
@@ -381,6 +405,9 @@
|
|
|
381
405
|
"value": {
|
|
382
406
|
"type": "integer"
|
|
383
407
|
},
|
|
408
|
+
"valueName": {
|
|
409
|
+
"type": "string"
|
|
410
|
+
},
|
|
384
411
|
"_copy": {
|
|
385
412
|
"type": "object",
|
|
386
413
|
"properties": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "decks.json",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"$defs": {
|
|
7
7
|
"deckData": {
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"name": {
|
|
11
11
|
"type": "string"
|
|
12
12
|
},
|
|
13
|
+
"alias": {
|
|
14
|
+
"$ref": "util.json#/$defs/alias"
|
|
15
|
+
},
|
|
13
16
|
"source": {
|
|
14
17
|
"type": "string"
|
|
15
18
|
},
|
|
@@ -74,6 +77,9 @@
|
|
|
74
77
|
"name": {
|
|
75
78
|
"type": "string"
|
|
76
79
|
},
|
|
80
|
+
"alias": {
|
|
81
|
+
"$ref": "util.json#/$defs/alias"
|
|
82
|
+
},
|
|
77
83
|
"source": {
|
|
78
84
|
"type": "string"
|
|
79
85
|
},
|
|
@@ -141,6 +147,9 @@
|
|
|
141
147
|
"name": {
|
|
142
148
|
"type": "string"
|
|
143
149
|
},
|
|
150
|
+
"alias": {
|
|
151
|
+
"$ref": "util.json#/$defs/alias"
|
|
152
|
+
},
|
|
144
153
|
"source": {
|
|
145
154
|
"type": "string"
|
|
146
155
|
},
|
|
@@ -266,6 +275,9 @@
|
|
|
266
275
|
"name": {
|
|
267
276
|
"type": "string"
|
|
268
277
|
},
|
|
278
|
+
"alias": {
|
|
279
|
+
"$ref": "util.json#/$defs/alias"
|
|
280
|
+
},
|
|
269
281
|
"source": {
|
|
270
282
|
"type": "string"
|
|
271
283
|
},
|
|
@@ -295,6 +307,9 @@
|
|
|
295
307
|
},
|
|
296
308
|
"value": {
|
|
297
309
|
"type": "integer"
|
|
310
|
+
},
|
|
311
|
+
"valueName": {
|
|
312
|
+
"type": "string"
|
|
298
313
|
}
|
|
299
314
|
},
|
|
300
315
|
"additionalProperties": false
|
|
@@ -307,6 +322,9 @@
|
|
|
307
322
|
"name": {
|
|
308
323
|
"type": "string"
|
|
309
324
|
},
|
|
325
|
+
"alias": {
|
|
326
|
+
"$ref": "util.json#/$defs/alias"
|
|
327
|
+
},
|
|
310
328
|
"source": {
|
|
311
329
|
"type": "string"
|
|
312
330
|
},
|
|
@@ -336,6 +354,9 @@
|
|
|
336
354
|
},
|
|
337
355
|
"value": {
|
|
338
356
|
"type": "integer"
|
|
357
|
+
},
|
|
358
|
+
"valueName": {
|
|
359
|
+
"type": "string"
|
|
339
360
|
}
|
|
340
361
|
},
|
|
341
362
|
"additionalProperties": false,
|
|
@@ -351,6 +372,9 @@
|
|
|
351
372
|
"name": {
|
|
352
373
|
"type": "string"
|
|
353
374
|
},
|
|
375
|
+
"alias": {
|
|
376
|
+
"$ref": "util.json#/$defs/alias"
|
|
377
|
+
},
|
|
354
378
|
"source": {
|
|
355
379
|
"type": "string"
|
|
356
380
|
},
|
|
@@ -381,6 +405,9 @@
|
|
|
381
405
|
"value": {
|
|
382
406
|
"type": "integer"
|
|
383
407
|
},
|
|
408
|
+
"valueName": {
|
|
409
|
+
"type": "string"
|
|
410
|
+
},
|
|
384
411
|
"_copy": {
|
|
385
412
|
"type": "object",
|
|
386
413
|
"properties": {
|
package/schema/site/decks.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "decks.json",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"$defs": {
|
|
7
7
|
"deckData": {
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"name": {
|
|
11
11
|
"type": "string"
|
|
12
12
|
},
|
|
13
|
+
"alias": {
|
|
14
|
+
"$ref": "util.json#/$defs/alias"
|
|
15
|
+
},
|
|
13
16
|
"source": {
|
|
14
17
|
"type": "string"
|
|
15
18
|
},
|
|
@@ -74,6 +77,9 @@
|
|
|
74
77
|
"name": {
|
|
75
78
|
"type": "string"
|
|
76
79
|
},
|
|
80
|
+
"alias": {
|
|
81
|
+
"$ref": "util.json#/$defs/alias"
|
|
82
|
+
},
|
|
77
83
|
"source": {
|
|
78
84
|
"type": "string"
|
|
79
85
|
},
|
|
@@ -141,6 +147,9 @@
|
|
|
141
147
|
"name": {
|
|
142
148
|
"type": "string"
|
|
143
149
|
},
|
|
150
|
+
"alias": {
|
|
151
|
+
"$ref": "util.json#/$defs/alias"
|
|
152
|
+
},
|
|
144
153
|
"source": {
|
|
145
154
|
"type": "string"
|
|
146
155
|
},
|
|
@@ -266,6 +275,9 @@
|
|
|
266
275
|
"name": {
|
|
267
276
|
"type": "string"
|
|
268
277
|
},
|
|
278
|
+
"alias": {
|
|
279
|
+
"$ref": "util.json#/$defs/alias"
|
|
280
|
+
},
|
|
269
281
|
"source": {
|
|
270
282
|
"type": "string"
|
|
271
283
|
},
|
|
@@ -295,6 +307,9 @@
|
|
|
295
307
|
},
|
|
296
308
|
"value": {
|
|
297
309
|
"type": "integer"
|
|
310
|
+
},
|
|
311
|
+
"valueName": {
|
|
312
|
+
"type": "string"
|
|
298
313
|
}
|
|
299
314
|
},
|
|
300
315
|
"additionalProperties": false
|
|
@@ -307,6 +322,9 @@
|
|
|
307
322
|
"name": {
|
|
308
323
|
"type": "string"
|
|
309
324
|
},
|
|
325
|
+
"alias": {
|
|
326
|
+
"$ref": "util.json#/$defs/alias"
|
|
327
|
+
},
|
|
310
328
|
"source": {
|
|
311
329
|
"type": "string"
|
|
312
330
|
},
|
|
@@ -336,6 +354,9 @@
|
|
|
336
354
|
},
|
|
337
355
|
"value": {
|
|
338
356
|
"type": "integer"
|
|
357
|
+
},
|
|
358
|
+
"valueName": {
|
|
359
|
+
"type": "string"
|
|
339
360
|
}
|
|
340
361
|
},
|
|
341
362
|
"additionalProperties": false,
|
|
@@ -351,6 +372,9 @@
|
|
|
351
372
|
"name": {
|
|
352
373
|
"type": "string"
|
|
353
374
|
},
|
|
375
|
+
"alias": {
|
|
376
|
+
"$ref": "util.json#/$defs/alias"
|
|
377
|
+
},
|
|
354
378
|
"source": {
|
|
355
379
|
"type": "string"
|
|
356
380
|
},
|
|
@@ -381,6 +405,9 @@
|
|
|
381
405
|
"value": {
|
|
382
406
|
"type": "integer"
|
|
383
407
|
},
|
|
408
|
+
"valueName": {
|
|
409
|
+
"type": "string"
|
|
410
|
+
},
|
|
384
411
|
"_copy": {
|
|
385
412
|
"type": "object",
|
|
386
413
|
"properties": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "decks.json",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"$defs": {
|
|
7
7
|
"deckData": {
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"name": {
|
|
11
11
|
"type": "string"
|
|
12
12
|
},
|
|
13
|
+
"alias": {
|
|
14
|
+
"$ref": "util.json#/$defs/alias"
|
|
15
|
+
},
|
|
13
16
|
"source": {
|
|
14
17
|
"type": "string"
|
|
15
18
|
},
|
|
@@ -74,6 +77,9 @@
|
|
|
74
77
|
"name": {
|
|
75
78
|
"type": "string"
|
|
76
79
|
},
|
|
80
|
+
"alias": {
|
|
81
|
+
"$ref": "util.json#/$defs/alias"
|
|
82
|
+
},
|
|
77
83
|
"source": {
|
|
78
84
|
"type": "string"
|
|
79
85
|
},
|
|
@@ -141,6 +147,9 @@
|
|
|
141
147
|
"name": {
|
|
142
148
|
"type": "string"
|
|
143
149
|
},
|
|
150
|
+
"alias": {
|
|
151
|
+
"$ref": "util.json#/$defs/alias"
|
|
152
|
+
},
|
|
144
153
|
"source": {
|
|
145
154
|
"type": "string"
|
|
146
155
|
},
|
|
@@ -266,6 +275,9 @@
|
|
|
266
275
|
"name": {
|
|
267
276
|
"type": "string"
|
|
268
277
|
},
|
|
278
|
+
"alias": {
|
|
279
|
+
"$ref": "util.json#/$defs/alias"
|
|
280
|
+
},
|
|
269
281
|
"source": {
|
|
270
282
|
"type": "string"
|
|
271
283
|
},
|
|
@@ -295,6 +307,9 @@
|
|
|
295
307
|
},
|
|
296
308
|
"value": {
|
|
297
309
|
"type": "integer"
|
|
310
|
+
},
|
|
311
|
+
"valueName": {
|
|
312
|
+
"type": "string"
|
|
298
313
|
}
|
|
299
314
|
},
|
|
300
315
|
"additionalProperties": false
|
|
@@ -307,6 +322,9 @@
|
|
|
307
322
|
"name": {
|
|
308
323
|
"type": "string"
|
|
309
324
|
},
|
|
325
|
+
"alias": {
|
|
326
|
+
"$ref": "util.json#/$defs/alias"
|
|
327
|
+
},
|
|
310
328
|
"source": {
|
|
311
329
|
"type": "string"
|
|
312
330
|
},
|
|
@@ -336,6 +354,9 @@
|
|
|
336
354
|
},
|
|
337
355
|
"value": {
|
|
338
356
|
"type": "integer"
|
|
357
|
+
},
|
|
358
|
+
"valueName": {
|
|
359
|
+
"type": "string"
|
|
339
360
|
}
|
|
340
361
|
},
|
|
341
362
|
"additionalProperties": false,
|
|
@@ -351,6 +372,9 @@
|
|
|
351
372
|
"name": {
|
|
352
373
|
"type": "string"
|
|
353
374
|
},
|
|
375
|
+
"alias": {
|
|
376
|
+
"$ref": "util.json#/$defs/alias"
|
|
377
|
+
},
|
|
354
378
|
"source": {
|
|
355
379
|
"type": "string"
|
|
356
380
|
},
|
|
@@ -381,6 +405,9 @@
|
|
|
381
405
|
"value": {
|
|
382
406
|
"type": "integer"
|
|
383
407
|
},
|
|
408
|
+
"valueName": {
|
|
409
|
+
"type": "string"
|
|
410
|
+
},
|
|
384
411
|
"_copy": {
|
|
385
412
|
"type": "object",
|
|
386
413
|
"properties": {
|