weloop-kosign 1.0.4 → 1.0.5
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 +1 -1
- package/scripts/cli-remote.js +49 -31
package/package.json
CHANGED
package/scripts/cli-remote.js
CHANGED
|
@@ -550,7 +550,7 @@ async function fetchCSSFromRegistry(registryUrl) {
|
|
|
550
550
|
return await fetchText(sourceCssPath);
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
-
async function installCSSStyles(config, registryUrl, forceUpdate = false) {
|
|
553
|
+
async function installCSSStyles(config, registryUrl, forceUpdate = false, silent = false) {
|
|
554
554
|
const cssPath = config.tailwind?.css || 'app/globals.css';
|
|
555
555
|
const fullCssPath = path.join(process.cwd(), cssPath);
|
|
556
556
|
|
|
@@ -560,13 +560,17 @@ async function installCSSStyles(config, registryUrl, forceUpdate = false) {
|
|
|
560
560
|
const existingContent = fs.readFileSync(fullCssPath, 'utf-8');
|
|
561
561
|
hasWeloopStylesInFile = hasWeloopStyles(existingContent);
|
|
562
562
|
|
|
563
|
-
|
|
564
|
-
|
|
563
|
+
// If styles already exist and not forcing update, skip silently
|
|
564
|
+
if (hasWeloopStylesInFile && !forceUpdate && silent) {
|
|
565
|
+
return;
|
|
565
566
|
}
|
|
566
567
|
}
|
|
567
568
|
|
|
568
569
|
try {
|
|
569
|
-
|
|
570
|
+
if (!silent) {
|
|
571
|
+
info('Installing CSS styles...');
|
|
572
|
+
}
|
|
573
|
+
|
|
570
574
|
const cssContent = await fetchCSSFromRegistry(registryUrl);
|
|
571
575
|
ensureDirectoryExists(path.dirname(fullCssPath));
|
|
572
576
|
|
|
@@ -577,9 +581,11 @@ async function installCSSStyles(config, registryUrl, forceUpdate = false) {
|
|
|
577
581
|
if (forceUpdate && fs.existsSync(fullCssPath)) {
|
|
578
582
|
// --overwrite: Replace entire file
|
|
579
583
|
fs.writeFileSync(fullCssPath, processedCssContent);
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
584
|
+
if (!silent) {
|
|
585
|
+
success(`Overwritten ${cssPath} with Weloop styles`);
|
|
586
|
+
if (hasTwAnimate) {
|
|
587
|
+
info(` tw-animate-css import included`);
|
|
588
|
+
}
|
|
583
589
|
}
|
|
584
590
|
} else if (fs.existsSync(fullCssPath)) {
|
|
585
591
|
// Normal mode: Merge intelligently
|
|
@@ -588,30 +594,36 @@ async function installCSSStyles(config, registryUrl, forceUpdate = false) {
|
|
|
588
594
|
existing.includes('@tailwind base');
|
|
589
595
|
|
|
590
596
|
if (hasWeloopStylesInFile) {
|
|
591
|
-
// Replace existing Weloop styles
|
|
597
|
+
// Replace existing Weloop styles (only if different)
|
|
592
598
|
let weloopStyles = removeTailwindImport(processedCssContent);
|
|
593
599
|
weloopStyles = ensureTwAnimateImport(weloopStyles, hasTwAnimate);
|
|
594
600
|
const finalContent = replaceWeloopStyles(existing, weloopStyles, hasTwAnimate);
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
601
|
+
|
|
602
|
+
// Only update if content actually changed
|
|
603
|
+
if (finalContent !== existing) {
|
|
604
|
+
fs.writeFileSync(fullCssPath, finalContent);
|
|
605
|
+
if (!silent) {
|
|
606
|
+
success(`Updated ${cssPath} with Weloop styles`);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
// If no changes, silently skip
|
|
598
610
|
} else if (hasTailwindImport) {
|
|
599
611
|
// Merge after Tailwind imports
|
|
600
612
|
let weloopStyles = removeTailwindImport(processedCssContent);
|
|
601
613
|
weloopStyles = ensureTwAnimateImport(weloopStyles, hasTwAnimate);
|
|
602
614
|
const merged = mergeCSSWithTailwind(existing, weloopStyles, hasTwAnimate);
|
|
603
615
|
fs.writeFileSync(fullCssPath, merged);
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
616
|
+
if (!silent) {
|
|
617
|
+
success(`Updated ${cssPath} with Weloop styles`);
|
|
618
|
+
if (hasTwAnimate) {
|
|
619
|
+
info(` tw-animate-css import included`);
|
|
620
|
+
}
|
|
621
|
+
info(` Your existing styles are preserved`);
|
|
607
622
|
}
|
|
608
|
-
info(` Your existing styles are preserved`);
|
|
609
623
|
} else {
|
|
610
624
|
// No Tailwind imports, prepend everything
|
|
611
|
-
// Remove duplicates from processedCssContent first
|
|
612
625
|
let finalCssContent = removeDuplicateTwAnimateImports(processedCssContent);
|
|
613
626
|
|
|
614
|
-
// Only add if not already present
|
|
615
627
|
if (hasTwAnimate && !finalCssContent.match(/@import\s+["']tw-animate-css["'];?\s*\n?/)) {
|
|
616
628
|
if (finalCssContent.includes('@import "tailwindcss"')) {
|
|
617
629
|
finalCssContent = finalCssContent.replace(
|
|
@@ -623,25 +635,31 @@ async function installCSSStyles(config, registryUrl, forceUpdate = false) {
|
|
|
623
635
|
}
|
|
624
636
|
}
|
|
625
637
|
fs.writeFileSync(fullCssPath, finalCssContent + '\n\n' + existing);
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
638
|
+
if (!silent) {
|
|
639
|
+
success(`Updated ${cssPath} with Weloop styles`);
|
|
640
|
+
if (hasTwAnimate) {
|
|
641
|
+
info(` tw-animate-css import included`);
|
|
642
|
+
}
|
|
629
643
|
}
|
|
630
644
|
}
|
|
631
645
|
} else {
|
|
632
646
|
// Create new file
|
|
633
647
|
fs.writeFileSync(fullCssPath, processedCssContent);
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
648
|
+
if (!silent) {
|
|
649
|
+
success(`Created ${cssPath} with Weloop styles`);
|
|
650
|
+
if (hasTwAnimate) {
|
|
651
|
+
info(` tw-animate-css import included`);
|
|
652
|
+
}
|
|
637
653
|
}
|
|
638
654
|
}
|
|
639
655
|
} catch (err) {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
656
|
+
if (!silent) {
|
|
657
|
+
warn(`Could not automatically install CSS styles: ${err.message}`);
|
|
658
|
+
info(`\n To add styles manually:`);
|
|
659
|
+
info(` 1. Download: ${registryUrl.replace('/registry', '/app/globals.css')}`);
|
|
660
|
+
info(` 2. Add the CSS variables to your ${cssPath} file`);
|
|
661
|
+
info(` 3. Or copy from: https://gitlab.com/Sophanithchrek/weloop-shadcn-next-app/-/raw/main/app/globals.css\n`);
|
|
662
|
+
}
|
|
645
663
|
}
|
|
646
664
|
}
|
|
647
665
|
|
|
@@ -691,8 +709,8 @@ async function installComponent(componentName, options = {}) {
|
|
|
691
709
|
await installPackages(['tw-animate-css']);
|
|
692
710
|
}
|
|
693
711
|
|
|
694
|
-
// Install CSS styles early (before component installation)
|
|
695
|
-
await installCSSStyles(config, registryUrl);
|
|
712
|
+
// Install CSS styles early (before component installation) - silent if already installed
|
|
713
|
+
await installCSSStyles(config, registryUrl, false, true);
|
|
696
714
|
|
|
697
715
|
// Get paths from components.json
|
|
698
716
|
const uiAlias = config.aliases?.ui || '@/components/ui';
|
|
@@ -840,7 +858,7 @@ Examples:
|
|
|
840
858
|
case 'css':
|
|
841
859
|
case 'styles':
|
|
842
860
|
const config = loadComponentsConfig();
|
|
843
|
-
await installCSSStyles(config, registryUrl, options.overwrite);
|
|
861
|
+
await installCSSStyles(config, registryUrl, options.overwrite, false);
|
|
844
862
|
break;
|
|
845
863
|
|
|
846
864
|
default:
|