@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/dist/bin.cjs ADDED
@@ -0,0 +1,1218 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+
29
+ // node_modules/.pnpm/tsup@8.5.1_postcss@8.4.31_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js
30
+ var init_cjs_shims = __esm({
31
+ "node_modules/.pnpm/tsup@8.5.1_postcss@8.4.31_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js"() {
32
+ "use strict";
33
+ }
34
+ });
35
+
36
+ // src/commands/utils/alias.util.ts
37
+ async function detectAlias(cwd) {
38
+ const configFiles = ["tsconfig.json", "jsconfig.json"];
39
+ for (const file of configFiles) {
40
+ const configPath = import_path.default.join(cwd, file);
41
+ if (!import_fs_extra.default.existsSync(configPath)) continue;
42
+ const config = await import_fs_extra.default.readJson(configPath);
43
+ const paths = config?.compilerOptions?.paths;
44
+ if (!paths || typeof paths !== "object") continue;
45
+ for (const [alias, targets] of Object.entries(paths)) {
46
+ if (!alias.endsWith("/*")) continue;
47
+ if (!Array.isArray(targets) || !targets[0]) continue;
48
+ const prefix = alias.replace("/*", "");
49
+ const baseDir = targets[0].replace("/*", "");
50
+ return { enabled: true, prefix, baseDir };
51
+ }
52
+ }
53
+ return null;
54
+ }
55
+ var import_fs_extra, import_path;
56
+ var init_alias_util = __esm({
57
+ "src/commands/utils/alias.util.ts"() {
58
+ "use strict";
59
+ init_cjs_shims();
60
+ import_fs_extra = __toESM(require("fs-extra"), 1);
61
+ import_path = __toESM(require("path"), 1);
62
+ }
63
+ });
64
+
65
+ // src/commands/utils/config.util.ts
66
+ async function getConfig(cwd) {
67
+ try {
68
+ const configPath = import_path2.default.resolve(cwd, "ui.config.json");
69
+ const configExists = await import_fs_extra2.default.pathExists(configPath);
70
+ if (configExists) return await import_fs_extra2.default.readJson(configPath);
71
+ return null;
72
+ } catch {
73
+ return null;
74
+ }
75
+ }
76
+ async function createConfig({
77
+ cwd,
78
+ projectInfo
79
+ }) {
80
+ try {
81
+ const detectedDir = await detectUIDirectory(cwd);
82
+ const { uiDir, environment, typescript } = await import_inquirer.default.prompt([
83
+ {
84
+ type: "input",
85
+ name: "uiDir",
86
+ message: "Where would you like to add UI components?",
87
+ default: detectedDir,
88
+ validate: (input) => {
89
+ if (!input.trim()) return "Please enter a valid directory path.";
90
+ return true;
91
+ }
92
+ },
93
+ {
94
+ type: "list",
95
+ name: "environment",
96
+ message: "Which environment are you using?",
97
+ choices: [
98
+ { name: "React", value: "react" },
99
+ { name: "Next.js", value: "next" }
100
+ ],
101
+ default: projectInfo.project
102
+ },
103
+ {
104
+ type: "confirm",
105
+ name: "typescript",
106
+ message: "Do you want to use TypeScript?",
107
+ default: projectInfo.hasTypeScript
108
+ }
109
+ ]);
110
+ const finalUiPath = uiDir.startsWith("/") ? uiDir : `./${uiDir}`;
111
+ const aliasInfo = await detectAlias(cwd);
112
+ const aliases = aliasInfo ? {
113
+ [aliasInfo.prefix]: aliasInfo.baseDir,
114
+ [`${aliasInfo.prefix}/ui`]: finalUiPath,
115
+ [`${aliasInfo.prefix}/elements`]: `${finalUiPath}/elements`,
116
+ [`${aliasInfo.prefix}/modules`]: `${finalUiPath}/modules`,
117
+ [`${aliasInfo.prefix}/helpers`]: `${finalUiPath}/helpers`,
118
+ [`${aliasInfo.prefix}/hooks`]: `${finalUiPath}/hooks`,
119
+ [`${aliasInfo.prefix}/utils`]: `${finalUiPath}/utils`
120
+ } : {
121
+ ui: finalUiPath,
122
+ elements: `${finalUiPath}/elements`,
123
+ modules: `${finalUiPath}/modules`,
124
+ helpers: `${finalUiPath}/helpers`,
125
+ hooks: `${finalUiPath}/hooks`,
126
+ utils: `${finalUiPath}/utils`
127
+ };
128
+ const config = {
129
+ uiDir: finalUiPath,
130
+ environment,
131
+ typescript,
132
+ aliases,
133
+ registry: "https://registry.npmjs.org"
134
+ };
135
+ const configPath = import_path2.default.join(cwd, "ui.config.json");
136
+ await import_fs_extra2.default.writeJson(configPath, config, { spaces: 4 });
137
+ return config;
138
+ } catch {
139
+ return null;
140
+ }
141
+ }
142
+ async function detectUIDirectory(cwd) {
143
+ const srcUiPath = import_path2.default.join(cwd, "src");
144
+ if (await import_fs_extra2.default.pathExists(srcUiPath)) return "src/ui";
145
+ return "ui";
146
+ }
147
+ var import_fs_extra2, import_inquirer, import_path2;
148
+ var init_config_util = __esm({
149
+ "src/commands/utils/config.util.ts"() {
150
+ "use strict";
151
+ init_cjs_shims();
152
+ import_fs_extra2 = __toESM(require("fs-extra"), 1);
153
+ import_inquirer = __toESM(require("inquirer"), 1);
154
+ import_path2 = __toESM(require("path"), 1);
155
+ init_alias_util();
156
+ }
157
+ });
158
+
159
+ // src/commands/utils/package.util.ts
160
+ async function getProjectInfo(cwd) {
161
+ const hasReact = await isPackageInstalled({ packageName: "react", cwd });
162
+ const hasNextJS = await isPackageInstalled({ packageName: "next", cwd });
163
+ const hasTypeScript = await isPackageInstalled({ packageName: "typescript", cwd });
164
+ const tailwindVersion = await getTailwindVersion(cwd);
165
+ const lucideVersion = await getPackageVersion({ packageName: "lucide-react", cwd });
166
+ const packageManager = await detectPackageManager(cwd);
167
+ const project = hasNextJS ? "next" : hasReact ? "react" : "none";
168
+ return { project, hasTypeScript, tailwindVersion, lucideVersion, packageManager };
169
+ }
170
+ async function isPackageInstalled({ packageName, cwd }) {
171
+ try {
172
+ const packageJsonPath = import_path3.default.join(cwd, "package.json");
173
+ if (!await import_fs_extra3.default.pathExists(packageJsonPath)) return false;
174
+ const packageJson = await import_fs_extra3.default.readJson(packageJsonPath);
175
+ const allDeps = {
176
+ ...packageJson.dependencies,
177
+ ...packageJson.devDependencies,
178
+ ...packageJson.peerDependencies
179
+ };
180
+ return Object.keys(allDeps).some((dependency) => dependency === packageName);
181
+ } catch {
182
+ return false;
183
+ }
184
+ }
185
+ async function installDependencies({
186
+ cwd,
187
+ packageManager,
188
+ dependencies
189
+ }) {
190
+ try {
191
+ const installCommand = getInstallCommand({ packageManager, packages: dependencies, isDev: false });
192
+ (0, import_child_process.execSync)(installCommand, { cwd, stdio: "pipe", encoding: "utf8" });
193
+ return true;
194
+ } catch {
195
+ return false;
196
+ }
197
+ }
198
+ async function getPackageVersion({ packageName, cwd }) {
199
+ const packageJsonPath = import_path3.default.join(cwd, "package.json");
200
+ if (!await import_fs_extra3.default.pathExists(packageJsonPath)) return null;
201
+ const packageJson = await import_fs_extra3.default.readJson(packageJsonPath);
202
+ const allDeps = {
203
+ ...packageJson.dependencies,
204
+ ...packageJson.devDependencies,
205
+ ...packageJson.peerDependencies
206
+ };
207
+ const rawVersion = allDeps[packageName];
208
+ if (rawVersion == null || typeof rawVersion !== "string") return null;
209
+ const packageVersion = rawVersion.replace(/^[\^~>=]+/, "").split(".");
210
+ if (packageVersion.length === 0 || packageVersion[0] === "") return null;
211
+ const version = packageVersion[1] != null ? `${packageVersion[0]}.${packageVersion[1]}` : packageVersion[0];
212
+ const parsed = Number.parseFloat(version);
213
+ return Number.isNaN(parsed) ? null : parsed;
214
+ }
215
+ async function detectPackageManager(cwd) {
216
+ try {
217
+ const pnpmLockPath = import_path3.default.join(cwd, "pnpm-lock.yaml");
218
+ if (await import_fs_extra3.default.pathExists(pnpmLockPath)) return "pnpm";
219
+ const yarnLockPath = import_path3.default.join(cwd, "yarn.lock");
220
+ if (await import_fs_extra3.default.pathExists(yarnLockPath)) return "yarn";
221
+ const bunLockPath = import_path3.default.join(cwd, "bun.lockb");
222
+ if (await import_fs_extra3.default.pathExists(bunLockPath)) return "bun";
223
+ const npmLockPath = import_path3.default.join(cwd, "package-lock.json");
224
+ if (await import_fs_extra3.default.pathExists(npmLockPath)) return "npm";
225
+ const packageJsonPath = import_path3.default.join(cwd, "package.json");
226
+ if (await import_fs_extra3.default.pathExists(packageJsonPath)) {
227
+ try {
228
+ const packageJson = await import_fs_extra3.default.readJson(packageJsonPath);
229
+ if (packageJson.packageManager) {
230
+ const packageManager = packageJson.packageManager;
231
+ if (packageManager.includes("pnpm")) return "pnpm";
232
+ if (packageManager.includes("yarn")) return "yarn";
233
+ if (packageManager.includes("bun")) return "bun";
234
+ if (packageManager.includes("npm")) return "npm";
235
+ }
236
+ } catch {
237
+ }
238
+ }
239
+ try {
240
+ (0, import_child_process.execSync)("pnpm --version", { stdio: "pipe", cwd });
241
+ return "pnpm";
242
+ } catch {
243
+ try {
244
+ (0, import_child_process.execSync)("yarn --version", { stdio: "pipe", cwd });
245
+ return "yarn";
246
+ } catch {
247
+ try {
248
+ (0, import_child_process.execSync)("bun --version", { stdio: "pipe", cwd });
249
+ return "bun";
250
+ } catch {
251
+ return "npm";
252
+ }
253
+ }
254
+ }
255
+ } catch {
256
+ return "npm";
257
+ }
258
+ }
259
+ function getInstallCommand({
260
+ packageManager,
261
+ packages,
262
+ isDev
263
+ }) {
264
+ const packagesStr = packages.join(" ");
265
+ switch (packageManager) {
266
+ case "pnpm":
267
+ return isDev ? `pnpm add -D ${packagesStr}` : `pnpm add ${packagesStr}`;
268
+ case "yarn":
269
+ return isDev ? `yarn add -D ${packagesStr}` : `yarn add ${packagesStr}`;
270
+ case "bun":
271
+ return isDev ? `bun add -d ${packagesStr}` : `bun add ${packagesStr}`;
272
+ default:
273
+ return isDev ? `npm install --save-dev ${packagesStr}` : `npm install ${packagesStr}`;
274
+ }
275
+ }
276
+ async function getTailwindVersion(cwd) {
277
+ const packageJsonPath = import_path3.default.join(cwd, "package.json");
278
+ if (!await import_fs_extra3.default.pathExists(packageJsonPath)) return "none";
279
+ const packageJson = await import_fs_extra3.default.readJson(packageJsonPath);
280
+ const allDeps = {
281
+ ...packageJson.dependencies,
282
+ ...packageJson.devDependencies,
283
+ ...packageJson.peerDependencies
284
+ };
285
+ if (allDeps["tailwindcss"] && (allDeps["tailwindcss"].startsWith("4") || allDeps["tailwindcss"].startsWith("^4"))) {
286
+ return "v4";
287
+ }
288
+ return "none";
289
+ }
290
+ var import_fs_extra3, import_child_process, import_path3;
291
+ var init_package_util = __esm({
292
+ "src/commands/utils/package.util.ts"() {
293
+ "use strict";
294
+ init_cjs_shims();
295
+ import_fs_extra3 = __toESM(require("fs-extra"), 1);
296
+ import_child_process = require("child_process");
297
+ import_path3 = __toESM(require("path"), 1);
298
+ }
299
+ });
300
+
301
+ // src/commands/utils/registry.util.ts
302
+ async function fetchRegistry(projectType) {
303
+ try {
304
+ let registryEnvironment;
305
+ if (projectType === "next" || projectType === "react") registryEnvironment = "react";
306
+ else return null;
307
+ const registryFile = `registry.${registryEnvironment}.json`;
308
+ const registryUrl = `${GITHUB_RAW_BASE}/src/content/${registryFile}`;
309
+ const response = await fetch(registryUrl);
310
+ if (!response.ok) return null;
311
+ const registry = await response.json();
312
+ return registry;
313
+ } catch {
314
+ return null;
315
+ }
316
+ }
317
+ async function fetchComponent({
318
+ componentName,
319
+ projectType
320
+ }) {
321
+ try {
322
+ if (projectType === "none") return null;
323
+ const registry = await fetchRegistry(projectType);
324
+ if (!registry) return null;
325
+ for (const [registryKey, component] of Object.entries(registry.components)) {
326
+ if (registryKey === componentName) {
327
+ return {
328
+ ...component,
329
+ name: registryKey
330
+ };
331
+ }
332
+ }
333
+ return null;
334
+ } catch {
335
+ return null;
336
+ }
337
+ }
338
+ async function fetchComponentFile(filePath) {
339
+ try {
340
+ const fileUrl = `${GITHUB_RAW_BASE}/${filePath}`;
341
+ const response = await fetch(fileUrl);
342
+ if (!response.ok) return null;
343
+ return await response.text();
344
+ } catch {
345
+ console.log(`\u26A0\uFE0F Failed to fetch file from GitHub: ${filePath}`);
346
+ return null;
347
+ }
348
+ }
349
+ var GITHUB_REPO, GITHUB_BRANCH, GITHUB_RAW_BASE;
350
+ var init_registry_util = __esm({
351
+ "src/commands/utils/registry.util.ts"() {
352
+ "use strict";
353
+ init_cjs_shims();
354
+ GITHUB_REPO = "sgx4u/sgx4u-ui";
355
+ GITHUB_BRANCH = "production";
356
+ GITHUB_RAW_BASE = `https://raw.githubusercontent.com/${GITHUB_REPO}/${GITHUB_BRANCH}`;
357
+ }
358
+ });
359
+
360
+ // src/commands/validation/data.validate.ts
361
+ function validateComponentName(name) {
362
+ if (!name || name.trim().length < 1 || typeof name !== "string") return false;
363
+ if (!/^[a-zA-Z0-9-_.]+$/.test(name)) return false;
364
+ return true;
365
+ }
366
+ function validateDirectory(directory) {
367
+ if (!directory || directory.trim().length < 1 || typeof directory !== "string") return false;
368
+ if (directory.includes("..")) return false;
369
+ if (directory.includes("\\") || directory.includes("//")) return false;
370
+ return true;
371
+ }
372
+ var init_data_validate = __esm({
373
+ "src/commands/validation/data.validate.ts"() {
374
+ "use strict";
375
+ init_cjs_shims();
376
+ }
377
+ });
378
+
379
+ // src/commands/add.ts
380
+ async function addComponent(componentName) {
381
+ try {
382
+ const cwd = process.cwd();
383
+ const validationSpinner = (0, import_ora.default)(" Validating...").start();
384
+ if (!validateComponentName(componentName)) {
385
+ validationSpinner.fail();
386
+ console.log("\u274C Component name is invalid!");
387
+ process.exit(1);
388
+ }
389
+ const config = await getConfig(cwd);
390
+ if (!config) {
391
+ validationSpinner.fail();
392
+ console.log("\u274C Failed to get configuration! Please initialize SGX4U UI first!");
393
+ process.exit(1);
394
+ }
395
+ const projectInfo = await getProjectInfo(cwd);
396
+ if (projectInfo.project === "none") {
397
+ console.log("\u274C No supported project detected!");
398
+ process.exit(1);
399
+ }
400
+ validationSpinner.succeed();
401
+ const installingSpinner = (0, import_ora.default)(` Installing ${componentName}`).start();
402
+ const component = await fetchComponent({ componentName, projectType: config.environment });
403
+ if (!component) {
404
+ installingSpinner.fail();
405
+ console.log("\u274C Failed to fetch component!");
406
+ process.exit(1);
407
+ }
408
+ const uiDirectory = config.uiDir;
409
+ const normalizedUiDirectory = uiDirectory.replace(/^[./\\]+/, "");
410
+ if (!normalizedUiDirectory || !validateDirectory(normalizedUiDirectory)) {
411
+ installingSpinner.fail();
412
+ console.log("\u274C Invalid directory!");
413
+ process.exit(1);
414
+ }
415
+ const baseDirectory = import_path4.default.join(cwd, normalizedUiDirectory);
416
+ const allFilesToInstall = /* @__PURE__ */ new Map();
417
+ const existingFiles = [];
418
+ const filesToProcess = component.files;
419
+ for (const file of filesToProcess) {
420
+ const normalizedOutputPath = file.outputPath.replace(/^ui[\\/]/, "");
421
+ const targetPath = import_path4.default.join(baseDirectory, normalizedOutputPath);
422
+ if (await import_fs_extra4.default.pathExists(targetPath)) {
423
+ existingFiles.push(file.outputPath);
424
+ } else {
425
+ allFilesToInstall.set(file.outputPath, {
426
+ filePath: file.path,
427
+ targetPath
428
+ });
429
+ }
430
+ }
431
+ if (existingFiles.length > 0) {
432
+ installingSpinner.stop();
433
+ console.log(`\u26A0\uFE0F Skipping existing files:`);
434
+ existingFiles.forEach((file) => console.log(` \u2022 ${file}`));
435
+ }
436
+ const installedFiles = [];
437
+ for (const [relativePath, { filePath, targetPath }] of allFilesToInstall) {
438
+ try {
439
+ const content = await fetchComponentFile(filePath);
440
+ if (!content) {
441
+ installingSpinner.fail();
442
+ console.log(`\u26A0\uFE0F Failed to fetch ${relativePath}`);
443
+ process.exit(1);
444
+ }
445
+ await import_fs_extra4.default.ensureDir(import_path4.default.dirname(targetPath));
446
+ await import_fs_extra4.default.writeFile(targetPath, content, "utf8");
447
+ installedFiles.push(relativePath);
448
+ } catch (error) {
449
+ installingSpinner.fail();
450
+ console.log(`\u26A0\uFE0F Failed to install ${relativePath}: ${error}`);
451
+ process.exit(1);
452
+ }
453
+ }
454
+ if (installedFiles.length === 0) {
455
+ installingSpinner.succeed();
456
+ console.log(`\u2714 ${componentName} is already up to date!`);
457
+ process.exit(1);
458
+ }
459
+ installingSpinner.succeed();
460
+ console.log("\u{1F4C1} Added files:");
461
+ installedFiles.forEach((file) => console.log(` \u2022 ${file}`));
462
+ const allPackageDependencies = new Set(component.dependencies);
463
+ if (allPackageDependencies.size > 0) {
464
+ console.log("\u{1F4E6} Dependencies detected:");
465
+ const installedDependencies = [];
466
+ const missingDependencies = [];
467
+ for (const dependency of Array.from(allPackageDependencies)) {
468
+ if (await isPackageInstalled({ packageName: dependency, cwd })) installedDependencies.push(dependency);
469
+ else missingDependencies.push(dependency);
470
+ }
471
+ if (installedDependencies.length > 0) {
472
+ console.log("\u2714 Already installed dependencies:");
473
+ installedDependencies.forEach((dep) => console.log(` \u2022 ${dep}`));
474
+ }
475
+ if (missingDependencies.length > 0) {
476
+ console.log("\u274C Missing dependencies:");
477
+ missingDependencies.forEach((dep) => console.log(` \u2022 ${dep}`));
478
+ const { installDeps } = await import_inquirer2.default.prompt([
479
+ {
480
+ type: "confirm",
481
+ name: "installDeps",
482
+ message: `Auto install missing dependencies using ${projectInfo.packageManager}?`,
483
+ default: true
484
+ }
485
+ ]);
486
+ if (installDeps) {
487
+ console.log(`\u{1F4E6} Installing missing dependencies using ${projectInfo.packageManager}...`);
488
+ const dependencyInstalled = await installDependencies({
489
+ cwd,
490
+ packageManager: projectInfo.packageManager,
491
+ dependencies: missingDependencies
492
+ });
493
+ if (dependencyInstalled) console.log("\u2714 Missing dependencies installed successfully!");
494
+ else console.log("\u274C Failed to install missing dependencies!");
495
+ } else {
496
+ console.log("\u26A0\uFE0F Please install missing dependencies manually:");
497
+ missingDependencies.forEach((dep) => console.log(` \u2022 ${dep}`));
498
+ }
499
+ } else {
500
+ console.log("\u2714 All dependencies are already installed!");
501
+ }
502
+ }
503
+ process.exit(1);
504
+ } catch (error) {
505
+ console.error(`\u274C Error: ${error}`);
506
+ process.exit(1);
507
+ }
508
+ }
509
+ var import_fs_extra4, import_inquirer2, import_ora, import_path4;
510
+ var init_add = __esm({
511
+ "src/commands/add.ts"() {
512
+ "use strict";
513
+ init_cjs_shims();
514
+ import_fs_extra4 = __toESM(require("fs-extra"), 1);
515
+ import_inquirer2 = __toESM(require("inquirer"), 1);
516
+ import_ora = __toESM(require("ora"), 1);
517
+ import_path4 = __toESM(require("path"), 1);
518
+ init_config_util();
519
+ init_package_util();
520
+ init_registry_util();
521
+ init_data_validate();
522
+ }
523
+ });
524
+
525
+ // src/commands/config.ts
526
+ async function manageConfig() {
527
+ try {
528
+ const cwd = process.cwd();
529
+ const configSpinner = (0, import_ora2.default)(" Loading configuration...").start();
530
+ const config = await getConfig(cwd);
531
+ if (!config) {
532
+ configSpinner.fail();
533
+ console.log('\u274C No configuration found. Please run "sgx4u-ui init" first!');
534
+ process.exit(1);
535
+ }
536
+ configSpinner.succeed();
537
+ console.log(`\u2699\uFE0F Configuration Management`);
538
+ const actionChoices = [
539
+ { name: "View full configuration", value: "view" },
540
+ { name: "Reset configuration", value: "reset" },
541
+ { name: "Exit", value: "exit" }
542
+ ];
543
+ actionChoices.forEach((choice, index) => {
544
+ console.log(` ${index + 1}) ${choice.name}`);
545
+ });
546
+ console.log("");
547
+ const { action } = await import_inquirer3.default.prompt([
548
+ {
549
+ type: "rawlist",
550
+ name: "action",
551
+ message: "What would you like to do?",
552
+ choices: actionChoices
553
+ }
554
+ ]);
555
+ switch (action) {
556
+ case "view":
557
+ await viewFullConfig(config);
558
+ process.exit(1);
559
+ break;
560
+ case "reset":
561
+ await resetConfig(cwd);
562
+ process.exit(1);
563
+ break;
564
+ case "exit":
565
+ console.log("\u{1F44B} Goodbye!");
566
+ process.exit(1);
567
+ break;
568
+ }
569
+ } catch (error) {
570
+ console.error(`\u274C Error: ${error}`);
571
+ process.exit(1);
572
+ }
573
+ }
574
+ async function viewFullConfig(config) {
575
+ console.log(`\u{1F4C4} Full Configuration:`);
576
+ console.log(JSON.stringify(config, null, 2));
577
+ }
578
+ async function resetConfig(cwd) {
579
+ const { confirm } = await import_inquirer3.default.prompt([
580
+ {
581
+ type: "confirm",
582
+ name: "confirm",
583
+ message: "Are you sure you want to reset the configuration to default values?",
584
+ default: false
585
+ }
586
+ ]);
587
+ if (confirm) {
588
+ const projectInfo = await getProjectInfo(cwd);
589
+ if (projectInfo.project === "none") {
590
+ console.log("\u274C No supported project detected!");
591
+ process.exit(1);
592
+ }
593
+ const config = await createConfig({ cwd, projectInfo });
594
+ if (!config) {
595
+ console.log("\u274C Failed to reset configuration file!");
596
+ process.exit(1);
597
+ } else console.log("\u2714 Configuration reset to default values");
598
+ const configPath = import_path5.default.join(cwd, "ui.config.json");
599
+ await import_fs_extra5.default.writeJson(configPath, config, { spaces: 4 });
600
+ console.log("\u2714 Configuration reset to default values");
601
+ } else {
602
+ console.log("\u274C Configuration reset cancelled");
603
+ }
604
+ }
605
+ var import_fs_extra5, import_inquirer3, import_ora2, import_path5;
606
+ var init_config = __esm({
607
+ "src/commands/config.ts"() {
608
+ "use strict";
609
+ init_cjs_shims();
610
+ import_fs_extra5 = __toESM(require("fs-extra"), 1);
611
+ import_inquirer3 = __toESM(require("inquirer"), 1);
612
+ import_ora2 = __toESM(require("ora"), 1);
613
+ import_path5 = __toESM(require("path"), 1);
614
+ init_config_util();
615
+ init_package_util();
616
+ }
617
+ });
618
+
619
+ // src/commands/help.ts
620
+ async function showHelp() {
621
+ console.log("\u2714 Help information!");
622
+ console.log("\u{1F680} SGX4U UI - Component Library CLI");
623
+ console.log("\n" + "=".repeat(50) + "\n");
624
+ console.log("\u{1F4D6} OVERVIEW");
625
+ console.log(" SGX4U UI is a modern component library for modular UI development");
626
+ console.log("\n\u{1F527} AVAILABLE COMMANDS");
627
+ console.log(" 1. sgx4u-ui init - Initialize SGX4U UI in your project");
628
+ console.log(" 2. sgx4u-ui add <component-name> - Install a component");
629
+ console.log(" 3. sgx4u-ui list - Show available components");
630
+ console.log(" 4. sgx4u-ui info <component-name> - Show information about a component");
631
+ console.log(" 5. sgx4u-ui config - Show configuration");
632
+ console.log(" 6. sgx4u-ui help - Show help information");
633
+ console.log("\n\u2728 KEY FEATURES");
634
+ console.log(" \u2604\uFE0F Access raw code - Flexibility and freedom from external dependencies");
635
+ console.log(" \u{1F3AF} Individual Component Installation - Install only what you need");
636
+ console.log(" \u{1F3A8} Tailwind CSS Integration - Seamless theme and styling setup");
637
+ console.log(" \u{1F4DD} TypeScript Support - Full TypeScript compatibility");
638
+ console.log(" \u26A1 Fast & Reliable - Optimized for developer experience");
639
+ console.log("\n\u{1F517} USEFUL LINKS");
640
+ console.log(" \u2022 Documentation: https://ui.sgx4u.com");
641
+ console.log(" \u2022 GitHub Repository: https://github.com/sgx4u/sgx4u-ui");
642
+ console.log(" \u2022 Support: https://ui.sgx4u.com/support");
643
+ console.log("\n\u{1F4A1} TIPS");
644
+ console.log(
645
+ ' \u2022 Run "sgx4u-ui init" first to set up your project properly and avoid overwriting existing configuration'
646
+ );
647
+ console.log(' \u2022 Use "sgx4u-ui list" to explore available components');
648
+ console.log("\n\u2753 NEED MORE HELP?");
649
+ console.log(" For more details please visit the documentation or reach out to me at sgx2050@gmail.com");
650
+ }
651
+ var init_help = __esm({
652
+ "src/commands/help.ts"() {
653
+ "use strict";
654
+ init_cjs_shims();
655
+ }
656
+ });
657
+
658
+ // src/commands/info.ts
659
+ async function showComponentInfo(componentName) {
660
+ try {
661
+ const cwd = process.cwd();
662
+ const configSpinner = (0, import_ora3.default)(" Checking...").start();
663
+ if (!componentName || !componentName.trim()) {
664
+ configSpinner.fail();
665
+ console.log("\u274C Component name is required!");
666
+ process.exit(1);
667
+ }
668
+ const config = await getConfig(cwd);
669
+ if (!config) {
670
+ configSpinner.fail();
671
+ console.log('\u274C No configuration found! Please run "sgx4u-ui init" first.');
672
+ process.exit(1);
673
+ }
674
+ const component = await fetchComponent({ componentName, projectType: config.environment });
675
+ if (!component) {
676
+ configSpinner.fail();
677
+ console.log(`\u274C Component "${componentName}" not found!`);
678
+ console.log('\u{1F4A1} Use "sgx4u-ui list" to see available components.');
679
+ process.exit(1);
680
+ }
681
+ configSpinner.succeed();
682
+ console.log(`\u{1F4CB} Component Information: ${component.name}`);
683
+ console.log("\n" + "=".repeat(50) + "\n");
684
+ console.log(`\u{1F680} Installation Command:`);
685
+ console.log(` sgx4u-ui add ${component.name}`);
686
+ console.log(`\u{1F4DD} Description:`);
687
+ console.log(` ${component.description}`);
688
+ console.log(`\u{1F4C1} Files:`);
689
+ if (Array.isArray(component.files) && component.files.length > 0) {
690
+ component.files.forEach((file, index) => {
691
+ console.log(
692
+ ` ${index + 1}. ${file.name}
693
+ Source: ${file.path}
694
+ Output: ${file.outputPath}`
695
+ );
696
+ });
697
+ } else {
698
+ console.log(" No files found for this component.");
699
+ }
700
+ console.log("\u{1F4E6} Package Dependencies:");
701
+ if (Array.isArray(component.dependencies) && component.dependencies.length > 0) {
702
+ component.dependencies.forEach((dep, index) => console.log(` ${index + 1}. ${dep}`));
703
+ } else {
704
+ console.log(" No external dependencies required.");
705
+ }
706
+ process.exit(1);
707
+ } catch (error) {
708
+ console.error(`\u274C Error: ${error}`);
709
+ process.exit(1);
710
+ }
711
+ }
712
+ var import_ora3;
713
+ var init_info = __esm({
714
+ "src/commands/info.ts"() {
715
+ "use strict";
716
+ init_cjs_shims();
717
+ import_ora3 = __toESM(require("ora"), 1);
718
+ init_config_util();
719
+ init_registry_util();
720
+ }
721
+ });
722
+
723
+ // src/commands/data/theme-tailwind-v4.data.ts
724
+ var themeVariablesV4;
725
+ var init_theme_tailwind_v4_data = __esm({
726
+ "src/commands/data/theme-tailwind-v4.data.ts"() {
727
+ "use strict";
728
+ init_cjs_shims();
729
+ themeVariablesV4 = `@import 'tailwindcss';
730
+
731
+ @custom-variant dark (&:is(.dark *));
732
+
733
+ :root {
734
+ --background: oklch(100% 0 0); /* #ffffff */
735
+ --background-light: oklch(97% 0 0); /* #f5f5f5 */
736
+ --foreground: oklch(26.9% 0 0); /* #262626 */
737
+
738
+ --primary: oklch(26.9% 0 0); /* #262626 */
739
+ --primary-dark: oklch(14.5% 0 0); /* #0a0a0a */
740
+ --primary-light: oklch(70.8% 0 0); /* #a1a1a1 */
741
+ --primary-foreground: var(--background);
742
+
743
+ --secondary: oklch(51.1% 0.262 276.966); /* #4f39f6 */
744
+ --secondary-dark: oklch(45.7% 0.24 277.023); /* #432dd7 */
745
+ --secondary-light: oklch(93% 0.034 272.788); /* #e0e7ff */
746
+ --secondary-foreground: var(--background);
747
+
748
+ --success: oklch(72.3% 0.219 149.579); /* #00c950 */
749
+ --success-dark: oklch(62.7% 0.194 149.214); /* #00a63e */
750
+ --success-light: oklch(96.2% 0.044 156.743); /* #dcfce7 */
751
+ --success-foreground: var(--background);
752
+
753
+ --warn: oklch(82.8% 0.189 84.429); /* #ffb900 */
754
+ --warn-dark: oklch(76.9% 0.188 70.08); /* #fe9a00 */
755
+ --warn-light: oklch(96.2% 0.059 95.617); /* #fef3c6 */
756
+ --warn-foreground: var(--background);
757
+
758
+ --danger: oklch(63.7% 0.237 25.331); /* #fb2c36 */
759
+ --danger-dark: oklch(57.7% 0.245 27.325); /* #e7000b */
760
+ --danger-light: oklch(93.6% 0.032 17.717); /* #ffe2e2 */
761
+ --danger-foreground: var(--background);
762
+
763
+ --muted: oklch(87% 0 0); /* #d4d4d4 */
764
+ --muted-dark: oklch(70.8% 0 0); /* #a1a1a1 */
765
+ --muted-light: oklch(95.514% 0.00011 271.152); /* #f0f0f0 */
766
+ --muted-foreground: oklch(43.9% 0 0); /* #525252 */
767
+
768
+ --card: var(--background);
769
+
770
+ --light: var(--background);
771
+ --dark: var(--foreground);
772
+ --border: var(--muted-light);
773
+ --input-placeholder: oklch(70.8% 0 0); /* #a1a1a1 */
774
+
775
+ --radius: 0.5rem;
776
+ }
777
+
778
+ .dark {
779
+ --background: oklch(23.929% 0.00003 271.152); /* #1f1f1f */
780
+ --background-light: oklch(26.9% 0 0); /* #262626 */
781
+ --foreground: oklch(98.5% 0 0); /* #fafafa */
782
+
783
+ --primary: oklch(97% 0 0); /* #f5f5f5 */
784
+ --primary-dark: oklch(92.2% 0 0); /* #e5e5e5 */
785
+ --primary-light: oklch(98.5% 0 0); /* #fafafa */
786
+ --primary-foreground: var(--background);
787
+
788
+ --secondary: oklch(0.6009 0.1957 277.79); /* #696cf2 */
789
+ --secondary-dark: oklch(0.5348 0.2183 278.55); /* #5951e6 */
790
+ --secondary-light: oklch(93% 0.034 272.788); /* #e0e7ff */
791
+ --secondary-foreground: var(--foreground);
792
+
793
+ --success: oklch(0.8152 0.1685 152.67); /* #5be18c */
794
+ --success-dark: oklch(0.7665 0.2043 149.52); /* #25d566 */
795
+ --success-light: oklch(96.2% 0.044 156.743); /* #dcfce7 */
796
+ --success-foreground: var(--foreground);
797
+
798
+ --warn: oklch(82.8% 0.189 84.429); /* #ffb900 */
799
+ --warn-dark: oklch(76.9% 0.188 70.08); /* #fe9a00 */
800
+ --warn-light: oklch(96.2% 0.059 95.617); /* #fef3c6 */
801
+ --warn-foreground: var(--foreground);
802
+
803
+ --danger: oklch(0.7287 0.1531 21.55); /* #f97c7c */
804
+ --danger-dark: oklch(0.6605 0.190501 23.9375); /* #f15656 */
805
+ --danger-light: oklch(93.6% 0.032 17.717); /* #ffe2e2 */
806
+ --danger-foreground: var(--foreground);
807
+
808
+ --muted: oklch(43.9% 0 0); /* #525252 */
809
+ --muted-dark: oklch(37.1% 0 0); /* #404040 */
810
+ --muted-light: oklch(55.6% 0 0); /* #737373 */
811
+ --muted-foreground: oklch(97% 0.001 106.424); /* #f5f5f5 */
812
+
813
+ --card: var(--background);
814
+
815
+ --light: var(--foreground);
816
+ --dark: var(--background);
817
+ --border: var(--muted-light);
818
+ --input-placeholder: oklch(70.8% 0 0); /* #a1a1a1 */
819
+ }
820
+
821
+ @theme {
822
+ --breakpoint-mobile: 36rem;
823
+ --breakpoint-tablet: 48rem;
824
+ --breakpoint-laptop: 64rem;
825
+ --breakpoint-desktop: 80rem;
826
+ --breakpoint-wide: 90rem;
827
+
828
+ --container-mobile: 36rem;
829
+ --container-tablet: 48rem;
830
+ --container-laptop: 64rem;
831
+ --container-desktop: 80rem;
832
+ --container-wide: 90rem;
833
+
834
+ --text-xxs: 0.625rem;
835
+
836
+ @keyframes animate-gradient {
837
+ 0% {
838
+ background-position: 100% 50%;
839
+ }
840
+ to {
841
+ background-position: 0 50%;
842
+ }
843
+ }
844
+
845
+ @keyframes animate-heart-beat {
846
+ 0% {
847
+ box-shadow: 0 0 0 0px hsl(239, 83%, 68%);
848
+ }
849
+ 100% {
850
+ box-shadow: 0 0 0 10px hsl(239, 83%, 68%, 0);
851
+ }
852
+ }
853
+ }
854
+
855
+ @theme inline {
856
+ --color-background: var(--background);
857
+ --color-background-light: var(--background-light);
858
+ --color-foreground: var(--foreground);
859
+
860
+ --color-primary: var(--primary);
861
+ --color-primary-dark: var(--primary-dark);
862
+ --color-primary-light: var(--primary-light);
863
+ --color-primary-foreground: var(--primary-foreground);
864
+
865
+ --color-secondary: var(--secondary);
866
+ --color-secondary-dark: var(--secondary-dark);
867
+ --color-secondary-light: var(--secondary-light);
868
+ --color-secondary-foreground: var(--secondary-foreground);
869
+
870
+ --color-success: var(--success);
871
+ --color-success-dark: var(--success-dark);
872
+ --color-success-light: var(--success-light);
873
+ --color-success-foreground: var(--success-foreground);
874
+
875
+ --color-warn: var(--warn);
876
+ --color-warn-dark: var(--warn-dark);
877
+ --color-warn-light: var(--warn-light);
878
+ --color-warn-foreground: var(--warn-foreground);
879
+
880
+ --color-danger: var(--danger);
881
+ --color-danger-dark: var(--danger-dark);
882
+ --color-danger-light: var(--danger-light);
883
+ --color-danger-foreground: var(--danger-foreground);
884
+
885
+ --color-muted: var(--muted);
886
+ --color-muted-dark: var(--muted-dark);
887
+ --color-muted-light: var(--muted-light);
888
+ --color-muted-foreground: var(--muted-foreground);
889
+
890
+ --color-card: var(--card);
891
+
892
+ --color-light: var(--light);
893
+ --color-dark: var(--dark);
894
+ --color-border: var(--border);
895
+ --color-input-placeholder: var(--input-placeholder);
896
+
897
+ --radius-sm: calc(var(--radius) - 4px);
898
+ --radius-md: calc(var(--radius) - 2px);
899
+ --radius-lg: var(--radius);
900
+ --radius-xl: calc(var(--radius) + 4px);
901
+ }
902
+
903
+ @layer base {
904
+ * {
905
+ @apply scroll-m-24 border-border;
906
+ }
907
+
908
+ body {
909
+ @apply bg-background text-foreground;
910
+ }
911
+
912
+ ::-webkit-scrollbar {
913
+ @apply size-1;
914
+ }
915
+
916
+ ::-webkit-scrollbar-track {
917
+ @apply bg-muted-light;
918
+ }
919
+
920
+ ::-webkit-scrollbar-thumb {
921
+ @apply bg-muted-dark;
922
+ }
923
+
924
+ ::-webkit-scrollbar-thumb:hover {
925
+ @apply bg-muted-foreground/75;
926
+ }
927
+
928
+ /* Selection */
929
+ ::selection {
930
+ -webkit-text-fill-color: var(--background);
931
+ @apply bg-primary text-primary-foreground;
932
+ }
933
+ }
934
+
935
+ @layer utilities {
936
+ /* Animate wave background */
937
+ .animate-wave-bg {
938
+ background-image: linear-gradient(
939
+ 90deg,
940
+ rgb(238, 238, 238) 35%,
941
+ rgb(245, 245, 245) 50%,
942
+ rgb(238, 238, 238) 65%
943
+ );
944
+ background-size: 300%;
945
+ animation: animate-gradient 2.5s ease infinite;
946
+ }
947
+
948
+ /* Elevated card */
949
+ .elevated-card {
950
+ box-shadow: 0 0 20px var(--muted-light);
951
+ }
952
+
953
+ /* Glass card */
954
+ .glass-card {
955
+ background: hsla(0, 0%, 100%, 0.2) !important;
956
+ border: 1px solid hsla(0, 0%, 100%, 0.3) !important;
957
+ box-shadow: 0 4px 30px hsla(0, 0%, 0%, 0.1) !important;
958
+ backdrop-filter: blur(5px);
959
+ -webkit-backdrop-filter: blur(5px);
960
+ }
961
+
962
+ /* Hide scrollbar */
963
+ .hide-scrollbar {
964
+ scrollbar-width: none;
965
+ -ms-overflow-style: none;
966
+ }
967
+
968
+ .animate-changelog-timeline {
969
+ animation: animate-heart-beat 1.5s ease infinite;
970
+ }
971
+ }
972
+ `;
973
+ }
974
+ });
975
+
976
+ // src/commands/utils/css.util.ts
977
+ async function createThemeFile({
978
+ cwd,
979
+ version
980
+ }) {
981
+ if (version === "none") return null;
982
+ const existingGlobalCssPath = await locateGlobalsCSS(cwd);
983
+ if (existingGlobalCssPath) {
984
+ const updated = await updateGlobalsCSS({
985
+ filePath: existingGlobalCssPath,
986
+ content: themeVariablesV4
987
+ });
988
+ if (!updated) return null;
989
+ return existingGlobalCssPath;
990
+ }
991
+ const srcAppDir = import_path6.default.join(cwd, "src", "app");
992
+ const appDir = import_path6.default.join(cwd, "app");
993
+ let newGlobalCssPath;
994
+ if (await import_fs_extra6.default.pathExists(srcAppDir)) {
995
+ newGlobalCssPath = import_path6.default.join(srcAppDir, "globals.css");
996
+ } else if (await import_fs_extra6.default.pathExists(appDir)) {
997
+ newGlobalCssPath = import_path6.default.join(appDir, "globals.css");
998
+ } else {
999
+ newGlobalCssPath = import_path6.default.join(cwd, "src", "app", "globals.css");
1000
+ }
1001
+ await import_fs_extra6.default.ensureDir(import_path6.default.dirname(newGlobalCssPath));
1002
+ const fileUpdated = await writeCSSFile({
1003
+ filePath: newGlobalCssPath,
1004
+ content: themeVariablesV4
1005
+ });
1006
+ if (!fileUpdated) return null;
1007
+ return newGlobalCssPath;
1008
+ }
1009
+ async function locateGlobalsCSS(cwd) {
1010
+ const commonPaths = [import_path6.default.join(cwd, "src", "app", "globals.css"), import_path6.default.join(cwd, "app", "globals.css")];
1011
+ for (const cssPath of commonPaths) {
1012
+ if (await import_fs_extra6.default.pathExists(cssPath)) return cssPath;
1013
+ }
1014
+ return null;
1015
+ }
1016
+ async function writeCSSFile({ filePath, content }) {
1017
+ try {
1018
+ await import_fs_extra6.default.writeFile(filePath, content, "utf8");
1019
+ return true;
1020
+ } catch {
1021
+ return false;
1022
+ }
1023
+ }
1024
+ async function updateGlobalsCSS({ filePath, content }) {
1025
+ try {
1026
+ await import_fs_extra6.default.writeFile(filePath, content, "utf8");
1027
+ return true;
1028
+ } catch {
1029
+ return false;
1030
+ }
1031
+ }
1032
+ var import_fs_extra6, import_path6;
1033
+ var init_css_util = __esm({
1034
+ "src/commands/utils/css.util.ts"() {
1035
+ "use strict";
1036
+ init_cjs_shims();
1037
+ import_fs_extra6 = __toESM(require("fs-extra"), 1);
1038
+ import_path6 = __toESM(require("path"), 1);
1039
+ init_theme_tailwind_v4_data();
1040
+ }
1041
+ });
1042
+
1043
+ // src/commands/init.ts
1044
+ async function initConfig() {
1045
+ try {
1046
+ console.log("\u2699\uFE0F Initializing configuration...");
1047
+ const cwd = process.cwd();
1048
+ const existingConfig = await getConfig(cwd);
1049
+ if (existingConfig) {
1050
+ console.log("\u2714 ui.config.json already exists in this project.");
1051
+ const { overwrite } = await import_inquirer4.default.prompt([
1052
+ {
1053
+ type: "confirm",
1054
+ name: "overwrite",
1055
+ message: "Do you want to overwrite the existing configuration?",
1056
+ default: false
1057
+ }
1058
+ ]);
1059
+ if (!overwrite) {
1060
+ console.log("\u274C Configuration initialization cancelled!");
1061
+ process.exit(1);
1062
+ }
1063
+ }
1064
+ const projectInfo = await getProjectInfo(cwd);
1065
+ if (projectInfo.project === "none") {
1066
+ console.log("\u274C No supported project detected!");
1067
+ process.exit(1);
1068
+ }
1069
+ if (projectInfo.tailwindVersion === "none") {
1070
+ console.log("\u{1F4E6} No supported Tailwind version detected!");
1071
+ const { installTailwind } = await import_inquirer4.default.prompt([
1072
+ {
1073
+ type: "confirm",
1074
+ name: "installTailwind",
1075
+ message: "Would you like to install Tailwind CSS?",
1076
+ default: true
1077
+ }
1078
+ ]);
1079
+ if (!installTailwind) {
1080
+ console.log("\u274C Tailwind CSS is required for the UI components to work properly!");
1081
+ process.exit(1);
1082
+ }
1083
+ const installTailwindSpinner = (0, import_ora4.default)(" Installing Tailwind CSS...").start();
1084
+ const tailwindInstalled = await installDependencies({
1085
+ cwd,
1086
+ packageManager: projectInfo.packageManager,
1087
+ dependencies: ["tailwindcss"]
1088
+ });
1089
+ if (tailwindInstalled) installTailwindSpinner.succeed();
1090
+ else {
1091
+ installTailwindSpinner.fail();
1092
+ console.log("\u274C Failed to install Tailwind CSS. Please install it manually!");
1093
+ process.exit(1);
1094
+ }
1095
+ }
1096
+ const config = await createConfig({ cwd, projectInfo });
1097
+ if (!config) {
1098
+ console.log("\u274C Failed to create configuration file!");
1099
+ process.exit(1);
1100
+ } else console.log("\u2714 Configuration file created successfully!");
1101
+ const isCorrectLucideVersion = projectInfo.lucideVersion && projectInfo.lucideVersion >= 0.563 ? true : false;
1102
+ if (!isCorrectLucideVersion) {
1103
+ const lucideInstalled = await installDependencies({
1104
+ cwd,
1105
+ packageManager: projectInfo.packageManager,
1106
+ dependencies: ["clsx", "lucide-react", "tailwind-merge"]
1107
+ });
1108
+ if (!lucideInstalled) {
1109
+ console.log("\u274C Failed to install Lucide Icons. Please install it manually!");
1110
+ process.exit(1);
1111
+ }
1112
+ }
1113
+ const themeSpinner = (0, import_ora4.default)(" Setting up theme variables...").start();
1114
+ const createdThemeFile = await createThemeFile({ cwd, version: projectInfo.tailwindVersion });
1115
+ if (!createdThemeFile) {
1116
+ themeSpinner.fail();
1117
+ console.log("\u274C Failed to setup theme variables!");
1118
+ process.exit(1);
1119
+ }
1120
+ themeSpinner.succeed();
1121
+ console.log("\u{1F389} Project initialization completed successfully!");
1122
+ console.log("\u{1F4A1} Feel free to update the values in the configuration file to your needs!");
1123
+ process.exit(1);
1124
+ } catch (error) {
1125
+ console.error(`\u274C Error: ${error}`);
1126
+ process.exit(1);
1127
+ }
1128
+ }
1129
+ var import_inquirer4, import_ora4;
1130
+ var init_init = __esm({
1131
+ "src/commands/init.ts"() {
1132
+ "use strict";
1133
+ init_cjs_shims();
1134
+ import_inquirer4 = __toESM(require("inquirer"), 1);
1135
+ import_ora4 = __toESM(require("ora"), 1);
1136
+ init_config_util();
1137
+ init_css_util();
1138
+ init_package_util();
1139
+ }
1140
+ });
1141
+
1142
+ // src/commands/list.ts
1143
+ async function listComponents() {
1144
+ const configSpinner = (0, import_ora5.default)(" Checking...").start();
1145
+ try {
1146
+ const cwd = process.cwd();
1147
+ const config = await getConfig(cwd);
1148
+ if (!config) {
1149
+ configSpinner.fail();
1150
+ console.log('\u274C No configuration found! Please run "sgx4u-ui init" first.');
1151
+ process.exit(1);
1152
+ }
1153
+ configSpinner.succeed();
1154
+ const fetchSpinner = (0, import_ora5.default)(" Fetching available components...").start();
1155
+ const registry = await fetchRegistry(config.environment);
1156
+ if (!registry) {
1157
+ fetchSpinner.fail();
1158
+ console.log("\u26A0\uFE0F Failed to fetch registry from GitHub!");
1159
+ process.exit(1);
1160
+ }
1161
+ fetchSpinner.succeed();
1162
+ console.log("\u{1F4CB} Available Components:");
1163
+ Object.entries(registry.components).forEach(([registryKey, component]) => {
1164
+ const componentName = component.name ?? registryKey;
1165
+ console.log(`${componentName}: ${component.description}`);
1166
+ console.log(` Install: sgx4u-ui add ${componentName}`);
1167
+ console.log();
1168
+ });
1169
+ process.exit(1);
1170
+ } catch (error) {
1171
+ configSpinner.fail();
1172
+ console.error(`\u274C Error: ${error}`);
1173
+ process.exit(1);
1174
+ }
1175
+ }
1176
+ var import_ora5;
1177
+ var init_list = __esm({
1178
+ "src/commands/list.ts"() {
1179
+ "use strict";
1180
+ init_cjs_shims();
1181
+ import_ora5 = __toESM(require("ora"), 1);
1182
+ init_config_util();
1183
+ init_registry_util();
1184
+ }
1185
+ });
1186
+
1187
+ // src/cli.ts
1188
+ var cli_exports = {};
1189
+ var import_commander, program;
1190
+ var init_cli = __esm({
1191
+ "src/cli.ts"() {
1192
+ "use strict";
1193
+ init_cjs_shims();
1194
+ import_commander = require("commander");
1195
+ init_add();
1196
+ init_config();
1197
+ init_help();
1198
+ init_info();
1199
+ init_init();
1200
+ init_list();
1201
+ program = new import_commander.Command();
1202
+ program.name("sgx4u-ui").description("CLI tool for installing SGX4U UI components").version("1.0.0");
1203
+ program.command("init").description("Initialize SGX4U UI in your project").action(initConfig);
1204
+ program.command("add").description("Add a component to your project").argument("<component>", "Component name to add (e.g., button, input)").action(addComponent);
1205
+ program.command("list").description("List all available components").action(listComponents);
1206
+ program.command("info").description("Show detailed information about a specific component").argument("<component>", "Component name to get info about").action(showComponentInfo);
1207
+ program.command("config").description("Manage configuration settings").action(manageConfig);
1208
+ program.command("help").description("Show comprehensive help information").action(showHelp);
1209
+ program.on("--help", () => {
1210
+ console.log("\n\u{1F4A1} For detailed help, run: sgx4u-ui help");
1211
+ });
1212
+ program.parse();
1213
+ }
1214
+ });
1215
+
1216
+ // src/bin.ts
1217
+ init_cjs_shims();
1218
+ Promise.resolve().then(() => init_cli());