solidui-cli 0.2.0 → 0.3.0
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/index.js +73 -86
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { log as log2, spinner as spinner2 } from "@clack/prompts";
|
|
|
11
11
|
import chalk from "chalk";
|
|
12
12
|
import prompts from "prompts";
|
|
13
13
|
|
|
14
|
-
// ../../node_modules/.pnpm/valibot@0.
|
|
14
|
+
// ../../node_modules/.pnpm/valibot@0.21.0/node_modules/valibot/dist/index.js
|
|
15
15
|
var ValiError = class extends Error {
|
|
16
16
|
issues;
|
|
17
17
|
/**
|
|
@@ -62,7 +62,7 @@ function executePipe(input, pipe, parseInfo, reason) {
|
|
|
62
62
|
let issues;
|
|
63
63
|
let output = input;
|
|
64
64
|
for (const action of pipe) {
|
|
65
|
-
const result = action(output);
|
|
65
|
+
const result = action._parse(output);
|
|
66
66
|
if (result.issues) {
|
|
67
67
|
pipeInfo = pipeInfo || getPipeInfo(parseInfo, reason);
|
|
68
68
|
for (const issueInfo of result.issues) {
|
|
@@ -81,17 +81,28 @@ function executePipe(input, pipe, parseInfo, reason) {
|
|
|
81
81
|
function getDefaultArgs(arg1, arg2) {
|
|
82
82
|
return Array.isArray(arg1) ? [void 0, arg1] : [arg1, arg2];
|
|
83
83
|
}
|
|
84
|
-
function getErrorMessage(
|
|
85
|
-
return typeof
|
|
84
|
+
function getErrorMessage(message) {
|
|
85
|
+
return typeof message === "function" ? message() : message;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function getRestAndDefaultArgs(arg1, arg2, arg3) {
|
|
88
|
+
if (!arg1 || typeof arg1 === "object" && !Array.isArray(arg1)) {
|
|
89
|
+
const [error2, pipe2] = getDefaultArgs(arg2, arg3);
|
|
90
|
+
return [arg1, error2, pipe2];
|
|
91
|
+
}
|
|
92
|
+
const [error, pipe] = getDefaultArgs(
|
|
93
|
+
arg1,
|
|
94
|
+
arg2
|
|
95
|
+
);
|
|
96
|
+
return [void 0, error, pipe];
|
|
97
|
+
}
|
|
98
|
+
function getSchemaIssues(info, reason, validation, message, input, issues) {
|
|
88
99
|
return {
|
|
89
100
|
issues: [
|
|
90
101
|
{
|
|
91
102
|
reason,
|
|
92
103
|
validation,
|
|
93
104
|
origin: info?.origin || "value",
|
|
94
|
-
message: getErrorMessage(
|
|
105
|
+
message: getErrorMessage(message),
|
|
95
106
|
input,
|
|
96
107
|
issues,
|
|
97
108
|
abortEarly: info?.abortEarly,
|
|
@@ -102,73 +113,35 @@ function getSchemaIssues(info, reason, validation, error, input, issues) {
|
|
|
102
113
|
};
|
|
103
114
|
}
|
|
104
115
|
function boolean(arg1, arg2) {
|
|
105
|
-
const [
|
|
116
|
+
const [message = "Invalid type", pipe] = getDefaultArgs(arg1, arg2);
|
|
106
117
|
return {
|
|
107
|
-
|
|
108
|
-
* The schema type.
|
|
109
|
-
*/
|
|
110
|
-
schema: "boolean",
|
|
111
|
-
/**
|
|
112
|
-
* Whether it's async.
|
|
113
|
-
*/
|
|
118
|
+
type: "boolean",
|
|
114
119
|
async: false,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
*
|
|
118
|
-
* @param input The input to be parsed.
|
|
119
|
-
* @param info The parse info.
|
|
120
|
-
*
|
|
121
|
-
* @returns The parsed output.
|
|
122
|
-
*/
|
|
120
|
+
message,
|
|
121
|
+
pipe,
|
|
123
122
|
_parse(input, info) {
|
|
124
123
|
if (typeof input !== "boolean") {
|
|
125
|
-
return getSchemaIssues(
|
|
126
|
-
info,
|
|
127
|
-
"type",
|
|
128
|
-
"boolean",
|
|
129
|
-
error || "Invalid type",
|
|
130
|
-
input
|
|
131
|
-
);
|
|
124
|
+
return getSchemaIssues(info, "type", "boolean", this.message, input);
|
|
132
125
|
}
|
|
133
|
-
return executePipe(input, pipe, info, "boolean");
|
|
126
|
+
return executePipe(input, this.pipe, info, "boolean");
|
|
134
127
|
}
|
|
135
128
|
};
|
|
136
129
|
}
|
|
137
|
-
function object(
|
|
138
|
-
const [
|
|
130
|
+
function object(entries, arg2, arg3, arg4) {
|
|
131
|
+
const [rest, message = "Invalid type", pipe] = getRestAndDefaultArgs(arg2, arg3, arg4);
|
|
139
132
|
let cachedEntries;
|
|
140
133
|
return {
|
|
141
|
-
|
|
142
|
-
* The schema type.
|
|
143
|
-
*/
|
|
144
|
-
schema: "object",
|
|
145
|
-
/**
|
|
146
|
-
* The object schema.
|
|
147
|
-
*/
|
|
148
|
-
object: object2,
|
|
149
|
-
/**
|
|
150
|
-
* Whether it's async.
|
|
151
|
-
*/
|
|
134
|
+
type: "object",
|
|
152
135
|
async: false,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
* @param info The parse info.
|
|
158
|
-
*
|
|
159
|
-
* @returns The parsed output.
|
|
160
|
-
*/
|
|
136
|
+
entries,
|
|
137
|
+
rest,
|
|
138
|
+
message,
|
|
139
|
+
pipe,
|
|
161
140
|
_parse(input, info) {
|
|
162
141
|
if (!input || typeof input !== "object") {
|
|
163
|
-
return getSchemaIssues(
|
|
164
|
-
info,
|
|
165
|
-
"type",
|
|
166
|
-
"object",
|
|
167
|
-
error || "Invalid type",
|
|
168
|
-
input
|
|
169
|
-
);
|
|
142
|
+
return getSchemaIssues(info, "type", "object", this.message, input);
|
|
170
143
|
}
|
|
171
|
-
cachedEntries = cachedEntries || Object.entries(
|
|
144
|
+
cachedEntries = cachedEntries || Object.entries(this.entries);
|
|
172
145
|
let issues;
|
|
173
146
|
const output = {};
|
|
174
147
|
for (const [key, schema] of cachedEntries) {
|
|
@@ -176,7 +149,7 @@ function object(object2, arg2, arg3) {
|
|
|
176
149
|
const result = schema._parse(value2, info);
|
|
177
150
|
if (result.issues) {
|
|
178
151
|
const pathItem = {
|
|
179
|
-
|
|
152
|
+
type: "object",
|
|
180
153
|
input,
|
|
181
154
|
key,
|
|
182
155
|
value: value2
|
|
@@ -195,13 +168,45 @@ function object(object2, arg2, arg3) {
|
|
|
195
168
|
if (info?.abortEarly) {
|
|
196
169
|
break;
|
|
197
170
|
}
|
|
198
|
-
} else {
|
|
171
|
+
} else if (result.output !== void 0 || key in input) {
|
|
199
172
|
output[key] = result.output;
|
|
200
173
|
}
|
|
201
174
|
}
|
|
175
|
+
if (this.rest && !(info?.abortEarly && issues)) {
|
|
176
|
+
for (const key in input) {
|
|
177
|
+
if (!(key in this.entries)) {
|
|
178
|
+
const value2 = input[key];
|
|
179
|
+
const result = this.rest._parse(value2, info);
|
|
180
|
+
if (result.issues) {
|
|
181
|
+
const pathItem = {
|
|
182
|
+
type: "object",
|
|
183
|
+
input,
|
|
184
|
+
key,
|
|
185
|
+
value: value2
|
|
186
|
+
};
|
|
187
|
+
for (const issue of result.issues) {
|
|
188
|
+
if (issue.path) {
|
|
189
|
+
issue.path.unshift(pathItem);
|
|
190
|
+
} else {
|
|
191
|
+
issue.path = [pathItem];
|
|
192
|
+
}
|
|
193
|
+
issues?.push(issue);
|
|
194
|
+
}
|
|
195
|
+
if (!issues) {
|
|
196
|
+
issues = result.issues;
|
|
197
|
+
}
|
|
198
|
+
if (info?.abortEarly) {
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
output[key] = result.output;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
202
207
|
return issues ? getIssues(issues) : executePipe(
|
|
203
208
|
output,
|
|
204
|
-
pipe,
|
|
209
|
+
this.pipe,
|
|
205
210
|
info,
|
|
206
211
|
"object"
|
|
207
212
|
);
|
|
@@ -209,35 +214,17 @@ function object(object2, arg2, arg3) {
|
|
|
209
214
|
};
|
|
210
215
|
}
|
|
211
216
|
function string(arg1, arg2) {
|
|
212
|
-
const [
|
|
217
|
+
const [message = "Invalid type", pipe] = getDefaultArgs(arg1, arg2);
|
|
213
218
|
return {
|
|
214
|
-
|
|
215
|
-
* The schema type.
|
|
216
|
-
*/
|
|
217
|
-
schema: "string",
|
|
218
|
-
/**
|
|
219
|
-
* Whether it's async.
|
|
220
|
-
*/
|
|
219
|
+
type: "string",
|
|
221
220
|
async: false,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
*
|
|
225
|
-
* @param input The input to be parsed.
|
|
226
|
-
* @param info The parse info.
|
|
227
|
-
*
|
|
228
|
-
* @returns The parsed output.
|
|
229
|
-
*/
|
|
221
|
+
message,
|
|
222
|
+
pipe,
|
|
230
223
|
_parse(input, info) {
|
|
231
224
|
if (typeof input !== "string") {
|
|
232
|
-
return getSchemaIssues(
|
|
233
|
-
info,
|
|
234
|
-
"type",
|
|
235
|
-
"string",
|
|
236
|
-
error || "Invalid type",
|
|
237
|
-
input
|
|
238
|
-
);
|
|
225
|
+
return getSchemaIssues(info, "type", "string", this.message, input);
|
|
239
226
|
}
|
|
240
|
-
return executePipe(input, pipe, info, "string");
|
|
227
|
+
return executePipe(input, this.pipe, info, "string");
|
|
241
228
|
}
|
|
242
229
|
};
|
|
243
230
|
}
|