create-astro 3.1.13 → 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 +46 -21
  2. package/package.json +4 -5
package/dist/index.js CHANGED
@@ -177,7 +177,6 @@ import detectPackageManager2 from "which-pm-runs";
177
177
  // src/messages.ts
178
178
  import { color, say as houston, label, spinner as load } from "@astrojs/cli-kit";
179
179
  import { align, sleep } from "@astrojs/cli-kit/utils";
180
- import { execa } from "execa";
181
180
  import fetch from "node-fetch-native";
182
181
  import { exec } from "node:child_process";
183
182
 
@@ -201,11 +200,44 @@ function stripAnsi(string) {
201
200
 
202
201
  // src/messages.ts
203
202
  import detectPackageManager from "which-pm-runs";
203
+
204
+ // src/shell.ts
205
+ import { spawn } from "node:child_process";
206
+ import { text as textFromStream } from "node:stream/consumers";
207
+ var text = (stream) => stream ? textFromStream(stream).then((t) => t.trimEnd()) : "";
208
+ async function shell(command, flags, opts = {}) {
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
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
+ }
225
+ const { exitCode } = child;
226
+ if (exitCode === null) {
227
+ throw new Error("Timeout");
228
+ }
229
+ if (exitCode !== 0) {
230
+ throw new Error(stderr);
231
+ }
232
+ return { stdout: stdout2, stderr, exitCode };
233
+ }
234
+
235
+ // src/messages.ts
204
236
  async function getRegistry() {
205
237
  var _a, _b;
206
238
  const packageManager = ((_a = detectPackageManager()) == null ? void 0 : _a.name) || "npm";
207
239
  try {
208
- const { stdout: stdout2 } = await execa(packageManager, ["config", "get", "registry"]);
240
+ const { stdout: stdout2 } = await shell(packageManager, ["config", "get", "registry"]);
209
241
  return ((_b = stdout2 == null ? void 0 : stdout2.trim()) == null ? void 0 : _b.replace(/\/$/, "")) || "https://registry.npmjs.org";
210
242
  } catch (e) {
211
243
  return "https://registry.npmjs.org";
@@ -221,7 +253,7 @@ async function say(messages, { clear = false, hat = "" } = {}) {
221
253
  async function spinner(args) {
222
254
  await load(args, { stdout });
223
255
  }
224
- var title = (text) => align(label(text), "end", 7) + " ";
256
+ var title = (text2) => align(label(text2), "end", 7) + " ";
225
257
  var welcome = [
226
258
  `Let's claim your corner of the internet.`,
227
259
  `I'll be your assistant today.`,
@@ -272,21 +304,21 @@ var banner = async (version) => log(
272
304
  `
273
305
  ${label("astro", color.bgGreen, color.black)} ${version ? color.green(color.bold(`v${version}`)) : ""} ${color.bold("Launch sequence initiated.")}`
274
306
  );
275
- var info = async (prefix, text) => {
307
+ var info = async (prefix, text2) => {
276
308
  await sleep(100);
277
309
  if (stdout.columns < 80) {
278
310
  log(`${" ".repeat(5)} ${color.cyan("\u25FC")} ${color.cyan(prefix)}`);
279
- log(`${" ".repeat(9)}${color.dim(text)}`);
311
+ log(`${" ".repeat(9)}${color.dim(text2)}`);
280
312
  } else {
281
- log(`${" ".repeat(5)} ${color.cyan("\u25FC")} ${color.cyan(prefix)} ${color.dim(text)}`);
313
+ log(`${" ".repeat(5)} ${color.cyan("\u25FC")} ${color.cyan(prefix)} ${color.dim(text2)}`);
282
314
  }
283
315
  };
284
- var error = async (prefix, text) => {
316
+ var error = async (prefix, text2) => {
285
317
  if (stdout.columns < 80) {
286
318
  log(`${" ".repeat(5)} ${color.red("\u25B2")} ${color.red(prefix)}`);
287
- log(`${" ".repeat(9)}${color.dim(text)}`);
319
+ log(`${" ".repeat(9)}${color.dim(text2)}`);
288
320
  } else {
289
- log(`${" ".repeat(5)} ${color.red("\u25B2")} ${color.red(prefix)} ${color.dim(text)}`);
321
+ log(`${" ".repeat(5)} ${color.red("\u25B2")} ${color.red(prefix)} ${color.dim(text2)}`);
290
322
  }
291
323
  };
292
324
  var typescriptByDefault = async () => {
@@ -355,7 +387,7 @@ function printHelp({
355
387
  if (headline) {
356
388
  message.push(
357
389
  linebreak(),
358
- `${title(commandName)} ${color.green(`v${"3.1.13"}`)} ${headline}`
390
+ `${title(commandName)} ${color.green(`v${"3.2.1"}`)} ${headline}`
359
391
  );
360
392
  }
361
393
  if (usage) {
@@ -456,7 +488,6 @@ async function getContext(argv) {
456
488
 
457
489
  // src/actions/dependencies.ts
458
490
  import { color as color2 } from "@astrojs/cli-kit";
459
- import { execa as execa2 } from "execa";
460
491
  import fs from "node:fs";
461
492
  import path from "node:path";
462
493
  async function dependencies(ctx) {
@@ -500,12 +531,7 @@ async function dependencies(ctx) {
500
531
  async function install({ pkgManager, cwd }) {
501
532
  if (pkgManager === "yarn")
502
533
  await ensureYarnLock({ cwd });
503
- const installExec = execa2(pkgManager, ["install"], { cwd });
504
- return new Promise((resolve, reject) => {
505
- setTimeout(() => reject(`Request timed out after 1m 30s`), 9e4);
506
- installExec.on("error", (e) => reject(e));
507
- installExec.on("close", () => resolve());
508
- });
534
+ return shell(pkgManager, ["install"], { cwd, timeout: 9e4, stdio: "ignore" });
509
535
  }
510
536
  async function ensureYarnLock({ cwd }) {
511
537
  const yarnLock = path.join(cwd, "yarn.lock");
@@ -518,7 +544,6 @@ async function ensureYarnLock({ cwd }) {
518
544
  import fs2 from "node:fs";
519
545
  import path2 from "node:path";
520
546
  import { color as color3 } from "@astrojs/cli-kit";
521
- import { execa as execa3 } from "execa";
522
547
  async function git(ctx) {
523
548
  if (fs2.existsSync(path2.join(ctx.cwd, ".git"))) {
524
549
  await info("Nice!", `Git has already been initialized`);
@@ -555,9 +580,9 @@ async function git(ctx) {
555
580
  }
556
581
  async function init({ cwd }) {
557
582
  try {
558
- await execa3("git", ["init"], { cwd, stdio: "ignore" });
559
- await execa3("git", ["add", "-A"], { cwd, stdio: "ignore" });
560
- await execa3(
583
+ await shell("git", ["init"], { cwd, stdio: "ignore" });
584
+ await shell("git", ["add", "-A"], { cwd, stdio: "ignore" });
585
+ await shell(
561
586
  "git",
562
587
  [
563
588
  "commit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "3.1.13",
3
+ "version": "3.2.1",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -26,15 +26,14 @@
26
26
  "//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES",
27
27
  "dependencies": {
28
28
  "@astrojs/cli-kit": "^0.2.3",
29
- "chai": "^4.3.7",
30
- "execa": "^6.1.0",
31
- "giget": "1.0.0",
32
- "mocha": "^9.2.2",
29
+ "giget": "^1.1.2",
33
30
  "node-fetch-native": "^1.2.0",
34
31
  "which-pm-runs": "^1.1.0"
35
32
  },
36
33
  "devDependencies": {
37
34
  "@types/which-pm-runs": "^1.0.0",
35
+ "chai": "^4.3.7",
36
+ "mocha": "^9.2.2",
38
37
  "arg": "^5.0.2",
39
38
  "strip-ansi": "^7.1.0",
40
39
  "strip-json-comments": "^5.0.0",