MCPcopy Create free account
hub / github.com/CedarCopilot/cedar-OS / ensureTailwindSetup

Function ensureTailwindSetup

packages/cli/src/utils/tailwindSetup.ts:231–300  ·  view source on GitHub ↗
(componentDir: string)

Source from the content-addressed store, hash-verified

229
230// Main function to handle Tailwind setup
231export 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

Callers 1

addSaplingCommandFunction · 0.90

Calls 6

detectPackageManagerFunction · 0.90
detectTailwindCSSFunction · 0.85
installTailwindCSSFunction · 0.85
initializeTailwindConfigFunction · 0.85
addTailwindImportToCSSFunction · 0.85
updateTailwindConfigFunction · 0.85

Tested by

no test coverage detected