solidui-cli 0.6.5 → 0.6.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/dist/index.js +110 -190
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,32 +11,14 @@ 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.
|
|
15
|
-
var ValiError = class extends Error {
|
|
16
|
-
issues;
|
|
17
|
-
/**
|
|
18
|
-
* Creates a Valibot error with useful information.
|
|
19
|
-
*
|
|
20
|
-
* @param issues The error issues.
|
|
21
|
-
*/
|
|
22
|
-
constructor(issues) {
|
|
23
|
-
super(issues[0].message);
|
|
24
|
-
this.name = "ValiError";
|
|
25
|
-
this.issues = issues;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var BrandSymbol = Symbol("brand");
|
|
29
|
-
function defaultArgs(arg1, arg2) {
|
|
30
|
-
return Array.isArray(arg1) ? [void 0, arg1] : [arg1, arg2];
|
|
31
|
-
}
|
|
14
|
+
// ../../node_modules/.pnpm/valibot@0.36.0/node_modules/valibot/dist/index.js
|
|
32
15
|
var store;
|
|
33
|
-
function getGlobalConfig(
|
|
16
|
+
function getGlobalConfig(config2) {
|
|
34
17
|
return {
|
|
35
|
-
lang:
|
|
36
|
-
message:
|
|
37
|
-
abortEarly:
|
|
38
|
-
abortPipeEarly:
|
|
39
|
-
skipPipe: config?.skipPipe ?? store?.skipPipe
|
|
18
|
+
lang: config2?.lang ?? store?.lang,
|
|
19
|
+
message: config2?.message,
|
|
20
|
+
abortEarly: config2?.abortEarly ?? store?.abortEarly,
|
|
21
|
+
abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
|
|
40
22
|
};
|
|
41
23
|
}
|
|
42
24
|
var store2;
|
|
@@ -51,132 +33,108 @@ var store4;
|
|
|
51
33
|
function getSpecificMessage(reference, lang) {
|
|
52
34
|
return store4?.get(reference)?.get(lang);
|
|
53
35
|
}
|
|
54
|
-
function
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
function schemaResult(typed, output, issues) {
|
|
59
|
-
return { typed, output, issues };
|
|
60
|
-
}
|
|
61
|
-
function stringify(input) {
|
|
62
|
-
let type = typeof input;
|
|
63
|
-
if (type === "object") {
|
|
64
|
-
type = input ? Object.getPrototypeOf(input).constructor.name : "null";
|
|
36
|
+
function _stringify(input) {
|
|
37
|
+
const type = typeof input;
|
|
38
|
+
if (type === "string") {
|
|
39
|
+
return `"${input}"`;
|
|
65
40
|
}
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
function pipeIssue(context, config, issue) {
|
|
69
|
-
const received = issue.received ?? stringify(issue.input);
|
|
70
|
-
const schemaIssue2 = {
|
|
71
|
-
reason: context.type,
|
|
72
|
-
context: issue.context.type,
|
|
73
|
-
expected: issue.context.expects,
|
|
74
|
-
received,
|
|
75
|
-
message: `Invalid ${issue.label}: ${issue.context.expects ? `Expected ${issue.context.expects} but r` : "R"}eceived ${received}`,
|
|
76
|
-
input: issue.input,
|
|
77
|
-
requirement: issue.context.requirement,
|
|
78
|
-
path: issue.path,
|
|
79
|
-
lang: config?.lang,
|
|
80
|
-
abortEarly: config?.abortEarly,
|
|
81
|
-
abortPipeEarly: config?.abortPipeEarly,
|
|
82
|
-
skipPipe: config?.skipPipe
|
|
83
|
-
};
|
|
84
|
-
schemaIssue2.message = i18n(
|
|
85
|
-
false,
|
|
86
|
-
issue.context,
|
|
87
|
-
issue.reference,
|
|
88
|
-
config,
|
|
89
|
-
schemaIssue2
|
|
90
|
-
);
|
|
91
|
-
return schemaIssue2;
|
|
92
|
-
}
|
|
93
|
-
function pipeResult(context, input, config, issues) {
|
|
94
|
-
if (context.pipe && !config?.skipPipe) {
|
|
95
|
-
for (const action of context.pipe) {
|
|
96
|
-
const result = action._parse(input);
|
|
97
|
-
if (result.issues) {
|
|
98
|
-
for (const actionIssue2 of result.issues) {
|
|
99
|
-
const schemaIssue2 = pipeIssue(context, config, actionIssue2);
|
|
100
|
-
issues ? issues.push(schemaIssue2) : issues = [schemaIssue2];
|
|
101
|
-
}
|
|
102
|
-
if (config?.abortEarly || config?.abortPipeEarly) {
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
input = result.output;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
41
|
+
if (type === "number" || type === "bigint" || type === "boolean") {
|
|
42
|
+
return `${input}`;
|
|
109
43
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
function restAndDefaultArgs(arg1, arg2, arg3) {
|
|
113
|
-
if (!arg1 || typeof arg1 === "object" && !Array.isArray(arg1)) {
|
|
114
|
-
const [error2, pipe2] = defaultArgs(arg2, arg3);
|
|
115
|
-
return [arg1, error2, pipe2];
|
|
44
|
+
if (type === "object" || type === "function") {
|
|
45
|
+
return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
116
46
|
}
|
|
117
|
-
|
|
118
|
-
arg1,
|
|
119
|
-
arg2
|
|
120
|
-
);
|
|
121
|
-
return [void 0, error, pipe];
|
|
47
|
+
return type;
|
|
122
48
|
}
|
|
123
|
-
function
|
|
124
|
-
const
|
|
125
|
-
const expected = other?.expected ?? context.expects;
|
|
49
|
+
function _addIssue(context, label, dataset, config2, other) {
|
|
50
|
+
const input = other && "input" in other ? other.input : dataset.value;
|
|
51
|
+
const expected = other?.expected ?? context.expects ?? null;
|
|
52
|
+
const received = other?.received ?? _stringify(input);
|
|
126
53
|
const issue = {
|
|
127
|
-
|
|
128
|
-
|
|
54
|
+
kind: context.kind,
|
|
55
|
+
type: context.type,
|
|
56
|
+
input,
|
|
129
57
|
expected,
|
|
130
58
|
received,
|
|
131
|
-
message: `Invalid
|
|
132
|
-
|
|
59
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
60
|
+
// @ts-expect-error
|
|
61
|
+
requirement: context.requirement,
|
|
133
62
|
path: other?.path,
|
|
134
63
|
issues: other?.issues,
|
|
135
|
-
lang:
|
|
136
|
-
abortEarly:
|
|
137
|
-
abortPipeEarly:
|
|
138
|
-
skipPipe: config?.skipPipe
|
|
64
|
+
lang: config2.lang,
|
|
65
|
+
abortEarly: config2.abortEarly,
|
|
66
|
+
abortPipeEarly: config2.abortPipeEarly
|
|
139
67
|
};
|
|
140
|
-
|
|
141
|
-
|
|
68
|
+
const isSchema = context.kind === "schema";
|
|
69
|
+
const message = other?.message ?? // @ts-expect-error
|
|
70
|
+
context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config2.message ?? getGlobalMessage(issue.lang);
|
|
71
|
+
if (message) {
|
|
72
|
+
issue.message = typeof message === "function" ? message(issue) : message;
|
|
73
|
+
}
|
|
74
|
+
if (isSchema) {
|
|
75
|
+
dataset.typed = false;
|
|
76
|
+
}
|
|
77
|
+
if (dataset.issues) {
|
|
78
|
+
dataset.issues.push(issue);
|
|
79
|
+
} else {
|
|
80
|
+
dataset.issues = [issue];
|
|
81
|
+
}
|
|
142
82
|
}
|
|
143
|
-
|
|
144
|
-
|
|
83
|
+
var ValiError = class extends Error {
|
|
84
|
+
/**
|
|
85
|
+
* The error issues.
|
|
86
|
+
*/
|
|
87
|
+
issues;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a Valibot error with useful information.
|
|
90
|
+
*
|
|
91
|
+
* @param issues The error issues.
|
|
92
|
+
*/
|
|
93
|
+
constructor(issues) {
|
|
94
|
+
super(issues[0].message);
|
|
95
|
+
this.name = "ValiError";
|
|
96
|
+
this.issues = issues;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
function boolean(message) {
|
|
145
100
|
return {
|
|
101
|
+
kind: "schema",
|
|
146
102
|
type: "boolean",
|
|
103
|
+
reference: boolean,
|
|
147
104
|
expects: "boolean",
|
|
148
105
|
async: false,
|
|
149
106
|
message,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
107
|
+
_run(dataset, config2) {
|
|
108
|
+
if (typeof dataset.value === "boolean") {
|
|
109
|
+
dataset.typed = true;
|
|
110
|
+
} else {
|
|
111
|
+
_addIssue(this, "type", dataset, config2);
|
|
154
112
|
}
|
|
155
|
-
return
|
|
113
|
+
return dataset;
|
|
156
114
|
}
|
|
157
115
|
};
|
|
158
116
|
}
|
|
159
|
-
function object(entries,
|
|
160
|
-
const [rest, message, pipe] = restAndDefaultArgs(arg2, arg3, arg4);
|
|
161
|
-
let cachedEntries;
|
|
117
|
+
function object(entries, message) {
|
|
162
118
|
return {
|
|
119
|
+
kind: "schema",
|
|
163
120
|
type: "object",
|
|
121
|
+
reference: object,
|
|
164
122
|
expects: "Object",
|
|
165
123
|
async: false,
|
|
166
124
|
entries,
|
|
167
|
-
rest,
|
|
168
125
|
message,
|
|
169
|
-
|
|
170
|
-
|
|
126
|
+
_run(dataset, config2) {
|
|
127
|
+
const input = dataset.value;
|
|
171
128
|
if (input && typeof input === "object") {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const output = {};
|
|
176
|
-
for (const [key, schema] of cachedEntries) {
|
|
129
|
+
dataset.typed = true;
|
|
130
|
+
dataset.value = {};
|
|
131
|
+
for (const key in this.entries) {
|
|
177
132
|
const value2 = input[key];
|
|
178
|
-
const
|
|
179
|
-
|
|
133
|
+
const valueDataset = this.entries[key]._run(
|
|
134
|
+
{ typed: false, value: value2 },
|
|
135
|
+
config2
|
|
136
|
+
);
|
|
137
|
+
if (valueDataset.issues) {
|
|
180
138
|
const pathItem = {
|
|
181
139
|
type: "object",
|
|
182
140
|
origin: "value",
|
|
@@ -184,101 +142,63 @@ function object(entries, arg2, arg3, arg4) {
|
|
|
184
142
|
key,
|
|
185
143
|
value: value2
|
|
186
144
|
};
|
|
187
|
-
for (const issue of
|
|
145
|
+
for (const issue of valueDataset.issues) {
|
|
188
146
|
if (issue.path) {
|
|
189
147
|
issue.path.unshift(pathItem);
|
|
190
148
|
} else {
|
|
191
149
|
issue.path = [pathItem];
|
|
192
150
|
}
|
|
193
|
-
issues?.push(issue);
|
|
151
|
+
dataset.issues?.push(issue);
|
|
194
152
|
}
|
|
195
|
-
if (!issues) {
|
|
196
|
-
issues =
|
|
153
|
+
if (!dataset.issues) {
|
|
154
|
+
dataset.issues = valueDataset.issues;
|
|
197
155
|
}
|
|
198
|
-
if (
|
|
199
|
-
typed = false;
|
|
156
|
+
if (config2.abortEarly) {
|
|
157
|
+
dataset.typed = false;
|
|
200
158
|
break;
|
|
201
159
|
}
|
|
202
160
|
}
|
|
203
|
-
if (!
|
|
204
|
-
typed = false;
|
|
161
|
+
if (!valueDataset.typed) {
|
|
162
|
+
dataset.typed = false;
|
|
205
163
|
}
|
|
206
|
-
if (
|
|
207
|
-
|
|
164
|
+
if (valueDataset.value !== void 0 || key in input) {
|
|
165
|
+
dataset.value[key] = valueDataset.value;
|
|
208
166
|
}
|
|
209
167
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (!(key in this.entries)) {
|
|
213
|
-
const value2 = input[key];
|
|
214
|
-
const result = this.rest._parse(value2, config);
|
|
215
|
-
if (result.issues) {
|
|
216
|
-
const pathItem = {
|
|
217
|
-
type: "object",
|
|
218
|
-
origin: "value",
|
|
219
|
-
input,
|
|
220
|
-
key,
|
|
221
|
-
value: value2
|
|
222
|
-
};
|
|
223
|
-
for (const issue of result.issues) {
|
|
224
|
-
if (issue.path) {
|
|
225
|
-
issue.path.unshift(pathItem);
|
|
226
|
-
} else {
|
|
227
|
-
issue.path = [pathItem];
|
|
228
|
-
}
|
|
229
|
-
issues?.push(issue);
|
|
230
|
-
}
|
|
231
|
-
if (!issues) {
|
|
232
|
-
issues = result.issues;
|
|
233
|
-
}
|
|
234
|
-
if (config?.abortEarly) {
|
|
235
|
-
typed = false;
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (!result.typed) {
|
|
240
|
-
typed = false;
|
|
241
|
-
}
|
|
242
|
-
output[key] = result.output;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
if (typed) {
|
|
247
|
-
return pipeResult(
|
|
248
|
-
this,
|
|
249
|
-
output,
|
|
250
|
-
config,
|
|
251
|
-
issues
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
return schemaResult(false, output, issues);
|
|
168
|
+
} else {
|
|
169
|
+
_addIssue(this, "type", dataset, config2);
|
|
255
170
|
}
|
|
256
|
-
return
|
|
171
|
+
return dataset;
|
|
257
172
|
}
|
|
258
173
|
};
|
|
259
174
|
}
|
|
260
|
-
function string(
|
|
261
|
-
const [message, pipe] = defaultArgs(arg1, arg2);
|
|
175
|
+
function string(message) {
|
|
262
176
|
return {
|
|
177
|
+
kind: "schema",
|
|
263
178
|
type: "string",
|
|
179
|
+
reference: string,
|
|
264
180
|
expects: "string",
|
|
265
181
|
async: false,
|
|
266
182
|
message,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
183
|
+
_run(dataset, config2) {
|
|
184
|
+
if (typeof dataset.value === "string") {
|
|
185
|
+
dataset.typed = true;
|
|
186
|
+
} else {
|
|
187
|
+
_addIssue(this, "type", dataset, config2);
|
|
271
188
|
}
|
|
272
|
-
return
|
|
189
|
+
return dataset;
|
|
273
190
|
}
|
|
274
191
|
};
|
|
275
192
|
}
|
|
276
|
-
function parse(schema, input,
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
193
|
+
function parse(schema, input, config2) {
|
|
194
|
+
const dataset = schema._run(
|
|
195
|
+
{ typed: false, value: input },
|
|
196
|
+
getGlobalConfig(config2)
|
|
197
|
+
);
|
|
198
|
+
if (dataset.issues) {
|
|
199
|
+
throw new ValiError(dataset.issues);
|
|
280
200
|
}
|
|
281
|
-
return
|
|
201
|
+
return dataset.value;
|
|
282
202
|
}
|
|
283
203
|
|
|
284
204
|
// src/lib/constants.ts
|