arcadible 0.1.24 → 0.1.26

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 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 ??= template.select.default;
129
+ opts.template ??= cfgtemplate.default;
130
130
  return opts;
131
131
  }
132
132
  if (!opts.template) {
133
- opts.template = await select(template.select);
133
+ opts.template = await select(cfgtemplate);
134
134
  }
135
135
  return opts;
136
136
  };
package/package.json CHANGED
@@ -61,5 +61,5 @@
61
61
  "license": "Apache-2.0",
62
62
  "main": "./src/cli/index.js",
63
63
  "name": "arcadible",
64
- "version": "0.1.24"
64
+ "version": "0.1.26"
65
65
  }
@@ -107,8 +107,8 @@ const createTag = function (root, version, cb) {
107
107
  `${PREFIX}${version}`,
108
108
  "-m",
109
109
  prereleaseSemver(version) === null
110
- ? `Release v${version}`
111
- : `Prerelease v${version}`,
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: "Staged but uncommitted changes will not be included.",
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
@@ -73,6 +73,12 @@ const gitRepoMissing = function () {
73
73
 
74
74
  // [function]
75
75
 
76
+ const gitStagedUnincluded = function () {
77
+ return ["Staged but uncommitted changes will not be included."].join("\n");
78
+ };
79
+
80
+ // [function]
81
+
76
82
  const gitTagCreateFailed = function () {
77
83
  return [
78
84
  "Unable to create Git tag.",
@@ -100,6 +106,42 @@ const gitVersionExists = function () {
100
106
 
101
107
  // [function]
102
108
 
109
+ const httpError = function (name, status) {
110
+ return `HttpError: ${name} (${status})`;
111
+ };
112
+
113
+ // [function]
114
+
115
+ const imageAspect = function (aspect) {
116
+ return `Image aspect ratio must be: ${aspect}`;
117
+ };
118
+
119
+ // [function]
120
+
121
+ const imageHeightMin = function (height) {
122
+ return `Image height must be at least: ${height}px`;
123
+ };
124
+
125
+ // [function]
126
+
127
+ const imageSizeMax = function (size) {
128
+ return `Image size must not exceed: ${size}`;
129
+ };
130
+
131
+ // [function]
132
+
133
+ const imageUnsupported = function () {
134
+ return "Image has an unsupported file type.";
135
+ };
136
+
137
+ // [function]
138
+
139
+ const imageWidthMin = function (width) {
140
+ return `Image width must be at least: ${width}px`;
141
+ };
142
+
143
+ // [function]
144
+
103
145
  const issuesFound = function (count) {
104
146
  return `${count} ${count === 1 ? "issue" : "issues"} found. Run ${cmdValidate()} for details.`;
105
147
  };
@@ -172,6 +214,60 @@ const packageTooLarge = function (size, assets) {
172
214
 
173
215
  // [function]
174
216
 
217
+ const sizeB = function (size) {
218
+ return `${size} B`;
219
+ };
220
+
221
+ // [function]
222
+
223
+ const sizeGb = function (size) {
224
+ return `${size} GB`;
225
+ };
226
+
227
+ // [function]
228
+
229
+ const sizeKb = function (size) {
230
+ return `${size} KB`;
231
+ };
232
+
233
+ // [function]
234
+
235
+ const sizeMb = function (size) {
236
+ return `${size} MB`;
237
+ };
238
+
239
+ // [function]
240
+
241
+ const starterBabylonJs = function () {
242
+ return "Babylon.js starter.";
243
+ };
244
+
245
+ // [function]
246
+
247
+ const starterBlank = function () {
248
+ return "Blank JavaScript starter.";
249
+ };
250
+
251
+ // [function]
252
+
253
+ const starterPhaser = function () {
254
+ return "Phaser starter.";
255
+ };
256
+
257
+ // [function]
258
+
259
+ const starterPixiJs = function () {
260
+ return "PixiJS starter.";
261
+ };
262
+
263
+ // [function]
264
+
265
+ const starterThreeJs = function () {
266
+ return "Three.js starter.";
267
+ };
268
+
269
+ // [function]
270
+
175
271
  const timedOut = function () {
176
272
  return "Timed out.";
177
273
  };
@@ -194,6 +290,66 @@ const uploadFailed = function (status) {
194
290
  return `Upload failed with status ${status}.`;
195
291
  };
196
292
 
293
+ // [function]
294
+
295
+ const versionPrerelease = function (version) {
296
+ return `Prerelease v${version}`;
297
+ };
298
+
299
+ // [function]
300
+
301
+ const versionRelease = function (version) {
302
+ return `Release v${version}`;
303
+ };
304
+
305
+ // [function]
306
+
307
+ const videoAspect = function (aspect) {
308
+ return `Video aspect ratio must be: ${aspect}`;
309
+ };
310
+
311
+ // [function]
312
+
313
+ const videoDurationMax = function (maxDuration) {
314
+ return `Video duration must not exceed: ${maxDuration}s`;
315
+ };
316
+
317
+ // [function]
318
+
319
+ const videoDurationMin = function (duration) {
320
+ return `Video duration must be at least: ${duration}s`;
321
+ };
322
+
323
+ // [function]
324
+
325
+ const videoHeightMin = function (height) {
326
+ return `Video height must be at least: ${height}px`;
327
+ };
328
+
329
+ // [function]
330
+
331
+ const videoInvalid = function () {
332
+ return "Video is an invalid file.";
333
+ };
334
+
335
+ // [function]
336
+
337
+ const videoSizeMax = function (size) {
338
+ return `Video size must not exceed: ${size}`;
339
+ };
340
+
341
+ // [function]
342
+
343
+ const videoUnsupported = function () {
344
+ return "Video has an unsupported file type.";
345
+ };
346
+
347
+ // [function]
348
+
349
+ const videoWidthMin = function (width) {
350
+ return `Video width must be at least: ${width}px`;
351
+ };
352
+
197
353
  // [export]
198
354
 
199
355
  module.exports = {
@@ -206,9 +362,16 @@ module.exports = {
206
362
  gitChangesPresent,
207
363
  gitRemoteMissing,
208
364
  gitRepoMissing,
365
+ gitStagedUnincluded,
209
366
  gitTagCreateFailed,
210
367
  gitTagPushFailed,
211
368
  gitVersionExists,
369
+ httpError,
370
+ imageAspect,
371
+ imageHeightMin,
372
+ imageSizeMax,
373
+ imageUnsupported,
374
+ imageWidthMin,
212
375
  issuesFound,
213
376
  loginExpired,
214
377
  loginFailed,
@@ -221,8 +384,27 @@ module.exports = {
221
384
  overwriteWithForce,
222
385
  packageFileMissing,
223
386
  packageTooLarge,
387
+ sizeB,
388
+ sizeGb,
389
+ sizeKb,
390
+ sizeMb,
391
+ starterBabylonJs,
392
+ starterBlank,
393
+ starterPhaser,
394
+ starterPixiJs,
395
+ starterThreeJs,
224
396
  timedOut,
225
397
  unableToFind,
226
398
  unableToParse,
227
399
  uploadFailed,
400
+ versionPrerelease,
401
+ versionRelease,
402
+ videoAspect,
403
+ videoDurationMax,
404
+ videoDurationMin,
405
+ videoHeightMin,
406
+ videoInvalid,
407
+ videoSizeMax,
408
+ videoUnsupported,
409
+ videoWidthMin,
228
410
  };
@@ -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: 192, min: 1 }));
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(4000)
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
- .min(1)
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
- // const field = "genres";
309
- return z.optional(z.array(z.enum(cfggenre)).max(3));
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
- // const field = "inputs";
376
- return z.optional(z.array(z.enum(cfginput)).max(3));
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
- // const field = "price";
418
- return z.optional(z.int().min(0).max(25));
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: 16, min: 1 }));
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: 96, min: 1 }));
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: 64, min: 1 }));
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,22 @@
1
1
  "use strict";
2
2
 
3
+ // [import]
4
+
5
+ const phrase = require("../phrase");
6
+ const size = require("./size");
7
+
3
8
  // [function]
4
9
 
5
10
  const formatBytes = function (bytes) {
6
11
  switch (true) {
7
- case bytes < 1024:
8
- return `${bytes} B`;
9
- case bytes < 1024 ** 2:
10
- return `${(bytes / 1024).toFixed(1)} KB`;
11
- case bytes < 1024 ** 3:
12
- return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
12
+ case bytes >= size.gb(1):
13
+ return phrase.sizeGb(size.toGb(bytes).toFixed(1));
14
+ case bytes >= size.mb(1):
15
+ return phrase.sizeMb(size.toMb(bytes).toFixed(1));
16
+ case bytes >= size.kb(1):
17
+ return phrase.sizeKb(size.toKb(bytes).toFixed(1));
13
18
  default:
14
- return `${(bytes / 1024 / 1024 / 1024).toFixed(1)} GB`;
19
+ return phrase.sizeB(size.toB(bytes));
15
20
  }
16
21
  };
17
22
 
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 = `HttpError: ${this.name} (${this.status})`;
17
+ this.message = phrase.httpError(this.name, this.status);
14
18
  }
15
19
  };
16
20
 
package/src/util/image.js CHANGED
@@ -13,6 +13,7 @@ const imageSize = require("image-size").imageSize;
13
13
 
14
14
  const bytes = require("./bytes");
15
15
  const cfgimage = require("../config/image");
16
+ const phrase = require("../phrase");
16
17
 
17
18
  // [use]
18
19
 
@@ -52,18 +53,18 @@ const checkSize = function (file, maxSize) {
52
53
 
53
54
  const checkPng = function (file, { aspect, maxSize, minHeight, minWidth }) {
54
55
  if (!checkSize(file, maxSize)) {
55
- return [`Image size must not exceed: ${formatBytes(maxSize)}`];
56
+ return [phrase.imageSizeMax(formatBytes(maxSize))];
56
57
  }
57
58
  const buffer = readFileSync(file);
58
59
  const { height, width } = imageSize(buffer);
59
60
  if (minWidth && width < minWidth) {
60
- return [`Image width must be at least: ${minWidth}px`];
61
+ return [phrase.imageWidthMin(minWidth)];
61
62
  }
62
63
  if (minHeight && height < minHeight) {
63
- return [`Image height must be at least: ${minHeight}px`];
64
+ return [phrase.imageHeightMin(minHeight)];
64
65
  }
65
66
  if (!checkAspect(width, height, aspect)) {
66
- return [`Image aspect ratio must be: ${aspect}`];
67
+ return [phrase.imageAspect(aspect)];
67
68
  }
68
69
  return [];
69
70
  };
@@ -72,7 +73,7 @@ const checkPng = function (file, { aspect, maxSize, minHeight, minWidth }) {
72
73
 
73
74
  const checkSvg = function (file, { maxSize }) {
74
75
  if (!checkSize(file, maxSize)) {
75
- return [`Image size must not exceed: ${formatBytes(maxSize)}`];
76
+ return [phrase.imageSizeMax(formatBytes(maxSize))];
76
77
  }
77
78
  return [];
78
79
  };
@@ -87,7 +88,7 @@ const check = function (file, { type, ...opts }) {
87
88
  const checkImage = checks[type];
88
89
  return checkImage && cfgimage[extname(file)] === type
89
90
  ? checkImage(file, opts)
90
- : ["Image has an unsupported file type."];
91
+ : [phrase.imageUnsupported()];
91
92
  };
92
93
 
93
94
  // [export]
package/src/util/size.js CHANGED
@@ -2,28 +2,52 @@
2
2
 
3
3
  // [function]
4
4
 
5
- const b = function (value) {
6
- return value;
5
+ const b = function (bytes) {
6
+ return bytes;
7
7
  };
8
8
 
9
9
  // [function]
10
10
 
11
- const kb = function (value) {
12
- return b(value * 1024);
11
+ const kb = function (bytes) {
12
+ return b(bytes * 1024);
13
13
  };
14
14
 
15
15
  // [function]
16
16
 
17
- const mb = function (value) {
18
- return kb(value * 1024);
17
+ const mb = function (bytes) {
18
+ return kb(bytes * 1024);
19
19
  };
20
20
 
21
21
  // [function]
22
22
 
23
- const gb = function (value) {
24
- return mb(value * 1024);
23
+ const gb = function (bytes) {
24
+ return mb(bytes * 1024);
25
+ };
26
+
27
+ // [function]
28
+
29
+ const toB = function (bytes) {
30
+ return bytes;
31
+ };
32
+
33
+ // [function]
34
+
35
+ const toKb = function (bytes) {
36
+ return toB(bytes / 1024);
37
+ };
38
+
39
+ // [function]
40
+
41
+ const toMb = function (bytes) {
42
+ return toKb(bytes / 1024);
43
+ };
44
+
45
+ // [function]
46
+
47
+ const toGb = function (bytes) {
48
+ return toMb(bytes / 1024);
25
49
  };
26
50
 
27
51
  // [export]
28
52
 
29
- module.exports = { b, gb, kb, mb };
53
+ module.exports = { b, gb, kb, mb, toB, toGb, toKb, toMb };
package/src/util/video.js CHANGED
@@ -94,29 +94,29 @@ const checkMp4 = function (
94
94
  { aspect, maxDuration, maxSize, minDuration, minHeight, minWidth },
95
95
  ) {
96
96
  if (!checkSize(file, maxSize)) {
97
- return [`Video size must not exceed: ${formatBytes(maxSize)}`];
97
+ return [phrase.videoSizeMax(formatBytes(maxSize))];
98
98
  }
99
99
  let video = null;
100
100
  try {
101
101
  video = readMp4(file);
102
102
  } catch {
103
- return ["Video is an invalid file."];
103
+ return [phrase.videoInvalid()];
104
104
  }
105
105
  const { duration, height, width } = video;
106
106
  if (minWidth && width < minWidth) {
107
- return [`Video width must be at least: ${minWidth}px`];
107
+ return [phrase.videoWidthMin(minWidth)];
108
108
  }
109
109
  if (minHeight && height < minHeight) {
110
- return [`Video height must be at least: ${minHeight}px`];
110
+ return [phrase.videoHeightMin(minHeight)];
111
111
  }
112
112
  if (minDuration && duration < minDuration) {
113
- return [`Video duration must be at least: ${minDuration}s`];
113
+ return [phrase.videoDurationMin(minDuration)];
114
114
  }
115
115
  if (maxDuration && duration > maxDuration) {
116
- return [`Video duration must not exceed: ${maxDuration}s`];
116
+ return [phrase.videoDurationMax(maxDuration)];
117
117
  }
118
118
  if (!checkAspect(width, height, aspect)) {
119
- return [`Video aspect ratio must be: ${aspect}`];
119
+ return [phrase.videoAspect(aspect)];
120
120
  }
121
121
  return [];
122
122
  };
@@ -130,7 +130,7 @@ const check = function (file, { type, ...opts }) {
130
130
  const checkVideo = checks[type];
131
131
  return checkVideo && cfgvideo[extname(file)] === type
132
132
  ? checkVideo(file, opts)
133
- : ["Video has an unsupported file type."];
133
+ : [phrase.videoUnsupported()];
134
134
  };
135
135
 
136
136
  // [export]
@@ -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
- };