weloop-kosign 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weloop-kosign",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "description": "CLI tool for installing Weloop UI components",
5
5
  "keywords": [
6
6
  "weloop",
@@ -26,5 +26,8 @@
26
26
  ],
27
27
  "engines": {
28
28
  "node": ">=18.0.0"
29
+ },
30
+ "scripts": {
31
+ "postpublish": "node scripts/postpublish.js"
29
32
  }
30
33
  }
@@ -472,6 +472,18 @@ function removeDuplicateTwAnimateImports(cssContent) {
472
472
  return cssContent;
473
473
  }
474
474
 
475
+ function removeDuplicateCustomVariant(cssContent) {
476
+ const variantPattern = /@custom-variant\s+dark\s+\(&:is\(\.dark \*\)\);\s*\n?/g;
477
+ const matches = cssContent.match(variantPattern);
478
+
479
+ if (matches && matches.length > 1) {
480
+ const withoutVariants = cssContent.replace(variantPattern, '');
481
+ return `@custom-variant dark (&:is(.dark *));\n\n${withoutVariants.trimStart()}`;
482
+ }
483
+
484
+ return cssContent;
485
+ }
486
+
475
487
  function processTwAnimateImport(cssContent, hasTwAnimate, forceUpdate = false) {
476
488
  const twAnimatePattern = /@import\s+["']tw-animate-css["'];?\s*\n?/g;
477
489
  let processed = cssContent;
@@ -550,12 +562,22 @@ function mergeCSSWithTailwind(existing, weloopStyles, hasTwAnimate) {
550
562
  const hasTwAnimateInExisting = existing.match(/@import\s+["']tw-animate-css["'];?\s*\n?/);
551
563
  const hasTwAnimateInWeloop = weloopStyles.match(/@import\s+["']tw-animate-css["'];?\s*\n?/);
552
564
 
565
+ // If the existing file already has the tw-animate import, strip it from the
566
+ // Weloop styles to avoid duplicating it in the merge output.
567
+ let weloopStylesCleaned = weloopStyles;
568
+ if (hasTwAnimateInExisting && hasTwAnimateInWeloop) {
569
+ weloopStylesCleaned = weloopStyles.replace(
570
+ /@import\s+["']tw-animate-css["'];?\s*\n?/g,
571
+ ''
572
+ );
573
+ }
574
+
553
575
  let importsToAdd = '';
554
576
  if (hasTwAnimate && !hasTwAnimateInExisting && !hasTwAnimateInWeloop) {
555
577
  importsToAdd = '@import "tw-animate-css";\n';
556
578
  }
557
-
558
- return beforeTailwind + tailwindMatch[0] + importsToAdd + weloopStyles + '\n' + afterTailwind;
579
+
580
+ return beforeTailwind + tailwindMatch[0] + importsToAdd + weloopStylesCleaned + '\n' + afterTailwind;
559
581
  }
560
582
 
561
583
  function replaceWeloopStyles(existing, newStyles, hasTwAnimate) {
@@ -642,7 +664,9 @@ async function installCSSStyles(config, registryUrl, forceUpdate = false, silent
642
664
  // Replace existing Weloop styles (only if different)
643
665
  let weloopStyles = removeTailwindImport(processedCssContent);
644
666
  weloopStyles = ensureTwAnimateImport(weloopStyles, hasTwAnimate);
645
- const finalContent = replaceWeloopStyles(existing, weloopStyles, hasTwAnimate);
667
+ let finalContent = replaceWeloopStyles(existing, weloopStyles, hasTwAnimate);
668
+ finalContent = removeDuplicateTwAnimateImports(finalContent);
669
+ finalContent = removeDuplicateCustomVariant(finalContent);
646
670
 
647
671
  // Only update if content actually changed
648
672
  if (finalContent !== existing) {
@@ -656,7 +680,9 @@ async function installCSSStyles(config, registryUrl, forceUpdate = false, silent
656
680
  // Merge after Tailwind imports
657
681
  let weloopStyles = removeTailwindImport(processedCssContent);
658
682
  weloopStyles = ensureTwAnimateImport(weloopStyles, hasTwAnimate);
659
- const merged = mergeCSSWithTailwind(existing, weloopStyles, hasTwAnimate);
683
+ let merged = mergeCSSWithTailwind(existing, weloopStyles, hasTwAnimate);
684
+ merged = removeDuplicateTwAnimateImports(merged);
685
+ merged = removeDuplicateCustomVariant(merged);
660
686
  fs.writeFileSync(fullCssPath, merged);
661
687
  if (!silent) {
662
688
  success(`Updated ${cssPath} with Weloop styles`);
@@ -784,10 +810,9 @@ async function installComponent(componentName, options = {}) {
784
810
  process.exit(1);
785
811
  }
786
812
 
787
- // Check if component already exists
813
+ // Check if component already exists (silently skip if exists, matching shadcn/ui behavior)
788
814
  const componentPath = path.join(componentsDir, `${componentName}.tsx`);
789
815
  if (fs.existsSync(componentPath) && !overwrite) {
790
- warn(`Component "${componentName}" already exists. Use --overwrite to replace it.`);
791
816
  return;
792
817
  }
793
818