solidui-cli 0.3.0 → 0.5.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 +188 -142
- package/package.json +2 -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.28.1/node_modules/valibot/dist/index.js
|
|
15
15
|
var ValiError = class extends Error {
|
|
16
16
|
issues;
|
|
17
17
|
/**
|
|
@@ -26,210 +26,254 @@ var ValiError = class extends Error {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
var BrandSymbol = Symbol("brand");
|
|
29
|
-
function
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
function getOutput(output) {
|
|
33
|
-
return { output };
|
|
29
|
+
function defaultArgs(arg1, arg2) {
|
|
30
|
+
return Array.isArray(arg1) ? [void 0, arg1] : [arg1, arg2];
|
|
34
31
|
}
|
|
35
|
-
|
|
32
|
+
var store;
|
|
33
|
+
function getGlobalConfig(config) {
|
|
36
34
|
return {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
path: issue.path,
|
|
43
|
-
abortEarly: info?.abortEarly,
|
|
44
|
-
abortPipeEarly: info?.abortPipeEarly,
|
|
45
|
-
skipPipe: info?.skipPipe
|
|
35
|
+
lang: config?.lang ?? store?.lang,
|
|
36
|
+
message: config?.message,
|
|
37
|
+
abortEarly: config?.abortEarly ?? store?.abortEarly,
|
|
38
|
+
abortPipeEarly: config?.abortPipeEarly ?? store?.abortPipeEarly,
|
|
39
|
+
skipPipe: config?.skipPipe ?? store?.skipPipe
|
|
46
40
|
};
|
|
47
41
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
var store2;
|
|
43
|
+
function getGlobalMessage(lang) {
|
|
44
|
+
return store2?.get(lang);
|
|
45
|
+
}
|
|
46
|
+
var store3;
|
|
47
|
+
function getSchemaMessage(lang) {
|
|
48
|
+
return store3?.get(lang);
|
|
49
|
+
}
|
|
50
|
+
var store4;
|
|
51
|
+
function getSpecificMessage(reference, lang) {
|
|
52
|
+
return store4?.get(reference)?.get(lang);
|
|
53
|
+
}
|
|
54
|
+
function i18n(context, reference, config, issue) {
|
|
55
|
+
const message = context.message ?? getSpecificMessage(reference, issue.lang) ?? (context.type === "type" ? getSchemaMessage(issue.lang) : null) ?? config?.message ?? getGlobalMessage(issue.lang) ?? issue.message;
|
|
56
|
+
return typeof message === "function" ? message(issue) : message;
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
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";
|
|
60
65
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
return type === "string" ? `"${input}"` : type === "number" || type === "bigint" || type === "boolean" ? `${input}` : type;
|
|
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
|
+
issue.context,
|
|
86
|
+
issue.reference,
|
|
87
|
+
config,
|
|
88
|
+
schemaIssue2
|
|
89
|
+
);
|
|
90
|
+
return schemaIssue2;
|
|
91
|
+
}
|
|
92
|
+
function pipeResult(context, input, config, issues) {
|
|
93
|
+
if (context.pipe && !config?.skipPipe) {
|
|
94
|
+
for (const action of context.pipe) {
|
|
95
|
+
const result = action._parse(input);
|
|
96
|
+
if (result.issues) {
|
|
97
|
+
for (const actionIssue2 of result.issues) {
|
|
98
|
+
const schemaIssue2 = pipeIssue(context, config, actionIssue2);
|
|
99
|
+
issues ? issues.push(schemaIssue2) : issues = [schemaIssue2];
|
|
100
|
+
}
|
|
101
|
+
if (config?.abortEarly || config?.abortPipeEarly) {
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
input = result.output;
|
|
74
106
|
}
|
|
75
|
-
} else {
|
|
76
|
-
output = result.output;
|
|
77
107
|
}
|
|
78
108
|
}
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
function getDefaultArgs(arg1, arg2) {
|
|
82
|
-
return Array.isArray(arg1) ? [void 0, arg1] : [arg1, arg2];
|
|
109
|
+
return schemaResult(true, input, issues);
|
|
83
110
|
}
|
|
84
|
-
function
|
|
85
|
-
return typeof message === "function" ? message() : message;
|
|
86
|
-
}
|
|
87
|
-
function getRestAndDefaultArgs(arg1, arg2, arg3) {
|
|
111
|
+
function restAndDefaultArgs(arg1, arg2, arg3) {
|
|
88
112
|
if (!arg1 || typeof arg1 === "object" && !Array.isArray(arg1)) {
|
|
89
|
-
const [error2, pipe2] =
|
|
113
|
+
const [error2, pipe2] = defaultArgs(arg2, arg3);
|
|
90
114
|
return [arg1, error2, pipe2];
|
|
91
115
|
}
|
|
92
|
-
const [error, pipe] =
|
|
116
|
+
const [error, pipe] = defaultArgs(
|
|
93
117
|
arg1,
|
|
94
118
|
arg2
|
|
95
119
|
);
|
|
96
120
|
return [void 0, error, pipe];
|
|
97
121
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
122
|
+
function schemaIssue(context, reference, input, config, other) {
|
|
123
|
+
const received = stringify(input);
|
|
124
|
+
const expected = other?.expected ?? context.expects;
|
|
125
|
+
const issue = {
|
|
126
|
+
reason: other?.reason ?? "type",
|
|
127
|
+
context: context.type,
|
|
128
|
+
expected,
|
|
129
|
+
received,
|
|
130
|
+
message: `Invalid type: Expected ${expected} but received ${received}`,
|
|
131
|
+
input,
|
|
132
|
+
path: other?.path,
|
|
133
|
+
issues: other?.issues,
|
|
134
|
+
lang: config?.lang,
|
|
135
|
+
abortEarly: config?.abortEarly,
|
|
136
|
+
abortPipeEarly: config?.abortPipeEarly,
|
|
137
|
+
skipPipe: config?.skipPipe
|
|
113
138
|
};
|
|
139
|
+
issue.message = i18n(context, reference, config, issue);
|
|
140
|
+
return { typed: false, output: input, issues: [issue] };
|
|
114
141
|
}
|
|
115
142
|
function boolean(arg1, arg2) {
|
|
116
|
-
const [message
|
|
143
|
+
const [message, pipe] = defaultArgs(arg1, arg2);
|
|
117
144
|
return {
|
|
118
145
|
type: "boolean",
|
|
146
|
+
expects: "boolean",
|
|
119
147
|
async: false,
|
|
120
148
|
message,
|
|
121
149
|
pipe,
|
|
122
|
-
_parse(input,
|
|
123
|
-
if (typeof input
|
|
124
|
-
return
|
|
150
|
+
_parse(input, config) {
|
|
151
|
+
if (typeof input === "boolean") {
|
|
152
|
+
return pipeResult(this, input, config);
|
|
125
153
|
}
|
|
126
|
-
return
|
|
154
|
+
return schemaIssue(this, boolean, input, config);
|
|
127
155
|
}
|
|
128
156
|
};
|
|
129
157
|
}
|
|
130
158
|
function object(entries, arg2, arg3, arg4) {
|
|
131
|
-
const [rest, message
|
|
159
|
+
const [rest, message, pipe] = restAndDefaultArgs(arg2, arg3, arg4);
|
|
132
160
|
let cachedEntries;
|
|
133
161
|
return {
|
|
134
162
|
type: "object",
|
|
163
|
+
expects: "Object",
|
|
135
164
|
async: false,
|
|
136
165
|
entries,
|
|
137
166
|
rest,
|
|
138
167
|
message,
|
|
139
168
|
pipe,
|
|
140
|
-
_parse(input,
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
169
|
+
_parse(input, config) {
|
|
170
|
+
if (input && typeof input === "object") {
|
|
171
|
+
cachedEntries = cachedEntries ?? Object.entries(this.entries);
|
|
172
|
+
let typed = true;
|
|
173
|
+
let issues;
|
|
174
|
+
const output = {};
|
|
175
|
+
for (const [key, schema] of cachedEntries) {
|
|
176
|
+
const value2 = input[key];
|
|
177
|
+
const result = schema._parse(value2, config);
|
|
178
|
+
if (result.issues) {
|
|
179
|
+
const pathItem = {
|
|
180
|
+
type: "object",
|
|
181
|
+
origin: "value",
|
|
182
|
+
input,
|
|
183
|
+
key,
|
|
184
|
+
value: value2
|
|
185
|
+
};
|
|
186
|
+
for (const issue of result.issues) {
|
|
187
|
+
if (issue.path) {
|
|
188
|
+
issue.path.unshift(pathItem);
|
|
189
|
+
} else {
|
|
190
|
+
issue.path = [pathItem];
|
|
191
|
+
}
|
|
192
|
+
issues?.push(issue);
|
|
193
|
+
}
|
|
194
|
+
if (!issues) {
|
|
195
|
+
issues = result.issues;
|
|
196
|
+
}
|
|
197
|
+
if (config?.abortEarly) {
|
|
198
|
+
typed = false;
|
|
199
|
+
break;
|
|
162
200
|
}
|
|
163
|
-
issues?.push(issue);
|
|
164
201
|
}
|
|
165
|
-
if (!
|
|
166
|
-
|
|
202
|
+
if (!result.typed) {
|
|
203
|
+
typed = false;
|
|
167
204
|
}
|
|
168
|
-
if (
|
|
169
|
-
|
|
205
|
+
if (result.output !== void 0 || key in input) {
|
|
206
|
+
output[key] = result.output;
|
|
170
207
|
}
|
|
171
|
-
} else if (result.output !== void 0 || key in input) {
|
|
172
|
-
output[key] = result.output;
|
|
173
208
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
209
|
+
if (this.rest && !(config?.abortEarly && issues)) {
|
|
210
|
+
for (const key in input) {
|
|
211
|
+
if (!(key in this.entries)) {
|
|
212
|
+
const value2 = input[key];
|
|
213
|
+
const result = this.rest._parse(value2, config);
|
|
214
|
+
if (result.issues) {
|
|
215
|
+
const pathItem = {
|
|
216
|
+
type: "object",
|
|
217
|
+
origin: "value",
|
|
218
|
+
input,
|
|
219
|
+
key,
|
|
220
|
+
value: value2
|
|
221
|
+
};
|
|
222
|
+
for (const issue of result.issues) {
|
|
223
|
+
if (issue.path) {
|
|
224
|
+
issue.path.unshift(pathItem);
|
|
225
|
+
} else {
|
|
226
|
+
issue.path = [pathItem];
|
|
227
|
+
}
|
|
228
|
+
issues?.push(issue);
|
|
229
|
+
}
|
|
230
|
+
if (!issues) {
|
|
231
|
+
issues = result.issues;
|
|
232
|
+
}
|
|
233
|
+
if (config?.abortEarly) {
|
|
234
|
+
typed = false;
|
|
235
|
+
break;
|
|
192
236
|
}
|
|
193
|
-
issues?.push(issue);
|
|
194
|
-
}
|
|
195
|
-
if (!issues) {
|
|
196
|
-
issues = result.issues;
|
|
197
237
|
}
|
|
198
|
-
if (
|
|
199
|
-
|
|
238
|
+
if (!result.typed) {
|
|
239
|
+
typed = false;
|
|
200
240
|
}
|
|
201
|
-
} else {
|
|
202
241
|
output[key] = result.output;
|
|
203
242
|
}
|
|
204
243
|
}
|
|
205
244
|
}
|
|
245
|
+
if (typed) {
|
|
246
|
+
return pipeResult(
|
|
247
|
+
this,
|
|
248
|
+
output,
|
|
249
|
+
config,
|
|
250
|
+
issues
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
return schemaResult(false, output, issues);
|
|
206
254
|
}
|
|
207
|
-
return
|
|
208
|
-
output,
|
|
209
|
-
this.pipe,
|
|
210
|
-
info,
|
|
211
|
-
"object"
|
|
212
|
-
);
|
|
255
|
+
return schemaIssue(this, object, input, config);
|
|
213
256
|
}
|
|
214
257
|
};
|
|
215
258
|
}
|
|
216
259
|
function string(arg1, arg2) {
|
|
217
|
-
const [message
|
|
260
|
+
const [message, pipe] = defaultArgs(arg1, arg2);
|
|
218
261
|
return {
|
|
219
262
|
type: "string",
|
|
263
|
+
expects: "string",
|
|
220
264
|
async: false,
|
|
221
265
|
message,
|
|
222
266
|
pipe,
|
|
223
|
-
_parse(input,
|
|
224
|
-
if (typeof input
|
|
225
|
-
return
|
|
267
|
+
_parse(input, config) {
|
|
268
|
+
if (typeof input === "string") {
|
|
269
|
+
return pipeResult(this, input, config);
|
|
226
270
|
}
|
|
227
|
-
return
|
|
271
|
+
return schemaIssue(this, string, input, config);
|
|
228
272
|
}
|
|
229
273
|
};
|
|
230
274
|
}
|
|
231
|
-
function parse(schema, input,
|
|
232
|
-
const result = schema._parse(input,
|
|
275
|
+
function parse(schema, input, config) {
|
|
276
|
+
const result = schema._parse(input, getGlobalConfig(config));
|
|
233
277
|
if (result.issues) {
|
|
234
278
|
throw new ValiError(result.issues);
|
|
235
279
|
}
|
|
@@ -434,6 +478,7 @@ module.exports = {
|
|
|
434
478
|
}
|
|
435
479
|
},
|
|
436
480
|
borderRadius: {
|
|
481
|
+
xl: "calc(var(--radius) + 4px)",
|
|
437
482
|
lg: "var(--radius)",
|
|
438
483
|
md: "calc(var(--radius) - 2px)",
|
|
439
484
|
sm: "calc(var(--radius) - 4px)"
|
|
@@ -575,6 +620,7 @@ import { execSync } from "child_process";
|
|
|
575
620
|
import { readFile } from "fs";
|
|
576
621
|
import { log, spinner } from "@clack/prompts";
|
|
577
622
|
import { detect } from "detect-package-manager";
|
|
623
|
+
import JSON5 from "json5";
|
|
578
624
|
function readJsonFile(filePath, callback) {
|
|
579
625
|
readFile(filePath, "utf8", (err, data) => {
|
|
580
626
|
if (err) {
|
|
@@ -582,7 +628,7 @@ function readJsonFile(filePath, callback) {
|
|
|
582
628
|
return;
|
|
583
629
|
}
|
|
584
630
|
try {
|
|
585
|
-
const jsonObject =
|
|
631
|
+
const jsonObject = JSON5.parse(data);
|
|
586
632
|
callback(null, jsonObject);
|
|
587
633
|
} catch (parseError) {
|
|
588
634
|
callback(parseError, null);
|
|
@@ -773,7 +819,7 @@ async function installDeps() {
|
|
|
773
819
|
initialValue: "npm"
|
|
774
820
|
});
|
|
775
821
|
runCommand(
|
|
776
|
-
`${packageManager} install ${PROJECT_DEPS.join(" ")}`,
|
|
822
|
+
`${packageManager} ${packageManager === "yarn" ? "add" : "install"} ${PROJECT_DEPS.join(" ")}`,
|
|
777
823
|
"Installing Solid UI Component dependencies",
|
|
778
824
|
"Dependencies installed"
|
|
779
825
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solidui-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Add Solid UI Components to your application using the Solid-UI CLI tool",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"chalk": "^5.3.0",
|
|
44
44
|
"commander": "^11.0.0",
|
|
45
45
|
"detect-package-manager": "^3.0.1",
|
|
46
|
+
"json5": "^2.2.3",
|
|
46
47
|
"prompts": "^2.4.2",
|
|
47
48
|
"recast": "^0.23.4",
|
|
48
49
|
"ts-morph": "^20.0.0"
|