weloop-kosign 1.0.4 → 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/package.json +1 -1
- package/scripts/cli-remote.js +95 -32
package/package.json
CHANGED
package/scripts/cli-remote.js
CHANGED
|
@@ -151,7 +151,52 @@ async function installPackages(packages) {
|
|
|
151
151
|
|
|
152
152
|
try {
|
|
153
153
|
const installCmd = getInstallCommand(packageManager, packages);
|
|
154
|
-
|
|
154
|
+
|
|
155
|
+
// Filter out ERESOLVE peer dependency warnings while keeping errors
|
|
156
|
+
if (packageManager === 'npm') {
|
|
157
|
+
const { spawn } = require('child_process');
|
|
158
|
+
const [cmd, ...args] = installCmd.split(' ');
|
|
159
|
+
|
|
160
|
+
await new Promise((resolve, reject) => {
|
|
161
|
+
const proc = spawn(cmd, args, {
|
|
162
|
+
cwd: process.cwd(),
|
|
163
|
+
stdio: ['inherit', 'inherit', 'pipe'],
|
|
164
|
+
shell: true
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
let stderr = '';
|
|
168
|
+
proc.stderr.on('data', (data) => {
|
|
169
|
+
const output = data.toString();
|
|
170
|
+
// Filter out ERESOLVE warnings but keep actual errors
|
|
171
|
+
if (!output.includes('ERESOLVE overriding peer dependency') &&
|
|
172
|
+
!output.includes('npm warn ERESOLVE')) {
|
|
173
|
+
process.stderr.write(data);
|
|
174
|
+
}
|
|
175
|
+
stderr += output;
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
proc.on('close', (code) => {
|
|
179
|
+
if (code !== 0) {
|
|
180
|
+
// Check if it's a real error (not just warnings)
|
|
181
|
+
const hasRealError = stderr.includes('npm error') &&
|
|
182
|
+
!stderr.match(/npm error.*ERESOLVE/);
|
|
183
|
+
if (hasRealError) {
|
|
184
|
+
reject(new Error(`Installation failed with code ${code}`));
|
|
185
|
+
} else {
|
|
186
|
+
// Installation succeeded despite warnings
|
|
187
|
+
resolve();
|
|
188
|
+
}
|
|
189
|
+
} else {
|
|
190
|
+
resolve();
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
proc.on('error', reject);
|
|
195
|
+
});
|
|
196
|
+
} else {
|
|
197
|
+
execSync(installCmd, { stdio: 'inherit', cwd: process.cwd() });
|
|
198
|
+
}
|
|
199
|
+
|
|
155
200
|
success(`Dependencies installed successfully`);
|
|
156
201
|
} catch (error) {
|
|
157
202
|
warn(`Failed to install dependencies automatically`);
|
|
@@ -550,7 +595,7 @@ async function fetchCSSFromRegistry(registryUrl) {
|
|
|
550
595
|
return await fetchText(sourceCssPath);
|
|
551
596
|
}
|
|
552
597
|
|
|
553
|
-
async function installCSSStyles(config, registryUrl, forceUpdate = false) {
|
|
598
|
+
async function installCSSStyles(config, registryUrl, forceUpdate = false, silent = false) {
|
|
554
599
|
const cssPath = config.tailwind?.css || 'app/globals.css';
|
|
555
600
|
const fullCssPath = path.join(process.cwd(), cssPath);
|
|
556
601
|
|
|
@@ -560,13 +605,17 @@ async function installCSSStyles(config, registryUrl, forceUpdate = false) {
|
|
|
560
605
|
const existingContent = fs.readFileSync(fullCssPath, 'utf-8');
|
|
561
606
|
hasWeloopStylesInFile = hasWeloopStyles(existingContent);
|
|
562
607
|
|
|
563
|
-
|
|
564
|
-
|
|
608
|
+
// If styles already exist and not forcing update, skip silently
|
|
609
|
+
if (hasWeloopStylesInFile && !forceUpdate && silent) {
|
|
610
|
+
return;
|
|
565
611
|
}
|
|
566
612
|
}
|
|
567
613
|
|
|
568
614
|
try {
|
|
569
|
-
|
|
615
|
+
if (!silent) {
|
|
616
|
+
info('Installing CSS styles...');
|
|
617
|
+
}
|
|
618
|
+
|
|
570
619
|
const cssContent = await fetchCSSFromRegistry(registryUrl);
|
|
571
620
|
ensureDirectoryExists(path.dirname(fullCssPath));
|
|
572
621
|
|
|
@@ -577,9 +626,11 @@ async function installCSSStyles(config, registryUrl, forceUpdate = false) {
|
|
|
577
626
|
if (forceUpdate && fs.existsSync(fullCssPath)) {
|
|
578
627
|
// --overwrite: Replace entire file
|
|
579
628
|
fs.writeFileSync(fullCssPath, processedCssContent);
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
629
|
+
if (!silent) {
|
|
630
|
+
success(`Overwritten ${cssPath} with Weloop styles`);
|
|
631
|
+
if (hasTwAnimate) {
|
|
632
|
+
info(` tw-animate-css import included`);
|
|
633
|
+
}
|
|
583
634
|
}
|
|
584
635
|
} else if (fs.existsSync(fullCssPath)) {
|
|
585
636
|
// Normal mode: Merge intelligently
|
|
@@ -588,30 +639,36 @@ async function installCSSStyles(config, registryUrl, forceUpdate = false) {
|
|
|
588
639
|
existing.includes('@tailwind base');
|
|
589
640
|
|
|
590
641
|
if (hasWeloopStylesInFile) {
|
|
591
|
-
// Replace existing Weloop styles
|
|
642
|
+
// Replace existing Weloop styles (only if different)
|
|
592
643
|
let weloopStyles = removeTailwindImport(processedCssContent);
|
|
593
644
|
weloopStyles = ensureTwAnimateImport(weloopStyles, hasTwAnimate);
|
|
594
645
|
const finalContent = replaceWeloopStyles(existing, weloopStyles, hasTwAnimate);
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
646
|
+
|
|
647
|
+
// Only update if content actually changed
|
|
648
|
+
if (finalContent !== existing) {
|
|
649
|
+
fs.writeFileSync(fullCssPath, finalContent);
|
|
650
|
+
if (!silent) {
|
|
651
|
+
success(`Updated ${cssPath} with Weloop styles`);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
// If no changes, silently skip
|
|
598
655
|
} else if (hasTailwindImport) {
|
|
599
656
|
// Merge after Tailwind imports
|
|
600
657
|
let weloopStyles = removeTailwindImport(processedCssContent);
|
|
601
658
|
weloopStyles = ensureTwAnimateImport(weloopStyles, hasTwAnimate);
|
|
602
659
|
const merged = mergeCSSWithTailwind(existing, weloopStyles, hasTwAnimate);
|
|
603
660
|
fs.writeFileSync(fullCssPath, merged);
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
661
|
+
if (!silent) {
|
|
662
|
+
success(`Updated ${cssPath} with Weloop styles`);
|
|
663
|
+
if (hasTwAnimate) {
|
|
664
|
+
info(` tw-animate-css import included`);
|
|
665
|
+
}
|
|
666
|
+
info(` Your existing styles are preserved`);
|
|
607
667
|
}
|
|
608
|
-
info(` Your existing styles are preserved`);
|
|
609
668
|
} else {
|
|
610
669
|
// No Tailwind imports, prepend everything
|
|
611
|
-
// Remove duplicates from processedCssContent first
|
|
612
670
|
let finalCssContent = removeDuplicateTwAnimateImports(processedCssContent);
|
|
613
671
|
|
|
614
|
-
// Only add if not already present
|
|
615
672
|
if (hasTwAnimate && !finalCssContent.match(/@import\s+["']tw-animate-css["'];?\s*\n?/)) {
|
|
616
673
|
if (finalCssContent.includes('@import "tailwindcss"')) {
|
|
617
674
|
finalCssContent = finalCssContent.replace(
|
|
@@ -623,25 +680,31 @@ async function installCSSStyles(config, registryUrl, forceUpdate = false) {
|
|
|
623
680
|
}
|
|
624
681
|
}
|
|
625
682
|
fs.writeFileSync(fullCssPath, finalCssContent + '\n\n' + existing);
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
683
|
+
if (!silent) {
|
|
684
|
+
success(`Updated ${cssPath} with Weloop styles`);
|
|
685
|
+
if (hasTwAnimate) {
|
|
686
|
+
info(` tw-animate-css import included`);
|
|
687
|
+
}
|
|
629
688
|
}
|
|
630
689
|
}
|
|
631
690
|
} else {
|
|
632
691
|
// Create new file
|
|
633
692
|
fs.writeFileSync(fullCssPath, processedCssContent);
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
693
|
+
if (!silent) {
|
|
694
|
+
success(`Created ${cssPath} with Weloop styles`);
|
|
695
|
+
if (hasTwAnimate) {
|
|
696
|
+
info(` tw-animate-css import included`);
|
|
697
|
+
}
|
|
637
698
|
}
|
|
638
699
|
}
|
|
639
700
|
} catch (err) {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
701
|
+
if (!silent) {
|
|
702
|
+
warn(`Could not automatically install CSS styles: ${err.message}`);
|
|
703
|
+
info(`\n To add styles manually:`);
|
|
704
|
+
info(` 1. Download: ${registryUrl.replace('/registry', '/app/globals.css')}`);
|
|
705
|
+
info(` 2. Add the CSS variables to your ${cssPath} file`);
|
|
706
|
+
info(` 3. Or copy from: https://gitlab.com/Sophanithchrek/weloop-shadcn-next-app/-/raw/main/app/globals.css\n`);
|
|
707
|
+
}
|
|
645
708
|
}
|
|
646
709
|
}
|
|
647
710
|
|
|
@@ -691,8 +754,8 @@ async function installComponent(componentName, options = {}) {
|
|
|
691
754
|
await installPackages(['tw-animate-css']);
|
|
692
755
|
}
|
|
693
756
|
|
|
694
|
-
// Install CSS styles early (before component installation)
|
|
695
|
-
await installCSSStyles(config, registryUrl);
|
|
757
|
+
// Install CSS styles early (before component installation) - silent if already installed
|
|
758
|
+
await installCSSStyles(config, registryUrl, false, true);
|
|
696
759
|
|
|
697
760
|
// Get paths from components.json
|
|
698
761
|
const uiAlias = config.aliases?.ui || '@/components/ui';
|
|
@@ -840,7 +903,7 @@ Examples:
|
|
|
840
903
|
case 'css':
|
|
841
904
|
case 'styles':
|
|
842
905
|
const config = loadComponentsConfig();
|
|
843
|
-
await installCSSStyles(config, registryUrl, options.overwrite);
|
|
906
|
+
await installCSSStyles(config, registryUrl, options.overwrite, false);
|
|
844
907
|
break;
|
|
845
908
|
|
|
846
909
|
default:
|