@sgx4u/ui 1.0.6
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/CHANGELOG.md +69 -0
- package/LICENSE +7 -0
- package/README.md +161 -0
- package/SECURITY.md +5 -0
- package/SUPPORT.md +5 -0
- package/dist/bin.cjs +1218 -0
- package/dist/bin.d.cts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +4 -0
- package/dist/chunk-SWLJZFBL.js +890 -0
- package/dist/cli-UJKWK2HV.js +200 -0
- package/dist/index.cjs +924 -0
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +10 -0
- package/logo.svg +18 -0
- package/package.json +88 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addComponent,
|
|
3
|
+
createConfig,
|
|
4
|
+
fetchComponent,
|
|
5
|
+
getConfig,
|
|
6
|
+
getProjectInfo,
|
|
7
|
+
initConfig,
|
|
8
|
+
listComponents
|
|
9
|
+
} from "./chunk-SWLJZFBL.js";
|
|
10
|
+
|
|
11
|
+
// src/cli.ts
|
|
12
|
+
import { Command } from "commander";
|
|
13
|
+
|
|
14
|
+
// src/commands/config.ts
|
|
15
|
+
import fs from "fs-extra";
|
|
16
|
+
import inquirer from "inquirer";
|
|
17
|
+
import ora from "ora";
|
|
18
|
+
import path from "path";
|
|
19
|
+
async function manageConfig() {
|
|
20
|
+
try {
|
|
21
|
+
const cwd = process.cwd();
|
|
22
|
+
const configSpinner = ora(" Loading configuration...").start();
|
|
23
|
+
const config = await getConfig(cwd);
|
|
24
|
+
if (!config) {
|
|
25
|
+
configSpinner.fail();
|
|
26
|
+
console.log('\u274C No configuration found. Please run "sgx4u-ui init" first!');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
configSpinner.succeed();
|
|
30
|
+
console.log(`\u2699\uFE0F Configuration Management`);
|
|
31
|
+
const actionChoices = [
|
|
32
|
+
{ name: "View full configuration", value: "view" },
|
|
33
|
+
{ name: "Reset configuration", value: "reset" },
|
|
34
|
+
{ name: "Exit", value: "exit" }
|
|
35
|
+
];
|
|
36
|
+
actionChoices.forEach((choice, index) => {
|
|
37
|
+
console.log(` ${index + 1}) ${choice.name}`);
|
|
38
|
+
});
|
|
39
|
+
console.log("");
|
|
40
|
+
const { action } = await inquirer.prompt([
|
|
41
|
+
{
|
|
42
|
+
type: "rawlist",
|
|
43
|
+
name: "action",
|
|
44
|
+
message: "What would you like to do?",
|
|
45
|
+
choices: actionChoices
|
|
46
|
+
}
|
|
47
|
+
]);
|
|
48
|
+
switch (action) {
|
|
49
|
+
case "view":
|
|
50
|
+
await viewFullConfig(config);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
break;
|
|
53
|
+
case "reset":
|
|
54
|
+
await resetConfig(cwd);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
break;
|
|
57
|
+
case "exit":
|
|
58
|
+
console.log("\u{1F44B} Goodbye!");
|
|
59
|
+
process.exit(1);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(`\u274C Error: ${error}`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function viewFullConfig(config) {
|
|
68
|
+
console.log(`\u{1F4C4} Full Configuration:`);
|
|
69
|
+
console.log(JSON.stringify(config, null, 2));
|
|
70
|
+
}
|
|
71
|
+
async function resetConfig(cwd) {
|
|
72
|
+
const { confirm } = await inquirer.prompt([
|
|
73
|
+
{
|
|
74
|
+
type: "confirm",
|
|
75
|
+
name: "confirm",
|
|
76
|
+
message: "Are you sure you want to reset the configuration to default values?",
|
|
77
|
+
default: false
|
|
78
|
+
}
|
|
79
|
+
]);
|
|
80
|
+
if (confirm) {
|
|
81
|
+
const projectInfo = await getProjectInfo(cwd);
|
|
82
|
+
if (projectInfo.project === "none") {
|
|
83
|
+
console.log("\u274C No supported project detected!");
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
const config = await createConfig({ cwd, projectInfo });
|
|
87
|
+
if (!config) {
|
|
88
|
+
console.log("\u274C Failed to reset configuration file!");
|
|
89
|
+
process.exit(1);
|
|
90
|
+
} else console.log("\u2714 Configuration reset to default values");
|
|
91
|
+
const configPath = path.join(cwd, "ui.config.json");
|
|
92
|
+
await fs.writeJson(configPath, config, { spaces: 4 });
|
|
93
|
+
console.log("\u2714 Configuration reset to default values");
|
|
94
|
+
} else {
|
|
95
|
+
console.log("\u274C Configuration reset cancelled");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/commands/help.ts
|
|
100
|
+
async function showHelp() {
|
|
101
|
+
console.log("\u2714 Help information!");
|
|
102
|
+
console.log("\u{1F680} SGX4U UI - Component Library CLI");
|
|
103
|
+
console.log("\n" + "=".repeat(50) + "\n");
|
|
104
|
+
console.log("\u{1F4D6} OVERVIEW");
|
|
105
|
+
console.log(" SGX4U UI is a modern component library for modular UI development");
|
|
106
|
+
console.log("\n\u{1F527} AVAILABLE COMMANDS");
|
|
107
|
+
console.log(" 1. sgx4u-ui init - Initialize SGX4U UI in your project");
|
|
108
|
+
console.log(" 2. sgx4u-ui add <component-name> - Install a component");
|
|
109
|
+
console.log(" 3. sgx4u-ui list - Show available components");
|
|
110
|
+
console.log(" 4. sgx4u-ui info <component-name> - Show information about a component");
|
|
111
|
+
console.log(" 5. sgx4u-ui config - Show configuration");
|
|
112
|
+
console.log(" 6. sgx4u-ui help - Show help information");
|
|
113
|
+
console.log("\n\u2728 KEY FEATURES");
|
|
114
|
+
console.log(" \u2604\uFE0F Access raw code - Flexibility and freedom from external dependencies");
|
|
115
|
+
console.log(" \u{1F3AF} Individual Component Installation - Install only what you need");
|
|
116
|
+
console.log(" \u{1F3A8} Tailwind CSS Integration - Seamless theme and styling setup");
|
|
117
|
+
console.log(" \u{1F4DD} TypeScript Support - Full TypeScript compatibility");
|
|
118
|
+
console.log(" \u26A1 Fast & Reliable - Optimized for developer experience");
|
|
119
|
+
console.log("\n\u{1F517} USEFUL LINKS");
|
|
120
|
+
console.log(" \u2022 Documentation: https://ui.sgx4u.com");
|
|
121
|
+
console.log(" \u2022 GitHub Repository: https://github.com/sgx4u/sgx4u-ui");
|
|
122
|
+
console.log(" \u2022 Support: https://ui.sgx4u.com/support");
|
|
123
|
+
console.log("\n\u{1F4A1} TIPS");
|
|
124
|
+
console.log(
|
|
125
|
+
' \u2022 Run "sgx4u-ui init" first to set up your project properly and avoid overwriting existing configuration'
|
|
126
|
+
);
|
|
127
|
+
console.log(' \u2022 Use "sgx4u-ui list" to explore available components');
|
|
128
|
+
console.log("\n\u2753 NEED MORE HELP?");
|
|
129
|
+
console.log(" For more details please visit the documentation or reach out to me at sgx2050@gmail.com");
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/commands/info.ts
|
|
133
|
+
import ora2 from "ora";
|
|
134
|
+
async function showComponentInfo(componentName) {
|
|
135
|
+
try {
|
|
136
|
+
const cwd = process.cwd();
|
|
137
|
+
const configSpinner = ora2(" Checking...").start();
|
|
138
|
+
if (!componentName || !componentName.trim()) {
|
|
139
|
+
configSpinner.fail();
|
|
140
|
+
console.log("\u274C Component name is required!");
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
const config = await getConfig(cwd);
|
|
144
|
+
if (!config) {
|
|
145
|
+
configSpinner.fail();
|
|
146
|
+
console.log('\u274C No configuration found! Please run "sgx4u-ui init" first.');
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
const component = await fetchComponent({ componentName, projectType: config.environment });
|
|
150
|
+
if (!component) {
|
|
151
|
+
configSpinner.fail();
|
|
152
|
+
console.log(`\u274C Component "${componentName}" not found!`);
|
|
153
|
+
console.log('\u{1F4A1} Use "sgx4u-ui list" to see available components.');
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
configSpinner.succeed();
|
|
157
|
+
console.log(`\u{1F4CB} Component Information: ${component.name}`);
|
|
158
|
+
console.log("\n" + "=".repeat(50) + "\n");
|
|
159
|
+
console.log(`\u{1F680} Installation Command:`);
|
|
160
|
+
console.log(` sgx4u-ui add ${component.name}`);
|
|
161
|
+
console.log(`\u{1F4DD} Description:`);
|
|
162
|
+
console.log(` ${component.description}`);
|
|
163
|
+
console.log(`\u{1F4C1} Files:`);
|
|
164
|
+
if (Array.isArray(component.files) && component.files.length > 0) {
|
|
165
|
+
component.files.forEach((file, index) => {
|
|
166
|
+
console.log(
|
|
167
|
+
` ${index + 1}. ${file.name}
|
|
168
|
+
Source: ${file.path}
|
|
169
|
+
Output: ${file.outputPath}`
|
|
170
|
+
);
|
|
171
|
+
});
|
|
172
|
+
} else {
|
|
173
|
+
console.log(" No files found for this component.");
|
|
174
|
+
}
|
|
175
|
+
console.log("\u{1F4E6} Package Dependencies:");
|
|
176
|
+
if (Array.isArray(component.dependencies) && component.dependencies.length > 0) {
|
|
177
|
+
component.dependencies.forEach((dep, index) => console.log(` ${index + 1}. ${dep}`));
|
|
178
|
+
} else {
|
|
179
|
+
console.log(" No external dependencies required.");
|
|
180
|
+
}
|
|
181
|
+
process.exit(1);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
console.error(`\u274C Error: ${error}`);
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/cli.ts
|
|
189
|
+
var program = new Command();
|
|
190
|
+
program.name("sgx4u-ui").description("CLI tool for installing SGX4U UI components").version("1.0.0");
|
|
191
|
+
program.command("init").description("Initialize SGX4U UI in your project").action(initConfig);
|
|
192
|
+
program.command("add").description("Add a component to your project").argument("<component>", "Component name to add (e.g., button, input)").action(addComponent);
|
|
193
|
+
program.command("list").description("List all available components").action(listComponents);
|
|
194
|
+
program.command("info").description("Show detailed information about a specific component").argument("<component>", "Component name to get info about").action(showComponentInfo);
|
|
195
|
+
program.command("config").description("Manage configuration settings").action(manageConfig);
|
|
196
|
+
program.command("help").description("Show comprehensive help information").action(showHelp);
|
|
197
|
+
program.on("--help", () => {
|
|
198
|
+
console.log("\n\u{1F4A1} For detailed help, run: sgx4u-ui help");
|
|
199
|
+
});
|
|
200
|
+
program.parse();
|