@moxxy/cli 0.8.0 → 0.8.1
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/dist/bin.js +42 -4
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -142603,16 +142603,54 @@ function findCycle(steps) {
|
|
|
142603
142603
|
}
|
|
142604
142604
|
return null;
|
|
142605
142605
|
}
|
|
142606
|
-
function
|
|
142606
|
+
function humanizeIssue(iss) {
|
|
142607
|
+
switch (iss.code) {
|
|
142608
|
+
case "too_small": {
|
|
142609
|
+
const min = Number(iss.minimum);
|
|
142610
|
+
if (iss.type === "string")
|
|
142611
|
+
return min === 1 ? "must not be empty" : `must be at least ${min} characters`;
|
|
142612
|
+
if (iss.type === "array")
|
|
142613
|
+
return min === 1 ? "needs at least one entry" : `needs at least ${min} entries`;
|
|
142614
|
+
return `must be at least ${min}`;
|
|
142615
|
+
}
|
|
142616
|
+
case "too_big": {
|
|
142617
|
+
const max = Number(iss.maximum);
|
|
142618
|
+
if (iss.type === "string")
|
|
142619
|
+
return `must be at most ${max} characters`;
|
|
142620
|
+
if (iss.type === "array")
|
|
142621
|
+
return `can have at most ${max} entries`;
|
|
142622
|
+
return `must be at most ${max}`;
|
|
142623
|
+
}
|
|
142624
|
+
case "invalid_type":
|
|
142625
|
+
return iss.received === "undefined" ? "is required" : `should be a ${iss.expected} (got ${iss.received})`;
|
|
142626
|
+
case "invalid_enum_value":
|
|
142627
|
+
return `must be one of: ${iss.options.map((o2) => `"${String(o2)}"`).join(", ")}`;
|
|
142628
|
+
default:
|
|
142629
|
+
return iss.message;
|
|
142630
|
+
}
|
|
142631
|
+
}
|
|
142632
|
+
function formatIssues(error2, raw) {
|
|
142633
|
+
const steps = raw !== null && typeof raw === "object" && Array.isArray(raw.steps) ? raw.steps : [];
|
|
142607
142634
|
return error2.issues.map((iss) => {
|
|
142608
|
-
|
|
142609
|
-
|
|
142635
|
+
if (iss.code === "custom")
|
|
142636
|
+
return iss.message;
|
|
142637
|
+
const msg = humanizeIssue(iss);
|
|
142638
|
+
const [head, idx, ...rest] = iss.path;
|
|
142639
|
+
if (head === "steps" && typeof idx === "number") {
|
|
142640
|
+
const step = steps[idx];
|
|
142641
|
+
const id = step !== null && typeof step === "object" && typeof step.id === "string" ? step.id : "";
|
|
142642
|
+
const where = id ? `step "${id}"` : `step ${idx + 1}`;
|
|
142643
|
+
const field = rest.join(".");
|
|
142644
|
+
return field ? `${where}: ${field} ${msg}` : `${where} ${msg}`;
|
|
142645
|
+
}
|
|
142646
|
+
const path61 = iss.path.join(".");
|
|
142647
|
+
return path61 ? `${path61} ${msg}` : `workflow ${msg}`;
|
|
142610
142648
|
});
|
|
142611
142649
|
}
|
|
142612
142650
|
function validateWorkflow(raw) {
|
|
142613
142651
|
const parsed = workflowSchema.safeParse(raw);
|
|
142614
142652
|
if (!parsed.success)
|
|
142615
|
-
return { ok: false, errors: formatIssues(parsed.error) };
|
|
142653
|
+
return { ok: false, errors: formatIssues(parsed.error, raw) };
|
|
142616
142654
|
return { ok: true, workflow: parsed.data, errors: [] };
|
|
142617
142655
|
}
|
|
142618
142656
|
function parseWorkflowYaml(text) {
|