create-astro 4.8.0 → 4.8.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 CHANGED
@@ -270,17 +270,15 @@ function getSeason() {
270
270
  }
271
271
  }
272
272
  function rarity(frequency, emoji) {
273
- if (frequency === 1)
274
- return emoji;
275
- if (frequency === 0)
276
- return [""];
273
+ if (frequency === 1) return emoji;
274
+ if (frequency === 0) return [""];
277
275
  const empty = Array.from({ length: Math.round(emoji.length * frequency) }, () => "");
278
276
  return [...emoji, ...empty];
279
277
  }
280
278
 
281
279
  // src/messages.ts
282
280
  import { exec } from "node:child_process";
283
- import { color, label, say as houston, spinner as load } from "@astrojs/cli-kit";
281
+ import { color, say as houston, label, spinner as load } from "@astrojs/cli-kit";
284
282
  import { align, sleep } from "@astrojs/cli-kit/utils";
285
283
 
286
284
  // ../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
@@ -335,14 +333,12 @@ async function shell(command, flags, opts = {}) {
335
333
  // src/messages.ts
336
334
  var _registry;
337
335
  async function getRegistry(packageManager) {
338
- if (_registry)
339
- return _registry;
336
+ if (_registry) return _registry;
340
337
  const fallback = "https://registry.npmjs.org";
341
338
  try {
342
339
  const { stdout: stdout2 } = await shell(packageManager, ["config", "get", "registry"]);
343
340
  _registry = stdout2?.trim()?.replace(/\/$/, "") || fallback;
344
- if (!new URL(_registry).host)
345
- _registry = fallback;
341
+ if (!new URL(_registry).host) _registry = fallback;
346
342
  } catch (e) {
347
343
  _registry = fallback;
348
344
  }
@@ -467,7 +463,7 @@ function printHelp({
467
463
  if (headline) {
468
464
  message.push(
469
465
  linebreak(),
470
- `${title(commandName)} ${color.green(`v${"4.8.0"}`)} ${headline}`
466
+ `${title(commandName)} ${color.green(`v${"4.8.1"}`)} ${headline}`
471
467
  );
472
468
  }
473
469
  if (usage) {
@@ -533,12 +529,9 @@ async function getContext(argv) {
533
529
  let projectName2 = cwd;
534
530
  if (no) {
535
531
  yes = false;
536
- if (install2 == void 0)
537
- install2 = false;
538
- if (git2 == void 0)
539
- git2 = false;
540
- if (typescript2 == void 0)
541
- typescript2 = "strict";
532
+ if (install2 == void 0) install2 = false;
533
+ if (git2 == void 0) git2 = false;
534
+ if (typescript2 == void 0) typescript2 = "strict";
542
535
  }
543
536
  skipHouston = (os.platform() === "win32" && !fancy || skipHouston) ?? [yes, no, install2, git2, typescript2].some((v) => v !== void 0);
544
537
  const { messages, hats, ties } = getSeasonalHouston({ fancy });
@@ -547,7 +540,7 @@ async function getContext(argv) {
547
540
  prompt,
548
541
  packageManager,
549
542
  username: getName(),
550
- version: getVersion(packageManager, "astro", "4.6.0"),
543
+ version: getVersion(packageManager, "astro", "4.12.3"),
551
544
  skipHouston,
552
545
  fancy,
553
546
  dryRun,
@@ -570,8 +563,7 @@ async function getContext(argv) {
570
563
  return context;
571
564
  }
572
565
  function detectPackageManager() {
573
- if (!process.env.npm_config_user_agent)
574
- return;
566
+ if (!process.env.npm_config_user_agent) return;
575
567
  const specifier = process.env.npm_config_user_agent.split(" ")[0];
576
568
  const name = specifier.substring(0, specifier.lastIndexOf("/"));
577
569
  return name === "npminstall" ? "cnpm" : name;
@@ -623,14 +615,12 @@ async function dependencies(ctx) {
623
615
  }
624
616
  }
625
617
  async function install({ packageManager, cwd }) {
626
- if (packageManager === "yarn")
627
- await ensureYarnLock({ cwd });
618
+ if (packageManager === "yarn") await ensureYarnLock({ cwd });
628
619
  return shell(packageManager, ["install"], { cwd, timeout: 9e4, stdio: "ignore" });
629
620
  }
630
621
  async function ensureYarnLock({ cwd }) {
631
622
  const yarnLock = path.join(cwd, "yarn.lock");
632
- if (fs.existsSync(yarnLock))
633
- return;
623
+ if (fs.existsSync(yarnLock)) return;
634
624
  return fs.promises.writeFile(yarnLock, "", { encoding: "utf-8" });
635
625
  }
636
626
 
@@ -802,8 +792,7 @@ function isValidName(projectName2) {
802
792
  return /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(projectName2);
803
793
  }
804
794
  function toValidName(projectName2) {
805
- if (isValidName(projectName2))
806
- return projectName2;
795
+ if (isValidName(projectName2)) return projectName2;
807
796
  return projectName2.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z\d\-~]+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
808
797
  }
809
798
 
@@ -871,8 +860,7 @@ import path5 from "node:path";
871
860
  import { color as color6 } from "@astrojs/cli-kit";
872
861
  import { downloadTemplate } from "giget";
873
862
  async function template(ctx) {
874
- if (!ctx.template && ctx.yes)
875
- ctx.template = "basics";
863
+ if (!ctx.template && ctx.yes) ctx.template = "basics";
876
864
  if (ctx.template) {
877
865
  await info("tmpl", `Using ${color6.reset(ctx.template)}${color6.dim(" as project template")}`);
878
866
  } else {
@@ -932,8 +920,7 @@ function getTemplateTarget(tmpl, ref = "latest") {
932
920
  return `withastro/starlight/examples/${starter}`;
933
921
  }
934
922
  const isThirdParty = tmpl.includes("/");
935
- if (isThirdParty)
936
- return tmpl;
923
+ if (isThirdParty) return tmpl;
937
924
  return `github:withastro/astro/examples/${tmpl}#${ref}`;
938
925
  }
939
926
  async function copyTemplate(tmpl, ctx) {
@@ -953,11 +940,22 @@ async function copyTemplate(tmpl, ctx) {
953
940
  } catch (_) {
954
941
  }
955
942
  }
956
- if (err.message.includes("404")) {
943
+ if (err.message?.includes("404")) {
957
944
  throw new Error(`Template ${color6.reset(tmpl)} ${color6.dim("does not exist!")}`);
958
- } else {
959
- throw new Error(err.message);
960
945
  }
946
+ if (err.message) {
947
+ error("error", err.message);
948
+ }
949
+ try {
950
+ if ("cause" in err) {
951
+ error("error", err.cause);
952
+ if ("cause" in err.cause) {
953
+ error("error", err.cause?.cause);
954
+ }
955
+ }
956
+ } catch {
957
+ }
958
+ throw new Error(`Unable to download template ${color6.reset(tmpl)}`);
961
959
  }
962
960
  if (fs4.readdirSync(ctx.cwd).length === 0) {
963
961
  throw new Error(`Template ${color6.reset(tmpl)} ${color6.dim("is empty!")}`);
@@ -1142,18 +1140,16 @@ var FILES_TO_UPDATE2 = {
1142
1140
  parsedPackageJson.scripts.build = `astro check && ${buildScript}`;
1143
1141
  }
1144
1142
  const [astroCheckVersion, typescriptVersion] = await Promise.all([
1145
- getVersion(options.ctx.packageManager, "@astrojs/check", "0.5.8"),
1146
- getVersion(options.ctx.packageManager, "typescript", "5.2.2")
1143
+ getVersion(options.ctx.packageManager, "@astrojs/check", "0.8.2"),
1144
+ getVersion(options.ctx.packageManager, "typescript", "5.5.3")
1147
1145
  ]);
1148
1146
  parsedPackageJson.dependencies ??= {};
1149
1147
  parsedPackageJson.dependencies["@astrojs/check"] = `^${astroCheckVersion}`;
1150
1148
  parsedPackageJson.dependencies.typescript = `^${typescriptVersion}`;
1151
1149
  await writeFile(file, JSON.stringify(parsedPackageJson, null, indent), "utf-8");
1152
1150
  } catch (err) {
1153
- if (err && err.code === "ENOENT")
1154
- return;
1155
- if (err instanceof Error)
1156
- throw new Error(err.message);
1151
+ if (err && err.code === "ENOENT") return;
1152
+ if (err instanceof Error) throw new Error(err.message);
1157
1153
  }
1158
1154
  },
1159
1155
  "tsconfig.json": async (file, options) => {
@@ -1236,8 +1232,7 @@ async function verifyTemplate(tmpl, ref) {
1236
1232
  var GIT_RE = /^(?<repo>[\w.-]+\/[\w.-]+)(?<subdir>[^#]+)?(?<ref>#[\w.-]+)?/;
1237
1233
  function parseGitURI(input) {
1238
1234
  const m = input.match(GIT_RE)?.groups;
1239
- if (!m)
1240
- throw new Error(`Unable to parse "${input}"`);
1235
+ if (!m) throw new Error(`Unable to parse "${input}"`);
1241
1236
  return {
1242
1237
  repo: m.repo,
1243
1238
  subdir: m.subdir || "/",
package/dist/shell.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { StdioOptions } from 'node:child_process';
3
2
  export interface ExecaOptions {
4
3
  cwd?: string | URL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "4.8.0",
3
+ "version": "4.8.1",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES",
27
27
  "dependencies": {
28
28
  "@astrojs/cli-kit": "^0.4.1",
29
- "giget": "1.1.3"
29
+ "giget": "1.2.3"
30
30
  },
31
31
  "devDependencies": {
32
32
  "arg": "^5.0.2",