create-astro 3.1.12 → 3.1.13

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 +39 -29
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -355,7 +355,7 @@ function printHelp({
355
355
  if (headline) {
356
356
  message.push(
357
357
  linebreak(),
358
- `${title(commandName)} ${color.green(`v${"3.1.12"}`)} ${headline}`
358
+ `${title(commandName)} ${color.green(`v${"3.1.13"}`)} ${headline}`
359
359
  );
360
360
  }
361
361
  if (usage) {
@@ -457,6 +457,8 @@ async function getContext(argv) {
457
457
  // src/actions/dependencies.ts
458
458
  import { color as color2 } from "@astrojs/cli-kit";
459
459
  import { execa as execa2 } from "execa";
460
+ import fs from "node:fs";
461
+ import path from "node:path";
460
462
  async function dependencies(ctx) {
461
463
  let deps = ctx.install ?? ctx.yes;
462
464
  if (deps === void 0) {
@@ -496,21 +498,29 @@ async function dependencies(ctx) {
496
498
  }
497
499
  }
498
500
  async function install({ pkgManager, cwd }) {
501
+ if (pkgManager === "yarn")
502
+ await ensureYarnLock({ cwd });
499
503
  const installExec = execa2(pkgManager, ["install"], { cwd });
500
504
  return new Promise((resolve, reject) => {
501
- setTimeout(() => reject(`Request timed out after one minute`), 6e4);
505
+ setTimeout(() => reject(`Request timed out after 1m 30s`), 9e4);
502
506
  installExec.on("error", (e) => reject(e));
503
507
  installExec.on("close", () => resolve());
504
508
  });
505
509
  }
510
+ async function ensureYarnLock({ cwd }) {
511
+ const yarnLock = path.join(cwd, "yarn.lock");
512
+ if (fs.existsSync(yarnLock))
513
+ return;
514
+ return fs.promises.writeFile(yarnLock, "", { encoding: "utf-8" });
515
+ }
506
516
 
507
517
  // src/actions/git.ts
508
- import fs from "node:fs";
509
- import path from "node:path";
518
+ import fs2 from "node:fs";
519
+ import path2 from "node:path";
510
520
  import { color as color3 } from "@astrojs/cli-kit";
511
521
  import { execa as execa3 } from "execa";
512
522
  async function git(ctx) {
513
- if (fs.existsSync(path.join(ctx.cwd, ".git"))) {
523
+ if (fs2.existsSync(path2.join(ctx.cwd, ".git"))) {
514
524
  await info("Nice!", `Git has already been initialized`);
515
525
  return;
516
526
  }
@@ -607,9 +617,9 @@ async function intro(ctx) {
607
617
  }
608
618
 
609
619
  // src/actions/next-steps.ts
610
- import path2 from "node:path";
620
+ import path3 from "node:path";
611
621
  async function next(ctx) {
612
- let projectDir = path2.relative(process.cwd(), ctx.cwd);
622
+ let projectDir = path3.relative(process.cwd(), ctx.cwd);
613
623
  const devCmd = ctx.pkgManager === "npm" ? "npm run dev" : `${ctx.pkgManager} dev`;
614
624
  await nextSteps({ projectDir, devCmd });
615
625
  if (!ctx.skipHouston) {
@@ -620,10 +630,10 @@ async function next(ctx) {
620
630
 
621
631
  // src/actions/project-name.ts
622
632
  import { color as color5, generateProjectName } from "@astrojs/cli-kit";
623
- import path3 from "node:path";
633
+ import path4 from "node:path";
624
634
 
625
635
  // src/actions/shared.ts
626
- import fs2 from "node:fs";
636
+ import fs3 from "node:fs";
627
637
  var VALID_PROJECT_DIRECTORY_SAFE_LIST = [
628
638
  ".DS_Store",
629
639
  ".git",
@@ -649,10 +659,10 @@ var VALID_PROJECT_DIRECTORY_SAFE_LIST = [
649
659
  /^yarn-error\.log/
650
660
  ];
651
661
  function isEmpty(dirPath) {
652
- if (!fs2.existsSync(dirPath)) {
662
+ if (!fs3.existsSync(dirPath)) {
653
663
  return true;
654
664
  }
655
- const conflicts = fs2.readdirSync(dirPath).filter((content) => {
665
+ const conflicts = fs3.readdirSync(dirPath).filter((content) => {
656
666
  return !VALID_PROJECT_DIRECTORY_SAFE_LIST.some((safeContent) => {
657
667
  return typeof safeContent === "string" ? content === safeContent : safeContent.test(content);
658
668
  });
@@ -695,7 +705,7 @@ async function projectName(ctx) {
695
705
  } else {
696
706
  let name = ctx.cwd;
697
707
  if (name === "." || name === "./") {
698
- const parts = process.cwd().split(path3.sep);
708
+ const parts = process.cwd().split(path4.sep);
699
709
  name = parts[parts.length - 1];
700
710
  } else if (name.startsWith("./") || name.startsWith("../")) {
701
711
  const parts = name.split("/");
@@ -719,8 +729,8 @@ async function checkCwd(cwd) {
719
729
  // src/actions/template.ts
720
730
  import { color as color6 } from "@astrojs/cli-kit";
721
731
  import { downloadTemplate } from "giget";
722
- import fs3 from "node:fs";
723
- import path4 from "node:path";
732
+ import fs4 from "node:fs";
733
+ import path5 from "node:path";
724
734
  async function template(ctx) {
725
735
  if (!ctx.template) {
726
736
  const { template: tmpl } = await ctx.prompt({
@@ -761,10 +771,10 @@ async function template(ctx) {
761
771
  }
762
772
  var FILES_TO_REMOVE = ["sandbox.config.json", "CHANGELOG.md"];
763
773
  var FILES_TO_UPDATE = {
764
- "package.json": (file, overrides) => fs3.promises.readFile(file, "utf-8").then((value) => {
774
+ "package.json": (file, overrides) => fs4.promises.readFile(file, "utf-8").then((value) => {
765
775
  var _a;
766
776
  const indent = ((_a = /(^\s+)/m.exec(value)) == null ? void 0 : _a[1]) ?? " ";
767
- fs3.promises.writeFile(
777
+ fs4.promises.writeFile(
768
778
  file,
769
779
  JSON.stringify(
770
780
  Object.assign(JSON.parse(value), Object.assign(overrides, { private: void 0 })),
@@ -796,25 +806,25 @@ async function copyTemplate(tmpl, ctx) {
796
806
  dir: "."
797
807
  });
798
808
  } catch (err) {
799
- fs3.rmdirSync(ctx.cwd);
809
+ fs4.rmdirSync(ctx.cwd);
800
810
  if (err.message.includes("404")) {
801
811
  throw new Error(`Template ${color6.reset(tmpl)} ${color6.dim("does not exist!")}`);
802
812
  } else {
803
813
  throw new Error(err.message);
804
814
  }
805
815
  }
806
- if (fs3.readdirSync(ctx.cwd).length === 0) {
816
+ if (fs4.readdirSync(ctx.cwd).length === 0) {
807
817
  throw new Error(`Template ${color6.reset(tmpl)} ${color6.dim("is empty!")}`);
808
818
  }
809
819
  const removeFiles = FILES_TO_REMOVE.map(async (file) => {
810
- const fileLoc = path4.resolve(path4.join(ctx.cwd, file));
811
- if (fs3.existsSync(fileLoc)) {
812
- return fs3.promises.rm(fileLoc, { recursive: true });
820
+ const fileLoc = path5.resolve(path5.join(ctx.cwd, file));
821
+ if (fs4.existsSync(fileLoc)) {
822
+ return fs4.promises.rm(fileLoc, { recursive: true });
813
823
  }
814
824
  });
815
825
  const updateFiles = Object.entries(FILES_TO_UPDATE).map(async ([file, update]) => {
816
- const fileLoc = path4.resolve(path4.join(ctx.cwd, file));
817
- if (fs3.existsSync(fileLoc)) {
826
+ const fileLoc = path5.resolve(path5.join(ctx.cwd, file));
827
+ if (fs4.existsSync(fileLoc)) {
818
828
  return update(fileLoc, { name: ctx.projectName });
819
829
  }
820
830
  });
@@ -824,9 +834,9 @@ async function copyTemplate(tmpl, ctx) {
824
834
 
825
835
  // src/actions/typescript.ts
826
836
  import { color as color7 } from "@astrojs/cli-kit";
827
- import fs4 from "node:fs";
837
+ import fs5 from "node:fs";
828
838
  import { readFile } from "node:fs/promises";
829
- import path5 from "node:path";
839
+ import path6 from "node:path";
830
840
 
831
841
  // ../../node_modules/.pnpm/strip-json-comments@5.0.0/node_modules/strip-json-comments/index.js
832
842
  var singleComment = Symbol("singleComment");
@@ -946,7 +956,7 @@ async function typescript(ctx) {
946
956
  } else {
947
957
  if (!["strict", "strictest", "relaxed", "default", "base"].includes(ts)) {
948
958
  if (!ctx.dryRun) {
949
- fs4.rmSync(ctx.cwd, { recursive: true, force: true });
959
+ fs5.rmSync(ctx.cwd, { recursive: true, force: true });
950
960
  }
951
961
  error(
952
962
  "Error",
@@ -976,7 +986,7 @@ async function typescript(ctx) {
976
986
  }
977
987
  }
978
988
  async function setupTypeScript(value, { cwd }) {
979
- const templateTSConfigPath = path5.join(cwd, "tsconfig.json");
989
+ const templateTSConfigPath = path6.join(cwd, "tsconfig.json");
980
990
  try {
981
991
  const data = await readFile(templateTSConfigPath, { encoding: "utf-8" });
982
992
  const templateTSConfig = JSON.parse(stripJsonComments(data));
@@ -984,7 +994,7 @@ async function setupTypeScript(value, { cwd }) {
984
994
  const result = Object.assign(templateTSConfig, {
985
995
  extends: `astro/tsconfigs/${value}`
986
996
  });
987
- fs4.writeFileSync(templateTSConfigPath, JSON.stringify(result, null, 2));
997
+ fs5.writeFileSync(templateTSConfigPath, JSON.stringify(result, null, 2));
988
998
  } else {
989
999
  throw new Error(
990
1000
  "There was an error applying the requested TypeScript settings. This could be because the template's tsconfig.json is malformed"
@@ -992,7 +1002,7 @@ async function setupTypeScript(value, { cwd }) {
992
1002
  }
993
1003
  } catch (err) {
994
1004
  if (err && err.code === "ENOENT") {
995
- fs4.writeFileSync(
1005
+ fs5.writeFileSync(
996
1006
  templateTSConfigPath,
997
1007
  JSON.stringify({ extends: `astro/tsconfigs/${value}` }, null, 2)
998
1008
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "3.1.12",
3
+ "version": "3.1.13",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",