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.
Files changed (2) hide show
  1. package/dist/index.js +27 -25
  2. 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 as sleep2 } from "@astrojs/cli-kit/utils";
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
- const controller = opts.timeout ? new AbortController() : void 0;
211
- const child = spawn(command, flags, {
212
- cwd: opts.cwd,
213
- shell: true,
214
- stdio: opts.stdio,
215
- signal: controller == null ? void 0 : controller.signal
216
- });
217
- const stdout2 = await text(child.stdout);
218
- const stderr = await text(child.stderr);
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 { stdout: stdout2, stderr, exitCode };
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 sleep2(100);
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 sleep2(1e3);
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 sleep2(200);
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 sleep2(100);
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 sleep2(100);
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 sleep2(100);
359
+ await sleep(100);
358
360
  log(`
359
361
  ${prefix}Stuck? Join us at ${color.cyan(`https://astro.build/chat`)}`);
360
- await sleep2(200);
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.0"}`)} ${headline}`
390
+ `${title(commandName)} ${color.green(`v${"3.2.1"}`)} ${headline}`
389
391
  );
390
392
  }
391
393
  if (usage) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",