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 +1 -1
- package/package.json +1 -1
- package/src/action/init/manifest.js +1 -1
- package/src/config/code.js +1 -0
- package/src/schema/workflow.js +44 -31
- package/src/util/schema.js +7 -0
package/README.md
CHANGED
package/package.json
CHANGED
package/src/config/code.js
CHANGED
package/src/schema/workflow.js
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
75
|
-
|
|
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
|
-
|
|
83
|
-
|
|
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
|
-
|
|
94
|
-
|
|
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
|
-
|
|
102
|
-
|
|
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]
|
package/src/util/schema.js
CHANGED
|
@@ -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":
|