@hemia/lume 0.0.2 → 0.0.4

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.
Files changed (2) hide show
  1. package/dist/index.js +348 -65
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -210,7 +210,7 @@ async function add(components = [], options = {}) {
210
210
  \u2705 Added ${copiedCount} component(s) to ${targetBase}/`), options);
211
211
  }
212
212
 
213
- // src/commands/init.ts
213
+ // src/commands/add-styles.ts
214
214
  import fs4 from "fs-extra";
215
215
  import path4 from "path";
216
216
  import pc3 from "picocolors";
@@ -336,6 +336,53 @@ export default {
336
336
  plugins: [],
337
337
  } satisfies Config
338
338
  `;
339
+ var TAILWIND_CONFIG_TEMPLATE_JS = `/** @type {import('tailwindcss').Config} */
340
+ export default {
341
+ darkMode: ['class'],
342
+ content: [
343
+ './index.html',
344
+ './src/**/*.{vue,js,ts,jsx,tsx}',
345
+ ],
346
+ theme: {
347
+ extend: {
348
+ colors: {
349
+ border: 'hsl(var(--border))',
350
+ input: 'hsl(var(--input))',
351
+ ring: 'hsl(var(--ring))',
352
+ background: 'hsl(var(--background))',
353
+ foreground: 'hsl(var(--foreground))',
354
+ primary: {
355
+ DEFAULT: 'hsl(var(--primary))',
356
+ foreground: 'hsl(var(--primary-foreground))',
357
+ },
358
+ secondary: {
359
+ DEFAULT: 'hsl(var(--secondary))',
360
+ foreground: 'hsl(var(--secondary-foreground))',
361
+ },
362
+ destructive: {
363
+ DEFAULT: 'hsl(var(--destructive))',
364
+ foreground: 'hsl(var(--destructive-foreground))',
365
+ },
366
+ muted: {
367
+ DEFAULT: 'hsl(var(--muted))',
368
+ foreground: 'hsl(var(--muted-foreground))',
369
+ },
370
+ accent: {
371
+ DEFAULT: 'hsl(var(--accent))',
372
+ foreground: 'hsl(var(--accent-foreground))',
373
+ },
374
+ },
375
+ borderRadius: {
376
+ sm: 'var(--radius-sm)',
377
+ md: 'var(--radius-md)',
378
+ lg: 'var(--radius-lg)',
379
+ DEFAULT: 'var(--radius)',
380
+ },
381
+ },
382
+ },
383
+ plugins: [],
384
+ }
385
+ `;
339
386
  function getTemplateConfig(framework, template) {
340
387
  const configs = {
341
388
  "vite-vue": {
@@ -369,12 +416,247 @@ function getTemplateConfig(framework, template) {
369
416
  };
370
417
  }
371
418
 
419
+ // src/commands/add-styles.ts
420
+ function log2(message, options) {
421
+ if (!options.silent) {
422
+ console.log(message);
423
+ }
424
+ }
425
+ function info(message, options) {
426
+ if (!options.silent) {
427
+ console.log(pc3.cyan(message));
428
+ }
429
+ }
430
+ function extractCssVariables(cssContent) {
431
+ const vars = /* @__PURE__ */ new Map();
432
+ const cleanContent = cssContent.replace(/\/\*[\s\S]*?\*\//g, "");
433
+ const varRegex = /--([a-zA-Z0-9-]+)\s*:\s*([^;]+);/g;
434
+ let match;
435
+ while ((match = varRegex.exec(cleanContent)) !== null) {
436
+ vars.set(match[1].trim(), match[2].trim());
437
+ }
438
+ return vars;
439
+ }
440
+ function mergeCssVariables(existingCss, templateCss) {
441
+ const existingVars = extractCssVariables(existingCss);
442
+ const templateVars = extractCssVariables(templateCss);
443
+ for (const [key, value] of templateVars) {
444
+ existingVars.set(key, value);
445
+ }
446
+ let result = existingCss;
447
+ const rootLayerMatch = result.match(/@layer base\s*\{[\s\S]*?:root\s*\{([\s\S]*?)\}/);
448
+ if (rootLayerMatch) {
449
+ const newRootVars = Array.from(existingVars.entries()).map(([key, value]) => ` --${key}: ${value};`).join("\n");
450
+ result = result.replace(
451
+ /@layer base\s*\{[\s\S]*?:root\s*\{[\s\S]*?\}/,
452
+ `@layer base {
453
+ :root {
454
+ ${newRootVars}
455
+ }`
456
+ );
457
+ } else {
458
+ const rootMatch = result.match(/:root\s*\{([\s\S]*?)\}/);
459
+ if (rootMatch) {
460
+ const newRootVars = Array.from(existingVars.entries()).map(([key, value]) => ` --${key}: ${value};`).join("\n");
461
+ result = result.replace(
462
+ /:root\s*\{[\s\S]*?\}/,
463
+ `:root {
464
+ ${newRootVars}
465
+ }`
466
+ );
467
+ } else {
468
+ const newRootVars = Array.from(existingVars.entries()).map(([key, value]) => ` --${key}: ${value};`).join("\n");
469
+ result = `@layer base {
470
+ :root {
471
+ ${newRootVars}
472
+ }
473
+ }
474
+
475
+ ${result}`;
476
+ }
477
+ }
478
+ return result;
479
+ }
480
+ function mergeTailwindConfig(existingConfig, templateConfig) {
481
+ const colorMatches = templateConfig.match(/colors:\s*\{([\s\S]*?)\}/);
482
+ const radiusMatches = templateConfig.match(/borderRadius:\s*\{([\s\S]*?)\}/);
483
+ let result = existingConfig;
484
+ if (!result.includes("theme:")) {
485
+ return templateConfig;
486
+ }
487
+ if (colorMatches) {
488
+ const colorsBlock = colorMatches[0];
489
+ if (!result.includes("colors:")) {
490
+ result = result.replace(
491
+ /theme:\s*\{/,
492
+ `theme: {
493
+ extend: {
494
+ colors: {${colorsBlock.replace("colors:", "")}`
495
+ );
496
+ }
497
+ }
498
+ if (radiusMatches) {
499
+ const radiusBlock = radiusMatches[0];
500
+ if (!result.includes("borderRadius:")) {
501
+ result = result.replace(
502
+ /theme:\s*\{/,
503
+ `theme: {
504
+ extend: {
505
+ borderRadius: {${radiusBlock.replace("borderRadius:", "")}`
506
+ );
507
+ }
508
+ }
509
+ if (!result.includes("colors:") && colorMatches) {
510
+ return templateConfig;
511
+ }
512
+ return result;
513
+ }
514
+ function getConfigPaths(cwd) {
515
+ try {
516
+ const config = fs4.readJsonSync(path4.resolve(cwd, "lume.config.json"));
517
+ return {
518
+ tailwindConfigPath: config.tailwind?.config ?? "tailwind.config.ts",
519
+ globalsCssPath: config.tailwind?.css ?? "src/assets/globals.css"
520
+ };
521
+ } catch {
522
+ return null;
523
+ }
524
+ }
525
+ function detectFramework(cwd) {
526
+ try {
527
+ const config = fs4.readJsonSync(path4.resolve(cwd, "lume.config.json"));
528
+ return config.framework ?? "vue";
529
+ } catch {
530
+ return "vue";
531
+ }
532
+ }
533
+ async function addStyles(_args = [], options = {}) {
534
+ if (options.silent === void 0 && process.argv.includes("--help") || process.argv.includes("-h")) {
535
+ console.log(`
536
+ lume add-styles
537
+
538
+ Add globals.css and tailwind.config.ts with merge support
539
+
540
+ Options:
541
+ -y, --yes Skip confirmation prompt
542
+ -o, --overwrite Overwrite existing files (don't merge)
543
+ -f, --force Force overwrite without asking
544
+ -c, --cwd Working directory
545
+ -s, --silent Mute output
546
+ -h, --help Show this help
547
+ `);
548
+ return;
549
+ }
550
+ const cwd = options.cwd ? path4.resolve(options.cwd) : process.cwd();
551
+ function detectTailwindConfigExtension(cwd2) {
552
+ const extensions = ["js", "ts", "mjs", "cjs"];
553
+ for (const ext of extensions) {
554
+ if (fs4.existsSync(path4.resolve(cwd2, `tailwind.config.${ext}`))) {
555
+ return ext;
556
+ }
557
+ }
558
+ return "js";
559
+ }
560
+ const configPath = path4.resolve(cwd, "lume.config.json");
561
+ if (!await fs4.pathExists(configPath)) {
562
+ const cssPath2 = path4.resolve(cwd, "src/assets/globals.css");
563
+ const tailwindPath2 = path4.resolve(cwd, "tailwind.config.ts");
564
+ log2(pc3.cyan("\n\u{1F4E6} Adding styles to your project\n"), options);
565
+ info("No lume.config.json found. Using default paths...", options);
566
+ await fs4.ensureDir(path4.dirname(cssPath2));
567
+ await fs4.writeFile(cssPath2, GLOBALS_CSS_TEMPLATE);
568
+ log2(pc3.green(`\u2705 Created src/assets/globals.css`), options);
569
+ await fs4.writeFile(tailwindPath2, tailwindTemplate);
570
+ log2(pc3.green(`\u2705 Created tailwind.config.ts`), options);
571
+ log2(pc3.green("\n\u2705 Styles added successfully!"), options);
572
+ return;
573
+ }
574
+ const configPaths = getConfigPaths(cwd);
575
+ if (!configPaths) {
576
+ log2(pc3.red("\u274C Could not read lume.config.json"), options);
577
+ process.exit(1);
578
+ }
579
+ const framework = detectFramework(cwd);
580
+ const templateConfig = getTemplateConfig(framework);
581
+ const tailwindExt = detectTailwindConfigExtension(cwd);
582
+ const tailwindTemplate = tailwindExt === "js" ? TAILWIND_CONFIG_TEMPLATE_JS : tailwindTemplate;
583
+ const cssPath = path4.resolve(cwd, configPaths.globalsCssPath);
584
+ const tailwindPath = path4.resolve(cwd, configPaths.tailwindConfigPath);
585
+ const cssExists = await fs4.pathExists(cssPath);
586
+ const tailwindExists = await fs4.pathExists(tailwindPath);
587
+ log2(pc3.cyan("\n\u{1F4E6} Adding styles to your project\n"), options);
588
+ if (!cssExists && !tailwindExists) {
589
+ info("No existing CSS or config found. Writing new files...", options);
590
+ await fs4.ensureDir(path4.dirname(cssPath));
591
+ await fs4.writeFile(cssPath, GLOBALS_CSS_TEMPLATE);
592
+ log2(pc3.green(`\u2705 Created ${configPaths.globalsCssPath}`), options);
593
+ await fs4.writeFile(tailwindPath, tailwindTemplate);
594
+ log2(pc3.green(`\u2705 Created ${configPaths.tailwindConfigPath}`), options);
595
+ log2(pc3.green("\n\u2705 Styles added successfully!"), options);
596
+ return;
597
+ }
598
+ let shouldMerge = options.yes;
599
+ let shouldOverwrite = options.overwrite || options.force;
600
+ if ((cssExists || tailwindExists) && !options.yes) {
601
+ const { action } = await prompts2({
602
+ type: "select",
603
+ name: "action",
604
+ message: "Styles already exist. What would you like to do?",
605
+ choices: [
606
+ { title: "Merge (recommended)", description: "Keep your variables, add missing ones from template", value: "merge" },
607
+ { title: "Overwrite", description: "Replace with template (your custom styles will be lost)", value: "overwrite" },
608
+ { title: "Skip", description: "Don't add styles", value: "skip" }
609
+ ]
610
+ });
611
+ if (action === "skip") {
612
+ log2(pc3.dim("Cancelled."), options);
613
+ return;
614
+ }
615
+ shouldMerge = action === "merge";
616
+ shouldOverwrite = action === "overwrite";
617
+ }
618
+ if (cssExists) {
619
+ if (shouldOverwrite && !shouldMerge) {
620
+ await fs4.writeFile(cssPath, GLOBALS_CSS_TEMPLATE);
621
+ log2(pc3.green(`\u2705 Overwrote ${configPaths.globalsCssPath}`), options);
622
+ } else if (shouldMerge) {
623
+ const existingCss = await fs4.readFile(cssPath, "utf-8");
624
+ const mergedCss = mergeCssVariables(existingCss, GLOBALS_CSS_TEMPLATE);
625
+ await fs4.writeFile(cssPath, mergedCss);
626
+ log2(pc3.green(`\u2705 Merged CSS variables in ${configPaths.globalsCssPath}`), options);
627
+ }
628
+ } else {
629
+ await fs4.ensureDir(path4.dirname(cssPath));
630
+ await fs4.writeFile(cssPath, GLOBALS_CSS_TEMPLATE);
631
+ log2(pc3.green(`\u2705 Created ${configPaths.globalsCssPath}`), options);
632
+ }
633
+ if (tailwindExists) {
634
+ if (shouldOverwrite && !shouldMerge) {
635
+ await fs4.writeFile(tailwindPath, tailwindTemplate);
636
+ log2(pc3.green(`\u2705 Overwrote ${configPaths.tailwindConfigPath}`), options);
637
+ } else if (shouldMerge) {
638
+ const existingConfig = await fs4.readFile(tailwindPath, "utf-8");
639
+ const mergedConfig = mergeTailwindConfig(existingConfig, tailwindTemplate);
640
+ await fs4.writeFile(tailwindPath, mergedConfig);
641
+ log2(pc3.green(`\u2705 Merged Tailwind config in ${configPaths.tailwindConfigPath}`), options);
642
+ }
643
+ } else {
644
+ await fs4.writeFile(tailwindPath, tailwindTemplate);
645
+ log2(pc3.green(`\u2705 Created ${configPaths.tailwindConfigPath}`), options);
646
+ }
647
+ log2(pc3.green("\n\u2705 Styles added successfully!"), options);
648
+ }
649
+
372
650
  // src/commands/init.ts
651
+ import fs5 from "fs-extra";
652
+ import path5 from "path";
653
+ import pc4 from "picocolors";
654
+ import prompts3 from "prompts";
373
655
  var SUPPORTED_FRAMEWORKS = ["vue", "react", "svelte", "astro"];
374
656
  var SUPPORTED_PACKAGE_MANAGERS = ["npm", "bun", "pnpm", "yarn"];
375
- function detectFramework() {
657
+ function detectFramework2() {
376
658
  try {
377
- const pkg = fs4.readJsonSync(path4.resolve(process.cwd(), "package.json"));
659
+ const pkg = fs5.readJsonSync(path5.resolve(process.cwd(), "package.json"));
378
660
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
379
661
  if (deps["vue"]) return "vue";
380
662
  if (deps["react"]) return "react";
@@ -385,19 +667,19 @@ function detectFramework() {
385
667
  return null;
386
668
  }
387
669
  }
388
- function log2(message, options) {
670
+ function log3(message, options) {
389
671
  if (!options.silent) {
390
672
  console.log(message);
391
673
  }
392
674
  }
393
675
  function warn2(message, options) {
394
676
  if (!options.silent) {
395
- console.log(pc3.yellow(`\u26A0\uFE0F ${message}`));
677
+ console.log(pc4.yellow(`\u26A0\uFE0F ${message}`));
396
678
  }
397
679
  }
398
- function info(message, options) {
680
+ function info2(message, options) {
399
681
  if (!options.silent) {
400
- console.log(pc3.cyan(message));
682
+ console.log(pc4.cyan(message));
401
683
  }
402
684
  }
403
685
  async function init(options = {}) {
@@ -417,36 +699,36 @@ async function init(options = {}) {
417
699
  }
418
700
  if (options.reinstall === false) {
419
701
  }
420
- const cwd = options.cwd ? path4.resolve(options.cwd) : process.cwd();
702
+ const cwd = options.cwd ? path5.resolve(options.cwd) : process.cwd();
421
703
  const validTemplates = ["next", "vite", "start", "react-router", "laravel", "astro"];
422
704
  let template = options.template?.toLowerCase();
423
705
  if (template && !validTemplates.includes(template)) {
424
706
  warn2(`Invalid template "${template}". Using default.`, options);
425
707
  template = void 0;
426
708
  }
427
- const configPath = path4.resolve(cwd, "lume.config.json");
428
- const configExists = await fs4.pathExists(configPath);
709
+ const configPath = path5.resolve(cwd, "lume.config.json");
710
+ const configExists = await fs5.pathExists(configPath);
429
711
  if (configExists && !options.force) {
430
712
  if (!options.yes) {
431
- const { overwrite } = await prompts2({
713
+ const { overwrite } = await prompts3({
432
714
  type: "confirm",
433
715
  name: "overwrite",
434
716
  message: "lume.config.json already exists. Overwrite?",
435
717
  initial: false
436
718
  });
437
719
  if (!overwrite) {
438
- log2("Cancelled.", options);
720
+ log3("Cancelled.", options);
439
721
  return;
440
722
  }
441
723
  }
442
724
  }
443
- const detected = detectFramework();
725
+ const detected = detectFramework2();
444
726
  let framework;
445
727
  if (detected) {
446
728
  framework = detected;
447
- info(`Detected framework: ${detected}`, options);
729
+ info2(`Detected framework: ${detected}`, options);
448
730
  } else if (!options.yes) {
449
- const { framework: selectedFramework } = await prompts2({
731
+ const { framework: selectedFramework } = await prompts3({
450
732
  type: "select",
451
733
  name: "framework",
452
734
  message: "Which framework are you using?",
@@ -457,16 +739,16 @@ async function init(options = {}) {
457
739
  framework = "vue";
458
740
  }
459
741
  if (!framework) {
460
- log2(pc3.red("\u274C Framework selection required"), options);
742
+ log3(pc4.red("\u274C Framework selection required"), options);
461
743
  process.exit(1);
462
744
  }
463
745
  const detectedPm = detectPackageManager(cwd);
464
746
  let packageManager;
465
747
  if (detectedPm) {
466
748
  packageManager = detectedPm;
467
- info(`Detected package manager: ${detectedPm}`, options);
749
+ info2(`Detected package manager: ${detectedPm}`, options);
468
750
  } else if (!options.yes) {
469
- const { pm } = await prompts2({
751
+ const { pm } = await prompts3({
470
752
  type: "select",
471
753
  name: "pm",
472
754
  message: "Which package manager are you using?",
@@ -477,7 +759,7 @@ async function init(options = {}) {
477
759
  packageManager = "npm";
478
760
  }
479
761
  if (!packageManager) {
480
- log2(pc3.red("\u274C Package manager selection required"), options);
762
+ log3(pc4.red("\u274C Package manager selection required"), options);
481
763
  process.exit(1);
482
764
  }
483
765
  const installCmd = getInstallCommand(packageManager);
@@ -498,11 +780,11 @@ async function init(options = {}) {
498
780
  utils: `@/${templateConfig.utilsPath}`
499
781
  }
500
782
  };
501
- await fs4.writeJson(configPath, config, { spaces: 2 });
502
- log2(pc3.green(`\u2705 Created lume.config.json`), options);
783
+ await fs5.writeJson(configPath, config, { spaces: 2 });
784
+ log3(pc4.green(`\u2705 Created lume.config.json`), options);
503
785
  let writeFiles = options.yes;
504
786
  if (!options.yes) {
505
- const { confirm } = await prompts2({
787
+ const { confirm } = await prompts3({
506
788
  type: "confirm",
507
789
  name: "confirm",
508
790
  message: "Write globals.css and tailwind.config.ts?",
@@ -511,47 +793,47 @@ async function init(options = {}) {
511
793
  writeFiles = confirm;
512
794
  }
513
795
  if (writeFiles) {
514
- const cssPath = path4.resolve(cwd, templateConfig.globalsCssPath);
515
- await fs4.ensureDir(path4.dirname(cssPath));
516
- if (await fs4.pathExists(cssPath)) {
796
+ const cssPath = path5.resolve(cwd, templateConfig.globalsCssPath);
797
+ await fs5.ensureDir(path5.dirname(cssPath));
798
+ if (await fs5.pathExists(cssPath)) {
517
799
  if (options.force || !options.yes) {
518
- const { overwrite } = await prompts2({
800
+ const { overwrite } = await prompts3({
519
801
  type: "confirm",
520
802
  name: "overwrite",
521
803
  message: `${templateConfig.globalsCssPath} already exists. Overwrite?`,
522
804
  initial: false
523
805
  });
524
806
  if (overwrite) {
525
- await fs4.writeFile(cssPath, GLOBALS_CSS_TEMPLATE);
526
- log2(pc3.green(`\u2705 Updated ${templateConfig.globalsCssPath}`), options);
807
+ await fs5.writeFile(cssPath, GLOBALS_CSS_TEMPLATE);
808
+ log3(pc4.green(`\u2705 Updated ${templateConfig.globalsCssPath}`), options);
527
809
  }
528
810
  }
529
811
  } else {
530
- await fs4.writeFile(cssPath, GLOBALS_CSS_TEMPLATE);
531
- log2(pc3.green(`\u2705 Created ${templateConfig.globalsCssPath}`), options);
812
+ await fs5.writeFile(cssPath, GLOBALS_CSS_TEMPLATE);
813
+ log3(pc4.green(`\u2705 Created ${templateConfig.globalsCssPath}`), options);
532
814
  }
533
- const tailwindPath = path4.resolve(cwd, templateConfig.tailwindConfigPath);
534
- if (await fs4.pathExists(tailwindPath)) {
815
+ const tailwindPath = path5.resolve(cwd, templateConfig.tailwindConfigPath);
816
+ if (await fs5.pathExists(tailwindPath)) {
535
817
  if (options.force || !options.yes) {
536
- const { overwrite } = await prompts2({
818
+ const { overwrite } = await prompts3({
537
819
  type: "confirm",
538
820
  name: "overwrite",
539
821
  message: `${templateConfig.tailwindConfigPath} already exists. Overwrite?`,
540
822
  initial: false
541
823
  });
542
824
  if (overwrite) {
543
- await fs4.writeFile(tailwindPath, TAILWIND_CONFIG_TEMPLATE);
544
- log2(pc3.green(`\u2705 Updated ${templateConfig.tailwindConfigPath}`), options);
825
+ await fs5.writeFile(tailwindPath, TAILWIND_CONFIG_TEMPLATE);
826
+ log3(pc4.green(`\u2705 Updated ${templateConfig.tailwindConfigPath}`), options);
545
827
  }
546
828
  }
547
829
  } else {
548
- await fs4.writeFile(tailwindPath, TAILWIND_CONFIG_TEMPLATE);
549
- log2(pc3.green(`\u2705 Created ${templateConfig.tailwindConfigPath}`), options);
830
+ await fs5.writeFile(tailwindPath, TAILWIND_CONFIG_TEMPLATE);
831
+ log3(pc4.green(`\u2705 Created ${templateConfig.tailwindConfigPath}`), options);
550
832
  }
551
833
  }
552
834
  let installDeps = options.yes;
553
835
  if (!options.yes) {
554
- const { confirm } = await prompts2({
836
+ const { confirm } = await prompts3({
555
837
  type: "confirm",
556
838
  name: "confirm",
557
839
  message: "Install base dependencies (tailwindcss, autoprefixer, postcss)?",
@@ -560,30 +842,30 @@ async function init(options = {}) {
560
842
  installDeps = confirm;
561
843
  }
562
844
  if (installDeps) {
563
- log2("", options);
845
+ log3("", options);
564
846
  const baseDeps = ["tailwindcss", "autoprefixer", "postcss"];
565
847
  installDependencies(baseDeps, { dev: true });
566
- log2("", options);
848
+ log3("", options);
567
849
  const frameworkPkg = framework === "vue" ? "@hemia/lume-vue" : `@hemia/lume-${framework}`;
568
- info(`\u{1F4E6} Installing ${frameworkPkg}...`, options);
569
- log2(pc3.dim(` When published, run: ${installCmd} ${frameworkPkg}`), options);
850
+ info2(`\u{1F4E6} Installing ${frameworkPkg}...`, options);
851
+ log3(pc4.dim(` When published, run: ${installCmd} ${frameworkPkg}`), options);
570
852
  }
571
- log2("", options);
572
- log2(pc3.green("\u{1F389} All done! Run the following to add components:"), options);
573
- info(` lume add button`, options);
574
- log2("", options);
853
+ log3("", options);
854
+ log3(pc4.green("\u{1F389} All done! Run the following to add components:"), options);
855
+ info2(` lume add button`, options);
856
+ log3("", options);
575
857
  }
576
858
 
577
859
  // src/commands/list.ts
578
- import fs5 from "fs-extra";
579
- import path5 from "path";
580
- import pc4 from "picocolors";
860
+ import fs6 from "fs-extra";
861
+ import path6 from "path";
862
+ import pc5 from "picocolors";
581
863
  import { createRequire as createRequire2 } from "module";
582
864
  var require3 = createRequire2(import.meta.url);
583
865
  function getFrameworkFromConfig2() {
584
866
  try {
585
- const config = fs5.readJsonSync(
586
- path5.resolve(process.cwd(), "hemia.config.json")
867
+ const config = fs6.readJsonSync(
868
+ path6.resolve(process.cwd(), "hemia.config.json")
587
869
  );
588
870
  return config.framework ?? "vue";
589
871
  } catch {
@@ -591,43 +873,43 @@ function getFrameworkFromConfig2() {
591
873
  }
592
874
  }
593
875
  function resolveRegistryPath2(framework) {
594
- const registryRoot = path5.dirname(
876
+ const registryRoot = path6.dirname(
595
877
  require3.resolve("@hemia/lume-registry/package.json")
596
878
  );
597
- return path5.join(registryRoot, "registry", framework);
879
+ return path6.join(registryRoot, "registry", framework);
598
880
  }
599
881
  async function list(options = {}) {
600
882
  const framework = options.framework ?? getFrameworkFromConfig2();
601
883
  const frameworkRegistry = resolveRegistryPath2(framework);
602
- if (!await fs5.pathExists(frameworkRegistry)) {
603
- console.log(pc4.red(`\u274C No components found for framework "${framework}"`));
884
+ if (!await fs6.pathExists(frameworkRegistry)) {
885
+ console.log(pc5.red(`\u274C No components found for framework "${framework}"`));
604
886
  process.exit(1);
605
887
  }
606
- const entries = await fs5.readdir(frameworkRegistry, { withFileTypes: true });
888
+ const entries = await fs6.readdir(frameworkRegistry, { withFileTypes: true });
607
889
  const components = entries.filter((entry) => entry.isDirectory());
608
890
  if (components.length === 0) {
609
- console.log(pc4.yellow(`\u26A0\uFE0F No components available for ${framework}`));
891
+ console.log(pc5.yellow(`\u26A0\uFE0F No components available for ${framework}`));
610
892
  return;
611
893
  }
612
- console.log(pc4.cyan(`
894
+ console.log(pc5.cyan(`
613
895
  \u{1F4E6} Available components for ${framework}:
614
896
  `));
615
897
  for (const component of components) {
616
898
  const meta = await readComponentMeta(
617
- path5.join(frameworkRegistry, component.name)
899
+ path6.join(frameworkRegistry, component.name)
618
900
  );
619
901
  if (meta) {
620
- const deps = meta.registryDependencies?.length ? pc4.dim(` (requires: ${meta.registryDependencies.join(", ")})`) : "";
621
- console.log(` ${pc4.green("\u25CF")} ${component.name}${deps}`);
902
+ const deps = meta.registryDependencies?.length ? pc5.dim(` (requires: ${meta.registryDependencies.join(", ")})`) : "";
903
+ console.log(` ${pc5.green("\u25CF")} ${component.name}${deps}`);
622
904
  } else {
623
- console.log(` ${pc4.green("\u25CF")} ${component.name}`);
905
+ console.log(` ${pc5.green("\u25CF")} ${component.name}`);
624
906
  }
625
907
  }
626
908
  console.log();
627
- console.log(pc4.dim(`Total: ${components.length} component(s)`));
909
+ console.log(pc5.dim(`Total: ${components.length} component(s)`));
628
910
  console.log();
629
- console.log(pc4.cyan("Usage:"));
630
- console.log(pc4.dim(` hemia add <component-name>`));
911
+ console.log(pc5.cyan("Usage:"));
912
+ console.log(pc5.dim(` hemia add <component-name>`));
631
913
  console.log();
632
914
  }
633
915
 
@@ -636,5 +918,6 @@ var program = new Command();
636
918
  program.name("lume").description("lume CLI \u2014 multi-framework component generator inspired by shadcn/ui").version("0.0.1");
637
919
  program.command("init").description("Initialize your project and install dependencies").allowUnknownOption(true).argument("[components...]", "name, url or local path to component").option("-t, --template <template>", "the template to use. (next, vite, start, react-router, laravel, astro)").option("-p, --preset [name]", "use a preset configuration. (name, URL, or preset code)").option("-d, --defaults", "use default configuration. (default: false)").option("-y, --yes", "skip confirmation prompt. (default: true)").option("-f, --force", "force overwrite of existing configuration. (default: false)").option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.").option("-s, --silent", "mute output. (default: false)").option("--monorepo", "scaffold a monorepo project.").option("--no-monorepo", "skip the monorepo prompt.").option("--reinstall", "re-install existing UI components.").option("--no-reinstall", "do not re-install existing UI components.").option("--css-variables", "use css variables for theming. (default: true)").option("--no-css-variables", "do not use css variables for theming.").option("-h, --help", "display help for command").action(init);
638
920
  program.command("add").description("add a component to your project").allowUnknownOption(true).argument("[components...]", "name, url or local path to component").option("-y, --yes", "skip confirmation prompt. (default: false)").option("-o, --overwrite", "overwrite existing files. (default: false)").option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.").option("-a, --all", "add all available components (default: false)").option("-p, --path <path>", "the path to add the component to.").option("-s, --silent", "mute output. (default: false)").option("--dry-run", "preview changes without writing files. (default: false)").option("--diff [path]", "show diff for a file.").option("--view [path]", "show file contents.").option("-h, --help", "display help for command").option("-f, --framework <framework>", "Target framework (vue, react, svelte, astro)").action(add);
921
+ program.command("add-styles").description("add globals.css and tailwind.config.ts with merge support").option("-y, --yes", "skip confirmation prompt. (default: false)").option("-o, --overwrite", "overwrite existing files. (default: false)").option("-f, --force", "force overwrite without asking. (default: false)").option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.").option("-s, --silent", "mute output. (default: false)").option("-h, --help", "display help for command").action(addStyles);
639
922
  program.command("list").description("List all available components").option("-f, --framework <framework>", "Target framework (vue, react, svelte, astro)").action(list);
640
923
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hemia/lume",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "files": ["dist"],
6
6
  "bin": {