zerozeeker 2.2.0 → 2.2.1
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 +57 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { Command } from "commander";
|
|
|
5
5
|
import { execSync } from "child_process";
|
|
6
6
|
import { existsSync, mkdirSync, writeFileSync, readFileSync } from "fs";
|
|
7
7
|
import { join, dirname } from "path";
|
|
8
|
+
import readline from "readline";
|
|
8
9
|
import ora from "ora";
|
|
9
10
|
import chalk from "chalk";
|
|
10
11
|
var REGISTRY_URL = "https://www.zerozeeker.com/r";
|
|
@@ -177,7 +178,62 @@ program.command("init").description("Initialize ZeroZeeker in your project").act
|
|
|
177
178
|
}
|
|
178
179
|
console.log(chalk.dim("\nOr create a new Next.js project:"));
|
|
179
180
|
console.log(chalk.white(" npx create-next-app@latest --typescript --tailwind\n"));
|
|
180
|
-
|
|
181
|
+
async function askYesNo(question, defaultYes = false) {
|
|
182
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
183
|
+
return new Promise((resolve) => {
|
|
184
|
+
rl.question(`${question} (${defaultYes ? "Y/n" : "y/N"}): `, (answer) => {
|
|
185
|
+
rl.close();
|
|
186
|
+
const a = answer.trim().toLowerCase();
|
|
187
|
+
if (a === "") return resolve(defaultYes);
|
|
188
|
+
if (["y", "yes"].includes(a)) return resolve(true);
|
|
189
|
+
return resolve(false);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
const needsTypeScript = !checks.find((c) => c.name === "TypeScript" || c.name === "TypeScript paths" || c.name === "TypeScript config")?.passed;
|
|
194
|
+
const tsPathsMissing = checks.find((c) => c.name === "TypeScript paths" && !c.passed) !== void 0;
|
|
195
|
+
const needsTailwind = !checks.find((c) => c.name === "Tailwind CSS")?.passed;
|
|
196
|
+
const doAuto = await askYesNo("Would you like ZeroZeeker to try to automatically fix these issues now?", true);
|
|
197
|
+
if (!doAuto) process.exit(1);
|
|
198
|
+
spinner.start();
|
|
199
|
+
try {
|
|
200
|
+
if (needsTypeScript) {
|
|
201
|
+
spinner.text = "Installing TypeScript and types...";
|
|
202
|
+
execSync("npm install -D typescript @types/node @types/react", { stdio: "inherit" });
|
|
203
|
+
}
|
|
204
|
+
const tsconfigPath2 = join(projectRoot, "tsconfig.json");
|
|
205
|
+
let tsconfig = {};
|
|
206
|
+
if (existsSync(tsconfigPath2)) {
|
|
207
|
+
try {
|
|
208
|
+
tsconfig = JSON.parse(readFileSync(tsconfigPath2, "utf-8"));
|
|
209
|
+
} catch {
|
|
210
|
+
tsconfig = {};
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
spinner.text = "Creating tsconfig.json...";
|
|
214
|
+
tsconfig = { compilerOptions: {} };
|
|
215
|
+
writeFileSync(tsconfigPath2, JSON.stringify(tsconfig, null, 2), "utf-8");
|
|
216
|
+
}
|
|
217
|
+
tsconfig.compilerOptions = tsconfig.compilerOptions || {};
|
|
218
|
+
tsconfig.compilerOptions.baseUrl = tsconfig.compilerOptions.baseUrl || ".";
|
|
219
|
+
tsconfig.compilerOptions.paths = tsconfig.compilerOptions.paths || {};
|
|
220
|
+
tsconfig.compilerOptions.paths["@/components/*"] = ["components/*"];
|
|
221
|
+
tsconfig.compilerOptions.paths["@/lib/*"] = ["lib/*"];
|
|
222
|
+
writeFileSync(tsconfigPath2, JSON.stringify(tsconfig, null, 2), "utf-8");
|
|
223
|
+
if (needsTailwind) {
|
|
224
|
+
spinner.text = "Installing Tailwind CSS...";
|
|
225
|
+
execSync("npm install -D tailwindcss postcss autoprefixer", { stdio: "inherit" });
|
|
226
|
+
spinner.text = "Initializing Tailwind config...";
|
|
227
|
+
execSync("npx tailwindcss init -p", { stdio: "inherit" });
|
|
228
|
+
}
|
|
229
|
+
spinner.stop();
|
|
230
|
+
console.log(chalk.green("\n\u2705 Auto-fix complete. Re-run `npx zerozeeker init` to re-check, or proceed to install components."));
|
|
231
|
+
process.exit(0);
|
|
232
|
+
} catch (err) {
|
|
233
|
+
spinner.stop();
|
|
234
|
+
console.error(chalk.red("\n\u2717 Auto-fix failed. See errors above."));
|
|
235
|
+
process.exit(1);
|
|
236
|
+
}
|
|
181
237
|
}
|
|
182
238
|
} catch (error) {
|
|
183
239
|
spinner.stop();
|