()
| 118 | |
| 119 | // Add Tailwind import to global CSS file |
| 120 | export async function addTailwindImportToCSS(): Promise<void> { |
| 121 | const commonCssFiles = [ |
| 122 | 'src/styles/globals.css', |
| 123 | 'src/app/globals.css', |
| 124 | 'styles/globals.css', |
| 125 | 'app/globals.css', |
| 126 | 'src/index.css', |
| 127 | 'index.css', |
| 128 | ]; |
| 129 | |
| 130 | let cssFilePath: string | undefined; |
| 131 | |
| 132 | // Find existing CSS file |
| 133 | for (const filePath of commonCssFiles) { |
| 134 | const fullPath = path.join(process.cwd(), filePath); |
| 135 | try { |
| 136 | await fs.access(fullPath); |
| 137 | cssFilePath = fullPath; |
| 138 | break; |
| 139 | } catch { |
| 140 | // File doesn't exist, continue checking |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | if (!cssFilePath) { |
| 145 | console.log(pc.yellow('⚠️ Could not find a global CSS file.')); |
| 146 | console.log(pc.gray(' Please add the following to your main CSS file:')); |
| 147 | console.log(pc.cyan(' @import "tailwindcss";')); |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | try { |
| 152 | let cssContent = await fs.readFile(cssFilePath, 'utf-8'); |
| 153 | |
| 154 | // Check if Tailwind import already exists |
| 155 | if (cssContent.includes('@import "tailwindcss"') || cssContent.includes("@import 'tailwindcss'")) { |
| 156 | console.log(pc.green('✅ Tailwind import already exists in CSS')); |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | // Add import to the top of the file |
| 161 | cssContent = `@import "tailwindcss";\n\n${cssContent}`; |
| 162 | |
| 163 | await fs.writeFile(cssFilePath, cssContent, 'utf-8'); |
| 164 | console.log(pc.green(`✅ Added Tailwind import to ${path.relative(process.cwd(), cssFilePath)}`)); |
| 165 | } catch { |
| 166 | console.log(pc.yellow('⚠️ Could not update CSS file automatically.')); |
| 167 | console.log(pc.gray(' Please add the following to your main CSS file:')); |
| 168 | console.log(pc.cyan(' @import "tailwindcss";')); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | // Update Tailwind config to include Cedar component paths |
| 173 | export async function updateTailwindConfig( |
no outgoing calls
no test coverage detected