zerozeeker 2.2.4 → 2.2.6

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.
Files changed (2) hide show
  1. package/dist/index.js +115 -30
  2. 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 hasTailwind = tailwindConfigs.some((config) => existsSync(join(projectRoot, config)));
187
- return hasTailwind ? { name: "Tailwind CSS", passed: true } : { name: "Tailwind CSS", passed: false, message: "Config file not found" };
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 === "Tailwind CSS");
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,69 @@ 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("npx tailwindcss init -p", { stdio: "inherit" });
289
+ execSync(`${pm} ${installCmd} -D tailwindcss @tailwindcss/postcss postcss`, { stdio: "inherit" });
245
290
  } catch {
246
- console.warn(chalk.yellow("\nWarning: `npx tailwindcss init -p` failed. Creating default config files instead."));
247
- const tailwindConfig = `/** @type {import('tailwindcss').Config} */
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 globalsCssPath;
305
+ if (existsSync(srcAppDir)) {
306
+ globalsCssPath = join(srcAppDir, "globals.css");
307
+ } else if (existsSync(appDir)) {
308
+ globalsCssPath = join(appDir, "globals.css");
309
+ } else {
310
+ globalsCssPath = join(appDir, "globals.css");
311
+ mkdirSync(appDir, { recursive: true });
312
+ }
313
+ const globals = `@import "tailwindcss";
314
+
315
+ /*
316
+ * Tailwind CSS v4 uses CSS-first configuration.
317
+ * Customize your theme using the @theme directive:
318
+ *
319
+ * @theme {
320
+ * --color-primary: oklch(0.7 0.15 200);
321
+ * --font-display: "Satoshi", sans-serif;
322
+ * }
323
+ *
324
+ * Learn more: https://tailwindcss.com/docs/v4-beta
325
+ */
326
+ `;
327
+ writeFileSync(join(projectRoot, "postcss.config.mjs"), postcssConfig, "utf-8");
328
+ if (!existsSync(globalsCssPath)) {
329
+ writeFileSync(globalsCssPath, globals, "utf-8");
330
+ console.log(chalk.green(`Created postcss.config.mjs and ${globalsCssPath.replace(projectRoot, "")}`));
331
+ } else {
332
+ const existingContent = readFileSync(globalsCssPath, "utf-8");
333
+ if (!existingContent.includes('@import "tailwindcss"') && !existingContent.includes("@import 'tailwindcss'") && !existingContent.includes("@tailwind")) {
334
+ writeFileSync(globalsCssPath, `@import "tailwindcss";
335
+
336
+ ${existingContent}`, "utf-8");
337
+ console.log(chalk.green(`Created postcss.config.mjs and added Tailwind import to ${globalsCssPath.replace(projectRoot, "")}`));
338
+ } else {
339
+ console.log(chalk.green("Created postcss.config.mjs"));
340
+ }
341
+ }
342
+ } catch (writeErr) {
343
+ const errorMessage = writeErr instanceof Error ? writeErr.message : String(writeErr);
344
+ console.warn(chalk.yellow(`Failed to write Tailwind config files: ${errorMessage}`));
345
+ console.log(chalk.dim("Attempting fallback to Tailwind v3 configuration..."));
346
+ try {
347
+ execSync("npx tailwindcss init -p", { stdio: "inherit" });
348
+ } catch {
349
+ const tailwindConfig = `/** @type {import('tailwindcss').Config} */
248
350
  export default {
249
351
  content: [
250
352
  './app/**/*.{js,ts,jsx,tsx,mdx}',
@@ -257,33 +359,16 @@ export default {
257
359
  plugins: [],
258
360
  };
259
361
  `;
260
- const postcssConfig = `export default {
362
+ const postcssConfig = `export default {
261
363
  plugins: {
262
364
  tailwindcss: {},
263
365
  autoprefixer: {},
264
366
  },
265
367
  };
266
368
  `;
267
- const globalsCssDir = join(projectRoot, "app");
268
- const globalsCssPath = join(globalsCssDir, "globals.css");
269
- try {
270
369
  writeFileSync(join(projectRoot, "tailwind.config.js"), tailwindConfig, "utf-8");
271
370
  writeFileSync(join(projectRoot, "postcss.config.js"), postcssConfig, "utf-8");
272
- if (!existsSync(globalsCssDir)) {
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;
371
+ console.log(chalk.green("Created tailwind.config.js and postcss.config.js (v3 fallback)"));
287
372
  }
288
373
  }
289
374
  }
@@ -329,7 +414,7 @@ program.command("init").description("Initialize ZeroZeeker in your project").act
329
414
  console.log(chalk.yellow("\n[!] Some setup issues detected\n"));
330
415
  displaySetupHelp(checks);
331
416
  const needsTypeScript = !checks.find((c) => c.name.startsWith("TypeScript"))?.passed;
332
- const needsTailwind = !checks.find((c) => c.name === "Tailwind CSS")?.passed;
417
+ const needsTailwind = !checks.find((c) => c.name.startsWith("Tailwind"))?.passed;
333
418
  const doAuto = await askYesNo("Would you like ZeroZeeker to try to automatically fix these issues now?", true);
334
419
  if (!doAuto) {
335
420
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zerozeeker",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "description": "Zero-config CLI for installing ZeroZeeker UI components. No shadcn required.",
5
5
  "type": "module",
6
6
  "bin": {