(componentDir: string)
| 229 | |
| 230 | // Main function to handle Tailwind setup |
| 231 | export async function ensureTailwindSetup(componentDir: string): Promise<void> { |
| 232 | console.log(pc.blue('\n🎨 Checking Tailwind CSS setup...')); |
| 233 | |
| 234 | const tailwindInfo = await detectTailwindCSS(); |
| 235 | |
| 236 | if (!tailwindInfo.hasTailwind) { |
| 237 | console.log( |
| 238 | pc.yellow('\n⚠️ Tailwind CSS is required for Cedar components.') |
| 239 | ); |
| 240 | |
| 241 | const shouldInstall = await confirm({ |
| 242 | message: 'Would you like to install Tailwind CSS now?', |
| 243 | initialValue: true, |
| 244 | }); |
| 245 | |
| 246 | if (p.isCancel(shouldInstall)) { |
| 247 | p.cancel('Operation cancelled.'); |
| 248 | process.exit(0); |
| 249 | } |
| 250 | |
| 251 | if (!shouldInstall) { |
| 252 | console.log( |
| 253 | pc.red('\n❌ Cedar components require Tailwind CSS to work properly.') |
| 254 | ); |
| 255 | console.log(pc.gray(' Please install it manually:')); |
| 256 | const { manager } = detectPackageManager(); |
| 257 | const devFlag = manager === 'npm' ? '--save-dev' : '-D'; |
| 258 | console.log( |
| 259 | pc.cyan( |
| 260 | ` ${manager} ${ |
| 261 | manager === 'npm' ? 'install' : 'add' |
| 262 | } ${devFlag} @tailwindcss/postcss tailwindcss` |
| 263 | ) |
| 264 | ); |
| 265 | console.log( |
| 266 | pc.gray( |
| 267 | '\n Then add Cedar components to your tailwind.config.js content array:' |
| 268 | ) |
| 269 | ); |
| 270 | console.log(pc.cyan(` './${componentDir}/**/*.{js,ts,jsx,tsx}'`)); |
| 271 | process.exit(1); |
| 272 | } |
| 273 | |
| 274 | // Install Tailwind |
| 275 | const installed = await installTailwindCSS(); |
| 276 | if (!installed) { |
| 277 | process.exit(1); |
| 278 | } |
| 279 | |
| 280 | // Initialize PostCSS config |
| 281 | const initialized = await initializeTailwindConfig(); |
| 282 | if (!initialized) { |
| 283 | console.log(pc.yellow('⚠️ Please create postcss.config.mjs manually.')); |
| 284 | } |
| 285 | |
| 286 | // Add Tailwind import to CSS |
| 287 | await addTailwindImportToCSS(); |
| 288 |
no test coverage detected