arcadible 0.1.6 → 0.1.7

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 CHANGED
@@ -51,5 +51,5 @@
51
51
  "license": "Apache-2.0",
52
52
  "main": "./src/cli/index.js",
53
53
  "name": "arcadible",
54
- "version": "0.1.6"
54
+ "version": "0.1.7"
55
55
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  // [import]
4
4
 
5
- const execFile = require("node:child_process").execFile;
5
+ const cp = require("node:child_process");
6
6
 
7
7
  // [import]
8
8
 
@@ -10,6 +10,7 @@ const semver = require("semver");
10
10
 
11
11
  // [use]
12
12
 
13
+ const execFile = cp.execFile;
13
14
  const prereleaseSemver = semver.prerelease;
14
15
 
15
16
  // [declare]
@@ -4,7 +4,7 @@
4
4
 
5
5
  module.exports = {
6
6
  /* eslint-disable camelcase */
7
+ build: "",
7
8
  deploy_dir: ".arcadible-public",
8
- skip_build: true,
9
9
  /* eslint-enable camelcase */
10
10
  };
package/src/parser/pkg.js CHANGED
@@ -40,7 +40,7 @@ const parseJson = function (buf) {
40
40
  const extract = function (pkg) {
41
41
  /* eslint-disable camelcase */
42
42
  const game = { version: pkg.version };
43
- const workflow = { skip_build: pkg.scripts?.build ? false : null };
43
+ const workflow = { build: pkg.scripts?.build ?? "" };
44
44
  /* eslint-enable camelcase */
45
45
  return deepCompact({ game, workflow });
46
46
  };
@@ -42,8 +42,14 @@ const reference = function (field) {
42
42
 
43
43
  // [function]
44
44
 
45
- const message = function (field, msg) {
46
- return { message: [msg, indentLines(reference(field))].join("\n") };
45
+ const message = function (field, lines) {
46
+ const [first, ...rest] = [...lines, reference(field)];
47
+ return {
48
+ message:
49
+ [first, ...rest].length > 1
50
+ ? [first, indentLines(rest.join("\n"))].join("\n")
51
+ : first,
52
+ };
47
53
  };
48
54
 
49
55
  // [function]
@@ -55,7 +61,7 @@ const zText = function (field, { max, min }) {
55
61
  .max(max)
56
62
  .regex(
57
63
  /^[\p{L}0-9 .,!?'"():;-]+$/u,
58
- message(field, "Contains invalid characters."),
64
+ message(field, ["Contains invalid characters."]),
59
65
  );
60
66
  };
61
67
 
@@ -67,17 +73,17 @@ const zMedia = function (field, root) {
67
73
  .min(1)
68
74
  .refine(
69
75
  (file) => isRelativeCheck(root, file),
70
- message(field, "Must be a relative path."),
76
+ message(field, ["Must be a relative path."]),
71
77
  )
72
78
  .refine(
73
79
  (file) => isOutCheck(root, file),
74
- message(field, "Must be within the project."),
80
+ message(field, ["Must be within the project."]),
75
81
  )
76
82
  .refine(
77
83
  (file) => isInCheck(root, file, MEDIA),
78
- message(field, `Must be within ${MEDIA}.`),
84
+ message(field, [`Must be within ${MEDIA}.`]),
79
85
  )
80
- .refine((file) => existsCheck(root, file), message(field, "Must exist."));
86
+ .refine((file) => existsCheck(root, file), message(field, ["Must exist."]));
81
87
  };
82
88
 
83
89
  // [function]
@@ -85,7 +91,7 @@ const zMedia = function (field, root) {
85
91
  const zPng = function (field, root, opts) {
86
92
  return zMedia(field, root).refine(
87
93
  (file) => imageCheck(root, file, { ...opts, type: "image/png" }),
88
- message(field, "Invalid PNG."),
94
+ message(field, ["Invalid PNG."]),
89
95
  );
90
96
  };
91
97
 
@@ -94,7 +100,7 @@ const zPng = function (field, root, opts) {
94
100
  const zSvg = function (field, root, opts) {
95
101
  return zMedia(field, root).refine(
96
102
  (file) => imageCheck(root, file, { ...opts, type: "image/svg+xml" }),
97
- message(field, "Invalid SVG."),
103
+ message(field, ["Invalid SVG."]),
98
104
  );
99
105
  };
100
106
 
@@ -108,7 +114,7 @@ const zMp4 = function (field, root, opts) {
108
114
  ...opts,
109
115
  type: "video/mp4",
110
116
  }),
111
- message(field, "Invalid MP4."),
117
+ message(field, ["Invalid MP4."]),
112
118
  );
113
119
  };
114
120
 
@@ -218,7 +224,7 @@ const zDescription = function () {
218
224
  ALLOWED_ATTR: cfghtml.ALLOWED_ATTR,
219
225
  ALLOWED_TAGS: cfghtml.ALLOWED_TAGS,
220
226
  }),
221
- message(field, "Contains invalid elements."),
227
+ message(field, ["Contains invalid elements."]),
222
228
  ),
223
229
  );
224
230
  };
@@ -256,7 +262,7 @@ const zHandle = function () {
256
262
  .string()
257
263
  .regex(
258
264
  /^[a-z0-9](?:(?![-]{2})[a-z0-9-]){1,22}[a-z0-9]$/u,
259
- message(field, "Contains invalid characters."),
265
+ message(field, ["Contains invalid characters."]),
260
266
  ),
261
267
  );
262
268
  };
@@ -295,10 +301,10 @@ const zId = function () {
295
301
  const field = "id";
296
302
  return z
297
303
  .string()
298
- .uuid(message(field, "Must be a valid UUID."))
304
+ .uuid(message(field, ["Must be a valid UUID."]))
299
305
  .refine(
300
306
  (value) => value === value.toLowerCase(),
301
- message(field, "Must use lowercase characters."),
307
+ message(field, ["Must use lowercase characters."]),
302
308
  );
303
309
  };
304
310
 
@@ -382,7 +388,7 @@ const zTrailer = function () {
382
388
  .refine(
383
389
  (url) =>
384
390
  zVimeo().safeParse(url).success || zYouTube().safeParse(url).success,
385
- message(field, "Must be a YouTube (or Vimeo) URL."),
391
+ message(field, ["Must be a YouTube (or Vimeo) URL."]),
386
392
  )
387
393
  .optional();
388
394
  };
@@ -395,7 +401,7 @@ const zVersion = function () {
395
401
  .string()
396
402
  .refine(
397
403
  (value) => validSemver(value) !== null,
398
- message(field, "Must be a valid semver."),
404
+ message(field, ["Must be a valid semver."]),
399
405
  );
400
406
  };
401
407
 
@@ -31,55 +31,58 @@ const reference = function (field) {
31
31
 
32
32
  // [function]
33
33
 
34
- const message = function (field, msg) {
35
- return { message: [msg, indentLines(reference(field))].join("\n") };
34
+ const message = function (field, lines) {
35
+ const [first, ...rest] = [...lines, reference(field)];
36
+ return {
37
+ message:
38
+ [first, ...rest].length > 1
39
+ ? [first, indentLines(rest.join("\n"))].join("\n")
40
+ : first,
41
+ };
36
42
  };
37
43
 
38
44
  // [function]
39
45
 
40
- const zMedia = function (field, root, { skipBuild }) {
46
+ const zBuild = function () {
47
+ // const field = "build";
48
+ return z.string();
49
+ };
50
+
51
+ // [function]
52
+
53
+ const zDeployDir = function (root, { build }) {
54
+ const field = "deploy_dir";
41
55
  return z
42
56
  .string()
43
57
  .min(1)
44
58
  .refine(
45
59
  (file) => isRelativeCheck(root, file),
46
- message(field, "Must be a relative path."),
60
+ message(field, ["Must be a relative path."]),
47
61
  )
48
62
  .refine(
49
63
  (file) => isOutCheck(root, file),
50
- message(field, "Must be within the project."),
64
+ message(field, ["Must be within the project."]),
51
65
  )
52
66
  .refine(
53
67
  (file) => isReservedCheck(root, file, MEDIA),
54
- message(field, `Must not contain ${MEDIA}.`),
68
+ message(field, [`Must not contain ${MEDIA}.`]),
55
69
  )
56
70
  .refine(
57
- (file) => !skipBuild || existsCheck(root, file),
58
- message(field, "Must exist."),
71
+ (file) => build || existsCheck(root, file),
72
+ message(field, [
73
+ "Must exist if there is no build step.",
74
+ "Run `arc inspect workflow.deploy_dir` for its value.",
75
+ ]),
59
76
  );
60
77
  };
61
78
 
62
79
  // [function]
63
80
 
64
- const zDeployDir = function (root, { skip_build: skipBuild }) {
65
- const field = "deploy_dir";
66
- return zMedia(field, root, { skipBuild });
67
- };
68
-
69
- // [function]
70
-
71
- const zSkipBuild = function () {
72
- // const field = "skip_build";
73
- return z.boolean();
74
- };
75
-
76
- // [function]
77
-
78
81
  const main = function (value, { root }) {
79
82
  /* eslint-disable camelcase */
80
83
  return z.object({
84
+ build: zBuild(),
81
85
  deploy_dir: zDeployDir(root, value),
82
- skip_build: zSkipBuild(),
83
86
  });
84
87
  /* eslint-enable camelcase */
85
88
  };