solidui-cli 0.1.6 → 0.2.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/index.js +101 -104
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
1
|
+
#! /usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command } from "commander";
|
|
@@ -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
|
}
|
|
@@ -462,11 +449,21 @@ module.exports = {
|
|
|
462
449
|
"accordion-up": {
|
|
463
450
|
from: { height: "var(--kb-accordion-content-height)" },
|
|
464
451
|
to: { height: 0 }
|
|
452
|
+
},
|
|
453
|
+
"content-show": {
|
|
454
|
+
from: { opacity: 0, transform: "scale(0.96)" },
|
|
455
|
+
to: { opacity: 1, transform: "scale(1)" }
|
|
456
|
+
},
|
|
457
|
+
"content-hide": {
|
|
458
|
+
from: { opacity: 1, transform: "scale(1)" },
|
|
459
|
+
to: { opacity: 0, transform: "scale(0.96)" }
|
|
465
460
|
}
|
|
466
461
|
},
|
|
467
462
|
animation: {
|
|
468
463
|
"accordion-down": "accordion-down 0.2s ease-out",
|
|
469
|
-
"accordion-up": "accordion-up 0.2s ease-out"
|
|
464
|
+
"accordion-up": "accordion-up 0.2s ease-out",
|
|
465
|
+
"content-show": "content-show 0.2s ease-out",
|
|
466
|
+
"content-hide": "content-hide 0.2s ease-out"
|
|
470
467
|
}
|
|
471
468
|
}
|
|
472
469
|
},
|
|
@@ -478,7 +475,7 @@ export default {
|
|
|
478
475
|
content: [
|
|
479
476
|
"./src/**/*.{html,js,jsx,md,mdx,ts,tsx}"
|
|
480
477
|
],
|
|
481
|
-
presets: [require("./
|
|
478
|
+
presets: [require("./ui.preset.js")]
|
|
482
479
|
}`;
|
|
483
480
|
|
|
484
481
|
// src/lib/transformImports.ts
|
|
@@ -646,10 +643,10 @@ async function add(componentNames) {
|
|
|
646
643
|
const activityIndicator = spinner2();
|
|
647
644
|
activityIndicator.start("Creating components...");
|
|
648
645
|
try {
|
|
649
|
-
const
|
|
650
|
-
const
|
|
651
|
-
const isTypescriptEnabled =
|
|
652
|
-
const componentFolderDir = path.resolve(cwd(),
|
|
646
|
+
const readUIConfig = readFileSync(path.resolve(cwd(), "ui.config.json"));
|
|
647
|
+
const uiConfig = parse(configSchema, JSON.parse(readUIConfig.toString()));
|
|
648
|
+
const isTypescriptEnabled = uiConfig.tsx;
|
|
649
|
+
const componentFolderDir = path.resolve(cwd(), uiConfig.componentDir);
|
|
653
650
|
const dirExists = existsSync(componentFolderDir);
|
|
654
651
|
if (!dirExists)
|
|
655
652
|
mkdirSync(componentFolderDir, { recursive: true });
|
|
@@ -669,7 +666,7 @@ async function add(componentNames) {
|
|
|
669
666
|
}
|
|
670
667
|
for (const file of component.files) {
|
|
671
668
|
log2.step(`Creating ${file.name}`);
|
|
672
|
-
const content = transformImports(file.content,
|
|
669
|
+
const content = transformImports(file.content, uiConfig);
|
|
673
670
|
if (isTypescriptEnabled) {
|
|
674
671
|
writeFileSync(componentFolderDir + `/${file.name}`, content);
|
|
675
672
|
} else {
|
|
@@ -732,7 +729,7 @@ async function init() {
|
|
|
732
729
|
saveConfig(config);
|
|
733
730
|
writeTsconfig(config.aliases.path);
|
|
734
731
|
writeUtils();
|
|
735
|
-
await
|
|
732
|
+
await writeUIPreset();
|
|
736
733
|
await writeTailwindConfig(config.tailwind.config);
|
|
737
734
|
await writeCSS(config.tailwind.css);
|
|
738
735
|
log3.success("Project configuration completed.");
|
|
@@ -784,25 +781,25 @@ async function installDeps() {
|
|
|
784
781
|
}
|
|
785
782
|
function saveConfig(config) {
|
|
786
783
|
const indicator = spinner3();
|
|
787
|
-
indicator.start("Writing
|
|
788
|
-
writeFile("
|
|
784
|
+
indicator.start("Writing ui.config.json...");
|
|
785
|
+
writeFile("ui.config.json", JSON.stringify(config, null, 2), (error) => {
|
|
789
786
|
if (error)
|
|
790
787
|
log3.error("There was an error while saving your preferences");
|
|
791
788
|
});
|
|
792
|
-
indicator.stop("
|
|
789
|
+
indicator.stop("ui.config.json successfully created!");
|
|
793
790
|
}
|
|
794
|
-
async function
|
|
791
|
+
async function writeUIPreset() {
|
|
795
792
|
const indicator = spinner3();
|
|
796
793
|
indicator.start("Writing Solid UI Components tailwind preset...");
|
|
797
794
|
try {
|
|
798
|
-
writeFile("
|
|
795
|
+
writeFile("ui.preset.js", TAILWIND_PRESET, (error) => {
|
|
799
796
|
if (error)
|
|
800
|
-
log3.error(`There was an error while writing the
|
|
797
|
+
log3.error(`There was an error while writing the ui.preset.js: ${error}`);
|
|
801
798
|
});
|
|
802
799
|
} catch (error) {
|
|
803
800
|
log3.error(`Sorry, something went wrong while getting the tailwind presets: ${error}`);
|
|
804
801
|
}
|
|
805
|
-
indicator.stop("
|
|
802
|
+
indicator.stop("ui.preset.js successfully created!");
|
|
806
803
|
}
|
|
807
804
|
async function writeTailwindConfig(tailwindConfigDir) {
|
|
808
805
|
const indicator = spinner3();
|
|
@@ -838,7 +835,7 @@ function writeTsconfig(alias) {
|
|
|
838
835
|
|
|
839
836
|
// src/index.ts
|
|
840
837
|
var program = new Command();
|
|
841
|
-
program.name("
|
|
842
|
-
program.command("init").description("Initialize and install the necessary things to make use of Solid
|
|
838
|
+
program.name("solidui-cli").description("A CLI used for the Solid-UI components library").version("0.1");
|
|
839
|
+
program.command("init").description("Initialize and install the necessary things to make use of Solid-UI").action(async () => await init());
|
|
843
840
|
program.command("add").argument("[components...]", "Components to be added to your project").description("Add a component to your project").action(async (component) => await add(component));
|
|
844
841
|
program.parse();
|