gladvn 0.2.32 → 0.2.33
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/bin/cli.js +41 -3
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -511,6 +511,8 @@ async function main() {
|
|
|
511
511
|
|
|
512
512
|
if (viteConfigPath) {
|
|
513
513
|
let content = fs.readFileSync(viteConfigPath, 'utf8');
|
|
514
|
+
let modified = false;
|
|
515
|
+
|
|
514
516
|
if (!content.includes('@gladvn')) {
|
|
515
517
|
// Add `import path from "path"` if missing
|
|
516
518
|
if (!content.includes('import path from') && !content.includes('require("path")')) {
|
|
@@ -538,9 +540,35 @@ async function main() {
|
|
|
538
540
|
} else {
|
|
539
541
|
content = content.replace(/defineConfig\s*\(\s*\{/, `defineConfig({${resolveAlias}`);
|
|
540
542
|
}
|
|
543
|
+
modified = true;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (!content.includes('@tailwindcss/vite')) {
|
|
547
|
+
if (content.includes('import ')) {
|
|
548
|
+
const lastImportIndex = content.lastIndexOf('import ');
|
|
549
|
+
const endOfLine = content.indexOf('\n', lastImportIndex);
|
|
550
|
+
if (endOfLine !== -1) {
|
|
551
|
+
content = content.slice(0, endOfLine + 1) + 'import tailwindcss from "@tailwindcss/vite"\n' + content.slice(endOfLine + 1);
|
|
552
|
+
} else {
|
|
553
|
+
content = 'import tailwindcss from "@tailwindcss/vite"\n' + content;
|
|
554
|
+
}
|
|
555
|
+
} else {
|
|
556
|
+
content = 'import tailwindcss from "@tailwindcss/vite"\n' + content;
|
|
557
|
+
}
|
|
541
558
|
|
|
559
|
+
if (content.includes('plugins: [')) {
|
|
560
|
+
content = content.replace(/plugins:\s*\[/, `plugins: [\n tailwindcss(),`);
|
|
561
|
+
} else if (content.match(/plugins:\s*\[/)) {
|
|
562
|
+
content = content.replace(/plugins:\s*\[/, `plugins: [\n tailwindcss(),`);
|
|
563
|
+
} else if (content.includes('defineConfig({')) {
|
|
564
|
+
content = content.replace(/defineConfig\s*\(\s*\{/, `defineConfig({\n plugins: [tailwindcss()],`);
|
|
565
|
+
}
|
|
566
|
+
modified = true;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (modified) {
|
|
542
570
|
fs.writeFileSync(viteConfigPath, content);
|
|
543
|
-
console.log(`\x1b[32m✔ Configured resolve.alias in ${path.basename(viteConfigPath)}\x1b[0m`);
|
|
571
|
+
console.log(`\x1b[32m✔ Configured resolve.alias & tailwindcss plugin in ${path.basename(viteConfigPath)}\x1b[0m`);
|
|
544
572
|
}
|
|
545
573
|
}
|
|
546
574
|
|
|
@@ -552,15 +580,25 @@ async function main() {
|
|
|
552
580
|
|
|
553
581
|
// Check if we need @types/node (Vite + TypeScript)
|
|
554
582
|
const viteConfigExists = ['vite.config.ts', 'vite.config.mts'].some(f => fs.existsSync(path.join(process.cwd(), f)));
|
|
555
|
-
if (viteConfigExists) {
|
|
583
|
+
if (viteConfigExists || viteConfigPath) {
|
|
556
584
|
try {
|
|
557
585
|
const userPkgPath = path.resolve(process.cwd(), 'package.json');
|
|
558
586
|
if (fs.existsSync(userPkgPath)) {
|
|
559
587
|
const userPkg = JSON.parse(fs.readFileSync(userPkgPath, 'utf8'));
|
|
560
588
|
const allUserDeps = { ...userPkg.dependencies, ...userPkg.devDependencies };
|
|
561
|
-
if (!allUserDeps['@types/node']) {
|
|
589
|
+
if (viteConfigExists && !allUserDeps['@types/node']) {
|
|
562
590
|
extraDepsToInstall.push('@types/node@"^20.0.0"');
|
|
563
591
|
}
|
|
592
|
+
if (!allUserDeps['tailwindcss']) {
|
|
593
|
+
extraDepsToInstall.push('tailwindcss@"^4.0.0"');
|
|
594
|
+
}
|
|
595
|
+
if (!allUserDeps['@tailwindcss/vite']) {
|
|
596
|
+
extraDepsToInstall.push('@tailwindcss/vite@"^4.0.0"');
|
|
597
|
+
}
|
|
598
|
+
} else {
|
|
599
|
+
// If no package.json, just push them to be safe
|
|
600
|
+
extraDepsToInstall.push('tailwindcss@"^4.0.0"');
|
|
601
|
+
extraDepsToInstall.push('@tailwindcss/vite@"^4.0.0"');
|
|
564
602
|
}
|
|
565
603
|
} catch (e) {}
|
|
566
604
|
}
|
package/package.json
CHANGED