zerozeeker 2.2.4 → 2.2.5
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/dist/index.js +119 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -177,14 +177,59 @@ function checkTypeScriptConfig(projectRoot) {
|
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
function checkTailwindConfig(projectRoot) {
|
|
180
|
+
const cssFileLocations = [
|
|
181
|
+
"app/globals.css",
|
|
182
|
+
"src/app/globals.css",
|
|
183
|
+
"styles/globals.css",
|
|
184
|
+
"src/styles/globals.css",
|
|
185
|
+
"app/global.css",
|
|
186
|
+
"src/app/global.css",
|
|
187
|
+
"styles/global.css",
|
|
188
|
+
"src/styles/global.css",
|
|
189
|
+
"app/index.css",
|
|
190
|
+
"src/index.css",
|
|
191
|
+
"index.css"
|
|
192
|
+
];
|
|
193
|
+
for (const cssPath of cssFileLocations) {
|
|
194
|
+
const fullPath = join(projectRoot, cssPath);
|
|
195
|
+
if (existsSync(fullPath)) {
|
|
196
|
+
try {
|
|
197
|
+
const content = readFileSync(fullPath, "utf-8");
|
|
198
|
+
if (content.includes('@import "tailwindcss"') || content.includes("@import 'tailwindcss'") || content.includes("@theme")) {
|
|
199
|
+
return { name: "Tailwind CSS v4", passed: true };
|
|
200
|
+
}
|
|
201
|
+
if (content.includes("@tailwind base") || content.includes("@tailwind components") || content.includes("@tailwind utilities")) {
|
|
202
|
+
return { name: "Tailwind CSS v3", passed: true };
|
|
203
|
+
}
|
|
204
|
+
} catch {
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
180
208
|
const tailwindConfigs = [
|
|
181
209
|
"tailwind.config.ts",
|
|
182
210
|
"tailwind.config.js",
|
|
183
211
|
"tailwind.config.mjs",
|
|
184
212
|
"tailwind.config.cjs"
|
|
185
213
|
];
|
|
186
|
-
const
|
|
187
|
-
|
|
214
|
+
const hasTailwindConfig = tailwindConfigs.some((config) => existsSync(join(projectRoot, config)));
|
|
215
|
+
if (hasTailwindConfig) {
|
|
216
|
+
return { name: "Tailwind CSS", passed: true };
|
|
217
|
+
}
|
|
218
|
+
const packageJson = parseJsonFile(join(projectRoot, "package.json"));
|
|
219
|
+
if (packageJson) {
|
|
220
|
+
const deps = {
|
|
221
|
+
...packageJson.dependencies ?? {},
|
|
222
|
+
...packageJson.devDependencies ?? {}
|
|
223
|
+
};
|
|
224
|
+
if (deps.tailwindcss) {
|
|
225
|
+
return {
|
|
226
|
+
name: "Tailwind CSS",
|
|
227
|
+
passed: true,
|
|
228
|
+
message: "Installed but config not detected - may need setup"
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return { name: "Tailwind CSS", passed: false, message: "Config file not found" };
|
|
188
233
|
}
|
|
189
234
|
function checkFramework(projectRoot) {
|
|
190
235
|
const packageJson = parseJsonFile(join(projectRoot, "package.json"));
|
|
@@ -201,7 +246,7 @@ function checkFramework(projectRoot) {
|
|
|
201
246
|
}
|
|
202
247
|
function displaySetupHelp(checks) {
|
|
203
248
|
const tsCheck = checks.find((c) => c.name.startsWith("TypeScript"));
|
|
204
|
-
const tailwindCheck = checks.find((c) => c.name
|
|
249
|
+
const tailwindCheck = checks.find((c) => c.name.startsWith("Tailwind"));
|
|
205
250
|
const pm = detectPackageManager();
|
|
206
251
|
if (tsCheck && !tsCheck.passed) {
|
|
207
252
|
console.log(chalk.dim("Install TypeScript:"));
|
|
@@ -210,7 +255,9 @@ function displaySetupHelp(checks) {
|
|
|
210
255
|
console.log(chalk.white(" npx tsc --init"));
|
|
211
256
|
}
|
|
212
257
|
if (tailwindCheck && !tailwindCheck.passed) {
|
|
213
|
-
console.log(chalk.dim("\nInstall Tailwind CSS:"));
|
|
258
|
+
console.log(chalk.dim("\nInstall Tailwind CSS v4:"));
|
|
259
|
+
console.log(chalk.white(` ${pm} ${pm === "npm" ? "install" : "add"} -D tailwindcss @tailwindcss/postcss postcss`));
|
|
260
|
+
console.log(chalk.dim("\nOr for Tailwind CSS v3:"));
|
|
214
261
|
console.log(chalk.white(` ${pm} ${pm === "npm" ? "install" : "add"} -D tailwindcss postcss autoprefixer`));
|
|
215
262
|
console.log(chalk.white(" npx tailwindcss init -p"));
|
|
216
263
|
}
|
|
@@ -237,14 +284,73 @@ async function autoFixSetup(projectRoot, needsTypeScript, needsTailwind, spinner
|
|
|
237
284
|
tsconfig.compilerOptions.paths["@/lib/*"] = ["lib/*"];
|
|
238
285
|
writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2), "utf-8");
|
|
239
286
|
if (needsTailwind) {
|
|
240
|
-
spinner.text = "Installing Tailwind CSS...";
|
|
241
|
-
execSync(`${pm} ${installCmd} -D tailwindcss postcss autoprefixer`, { stdio: "inherit" });
|
|
242
|
-
spinner.text = "Initializing Tailwind config...";
|
|
287
|
+
spinner.text = "Installing Tailwind CSS v4...";
|
|
243
288
|
try {
|
|
244
|
-
execSync(
|
|
289
|
+
execSync(`${pm} ${installCmd} -D tailwindcss @tailwindcss/postcss postcss`, { stdio: "inherit" });
|
|
245
290
|
} catch {
|
|
246
|
-
console.warn(chalk.yellow("\nWarning:
|
|
247
|
-
|
|
291
|
+
console.warn(chalk.yellow("\nWarning: Tailwind CSS v4 packages not available. Installing v3 instead."));
|
|
292
|
+
execSync(`${pm} ${installCmd} -D tailwindcss postcss autoprefixer`, { stdio: "inherit" });
|
|
293
|
+
}
|
|
294
|
+
spinner.text = "Creating Tailwind CSS configuration...";
|
|
295
|
+
try {
|
|
296
|
+
const postcssConfig = `export default {
|
|
297
|
+
plugins: {
|
|
298
|
+
"@tailwindcss/postcss": {},
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
`;
|
|
302
|
+
const appDir = join(projectRoot, "app");
|
|
303
|
+
const srcAppDir = join(projectRoot, "src", "app");
|
|
304
|
+
let globalsCssDir;
|
|
305
|
+
let globalsCssPath;
|
|
306
|
+
if (existsSync(srcAppDir)) {
|
|
307
|
+
globalsCssDir = srcAppDir;
|
|
308
|
+
globalsCssPath = join(srcAppDir, "globals.css");
|
|
309
|
+
} else if (existsSync(appDir)) {
|
|
310
|
+
globalsCssDir = appDir;
|
|
311
|
+
globalsCssPath = join(appDir, "globals.css");
|
|
312
|
+
} else {
|
|
313
|
+
globalsCssDir = appDir;
|
|
314
|
+
globalsCssPath = join(appDir, "globals.css");
|
|
315
|
+
mkdirSync(appDir, { recursive: true });
|
|
316
|
+
}
|
|
317
|
+
const globals = `@import "tailwindcss";
|
|
318
|
+
|
|
319
|
+
/*
|
|
320
|
+
* Tailwind CSS v4 uses CSS-first configuration.
|
|
321
|
+
* Customize your theme using the @theme directive:
|
|
322
|
+
*
|
|
323
|
+
* @theme {
|
|
324
|
+
* --color-primary: oklch(0.7 0.15 200);
|
|
325
|
+
* --font-display: "Satoshi", sans-serif;
|
|
326
|
+
* }
|
|
327
|
+
*
|
|
328
|
+
* Learn more: https://tailwindcss.com/docs/v4-beta
|
|
329
|
+
*/
|
|
330
|
+
`;
|
|
331
|
+
writeFileSync(join(projectRoot, "postcss.config.mjs"), postcssConfig, "utf-8");
|
|
332
|
+
if (!existsSync(globalsCssPath)) {
|
|
333
|
+
writeFileSync(globalsCssPath, globals, "utf-8");
|
|
334
|
+
console.log(chalk.green(`Created postcss.config.mjs and ${globalsCssPath.replace(projectRoot, "")}`));
|
|
335
|
+
} else {
|
|
336
|
+
const existingContent = readFileSync(globalsCssPath, "utf-8");
|
|
337
|
+
if (!existingContent.includes('@import "tailwindcss"') && !existingContent.includes("@import 'tailwindcss'") && !existingContent.includes("@tailwind")) {
|
|
338
|
+
writeFileSync(globalsCssPath, `@import "tailwindcss";
|
|
339
|
+
|
|
340
|
+
${existingContent}`, "utf-8");
|
|
341
|
+
console.log(chalk.green(`Created postcss.config.mjs and added Tailwind import to ${globalsCssPath.replace(projectRoot, "")}`));
|
|
342
|
+
} else {
|
|
343
|
+
console.log(chalk.green("Created postcss.config.mjs"));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
} catch (writeErr) {
|
|
347
|
+
const errorMessage = writeErr instanceof Error ? writeErr.message : String(writeErr);
|
|
348
|
+
console.warn(chalk.yellow(`Failed to write Tailwind config files: ${errorMessage}`));
|
|
349
|
+
console.log(chalk.dim("Attempting fallback to Tailwind v3 configuration..."));
|
|
350
|
+
try {
|
|
351
|
+
execSync("npx tailwindcss init -p", { stdio: "inherit" });
|
|
352
|
+
} catch {
|
|
353
|
+
const tailwindConfig = `/** @type {import('tailwindcss').Config} */
|
|
248
354
|
export default {
|
|
249
355
|
content: [
|
|
250
356
|
'./app/**/*.{js,ts,jsx,tsx,mdx}',
|
|
@@ -257,33 +363,16 @@ export default {
|
|
|
257
363
|
plugins: [],
|
|
258
364
|
};
|
|
259
365
|
`;
|
|
260
|
-
|
|
366
|
+
const postcssConfig = `export default {
|
|
261
367
|
plugins: {
|
|
262
368
|
tailwindcss: {},
|
|
263
369
|
autoprefixer: {},
|
|
264
370
|
},
|
|
265
371
|
};
|
|
266
372
|
`;
|
|
267
|
-
const globalsCssDir = join(projectRoot, "app");
|
|
268
|
-
const globalsCssPath = join(globalsCssDir, "globals.css");
|
|
269
|
-
try {
|
|
270
373
|
writeFileSync(join(projectRoot, "tailwind.config.js"), tailwindConfig, "utf-8");
|
|
271
374
|
writeFileSync(join(projectRoot, "postcss.config.js"), postcssConfig, "utf-8");
|
|
272
|
-
|
|
273
|
-
mkdirSync(globalsCssDir, { recursive: true });
|
|
274
|
-
}
|
|
275
|
-
if (!existsSync(globalsCssPath)) {
|
|
276
|
-
const globals = `@tailwind base;
|
|
277
|
-
@tailwind components;
|
|
278
|
-
@tailwind utilities;
|
|
279
|
-
`;
|
|
280
|
-
writeFileSync(globalsCssPath, globals, "utf-8");
|
|
281
|
-
}
|
|
282
|
-
console.log(chalk.green("Created tailwind.config.js, postcss.config.js, and app/globals.css"));
|
|
283
|
-
} catch (writeErr) {
|
|
284
|
-
const errorMessage = writeErr instanceof Error ? writeErr.message : String(writeErr);
|
|
285
|
-
console.warn(chalk.yellow(`Failed to write fallback Tailwind files: ${errorMessage}`));
|
|
286
|
-
throw writeErr;
|
|
375
|
+
console.log(chalk.green("Created tailwind.config.js and postcss.config.js (v3 fallback)"));
|
|
287
376
|
}
|
|
288
377
|
}
|
|
289
378
|
}
|
|
@@ -329,7 +418,7 @@ program.command("init").description("Initialize ZeroZeeker in your project").act
|
|
|
329
418
|
console.log(chalk.yellow("\n[!] Some setup issues detected\n"));
|
|
330
419
|
displaySetupHelp(checks);
|
|
331
420
|
const needsTypeScript = !checks.find((c) => c.name.startsWith("TypeScript"))?.passed;
|
|
332
|
-
const needsTailwind = !checks.find((c) => c.name
|
|
421
|
+
const needsTailwind = !checks.find((c) => c.name.startsWith("Tailwind"))?.passed;
|
|
333
422
|
const doAuto = await askYesNo("Would you like ZeroZeeker to try to automatically fix these issues now?", true);
|
|
334
423
|
if (!doAuto) {
|
|
335
424
|
process.exit(1);
|