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

Function updateTailwindConfig

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

Source from the content-addressed store, hash-verified

171
172// Update Tailwind config to include Cedar component paths
173export async function updateTailwindConfig(
174 componentDir: string
175): Promise<void> {
176 const tailwindInfo = await detectTailwindCSS();
177
178 if (!tailwindInfo.configPath) {
179 console.log(pc.yellow('⚠️ No Tailwind config file found to update.'));
180 return;
181 }
182
183 try {
184 const configPath = path.join(process.cwd(), tailwindInfo.configPath);
185 let configContent = await fs.readFile(configPath, 'utf-8');
186
187 // Add Cedar component paths to content array
188 const cedarPaths = `\n './${componentDir}/**/*.{js,ts,jsx,tsx}',`;
189
190 // Try to find the content array and add our paths
191 if (configContent.includes('content:')) {
192 // Check if our specific path is already there
193 const expectedPath = `'./${componentDir}/**/*.{js,ts,jsx,tsx}'`;
194 if (!configContent.includes(expectedPath)) {
195 // Find content array and add our path
196 configContent = configContent.replace(
197 /(content:\s*\[)/,
198 `$1${cedarPaths}`
199 );
200
201 await fs.writeFile(configPath, configContent, 'utf-8');
202 console.log(
203 pc.green(
204 `✅ Updated ${tailwindInfo.configPath} to include Cedar components`
205 )
206 );
207 }
208 } else {
209 console.log(
210 pc.yellow('⚠️ Could not find content array in Tailwind config.')
211 );
212 console.log(
213 pc.gray(` Please add the following to your content array:`)
214 );
215 console.log(pc.cyan(` './${componentDir}/**/*.{js,ts,jsx,tsx}'`));
216 }
217 } catch {
218 console.log(
219 pc.yellow('⚠️ Could not update Tailwind config automatically.')
220 );
221 console.log(
222 pc.gray(
223 ` Please add the following to your content array in ${tailwindInfo.configPath}:`
224 )
225 );
226 console.log(pc.cyan(` './${componentDir}/**/*.{js,ts,jsx,tsx}'`));
227 }
228}
229
230// Main function to handle Tailwind setup

Callers 1

ensureTailwindSetupFunction · 0.85

Calls 1

detectTailwindCSSFunction · 0.85

Tested by

no test coverage detected