create-astro 3.1.0 → 3.1.2

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 +22 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16,6 +16,10 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
19
23
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
20
24
  mod
21
25
  ));
@@ -134,7 +138,8 @@ var require_arg = __commonJS({
134
138
  if (isFlag) {
135
139
  result[argName] = type(true, argName, result[argName]);
136
140
  } else if (argStr === void 0) {
137
- if (argv.length < i + 2 || argv[i + 1].length > 1 && argv[i + 1][0] === "-" && !(argv[i + 1].match(/^-?\d*(\.(?=\d))?\d*$/) && (type === Number || typeof BigInt !== "undefined" && type === BigInt))) {
141
+ if (argv.length < i + 2 || argv[i + 1].length > 1 && argv[i + 1][0] === "-" && !(argv[i + 1].match(/^-?\d*(\.(?=\d))?\d*$/) && (type === Number || // eslint-disable-next-line no-undef
142
+ typeof BigInt !== "undefined" && type === BigInt))) {
138
143
  const extended = originalArgName === argName ? "" : ` (alias for ${argName})`;
139
144
  throw new ArgError(
140
145
  `option requires argument: ${originalArgName}${extended}`,
@@ -314,10 +319,11 @@ var nextSteps = async ({ projectDir, devCmd }) => {
314
319
  );
315
320
  await sleep(100);
316
321
  if (projectDir !== "") {
322
+ projectDir = projectDir.includes(" ") ? `"./${projectDir}"` : `./${projectDir}`;
317
323
  const enter = [
318
324
  `
319
325
  ${prefix}Enter your project directory using`,
320
- color.cyan(`cd ./${projectDir}`, "")
326
+ color.cyan(`cd ${projectDir}`, "")
321
327
  ];
322
328
  const len = enter[0].length + stripAnsi(enter[1]).length;
323
329
  log(enter.join(len > max ? "\n" + prefix : " "));
@@ -362,7 +368,7 @@ function printHelp({
362
368
  if (headline) {
363
369
  message.push(
364
370
  linebreak(),
365
- `${title(commandName)} ${color.green(`v${"3.1.0"}`)} ${headline}`
371
+ `${title(commandName)} ${color.green(`v${"3.1.2"}`)} ${headline}`
366
372
  );
367
373
  }
368
374
  if (usage) {
@@ -743,8 +749,13 @@ async function template(ctx) {
743
749
  start: "Template copying...",
744
750
  end: "Template copied",
745
751
  while: () => copyTemplate(ctx.template, ctx).catch((e) => {
746
- error("error", e);
747
- process.exit(1);
752
+ if (e instanceof Error) {
753
+ error("error", e.message);
754
+ process.exit(1);
755
+ } else {
756
+ error("error", "Unable to clone template.");
757
+ process.exit(1);
758
+ }
748
759
  })
749
760
  });
750
761
  } else {
@@ -782,11 +793,13 @@ async function copyTemplate(tmpl, ctx) {
782
793
  } catch (err) {
783
794
  fs3.rmdirSync(ctx.cwd);
784
795
  if (err.message.includes("404")) {
785
- await error("Error", `Template ${color5.reset(tmpl)} ${color5.dim("does not exist!")}`);
796
+ throw new Error(`Template ${color5.reset(tmpl)} ${color5.dim("does not exist!")}`);
786
797
  } else {
787
- console.error(err.message);
798
+ throw new Error(err.message);
788
799
  }
789
- ctx.exit(1);
800
+ }
801
+ if (fs3.readdirSync(ctx.cwd).length === 0) {
802
+ throw new Error(`Template ${color5.reset(tmpl)} ${color5.dim("is empty!")}`);
790
803
  }
791
804
  const removeFiles = FILES_TO_REMOVE.map(async (file) => {
792
805
  const fileLoc = path4.resolve(path4.join(ctx.cwd, file));
@@ -999,6 +1012,7 @@ async function main() {
999
1012
  template,
1000
1013
  dependencies,
1001
1014
  typescript,
1015
+ // Steps which write to files need to go above git
1002
1016
  git,
1003
1017
  next
1004
1018
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",