arcadible 0.1.24 → 0.1.25
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/bin/arc-init.js +3 -3
- package/package.json +1 -1
- package/src/action/predeploy/git.js +2 -2
- package/src/action/predeploy/pm.js +4 -4
- package/src/action/predeploy/tool-git.js +2 -1
- package/src/config/template.js +45 -0
- package/src/phrase.js +187 -0
- package/src/schema/game.js +30 -18
- package/src/util/bytes.js +8 -4
- package/src/util/http.js +5 -1
- package/src/util/image.js +7 -8
- package/src/util/video.js +8 -10
- package/src/prompt/template.js +0 -46
package/bin/arc-init.js
CHANGED
|
@@ -16,12 +16,12 @@ const yargs = require("yargs/yargs");
|
|
|
16
16
|
|
|
17
17
|
const cfgpackage = require("../src/config/package");
|
|
18
18
|
const cfgproduct = require("../src/config/product");
|
|
19
|
+
const cfgtemplate = require("../src/config/template");
|
|
19
20
|
const init = require("../src/cli/init");
|
|
20
21
|
const log = require("../src/util/log");
|
|
21
22
|
const output = require("../src/util/output");
|
|
22
23
|
const rc = require("../src/util/rc");
|
|
23
24
|
const spinner = require("../src/util/spinner");
|
|
24
|
-
const template = require("../src/prompt/template");
|
|
25
25
|
|
|
26
26
|
// [use]
|
|
27
27
|
|
|
@@ -126,11 +126,11 @@ const prompt = async function ({ yes, ...argv }) {
|
|
|
126
126
|
const opts = { ...argv };
|
|
127
127
|
opts.patch = await patch(opts.cwd, opts.project);
|
|
128
128
|
if (opts.patch || yes) {
|
|
129
|
-
opts.template ??=
|
|
129
|
+
opts.template ??= cfgtemplate.default;
|
|
130
130
|
return opts;
|
|
131
131
|
}
|
|
132
132
|
if (!opts.template) {
|
|
133
|
-
opts.template = await select(
|
|
133
|
+
opts.template = await select(cfgtemplate);
|
|
134
134
|
}
|
|
135
135
|
return opts;
|
|
136
136
|
};
|
package/package.json
CHANGED
|
@@ -107,8 +107,8 @@ const createTag = function (root, version, cb) {
|
|
|
107
107
|
`${PREFIX}${version}`,
|
|
108
108
|
"-m",
|
|
109
109
|
prereleaseSemver(version) === null
|
|
110
|
-
?
|
|
111
|
-
:
|
|
110
|
+
? phrase.versionRelease(version)
|
|
111
|
+
: phrase.versionPrerelease(version),
|
|
112
112
|
],
|
|
113
113
|
(err) => {
|
|
114
114
|
if (err) {
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
const fs = require("node:fs");
|
|
6
6
|
const path = require("node:path");
|
|
7
7
|
|
|
8
|
+
// [import]
|
|
9
|
+
|
|
10
|
+
const phrase = require("../../phrase");
|
|
11
|
+
|
|
8
12
|
// [use]
|
|
9
13
|
|
|
10
14
|
const existsSync = fs.existsSync; // eslint-disable-line no-sync
|
|
11
15
|
const join = path.join;
|
|
12
16
|
|
|
13
|
-
// [import]
|
|
14
|
-
|
|
15
|
-
const phrase = require("../../phrase");
|
|
16
|
-
|
|
17
17
|
// [function]
|
|
18
18
|
|
|
19
19
|
const ensureLockFile = function (root, cb) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// [import]
|
|
4
4
|
|
|
5
5
|
const git = require("./git");
|
|
6
|
+
const phrase = require("../../phrase");
|
|
6
7
|
const pm = require("./pm");
|
|
7
8
|
const project = require("../../parser/project");
|
|
8
9
|
|
|
@@ -42,7 +43,7 @@ const deployEnsureGit = function ({ root }, { onLogInfo }, cb) {
|
|
|
42
43
|
if (diff.cached && onLogInfo) {
|
|
43
44
|
onLogInfo({
|
|
44
45
|
level: "warn",
|
|
45
|
-
message:
|
|
46
|
+
message: phrase.gitStagedUnincluded(),
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
ensureRemote(root, cb);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const cfgproduct = require("./product");
|
|
6
|
+
const phrase = require("../phrase");
|
|
7
|
+
|
|
8
|
+
// [declare]
|
|
9
|
+
|
|
10
|
+
const HANDLE = cfgproduct.handle;
|
|
11
|
+
const STARTER = `${HANDLE}/starter`;
|
|
12
|
+
|
|
13
|
+
// [export]
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
choices: [
|
|
17
|
+
{
|
|
18
|
+
description: phrase.starterBlank(),
|
|
19
|
+
name: "Blank",
|
|
20
|
+
value: STARTER,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
description: phrase.starterThreeJs(),
|
|
24
|
+
name: "Three.js",
|
|
25
|
+
value: `${STARTER}-threejs`,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
description: phrase.starterPhaser(),
|
|
29
|
+
name: "Phaser",
|
|
30
|
+
value: `${STARTER}-phaser`,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
description: phrase.starterPixiJs(),
|
|
34
|
+
name: "PixiJS",
|
|
35
|
+
value: `${STARTER}-pixijs`,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
description: phrase.starterBabylonJs(),
|
|
39
|
+
name: "Babylon.js",
|
|
40
|
+
value: `${STARTER}-babylonjs`,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
default: STARTER,
|
|
44
|
+
message: "Template",
|
|
45
|
+
};
|
package/src/phrase.js
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
// [import]
|
|
4
4
|
|
|
5
|
+
const bytes = require("./util/bytes");
|
|
5
6
|
const cfgproduct = require("./config/product");
|
|
6
7
|
|
|
8
|
+
// [use]
|
|
9
|
+
|
|
10
|
+
const formatBytes = bytes.formatBytes;
|
|
11
|
+
|
|
7
12
|
// [declare]
|
|
8
13
|
|
|
9
14
|
const TOOL = cfgproduct.tool;
|
|
@@ -73,6 +78,12 @@ const gitRepoMissing = function () {
|
|
|
73
78
|
|
|
74
79
|
// [function]
|
|
75
80
|
|
|
81
|
+
const gitStagedUnincluded = function () {
|
|
82
|
+
return ["Staged but uncommitted changes will not be included."].join("\n");
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// [function]
|
|
86
|
+
|
|
76
87
|
const gitTagCreateFailed = function () {
|
|
77
88
|
return [
|
|
78
89
|
"Unable to create Git tag.",
|
|
@@ -100,6 +111,42 @@ const gitVersionExists = function () {
|
|
|
100
111
|
|
|
101
112
|
// [function]
|
|
102
113
|
|
|
114
|
+
const httpError = function (name, status) {
|
|
115
|
+
return `HttpError: ${name} (${status})`;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// [function]
|
|
119
|
+
|
|
120
|
+
const imageAspect = function (aspect) {
|
|
121
|
+
return `Image aspect ratio must be: ${aspect}`;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// [function]
|
|
125
|
+
|
|
126
|
+
const imageHeightMin = function (height) {
|
|
127
|
+
return `Image height must be at least: ${height}px`;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// [function]
|
|
131
|
+
|
|
132
|
+
const imageSizeMax = function (size) {
|
|
133
|
+
return `Image size must not exceed: ${formatBytes(size)}`;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// [function]
|
|
137
|
+
|
|
138
|
+
const imageUnsupported = function () {
|
|
139
|
+
return "Image has an unsupported file type.";
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// [function]
|
|
143
|
+
|
|
144
|
+
const imageWidthMin = function (width) {
|
|
145
|
+
return `Image width must be at least: ${width}px`;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// [function]
|
|
149
|
+
|
|
103
150
|
const issuesFound = function (count) {
|
|
104
151
|
return `${count} ${count === 1 ? "issue" : "issues"} found. Run ${cmdValidate()} for details.`;
|
|
105
152
|
};
|
|
@@ -172,6 +219,60 @@ const packageTooLarge = function (size, assets) {
|
|
|
172
219
|
|
|
173
220
|
// [function]
|
|
174
221
|
|
|
222
|
+
const sizeB = function (size) {
|
|
223
|
+
return `${size} B`;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// [function]
|
|
227
|
+
|
|
228
|
+
const sizeGb = function (size) {
|
|
229
|
+
return `${size} GB`;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// [function]
|
|
233
|
+
|
|
234
|
+
const sizeKb = function (size) {
|
|
235
|
+
return `${size} KB`;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// [function]
|
|
239
|
+
|
|
240
|
+
const sizeMb = function (size) {
|
|
241
|
+
return `${size} MB`;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// [function]
|
|
245
|
+
|
|
246
|
+
const starterBabylonJs = function () {
|
|
247
|
+
return "Babylon.js starter.";
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// [function]
|
|
251
|
+
|
|
252
|
+
const starterBlank = function () {
|
|
253
|
+
return "Blank JavaScript starter.";
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// [function]
|
|
257
|
+
|
|
258
|
+
const starterPhaser = function () {
|
|
259
|
+
return "Phaser starter.";
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// [function]
|
|
263
|
+
|
|
264
|
+
const starterPixiJs = function () {
|
|
265
|
+
return "PixiJS starter.";
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
// [function]
|
|
269
|
+
|
|
270
|
+
const starterThreeJs = function () {
|
|
271
|
+
return "Three.js starter.";
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
// [function]
|
|
275
|
+
|
|
175
276
|
const timedOut = function () {
|
|
176
277
|
return "Timed out.";
|
|
177
278
|
};
|
|
@@ -194,6 +295,66 @@ const uploadFailed = function (status) {
|
|
|
194
295
|
return `Upload failed with status ${status}.`;
|
|
195
296
|
};
|
|
196
297
|
|
|
298
|
+
// [function]
|
|
299
|
+
|
|
300
|
+
const versionPrerelease = function (version) {
|
|
301
|
+
return `Prerelease v${version}`;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// [function]
|
|
305
|
+
|
|
306
|
+
const versionRelease = function (version) {
|
|
307
|
+
return `Release v${version}`;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
// [function]
|
|
311
|
+
|
|
312
|
+
const videoAspect = function (aspect) {
|
|
313
|
+
return `Video aspect ratio must be: ${aspect}`;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// [function]
|
|
317
|
+
|
|
318
|
+
const videoDurationMax = function (maxDuration) {
|
|
319
|
+
return `Video duration must not exceed: ${maxDuration}s`;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// [function]
|
|
323
|
+
|
|
324
|
+
const videoDurationMin = function (duration) {
|
|
325
|
+
return `Video duration must be at least: ${duration}s`;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// [function]
|
|
329
|
+
|
|
330
|
+
const videoHeightMin = function (height) {
|
|
331
|
+
return `Video height must be at least: ${height}px`;
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// [function]
|
|
335
|
+
|
|
336
|
+
const videoInvalid = function () {
|
|
337
|
+
return "Video is an invalid file.";
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// [function]
|
|
341
|
+
|
|
342
|
+
const videoSizeMax = function (size) {
|
|
343
|
+
return `Video size must not exceed: ${formatBytes(size)}`;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
// [function]
|
|
347
|
+
|
|
348
|
+
const videoUnsupported = function () {
|
|
349
|
+
return "Video has an unsupported file type.";
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// [function]
|
|
353
|
+
|
|
354
|
+
const videoWidthMin = function (width) {
|
|
355
|
+
return `Video width must be at least: ${width}px`;
|
|
356
|
+
};
|
|
357
|
+
|
|
197
358
|
// [export]
|
|
198
359
|
|
|
199
360
|
module.exports = {
|
|
@@ -206,9 +367,16 @@ module.exports = {
|
|
|
206
367
|
gitChangesPresent,
|
|
207
368
|
gitRemoteMissing,
|
|
208
369
|
gitRepoMissing,
|
|
370
|
+
gitStagedUnincluded,
|
|
209
371
|
gitTagCreateFailed,
|
|
210
372
|
gitTagPushFailed,
|
|
211
373
|
gitVersionExists,
|
|
374
|
+
httpError,
|
|
375
|
+
imageAspect,
|
|
376
|
+
imageHeightMin,
|
|
377
|
+
imageSizeMax,
|
|
378
|
+
imageUnsupported,
|
|
379
|
+
imageWidthMin,
|
|
212
380
|
issuesFound,
|
|
213
381
|
loginExpired,
|
|
214
382
|
loginFailed,
|
|
@@ -221,8 +389,27 @@ module.exports = {
|
|
|
221
389
|
overwriteWithForce,
|
|
222
390
|
packageFileMissing,
|
|
223
391
|
packageTooLarge,
|
|
392
|
+
sizeB,
|
|
393
|
+
sizeGb,
|
|
394
|
+
sizeKb,
|
|
395
|
+
sizeMb,
|
|
396
|
+
starterBabylonJs,
|
|
397
|
+
starterBlank,
|
|
398
|
+
starterPhaser,
|
|
399
|
+
starterPixiJs,
|
|
400
|
+
starterThreeJs,
|
|
224
401
|
timedOut,
|
|
225
402
|
unableToFind,
|
|
226
403
|
unableToParse,
|
|
227
404
|
uploadFailed,
|
|
405
|
+
versionPrerelease,
|
|
406
|
+
versionRelease,
|
|
407
|
+
videoAspect,
|
|
408
|
+
videoDurationMax,
|
|
409
|
+
videoDurationMin,
|
|
410
|
+
videoHeightMin,
|
|
411
|
+
videoInvalid,
|
|
412
|
+
videoSizeMax,
|
|
413
|
+
videoUnsupported,
|
|
414
|
+
videoWidthMin,
|
|
228
415
|
};
|
package/src/schema/game.js
CHANGED
|
@@ -64,8 +64,8 @@ const message = function (field, lines) {
|
|
|
64
64
|
const zText = function (field, { max, min }) {
|
|
65
65
|
return z
|
|
66
66
|
.string()
|
|
67
|
-
.min(min)
|
|
68
|
-
.max(max)
|
|
67
|
+
.min(min, message(field, [`Must be at least: ${min} character`]))
|
|
68
|
+
.max(max, message(field, [`Must not exceed: ${max} characters`]))
|
|
69
69
|
.regex(
|
|
70
70
|
/^[\p{L}0-9 .,!?'"():;-]+$/u,
|
|
71
71
|
message(field, ["Contains invalid characters."]),
|
|
@@ -77,7 +77,7 @@ const zText = function (field, { max, min }) {
|
|
|
77
77
|
const zMedia = function (field, root) {
|
|
78
78
|
return z
|
|
79
79
|
.string()
|
|
80
|
-
.min(1)
|
|
80
|
+
.min(1, message(field, ["Must be defined."]))
|
|
81
81
|
.refine(
|
|
82
82
|
(file) => isRelativeCheck(root, file),
|
|
83
83
|
message(field, ["Must be a relative path."]),
|
|
@@ -199,7 +199,7 @@ const zBannerVideo = function (root) {
|
|
|
199
199
|
|
|
200
200
|
const zBio = function () {
|
|
201
201
|
const field = "bio";
|
|
202
|
-
return z.optional(zText(field, { max:
|
|
202
|
+
return z.optional(zText(field, { max: 30 * 5, min: 1 }));
|
|
203
203
|
};
|
|
204
204
|
|
|
205
205
|
// [function]
|
|
@@ -237,8 +237,8 @@ const zDescription = function () {
|
|
|
237
237
|
return z.optional(
|
|
238
238
|
z
|
|
239
239
|
.string()
|
|
240
|
-
.min(1)
|
|
241
|
-
.max(
|
|
240
|
+
.min(1, message(field, ["Must be at least: 1 character"]))
|
|
241
|
+
.max(3000, message(field, ["Must not exceed: 3000 characters"]))
|
|
242
242
|
.refine(
|
|
243
243
|
(str) =>
|
|
244
244
|
str ===
|
|
@@ -297,16 +297,19 @@ const zGallery = function (root) {
|
|
|
297
297
|
}
|
|
298
298
|
}),
|
|
299
299
|
)
|
|
300
|
-
.
|
|
301
|
-
.max(12),
|
|
300
|
+
.max(12, message(field, ["Must not exceed: 12 elements"])),
|
|
302
301
|
);
|
|
303
302
|
};
|
|
304
303
|
|
|
305
304
|
// [function]
|
|
306
305
|
|
|
307
306
|
const zGenres = function () {
|
|
308
|
-
|
|
309
|
-
return z.optional(
|
|
307
|
+
const field = "genres";
|
|
308
|
+
return z.optional(
|
|
309
|
+
z
|
|
310
|
+
.array(z.enum(cfggenre))
|
|
311
|
+
.max(3, message(field, ["Must not exceed: 3 elements"])),
|
|
312
|
+
);
|
|
310
313
|
};
|
|
311
314
|
|
|
312
315
|
// [function]
|
|
@@ -372,8 +375,12 @@ const zId = function () {
|
|
|
372
375
|
// [function]
|
|
373
376
|
|
|
374
377
|
const zInputs = function () {
|
|
375
|
-
|
|
376
|
-
return z.optional(
|
|
378
|
+
const field = "inputs";
|
|
379
|
+
return z.optional(
|
|
380
|
+
z
|
|
381
|
+
.array(z.enum(cfginput))
|
|
382
|
+
.max(3, message(field, ["Must not exceed: 3 elements"])),
|
|
383
|
+
);
|
|
377
384
|
};
|
|
378
385
|
|
|
379
386
|
// [function]
|
|
@@ -414,29 +421,34 @@ const zPosterVideo = function (root) {
|
|
|
414
421
|
// [function]
|
|
415
422
|
|
|
416
423
|
const zPrice = function () {
|
|
417
|
-
|
|
418
|
-
return z.optional(
|
|
424
|
+
const field = "price";
|
|
425
|
+
return z.optional(
|
|
426
|
+
z
|
|
427
|
+
.int()
|
|
428
|
+
.min(0, message(field, ["Must not be below: 0"]))
|
|
429
|
+
.max(25, message(field, ["Must not be above: 25"])),
|
|
430
|
+
);
|
|
419
431
|
};
|
|
420
432
|
|
|
421
433
|
// [function]
|
|
422
434
|
|
|
423
435
|
const zShortTitle = function () {
|
|
424
436
|
const field = "short_title";
|
|
425
|
-
return z.optional(zText(field, { max:
|
|
437
|
+
return z.optional(zText(field, { max: 30 / 2, min: 1 }));
|
|
426
438
|
};
|
|
427
439
|
|
|
428
440
|
// [function]
|
|
429
441
|
|
|
430
442
|
const zTagline = function () {
|
|
431
443
|
const field = "tagline";
|
|
432
|
-
return z.optional(zText(field, { max:
|
|
444
|
+
return z.optional(zText(field, { max: 30 * 1, min: 1 }));
|
|
433
445
|
};
|
|
434
446
|
|
|
435
447
|
// [function]
|
|
436
448
|
|
|
437
449
|
const zTitle = function () {
|
|
438
450
|
const field = "title";
|
|
439
|
-
return z.optional(zText(field, { max:
|
|
451
|
+
return z.optional(zText(field, { max: 30 * 1, min: 1 }));
|
|
440
452
|
};
|
|
441
453
|
|
|
442
454
|
// [function]
|
|
@@ -445,7 +457,7 @@ const zTrailer = function () {
|
|
|
445
457
|
const field = "trailer";
|
|
446
458
|
return z
|
|
447
459
|
.string()
|
|
448
|
-
.max(255)
|
|
460
|
+
.max(255, message(field, ["Must not exceed: 255 characters"]))
|
|
449
461
|
.refine(
|
|
450
462
|
(url) =>
|
|
451
463
|
zVimeo().safeParse(url).success || zYouTube().safeParse(url).success,
|
package/src/util/bytes.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const phrase = require("../phrase");
|
|
6
|
+
|
|
3
7
|
// [function]
|
|
4
8
|
|
|
5
9
|
const formatBytes = function (bytes) {
|
|
6
10
|
switch (true) {
|
|
7
11
|
case bytes < 1024:
|
|
8
|
-
return
|
|
12
|
+
return phrase.sizeB(bytes);
|
|
9
13
|
case bytes < 1024 ** 2:
|
|
10
|
-
return
|
|
14
|
+
return phrase.sizeKb((bytes / 1024).toFixed(1));
|
|
11
15
|
case bytes < 1024 ** 3:
|
|
12
|
-
return
|
|
16
|
+
return phrase.sizeMb((bytes / 1024 / 1024).toFixed(1));
|
|
13
17
|
default:
|
|
14
|
-
return
|
|
18
|
+
return phrase.sizeGb((bytes / 1024 / 1024 / 1024).toFixed(1));
|
|
15
19
|
}
|
|
16
20
|
};
|
|
17
21
|
|
package/src/util/http.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const phrase = require("../phrase");
|
|
6
|
+
|
|
3
7
|
// [class]
|
|
4
8
|
|
|
5
9
|
const HttpError = class extends Error {
|
|
@@ -10,7 +14,7 @@ const HttpError = class extends Error {
|
|
|
10
14
|
super(message);
|
|
11
15
|
this.status = status;
|
|
12
16
|
this.name = title;
|
|
13
|
-
this.message =
|
|
17
|
+
this.message = phrase.httpError(this.name, this.status);
|
|
14
18
|
}
|
|
15
19
|
};
|
|
16
20
|
|
package/src/util/image.js
CHANGED
|
@@ -11,13 +11,12 @@ const imageSize = require("image-size").imageSize;
|
|
|
11
11
|
|
|
12
12
|
// [import]
|
|
13
13
|
|
|
14
|
-
const bytes = require("./bytes");
|
|
15
14
|
const cfgimage = require("../config/image");
|
|
15
|
+
const phrase = require("../phrase");
|
|
16
16
|
|
|
17
17
|
// [use]
|
|
18
18
|
|
|
19
19
|
const extname = path.extname;
|
|
20
|
-
const formatBytes = bytes.formatBytes;
|
|
21
20
|
const readFileSync = fs.readFileSync; // eslint-disable-line no-sync
|
|
22
21
|
const statSync = fs.statSync; // eslint-disable-line no-sync
|
|
23
22
|
|
|
@@ -52,18 +51,18 @@ const checkSize = function (file, maxSize) {
|
|
|
52
51
|
|
|
53
52
|
const checkPng = function (file, { aspect, maxSize, minHeight, minWidth }) {
|
|
54
53
|
if (!checkSize(file, maxSize)) {
|
|
55
|
-
return [
|
|
54
|
+
return [phrase.imageSizeMax(maxSize)];
|
|
56
55
|
}
|
|
57
56
|
const buffer = readFileSync(file);
|
|
58
57
|
const { height, width } = imageSize(buffer);
|
|
59
58
|
if (minWidth && width < minWidth) {
|
|
60
|
-
return [
|
|
59
|
+
return [phrase.imageWidthMin(minWidth)];
|
|
61
60
|
}
|
|
62
61
|
if (minHeight && height < minHeight) {
|
|
63
|
-
return [
|
|
62
|
+
return [phrase.imageHeightMin(minHeight)];
|
|
64
63
|
}
|
|
65
64
|
if (!checkAspect(width, height, aspect)) {
|
|
66
|
-
return [
|
|
65
|
+
return [phrase.imageAspect(aspect)];
|
|
67
66
|
}
|
|
68
67
|
return [];
|
|
69
68
|
};
|
|
@@ -72,7 +71,7 @@ const checkPng = function (file, { aspect, maxSize, minHeight, minWidth }) {
|
|
|
72
71
|
|
|
73
72
|
const checkSvg = function (file, { maxSize }) {
|
|
74
73
|
if (!checkSize(file, maxSize)) {
|
|
75
|
-
return [
|
|
74
|
+
return [phrase.imageSizeMax(maxSize)];
|
|
76
75
|
}
|
|
77
76
|
return [];
|
|
78
77
|
};
|
|
@@ -87,7 +86,7 @@ const check = function (file, { type, ...opts }) {
|
|
|
87
86
|
const checkImage = checks[type];
|
|
88
87
|
return checkImage && cfgimage[extname(file)] === type
|
|
89
88
|
? checkImage(file, opts)
|
|
90
|
-
: [
|
|
89
|
+
: [phrase.imageUnsupported()];
|
|
91
90
|
};
|
|
92
91
|
|
|
93
92
|
// [export]
|
package/src/util/video.js
CHANGED
|
@@ -11,14 +11,12 @@ const fs = require("fs-extra");
|
|
|
11
11
|
|
|
12
12
|
// [import]
|
|
13
13
|
|
|
14
|
-
const bytes = require("./bytes");
|
|
15
14
|
const cfgvideo = require("../config/video");
|
|
16
15
|
const phrase = require("../phrase");
|
|
17
16
|
|
|
18
17
|
// [use]
|
|
19
18
|
|
|
20
19
|
const extname = path.extname;
|
|
21
|
-
const formatBytes = bytes.formatBytes;
|
|
22
20
|
const readFileSync = fs.readFileSync; // eslint-disable-line no-sync
|
|
23
21
|
const statSync = fs.statSync; // eslint-disable-line no-sync
|
|
24
22
|
|
|
@@ -94,29 +92,29 @@ const checkMp4 = function (
|
|
|
94
92
|
{ aspect, maxDuration, maxSize, minDuration, minHeight, minWidth },
|
|
95
93
|
) {
|
|
96
94
|
if (!checkSize(file, maxSize)) {
|
|
97
|
-
return [
|
|
95
|
+
return [phrase.videoSizeMax(maxSize)];
|
|
98
96
|
}
|
|
99
97
|
let video = null;
|
|
100
98
|
try {
|
|
101
99
|
video = readMp4(file);
|
|
102
100
|
} catch {
|
|
103
|
-
return [
|
|
101
|
+
return [phrase.videoInvalid()];
|
|
104
102
|
}
|
|
105
103
|
const { duration, height, width } = video;
|
|
106
104
|
if (minWidth && width < minWidth) {
|
|
107
|
-
return [
|
|
105
|
+
return [phrase.videoWidthMin(minWidth)];
|
|
108
106
|
}
|
|
109
107
|
if (minHeight && height < minHeight) {
|
|
110
|
-
return [
|
|
108
|
+
return [phrase.videoHeightMin(minHeight)];
|
|
111
109
|
}
|
|
112
110
|
if (minDuration && duration < minDuration) {
|
|
113
|
-
return [
|
|
111
|
+
return [phrase.videoDurationMin(minDuration)];
|
|
114
112
|
}
|
|
115
113
|
if (maxDuration && duration > maxDuration) {
|
|
116
|
-
return [
|
|
114
|
+
return [phrase.videoDurationMax(maxDuration)];
|
|
117
115
|
}
|
|
118
116
|
if (!checkAspect(width, height, aspect)) {
|
|
119
|
-
return [
|
|
117
|
+
return [phrase.videoAspect(aspect)];
|
|
120
118
|
}
|
|
121
119
|
return [];
|
|
122
120
|
};
|
|
@@ -130,7 +128,7 @@ const check = function (file, { type, ...opts }) {
|
|
|
130
128
|
const checkVideo = checks[type];
|
|
131
129
|
return checkVideo && cfgvideo[extname(file)] === type
|
|
132
130
|
? checkVideo(file, opts)
|
|
133
|
-
: [
|
|
131
|
+
: [phrase.videoUnsupported()];
|
|
134
132
|
};
|
|
135
133
|
|
|
136
134
|
// [export]
|
package/src/prompt/template.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const cfgproduct = require("../config/product");
|
|
6
|
-
|
|
7
|
-
// [declare]
|
|
8
|
-
|
|
9
|
-
const HANDLE = cfgproduct.handle;
|
|
10
|
-
const STARTER = `${HANDLE}/starter`;
|
|
11
|
-
|
|
12
|
-
// [export]
|
|
13
|
-
|
|
14
|
-
module.exports = {
|
|
15
|
-
select: {
|
|
16
|
-
choices: [
|
|
17
|
-
{
|
|
18
|
-
description: "Blank JavaScript starter.",
|
|
19
|
-
name: "Blank",
|
|
20
|
-
value: STARTER,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
description: "Three.js starter.",
|
|
24
|
-
name: "Three.js",
|
|
25
|
-
value: `${STARTER}-threejs`,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
description: "Phaser starter.",
|
|
29
|
-
name: "Phaser",
|
|
30
|
-
value: `${STARTER}-phaser`,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
description: "PixiJS starter.",
|
|
34
|
-
name: "PixiJS",
|
|
35
|
-
value: `${STARTER}-pixijs`,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
description: "Babylon.js starter.",
|
|
39
|
-
name: "Babylon.js",
|
|
40
|
-
value: `${STARTER}-babylonjs`,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
default: STARTER,
|
|
44
|
-
message: "Template",
|
|
45
|
-
},
|
|
46
|
-
};
|