arcadible 0.1.40 → 0.1.42

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 CHANGED
@@ -7,7 +7,7 @@
7
7
  <h1 align="center">Arcadible CLI</h1>
8
8
 
9
9
  <p align="center">
10
- Create, play, and share games with the world.
10
+ Create, play, and share games made with AI.
11
11
  </p>
12
12
 
13
13
  <p align="center">
package/package.json CHANGED
@@ -75,5 +75,5 @@
75
75
  "scripts": {
76
76
  "test": "node --test \"test/**/*.test.js\""
77
77
  },
78
- "version": "0.1.40"
78
+ "version": "0.1.42"
79
79
  }
@@ -59,7 +59,7 @@ const pickVersion = function (version, envVersion) {
59
59
  if (version) {
60
60
  return { version };
61
61
  }
62
- return envVersion ? {} : { version: "0.1.0" };
62
+ return envVersion ? {} : { version: "0.1.0-beta.1" };
63
63
  };
64
64
 
65
65
  // [function]
@@ -50,6 +50,7 @@ const CLI = {
50
50
  const RELEASE = {
51
51
  APP_NOT_INSTALLED: "app_not_installed",
52
52
  EXPIRED: "expired",
53
+ GAME_LIMIT_REACHED: "game_limit_reached",
53
54
  GAME_MISMATCH: "game_mismatch",
54
55
  GAME_UNAVAILABLE: "game_unavailable",
55
56
  INTERNAL: "internal",
@@ -43,45 +43,57 @@ const hasBuild = function (build) {
43
43
 
44
44
  // [function]
45
45
 
46
+ // a value of neither type says what the matching kind expected, a list's for
47
+ // a list and a string's otherwise, not the union's bare "Invalid input".
48
+ const typeMessage = function (issue) {
49
+ const branch = Array.isArray(issue.input) ? 1 : 0;
50
+ return issue.errors?.[branch]?.[0]?.message;
51
+ };
52
+
53
+ // [function]
54
+
46
55
  const zBuild = function () {
47
- // const field = "build";
48
- return z.union([z.string(), z.array(z.string())]);
56
+ return z.union([z.string(), z.array(z.string())], { error: typeMessage });
49
57
  };
50
58
 
51
59
  // [function]
52
60
 
61
+ // a directory inside the project with an index.html. Each check aborts the
62
+ // rest when it fails, so one bad path gets one issue.
53
63
  const zDeployDir = function (root, { build }) {
54
64
  const field = "deploy_dir";
55
65
  return z
56
66
  .string()
57
- .min(1, message(field, ["Must not be empty. Leave the field out instead."]))
58
- .refine(
59
- (file) => isRelativeCheck(root, file),
60
- message(field, ["Must be a relative path."], ISSUE.PATH_INVALID),
61
- )
62
- .refine(
63
- (file) => isInsideCheck(root, file),
64
- message(field, ["Must be within the project."], ISSUE.PATH_INVALID),
65
- )
66
- .refine(
67
- (file) => !isRootCheck(root, file),
68
- message(
67
+ .min(1, {
68
+ ...message(field, ["Must not be empty. Leave the field out instead."]),
69
+ abort: true,
70
+ })
71
+ .refine((file) => isRelativeCheck(root, file), {
72
+ ...message(field, ["Must be a relative path."], ISSUE.PATH_INVALID),
73
+ abort: true,
74
+ })
75
+ .refine((file) => isInsideCheck(root, file), {
76
+ ...message(field, ["Must be within the project."], ISSUE.PATH_INVALID),
77
+ abort: true,
78
+ })
79
+ .refine((file) => !isRootCheck(root, file), {
80
+ ...message(
69
81
  field,
70
82
  ["Must be a directory inside the project, not the project root."],
71
83
  ISSUE.PATH_INVALID,
72
84
  ),
73
- )
74
- .refine(
75
- (file) => avoidsCheck(root, file, MEDIA),
76
- message(
85
+ abort: true,
86
+ })
87
+ .refine((file) => avoidsCheck(root, file, MEDIA), {
88
+ ...message(
77
89
  field,
78
90
  [`Must not contain ${MEDIA} in path.`],
79
91
  ISSUE.PATH_INVALID,
80
92
  ),
81
- )
82
- .refine(
83
- (file) => hasBuild(build) || existsCheck(root, file),
84
- message(
93
+ abort: true,
94
+ })
95
+ .refine((file) => hasBuild(build) || existsCheck(root, file), {
96
+ ...message(
85
97
  field,
86
98
  [
87
99
  "Must exist when no build step is defined.",
@@ -89,25 +101,26 @@ const zDeployDir = function (root, { build }) {
89
101
  ],
90
102
  ISSUE.PATH_INVALID,
91
103
  ),
92
- )
93
- .refine(
94
- (file) => hasFileCheck(root, file, INDEX),
95
- message(
104
+ abort: true,
105
+ })
106
+ .refine((file) => hasFileCheck(root, file, INDEX), {
107
+ ...message(
96
108
  field,
97
109
  [`Must have an ${INDEX} at its root.`],
98
110
  ISSUE.INDEX_MISSING,
99
111
  ),
100
- )
101
- .refine(
102
- (file) => lacksFilesCheck(root, file, RESERVED),
103
- message(
112
+ abort: true,
113
+ })
114
+ .refine((file) => lacksFilesCheck(root, file, RESERVED), {
115
+ ...message(
104
116
  field,
105
117
  [
106
118
  `Must not have ${RESERVED.join(" or ")} at its root. They're reserved for the files ${cfgproduct.title} adds.`,
107
119
  ],
108
120
  ISSUE.PATH_INVALID,
109
121
  ),
110
- );
122
+ abort: true,
123
+ });
111
124
  };
112
125
 
113
126
  // [function]
@@ -39,6 +39,13 @@ const codeOf = function (issue) {
39
39
  return typeof issue.input === "undefined"
40
40
  ? ISSUE.REQUIRED
41
41
  : ISSUE.TYPE_INVALID;
42
+ case "invalid_union":
43
+ // every branch refused the value's type, e.g. `build = 3`
44
+ return issue.errors.every((branch) =>
45
+ branch.every((each) => each.code === "invalid_type"),
46
+ )
47
+ ? ISSUE.TYPE_INVALID
48
+ : ISSUE.INVALID;
42
49
  case "invalid_value":
43
50
  return ISSUE.OPTION_INVALID;
44
51
  case "too_big":