@teardown/cli 2.0.50 → 2.0.51
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/package.json +2 -2
- package/src/cli/commands/init.ts +52 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teardown/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.51",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@biomejs/biome": "2.3.11",
|
|
74
|
-
"@teardown/tsconfig": "2.0.
|
|
74
|
+
"@teardown/tsconfig": "2.0.51",
|
|
75
75
|
"@types/bun": "1.3.5",
|
|
76
76
|
"@types/ejs": "^3.1.5",
|
|
77
77
|
"typescript": "5.9.3"
|
package/src/cli/commands/init.ts
CHANGED
|
@@ -70,6 +70,7 @@ export function createInitCommand(): Command {
|
|
|
70
70
|
.option("--skip-src", "Skip generating src folder", false)
|
|
71
71
|
.option("--skip-git", "Skip generating .gitignore", false)
|
|
72
72
|
.option("--skip-install", "Skip installing dependencies", false)
|
|
73
|
+
.option("-v, --verbose", "Show detailed output", false)
|
|
73
74
|
.action(async (name: string, options) => {
|
|
74
75
|
const spinner = ora("Initializing project...").start();
|
|
75
76
|
|
|
@@ -203,6 +204,9 @@ export function createInitCommand(): Command {
|
|
|
203
204
|
// Run bun install (unless skipped)
|
|
204
205
|
if (!options.skipInstall) {
|
|
205
206
|
const installSpinner = ora("Installing dependencies...").start();
|
|
207
|
+
const startTime = Date.now();
|
|
208
|
+
let lastLogTime = startTime;
|
|
209
|
+
|
|
206
210
|
await new Promise<void>((resolve, reject) => {
|
|
207
211
|
const child = spawn("bun", ["install"], {
|
|
208
212
|
cwd: projectRoot,
|
|
@@ -210,25 +214,71 @@ export function createInitCommand(): Command {
|
|
|
210
214
|
});
|
|
211
215
|
|
|
212
216
|
let stderr = "";
|
|
217
|
+
let stdout = "";
|
|
218
|
+
|
|
219
|
+
// Log progress periodically
|
|
220
|
+
const progressInterval = setInterval(() => {
|
|
221
|
+
const elapsed = Math.round((Date.now() - startTime) / 1000);
|
|
222
|
+
installSpinner.text = `Installing dependencies... (${elapsed}s)`;
|
|
223
|
+
}, 1000);
|
|
224
|
+
|
|
225
|
+
// Log stdout for debugging
|
|
226
|
+
child.stdout?.on("data", (data) => {
|
|
227
|
+
stdout += data.toString();
|
|
228
|
+
const now = Date.now();
|
|
229
|
+
// Log every 5 seconds if there's activity
|
|
230
|
+
if (now - lastLogTime > 5000) {
|
|
231
|
+
const lines = stdout.trim().split("\n");
|
|
232
|
+
const lastLine = lines[lines.length - 1];
|
|
233
|
+
if (lastLine && options.verbose) {
|
|
234
|
+
console.log(chalk.gray(` [bun] ${lastLine}`));
|
|
235
|
+
}
|
|
236
|
+
lastLogTime = now;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
213
240
|
child.stderr?.on("data", (data) => {
|
|
214
241
|
stderr += data.toString();
|
|
215
242
|
});
|
|
216
243
|
|
|
217
244
|
child.on("close", (code) => {
|
|
245
|
+
clearInterval(progressInterval);
|
|
246
|
+
const elapsed = Math.round((Date.now() - startTime) / 1000);
|
|
218
247
|
if (code === 0) {
|
|
219
|
-
installSpinner.succeed(
|
|
248
|
+
installSpinner.succeed(`Dependencies installed (${elapsed}s)`);
|
|
220
249
|
resolve();
|
|
221
250
|
} else {
|
|
222
|
-
installSpinner.fail(
|
|
251
|
+
installSpinner.fail(`Failed to install dependencies after ${elapsed}s`);
|
|
223
252
|
console.error(chalk.red(stderr));
|
|
253
|
+
if (stdout && options.verbose) {
|
|
254
|
+
console.log(chalk.gray("Stdout:"), stdout);
|
|
255
|
+
}
|
|
224
256
|
reject(new Error(`bun install exited with code ${code}`));
|
|
225
257
|
}
|
|
226
258
|
});
|
|
227
259
|
|
|
228
260
|
child.on("error", (err) => {
|
|
261
|
+
clearInterval(progressInterval);
|
|
229
262
|
installSpinner.fail("Failed to run bun install");
|
|
263
|
+
console.error(chalk.red(`Error: ${err.message}`));
|
|
230
264
|
reject(err);
|
|
231
265
|
});
|
|
266
|
+
|
|
267
|
+
// Timeout after 5 minutes
|
|
268
|
+
const timeout = setTimeout(
|
|
269
|
+
() => {
|
|
270
|
+
clearInterval(progressInterval);
|
|
271
|
+
child.kill("SIGTERM");
|
|
272
|
+
installSpinner.fail("bun install timed out after 5 minutes");
|
|
273
|
+
if (stdout) {
|
|
274
|
+
console.log(chalk.gray("Last output:"), stdout.slice(-500));
|
|
275
|
+
}
|
|
276
|
+
reject(new Error("bun install timed out"));
|
|
277
|
+
},
|
|
278
|
+
5 * 60 * 1000
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
child.on("close", () => clearTimeout(timeout));
|
|
232
282
|
});
|
|
233
283
|
}
|
|
234
284
|
|