create-astro 3.2.0 → 3.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 +27 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -176,7 +176,7 @@ import detectPackageManager2 from "which-pm-runs";
|
|
|
176
176
|
|
|
177
177
|
// src/messages.ts
|
|
178
178
|
import { color, say as houston, label, spinner as load } from "@astrojs/cli-kit";
|
|
179
|
-
import { align, sleep
|
|
179
|
+
import { align, sleep } from "@astrojs/cli-kit/utils";
|
|
180
180
|
import fetch from "node-fetch-native";
|
|
181
181
|
import { exec } from "node:child_process";
|
|
182
182
|
|
|
@@ -204,28 +204,30 @@ import detectPackageManager from "which-pm-runs";
|
|
|
204
204
|
// src/shell.ts
|
|
205
205
|
import { spawn } from "node:child_process";
|
|
206
206
|
import { text as textFromStream } from "node:stream/consumers";
|
|
207
|
-
import { setTimeout as sleep } from "node:timers/promises";
|
|
208
207
|
var text = (stream) => stream ? textFromStream(stream).then((t) => t.trimEnd()) : "";
|
|
209
208
|
async function shell(command, flags, opts = {}) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (opts.timeout) {
|
|
220
|
-
sleep(opts.timeout).then(() => {
|
|
221
|
-
controller.abort();
|
|
222
|
-
throw { stdout: stdout2, stderr, exitCode: 1 };
|
|
209
|
+
let child;
|
|
210
|
+
let stdout2 = "";
|
|
211
|
+
let stderr = "";
|
|
212
|
+
try {
|
|
213
|
+
child = spawn(command, flags, {
|
|
214
|
+
cwd: opts.cwd,
|
|
215
|
+
shell: true,
|
|
216
|
+
stdio: opts.stdio,
|
|
217
|
+
timeout: opts.timeout
|
|
223
218
|
});
|
|
219
|
+
const done = new Promise((resolve) => child.on("close", resolve));
|
|
220
|
+
[stdout2, stderr] = await Promise.all([text(child.stdout), text(child.stderr)]);
|
|
221
|
+
await done;
|
|
222
|
+
} catch (e) {
|
|
223
|
+
throw { stdout: stdout2, stderr, exitCode: 1 };
|
|
224
224
|
}
|
|
225
|
-
await new Promise((resolve) => child.on("exit", resolve));
|
|
226
225
|
const { exitCode } = child;
|
|
226
|
+
if (exitCode === null) {
|
|
227
|
+
throw new Error("Timeout");
|
|
228
|
+
}
|
|
227
229
|
if (exitCode !== 0) {
|
|
228
|
-
throw
|
|
230
|
+
throw new Error(stderr);
|
|
229
231
|
}
|
|
230
232
|
return { stdout: stdout2, stderr, exitCode };
|
|
231
233
|
}
|
|
@@ -303,7 +305,7 @@ var banner = async (version) => log(
|
|
|
303
305
|
${label("astro", color.bgGreen, color.black)} ${version ? color.green(color.bold(`v${version}`)) : ""} ${color.bold("Launch sequence initiated.")}`
|
|
304
306
|
);
|
|
305
307
|
var info = async (prefix, text2) => {
|
|
306
|
-
await
|
|
308
|
+
await sleep(100);
|
|
307
309
|
if (stdout.columns < 80) {
|
|
308
310
|
log(`${" ".repeat(5)} ${color.cyan("\u25FC")} ${color.cyan(prefix)}`);
|
|
309
311
|
log(`${" ".repeat(9)}${color.dim(text2)}`);
|
|
@@ -322,19 +324,19 @@ var error = async (prefix, text2) => {
|
|
|
322
324
|
var typescriptByDefault = async () => {
|
|
323
325
|
await info(`No worries!`, "TypeScript is supported in Astro by default,");
|
|
324
326
|
log(`${" ".repeat(9)}${color.dim("but you are free to continue writing JavaScript instead.")}`);
|
|
325
|
-
await
|
|
327
|
+
await sleep(1e3);
|
|
326
328
|
};
|
|
327
329
|
var nextSteps = async ({ projectDir, devCmd }) => {
|
|
328
330
|
const max = stdout.columns;
|
|
329
331
|
const prefix = max < 80 ? " " : " ".repeat(9);
|
|
330
|
-
await
|
|
332
|
+
await sleep(200);
|
|
331
333
|
log(
|
|
332
334
|
`
|
|
333
335
|
${color.bgCyan(` ${color.black("next")} `)} ${color.bold(
|
|
334
336
|
"Liftoff confirmed. Explore your project!"
|
|
335
337
|
)}`
|
|
336
338
|
);
|
|
337
|
-
await
|
|
339
|
+
await sleep(100);
|
|
338
340
|
if (projectDir !== "") {
|
|
339
341
|
projectDir = projectDir.includes(" ") ? `"./${projectDir}"` : `./${projectDir}`;
|
|
340
342
|
const enter = [
|
|
@@ -348,16 +350,16 @@ ${prefix}Enter your project directory using`,
|
|
|
348
350
|
log(
|
|
349
351
|
`${prefix}Run ${color.cyan(devCmd)} to start the dev server. ${color.cyan("CTRL+C")} to stop.`
|
|
350
352
|
);
|
|
351
|
-
await
|
|
353
|
+
await sleep(100);
|
|
352
354
|
log(
|
|
353
355
|
`${prefix}Add frameworks like ${color.cyan(`react`)} or ${color.cyan(
|
|
354
356
|
"tailwind"
|
|
355
357
|
)} using ${color.cyan("astro add")}.`
|
|
356
358
|
);
|
|
357
|
-
await
|
|
359
|
+
await sleep(100);
|
|
358
360
|
log(`
|
|
359
361
|
${prefix}Stuck? Join us at ${color.cyan(`https://astro.build/chat`)}`);
|
|
360
|
-
await
|
|
362
|
+
await sleep(200);
|
|
361
363
|
};
|
|
362
364
|
function printHelp({
|
|
363
365
|
commandName,
|
|
@@ -385,7 +387,7 @@ function printHelp({
|
|
|
385
387
|
if (headline) {
|
|
386
388
|
message.push(
|
|
387
389
|
linebreak(),
|
|
388
|
-
`${title(commandName)} ${color.green(`v${"3.2.
|
|
390
|
+
`${title(commandName)} ${color.green(`v${"3.2.1"}`)} ${headline}`
|
|
389
391
|
);
|
|
390
392
|
}
|
|
391
393
|
if (usage) {
|