arcadible 0.1.32 → 0.1.34
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/README.md +4 -4
- package/bin/arc-build.js +23 -5
- package/bin/arc-deploy.js +78 -13
- package/bin/arc-init.js +6 -1
- package/bin/arc-inspect.js +1 -0
- package/bin/arc-login.js +4 -1
- package/bin/arc-open.js +4 -1
- package/bin/arc-pack.js +23 -3
- package/bin/arc-play.js +4 -1
- package/bin/arc-validate.js +1 -0
- package/bin/arc-whoami.js +1 -0
- package/package.json +3 -3
- package/src/account.js +7 -4
- package/src/action/build/tool.js +8 -4
- package/src/action/deploy/tool-git.js +49 -61
- package/src/action/deploy/tool.js +50 -44
- package/src/action/deploy/wait.js +37 -22
- package/src/action/init/manifest.js +23 -6
- package/src/action/init/tool-patch.js +1 -7
- package/src/action/init/tool.js +12 -9
- package/src/action/login/flow.js +7 -3
- package/src/action/pack/limits.js +13 -3
- package/src/action/pack/tool.js +19 -6
- package/src/action/play/tool.js +7 -1
- package/src/action/predeploy/ac.js +39 -22
- package/src/action/predeploy/git.js +69 -58
- package/src/action/predeploy/pm.js +24 -17
- package/src/action/predeploy/published.js +15 -2
- package/src/action/predeploy/tool-git.js +74 -86
- package/src/action/predeploy/tool.js +7 -33
- package/src/action/validate/tool.js +5 -4
- package/src/api.js +14 -1
- package/src/cli/predeploy.js +1 -1
- package/src/config/code.js +112 -0
- package/src/config/url.js +2 -1
- package/src/parser/env.js +19 -3
- package/src/parser/given.js +17 -0
- package/src/parser/manifest.js +8 -1
- package/src/parser/media.js +5 -9
- package/src/parser/project.js +4 -1
- package/src/parser/readme-file.js +8 -1
- package/src/phrase.js +75 -7
- package/src/schema/check/game.js +5 -26
- package/src/schema/game.js +117 -210
- package/src/schema/message.js +46 -7
- package/src/schema/readme.js +8 -3
- package/src/schema/workflow.js +35 -15
- package/src/util/argv.js +33 -1
- package/src/util/delay.js +4 -1
- package/src/util/error.js +49 -0
- package/src/util/image.js +4 -30
- package/src/util/log.js +8 -0
- package/src/util/media.js +40 -0
- package/src/util/output.js +34 -4
- package/src/util/request.js +11 -2
- package/src/util/s3.js +37 -20
- package/src/util/schema.js +93 -30
- package/src/util/video.js +4 -27
package/src/schema/game.js
CHANGED
|
@@ -13,6 +13,7 @@ const z = require("zod");
|
|
|
13
13
|
|
|
14
14
|
const cfgai = require("../config/ai");
|
|
15
15
|
const cfgaudience = require("../config/audience");
|
|
16
|
+
const cfgcode = require("../config/code");
|
|
16
17
|
const cfgdoc = require("../config/doc");
|
|
17
18
|
const cfggenre = require("../config/genre");
|
|
18
19
|
const cfghtml = require("../config/html");
|
|
@@ -37,10 +38,11 @@ const cleanSemver = semver.clean;
|
|
|
37
38
|
const docCheck = check.doc;
|
|
38
39
|
const existsCheck = check.exists;
|
|
39
40
|
const extname = path.extname;
|
|
41
|
+
const ISSUE = cfgcode.ISSUE;
|
|
40
42
|
const imageCheck = check.image;
|
|
41
43
|
const invalidChars = chars.invalid;
|
|
42
44
|
const isInCheck = check.isIn;
|
|
43
|
-
const
|
|
45
|
+
const isInsideCheck = check.isInside;
|
|
44
46
|
const isRelativeCheck = check.isRelative;
|
|
45
47
|
const isSafeUri = uris.isSafeUri;
|
|
46
48
|
const showChar = chars.show;
|
|
@@ -67,6 +69,55 @@ const MAX_SIZE_PNG = size.mb(2);
|
|
|
67
69
|
// the media a description can embed, by extension.
|
|
68
70
|
const MEDIA_TYPES = [...Object.keys(cfgimage), ...Object.keys(cfgvideo)];
|
|
69
71
|
|
|
72
|
+
// [declare]
|
|
73
|
+
|
|
74
|
+
// the store art: each field's aspect ratio and dimensions, which its PNG and
|
|
75
|
+
// its `_video` MP4 share.
|
|
76
|
+
const ART = {
|
|
77
|
+
banner: {
|
|
78
|
+
aspect: "2:1",
|
|
79
|
+
maxHeight: 2048,
|
|
80
|
+
maxWidth: 4096,
|
|
81
|
+
minHeight: 512,
|
|
82
|
+
minWidth: 1024,
|
|
83
|
+
},
|
|
84
|
+
cover: {
|
|
85
|
+
aspect: "3:2",
|
|
86
|
+
maxHeight: 2048,
|
|
87
|
+
maxWidth: 3072,
|
|
88
|
+
minHeight: 512,
|
|
89
|
+
minWidth: 768,
|
|
90
|
+
},
|
|
91
|
+
icon: {
|
|
92
|
+
aspect: "1:1",
|
|
93
|
+
maxHeight: 2048,
|
|
94
|
+
maxWidth: 2048,
|
|
95
|
+
minHeight: 512,
|
|
96
|
+
minWidth: 512,
|
|
97
|
+
},
|
|
98
|
+
poster: {
|
|
99
|
+
aspect: "2:3",
|
|
100
|
+
maxHeight: 3072,
|
|
101
|
+
maxWidth: 2048,
|
|
102
|
+
minHeight: 768,
|
|
103
|
+
minWidth: 512,
|
|
104
|
+
},
|
|
105
|
+
splash: {
|
|
106
|
+
aspect: "16:9",
|
|
107
|
+
maxHeight: 2304,
|
|
108
|
+
maxWidth: 4096,
|
|
109
|
+
minHeight: 576,
|
|
110
|
+
minWidth: 1024,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
// the gallery's dimensions, for its PNGs and MP4s, at any ratio.
|
|
114
|
+
const GALLERY_DIMENSIONS = {
|
|
115
|
+
maxHeight: 2048,
|
|
116
|
+
maxWidth: 2048,
|
|
117
|
+
minHeight: 512,
|
|
118
|
+
minWidth: 512,
|
|
119
|
+
};
|
|
120
|
+
|
|
70
121
|
// [function]
|
|
71
122
|
|
|
72
123
|
// the message for a value below its minimum. An empty value gets its own:
|
|
@@ -87,7 +138,7 @@ const zSet = function (field, schema, { max = Infinity, min }) {
|
|
|
87
138
|
.max(max, message(field, [`Must not exceed: ${max} elements`]))
|
|
88
139
|
.refine(
|
|
89
140
|
(items) => new Set(items).size === items.length,
|
|
90
|
-
message(field, ["Must not contain duplicate elements."]),
|
|
141
|
+
message(field, ["Must not contain duplicate elements."], ISSUE.DUPLICATE),
|
|
91
142
|
);
|
|
92
143
|
};
|
|
93
144
|
|
|
@@ -100,9 +151,11 @@ const zSetBasefile = function (field, schema, { max, min }) {
|
|
|
100
151
|
.max(max, message(field, [`Must not exceed: ${max} files`]))
|
|
101
152
|
.refine(
|
|
102
153
|
(items) => new Set(items.map(basefile)).size === items.length,
|
|
103
|
-
message(
|
|
104
|
-
|
|
105
|
-
|
|
154
|
+
message(
|
|
155
|
+
field,
|
|
156
|
+
["Must not contain duplicate filenames (ignoring extensions)."],
|
|
157
|
+
ISSUE.DUPLICATE,
|
|
158
|
+
),
|
|
106
159
|
);
|
|
107
160
|
};
|
|
108
161
|
|
|
@@ -119,7 +172,11 @@ const zString = function (field, char, { max, min }) {
|
|
|
119
172
|
const list = invalid.map(showChar).join(", ");
|
|
120
173
|
ctx.addIssue({
|
|
121
174
|
code: "custom",
|
|
122
|
-
...message(
|
|
175
|
+
...message(
|
|
176
|
+
field,
|
|
177
|
+
[`Contains invalid characters: ${list}.`],
|
|
178
|
+
ISSUE.CHARACTERS_INVALID,
|
|
179
|
+
),
|
|
123
180
|
});
|
|
124
181
|
}
|
|
125
182
|
});
|
|
@@ -140,7 +197,11 @@ const zHtml = function (field, root, { max, min, ...opts }) {
|
|
|
140
197
|
if (issues.length) {
|
|
141
198
|
ctx.addIssue({
|
|
142
199
|
code: "custom",
|
|
143
|
-
...message(
|
|
200
|
+
...message(
|
|
201
|
+
field,
|
|
202
|
+
["Invalid Markdown.", ...issues],
|
|
203
|
+
ISSUE.MARKDOWN_INVALID,
|
|
204
|
+
),
|
|
144
205
|
});
|
|
145
206
|
}
|
|
146
207
|
});
|
|
@@ -153,21 +214,21 @@ const zHtml = function (field, root, { max, min, ...opts }) {
|
|
|
153
214
|
const zMedia = function (field, root) {
|
|
154
215
|
return z
|
|
155
216
|
.string()
|
|
156
|
-
.min(1, { ...
|
|
217
|
+
.min(1, { ...atLeast(field, 1), abort: true })
|
|
157
218
|
.refine((file) => isRelativeCheck(root, file), {
|
|
158
|
-
...message(field, ["Must be a relative path."]),
|
|
219
|
+
...message(field, ["Must be a relative path."], ISSUE.PATH_INVALID),
|
|
159
220
|
abort: true,
|
|
160
221
|
})
|
|
161
|
-
.refine((file) =>
|
|
162
|
-
...message(field, ["Must be within the project."]),
|
|
222
|
+
.refine((file) => isInsideCheck(root, file), {
|
|
223
|
+
...message(field, ["Must be within the project."], ISSUE.PATH_INVALID),
|
|
163
224
|
abort: true,
|
|
164
225
|
})
|
|
165
226
|
.refine((file) => isInCheck(root, file, MEDIA), {
|
|
166
|
-
...message(field, [`Must be within ${MEDIA}.`]),
|
|
227
|
+
...message(field, [`Must be within ${MEDIA}.`], ISSUE.PATH_INVALID),
|
|
167
228
|
abort: true,
|
|
168
229
|
})
|
|
169
230
|
.refine((file) => existsCheck(root, file), {
|
|
170
|
-
...message(field, ["Must exist."]),
|
|
231
|
+
...message(field, ["Must exist."], ISSUE.PATH_INVALID),
|
|
171
232
|
abort: true,
|
|
172
233
|
});
|
|
173
234
|
};
|
|
@@ -180,7 +241,7 @@ const zPng = function (field, root, opts) {
|
|
|
180
241
|
if (issues.length) {
|
|
181
242
|
ctx.addIssue({
|
|
182
243
|
code: "custom",
|
|
183
|
-
...message(field, ["Invalid PNG.", ...issues]),
|
|
244
|
+
...message(field, ["Invalid PNG.", ...issues], ISSUE.MEDIA_INVALID),
|
|
184
245
|
});
|
|
185
246
|
}
|
|
186
247
|
});
|
|
@@ -199,7 +260,7 @@ const zMp4 = function (field, root, opts) {
|
|
|
199
260
|
if (issues.length) {
|
|
200
261
|
ctx.addIssue({
|
|
201
262
|
code: "custom",
|
|
202
|
-
...message(field, ["Invalid MP4.", ...issues]),
|
|
263
|
+
...message(field, ["Invalid MP4.", ...issues], ISSUE.MEDIA_INVALID),
|
|
203
264
|
});
|
|
204
265
|
}
|
|
205
266
|
});
|
|
@@ -211,17 +272,18 @@ const zPngMp4 = function (field, root, optsPng, optsMp4) {
|
|
|
211
272
|
const pngSchema = zPng(field, root, optsPng);
|
|
212
273
|
const mp4Schema = zMp4(field, root, optsMp4);
|
|
213
274
|
return z.string().superRefine((file, ctx) => {
|
|
275
|
+
const ext = extname(file);
|
|
214
276
|
let schema = null;
|
|
215
|
-
if (
|
|
277
|
+
if (Object.hasOwn(cfgimage, ext)) {
|
|
216
278
|
schema = pngSchema;
|
|
217
279
|
}
|
|
218
|
-
if (
|
|
280
|
+
if (Object.hasOwn(cfgvideo, ext)) {
|
|
219
281
|
schema = mp4Schema;
|
|
220
282
|
}
|
|
221
283
|
if (!schema) {
|
|
222
284
|
ctx.addIssue({
|
|
223
285
|
code: "custom",
|
|
224
|
-
...message(field, ["Must be a PNG or MP4 file."]),
|
|
286
|
+
...message(field, ["Must be a PNG or MP4 file."], ISSUE.MEDIA_INVALID),
|
|
225
287
|
});
|
|
226
288
|
return;
|
|
227
289
|
}
|
|
@@ -234,6 +296,24 @@ const zPngMp4 = function (field, root, optsPng, optsMp4) {
|
|
|
234
296
|
|
|
235
297
|
// [function]
|
|
236
298
|
|
|
299
|
+
// an art field's PNG, such as `banner`.
|
|
300
|
+
const zArt = function (field, root) {
|
|
301
|
+
return z.optional(
|
|
302
|
+
zPng(field, root, { ...ART[field], maxSize: MAX_SIZE_PNG }),
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// [function]
|
|
307
|
+
|
|
308
|
+
// an art field's MP4, such as `banner_video`.
|
|
309
|
+
const zArtVideo = function (field, root) {
|
|
310
|
+
return z.optional(
|
|
311
|
+
zMp4(`${field}_video`, root, { ...ART[field], maxSize: MAX_SIZE_MP4 }),
|
|
312
|
+
);
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
// [function]
|
|
316
|
+
|
|
237
317
|
const zVimeo = function () {
|
|
238
318
|
return z
|
|
239
319
|
.string()
|
|
@@ -266,38 +346,6 @@ const zAudience = function () {
|
|
|
266
346
|
|
|
267
347
|
// [function]
|
|
268
348
|
|
|
269
|
-
const zBanner = function (root) {
|
|
270
|
-
const field = "banner";
|
|
271
|
-
return z.optional(
|
|
272
|
-
zPng(field, root, {
|
|
273
|
-
aspect: "2:1",
|
|
274
|
-
maxHeight: 2048,
|
|
275
|
-
maxSize: MAX_SIZE_PNG,
|
|
276
|
-
maxWidth: 4096,
|
|
277
|
-
minHeight: 512,
|
|
278
|
-
minWidth: 1024,
|
|
279
|
-
}),
|
|
280
|
-
);
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
// [function]
|
|
284
|
-
|
|
285
|
-
const zBannerVideo = function (root) {
|
|
286
|
-
const field = "banner_video";
|
|
287
|
-
return z.optional(
|
|
288
|
-
zMp4(field, root, {
|
|
289
|
-
aspect: "2:1",
|
|
290
|
-
maxHeight: 2048,
|
|
291
|
-
maxSize: MAX_SIZE_MP4,
|
|
292
|
-
maxWidth: 4096,
|
|
293
|
-
minHeight: 512,
|
|
294
|
-
minWidth: 1024,
|
|
295
|
-
}),
|
|
296
|
-
);
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
// [function]
|
|
300
|
-
|
|
301
349
|
const zBio = function () {
|
|
302
350
|
const field = "bio";
|
|
303
351
|
return z.optional(zText(field, { max: 30 * 6, min: 1 }));
|
|
@@ -305,38 +353,6 @@ const zBio = function () {
|
|
|
305
353
|
|
|
306
354
|
// [function]
|
|
307
355
|
|
|
308
|
-
const zCover = function (root) {
|
|
309
|
-
const field = "cover";
|
|
310
|
-
return z.optional(
|
|
311
|
-
zPng(field, root, {
|
|
312
|
-
aspect: "3:2",
|
|
313
|
-
maxHeight: 2048,
|
|
314
|
-
maxSize: MAX_SIZE_PNG,
|
|
315
|
-
maxWidth: 3072,
|
|
316
|
-
minHeight: 512,
|
|
317
|
-
minWidth: 768,
|
|
318
|
-
}),
|
|
319
|
-
);
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
// [function]
|
|
323
|
-
|
|
324
|
-
const zCoverVideo = function (root) {
|
|
325
|
-
const field = "cover_video";
|
|
326
|
-
return z.optional(
|
|
327
|
-
zMp4(field, root, {
|
|
328
|
-
aspect: "3:2",
|
|
329
|
-
maxHeight: 2048,
|
|
330
|
-
maxSize: MAX_SIZE_MP4,
|
|
331
|
-
maxWidth: 3072,
|
|
332
|
-
minHeight: 512,
|
|
333
|
-
minWidth: 768,
|
|
334
|
-
}),
|
|
335
|
-
);
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
// [function]
|
|
339
|
-
|
|
340
356
|
// a description image or video's src: true when it's allowed, a message when
|
|
341
357
|
// the problem is worth naming, and false otherwise. An img shows an image and
|
|
342
358
|
// a video a video.
|
|
@@ -349,7 +365,7 @@ const checkSrc = function (root, src, tag) {
|
|
|
349
365
|
}
|
|
350
366
|
if (
|
|
351
367
|
!isRelativeCheck(root, src) ||
|
|
352
|
-
!
|
|
368
|
+
!isInsideCheck(root, src) ||
|
|
353
369
|
!isInCheck(root, src, GALLERY)
|
|
354
370
|
) {
|
|
355
371
|
return false;
|
|
@@ -384,22 +400,8 @@ const zGallery = function (root) {
|
|
|
384
400
|
zPngMp4(
|
|
385
401
|
field,
|
|
386
402
|
root,
|
|
387
|
-
|
|
388
|
-
{
|
|
389
|
-
maxHeight: 2048,
|
|
390
|
-
maxSize: MAX_SIZE_PNG,
|
|
391
|
-
maxWidth: 2048,
|
|
392
|
-
minHeight: 512,
|
|
393
|
-
minWidth: 512,
|
|
394
|
-
},
|
|
395
|
-
// mp4
|
|
396
|
-
{
|
|
397
|
-
maxHeight: 2048,
|
|
398
|
-
maxSize: MAX_SIZE_MP4,
|
|
399
|
-
maxWidth: 2048,
|
|
400
|
-
minHeight: 512,
|
|
401
|
-
minWidth: 512,
|
|
402
|
-
},
|
|
403
|
+
{ ...GALLERY_DIMENSIONS, maxSize: MAX_SIZE_PNG },
|
|
404
|
+
{ ...GALLERY_DIMENSIONS, maxSize: MAX_SIZE_MP4 },
|
|
403
405
|
),
|
|
404
406
|
{ max: 8 * 3, min: 1 },
|
|
405
407
|
),
|
|
@@ -429,38 +431,6 @@ const zHandle = function () {
|
|
|
429
431
|
|
|
430
432
|
// [function]
|
|
431
433
|
|
|
432
|
-
const zIcon = function (root) {
|
|
433
|
-
const field = "icon";
|
|
434
|
-
return z.optional(
|
|
435
|
-
zPng(field, root, {
|
|
436
|
-
aspect: "1:1",
|
|
437
|
-
maxHeight: 2048,
|
|
438
|
-
maxSize: MAX_SIZE_PNG,
|
|
439
|
-
maxWidth: 2048,
|
|
440
|
-
minHeight: 512,
|
|
441
|
-
minWidth: 512,
|
|
442
|
-
}),
|
|
443
|
-
);
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
// [function]
|
|
447
|
-
|
|
448
|
-
const zIconVideo = function (root) {
|
|
449
|
-
const field = "icon_video";
|
|
450
|
-
return z.optional(
|
|
451
|
-
zMp4(field, root, {
|
|
452
|
-
aspect: "1:1",
|
|
453
|
-
maxHeight: 2048,
|
|
454
|
-
maxSize: MAX_SIZE_MP4,
|
|
455
|
-
maxWidth: 2048,
|
|
456
|
-
minHeight: 512,
|
|
457
|
-
minWidth: 512,
|
|
458
|
-
}),
|
|
459
|
-
);
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
// [function]
|
|
463
|
-
|
|
464
434
|
const zId = function () {
|
|
465
435
|
const field = "id";
|
|
466
436
|
return z
|
|
@@ -473,7 +443,7 @@ const zId = function () {
|
|
|
473
443
|
.uuid(message(field, ["Must be a valid UUID."]))
|
|
474
444
|
.refine(
|
|
475
445
|
(value) => value === value.toLowerCase(),
|
|
476
|
-
message(field, ["Must be lowercase."]),
|
|
446
|
+
message(field, ["Must be lowercase."], ISSUE.UUID_INVALID),
|
|
477
447
|
);
|
|
478
448
|
};
|
|
479
449
|
|
|
@@ -492,38 +462,6 @@ const zOrientation = function () {
|
|
|
492
462
|
|
|
493
463
|
// [function]
|
|
494
464
|
|
|
495
|
-
const zPoster = function (root) {
|
|
496
|
-
const field = "poster";
|
|
497
|
-
return z.optional(
|
|
498
|
-
zPng(field, root, {
|
|
499
|
-
aspect: "2:3",
|
|
500
|
-
maxHeight: 3072,
|
|
501
|
-
maxSize: MAX_SIZE_PNG,
|
|
502
|
-
maxWidth: 2048,
|
|
503
|
-
minHeight: 768,
|
|
504
|
-
minWidth: 512,
|
|
505
|
-
}),
|
|
506
|
-
);
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
// [function]
|
|
510
|
-
|
|
511
|
-
const zPosterVideo = function (root) {
|
|
512
|
-
const field = "poster_video";
|
|
513
|
-
return z.optional(
|
|
514
|
-
zMp4(field, root, {
|
|
515
|
-
aspect: "2:3",
|
|
516
|
-
maxHeight: 3072,
|
|
517
|
-
maxSize: MAX_SIZE_MP4,
|
|
518
|
-
maxWidth: 2048,
|
|
519
|
-
minHeight: 768,
|
|
520
|
-
minWidth: 512,
|
|
521
|
-
}),
|
|
522
|
-
);
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
// [function]
|
|
526
|
-
|
|
527
465
|
const zPrice = function () {
|
|
528
466
|
const field = "price";
|
|
529
467
|
return z.optional(
|
|
@@ -543,38 +481,6 @@ const zShortTitle = function () {
|
|
|
543
481
|
|
|
544
482
|
// [function]
|
|
545
483
|
|
|
546
|
-
const zSplash = function (root) {
|
|
547
|
-
const field = "splash";
|
|
548
|
-
return z.optional(
|
|
549
|
-
zPng(field, root, {
|
|
550
|
-
aspect: "16:9",
|
|
551
|
-
maxHeight: 2304,
|
|
552
|
-
maxSize: MAX_SIZE_PNG,
|
|
553
|
-
maxWidth: 4096,
|
|
554
|
-
minHeight: 576,
|
|
555
|
-
minWidth: 1024,
|
|
556
|
-
}),
|
|
557
|
-
);
|
|
558
|
-
};
|
|
559
|
-
|
|
560
|
-
// [function]
|
|
561
|
-
|
|
562
|
-
const zSplashVideo = function (root) {
|
|
563
|
-
const field = "splash_video";
|
|
564
|
-
return z.optional(
|
|
565
|
-
zMp4(field, root, {
|
|
566
|
-
aspect: "16:9",
|
|
567
|
-
maxHeight: 2304,
|
|
568
|
-
maxSize: MAX_SIZE_MP4,
|
|
569
|
-
maxWidth: 4096,
|
|
570
|
-
minHeight: 576,
|
|
571
|
-
minWidth: 1024,
|
|
572
|
-
}),
|
|
573
|
-
);
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
// [function]
|
|
577
|
-
|
|
578
484
|
const zTagline = function () {
|
|
579
485
|
const field = "tagline";
|
|
580
486
|
return z.optional(zText(field, { max: 30 * 1, min: 1 }));
|
|
@@ -597,7 +503,7 @@ const zTrailer = function () {
|
|
|
597
503
|
.refine(
|
|
598
504
|
(url) =>
|
|
599
505
|
zVimeo().safeParse(url).success || zYouTube().safeParse(url).success,
|
|
600
|
-
message(field, ["Must be a YouTube or Vimeo URL."]),
|
|
506
|
+
message(field, ["Must be a YouTube or Vimeo URL."], ISSUE.URL_INVALID),
|
|
601
507
|
)
|
|
602
508
|
.optional();
|
|
603
509
|
};
|
|
@@ -615,11 +521,12 @@ const zVersion = function () {
|
|
|
615
521
|
)
|
|
616
522
|
.refine(
|
|
617
523
|
(value) => validSemver(value) !== null,
|
|
618
|
-
message(field, ["Must be valid semver."]),
|
|
524
|
+
message(field, ["Must be valid semver."], ISSUE.VERSION_INVALID),
|
|
619
525
|
)
|
|
620
526
|
.refine(
|
|
621
|
-
|
|
622
|
-
|
|
527
|
+
// lowercase too, since the database refuses an uppercase prerelease.
|
|
528
|
+
(value) => cleanSemver(value) === value && value === value.toLowerCase(),
|
|
529
|
+
message(field, ["Must be normalized semver."], ISSUE.VERSION_INVALID),
|
|
623
530
|
);
|
|
624
531
|
};
|
|
625
532
|
|
|
@@ -636,26 +543,26 @@ const main = function (value, { root }) {
|
|
|
636
543
|
return z.object({
|
|
637
544
|
ai: zAi(),
|
|
638
545
|
audience: zAudience(),
|
|
639
|
-
banner:
|
|
640
|
-
banner_video:
|
|
546
|
+
banner: zArt("banner", root),
|
|
547
|
+
banner_video: zArtVideo("banner", root),
|
|
641
548
|
bio: zBio(),
|
|
642
|
-
cover:
|
|
643
|
-
cover_video:
|
|
549
|
+
cover: zArt("cover", root),
|
|
550
|
+
cover_video: zArtVideo("cover", root),
|
|
644
551
|
description: zDescription(root),
|
|
645
552
|
gallery: zGallery(root),
|
|
646
553
|
genres: zGenres(),
|
|
647
554
|
handle: zHandle(),
|
|
648
|
-
icon:
|
|
649
|
-
icon_video:
|
|
555
|
+
icon: zArt("icon", root),
|
|
556
|
+
icon_video: zArtVideo("icon", root),
|
|
650
557
|
id: zId(),
|
|
651
558
|
inputs: zInputs(),
|
|
652
559
|
orientation: zOrientation(),
|
|
653
|
-
poster:
|
|
654
|
-
poster_video:
|
|
560
|
+
poster: zArt("poster", root),
|
|
561
|
+
poster_video: zArtVideo("poster", root),
|
|
655
562
|
price: zPrice(),
|
|
656
563
|
short_title: zShortTitle(),
|
|
657
|
-
splash:
|
|
658
|
-
splash_video:
|
|
564
|
+
splash: zArt("splash", root),
|
|
565
|
+
splash_video: zArtVideo("splash", root),
|
|
659
566
|
tagline: zTagline(),
|
|
660
567
|
title: zTitle(),
|
|
661
568
|
trailer: zTrailer(),
|
package/src/schema/message.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
// [import]
|
|
4
4
|
|
|
5
|
+
const util = require("node:util");
|
|
6
|
+
|
|
7
|
+
// [import]
|
|
8
|
+
|
|
5
9
|
const chalk = require("chalk");
|
|
6
10
|
|
|
7
11
|
// [import]
|
|
@@ -12,35 +16,70 @@ const strs = require("../util/strs");
|
|
|
12
16
|
// [use]
|
|
13
17
|
|
|
14
18
|
const indentLines = strs.indentLines;
|
|
19
|
+
const stripVTControlCharacters = util.stripVTControlCharacters;
|
|
20
|
+
|
|
21
|
+
// [declare]
|
|
22
|
+
|
|
23
|
+
// fields the CLI checks but the docs leave out until they ship, so their
|
|
24
|
+
// issues have no link: `price`, until paid games do (ONE.md).
|
|
25
|
+
const UNDOCUMENTED = new Set(["game.price"]);
|
|
15
26
|
|
|
16
27
|
// [function]
|
|
17
28
|
|
|
18
|
-
// the
|
|
29
|
+
// the URL of a field's rules in the manifest reference, e.g. #game.title,
|
|
30
|
+
// or null for an undocumented field.
|
|
31
|
+
const link = function (table, field) {
|
|
32
|
+
if (UNDOCUMENTED.has(`${table}.${field}`)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return `${cfgurl.MANIFEST}#${table}.${field}`;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// [function]
|
|
39
|
+
|
|
40
|
+
// `link`, as it's printed.
|
|
19
41
|
const reference = function (table, field) {
|
|
20
|
-
|
|
42
|
+
const url = link(table, field);
|
|
43
|
+
return url && chalk.cyan.underline(url);
|
|
21
44
|
};
|
|
22
45
|
|
|
23
46
|
// [function]
|
|
24
47
|
|
|
25
48
|
// an issue's message: the first line, then any detail lines and the field's
|
|
26
|
-
// reference, indented beneath it.
|
|
27
|
-
|
|
28
|
-
|
|
49
|
+
// reference, indented beneath it. `code` is the rule's, from ISSUE in
|
|
50
|
+
// config/code.js, which zod keeps in the issue's params.
|
|
51
|
+
const message = function (table, field, lines, code) {
|
|
52
|
+
const [first, ...rest] = [...lines, reference(table, field)].filter(
|
|
53
|
+
(line) => line !== null,
|
|
54
|
+
);
|
|
29
55
|
return {
|
|
30
56
|
message:
|
|
31
57
|
[first, ...rest].length > 1
|
|
32
58
|
? [first, indentLines(rest.join("\n"))].join("\n")
|
|
33
59
|
: first,
|
|
60
|
+
...(code ? { params: { code } } : {}),
|
|
34
61
|
};
|
|
35
62
|
};
|
|
36
63
|
|
|
37
64
|
// [function]
|
|
38
65
|
|
|
66
|
+
// `message`'s text back into its first line and details, without the
|
|
67
|
+
// reference.
|
|
68
|
+
const parse = function (text) {
|
|
69
|
+
const [first, ...rest] = text.split("\n");
|
|
70
|
+
const details = rest
|
|
71
|
+
.map((line) => stripVTControlCharacters(line).trim())
|
|
72
|
+
.filter((line) => !line.startsWith(cfgurl.MANIFEST));
|
|
73
|
+
return { details, message: stripVTControlCharacters(first) };
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// [function]
|
|
77
|
+
|
|
39
78
|
// `message` for one table, e.g. messages("game")("title", ["Too long."]).
|
|
40
79
|
const messages = function (table) {
|
|
41
|
-
return (field, lines) => message(table, field, lines);
|
|
80
|
+
return (field, lines, code) => message(table, field, lines, code);
|
|
42
81
|
};
|
|
43
82
|
|
|
44
83
|
// [export]
|
|
45
84
|
|
|
46
|
-
module.exports = { message, messages, reference };
|
|
85
|
+
module.exports = { UNDOCUMENTED, link, message, messages, parse, reference };
|
package/src/schema/readme.js
CHANGED
|
@@ -6,6 +6,7 @@ const z = require("zod");
|
|
|
6
6
|
|
|
7
7
|
// [import]
|
|
8
8
|
|
|
9
|
+
const cfgcode = require("../config/code");
|
|
9
10
|
const schemaMessage = require("./message");
|
|
10
11
|
|
|
11
12
|
// [declare]
|
|
@@ -25,9 +26,13 @@ const main = function (value, { file }) {
|
|
|
25
26
|
ctx.addIssue({
|
|
26
27
|
code: "custom",
|
|
27
28
|
path: ["description"],
|
|
28
|
-
...message(
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
...message(
|
|
30
|
+
"description",
|
|
31
|
+
[
|
|
32
|
+
`${file} has content after its title, tagline, and bio, so it needs two --- rules around the description.`,
|
|
33
|
+
],
|
|
34
|
+
cfgcode.ISSUE.DESCRIPTION_RULES_MISSING,
|
|
35
|
+
),
|
|
31
36
|
});
|
|
32
37
|
}
|
|
33
38
|
});
|