create-astro 0.12.1 → 0.12.4

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/create-astro.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  const currentVersion = process.versions.node;
5
5
  const requiredMajorVersion = parseInt(currentVersion.split('.')[0], 10);
6
- const minimumMajorVersion = 12;
6
+ const minimumMajorVersion = 14;
7
7
 
8
8
  if (requiredMajorVersion < minimumMajorVersion) {
9
9
  console.error(`Node.js v${currentVersion} is out of date and unsupported!`);
package/dist/index.js CHANGED
@@ -1,14 +1,21 @@
1
+ import degit from "degit";
2
+ import { execa, execaCommand } from "execa";
1
3
  import fs from "fs";
4
+ import { bgCyan, black, bold, cyan, dim, gray, green, red, yellow } from "kleur/colors";
5
+ import ora from "ora";
2
6
  import path from "path";
3
- import { bgCyan, black, bold, cyan, gray, green, red, yellow } from "kleur/colors";
4
7
  import prompts from "prompts";
5
- import degit from "degit";
6
8
  import yargs from "yargs-parser";
7
- import ora from "ora";
8
- import { TEMPLATES } from "./templates.js";
9
- import { logger, defaultLogLevel } from "./logger.js";
10
- import { execa, execaCommand } from "execa";
11
9
  import { loadWithRocketGradient, rocketAscii } from "./gradient.js";
10
+ import { defaultLogLevel, logger } from "./logger.js";
11
+ import { TEMPLATES } from "./templates.js";
12
+ function wait(ms) {
13
+ return new Promise((resolve) => setTimeout(resolve, ms));
14
+ }
15
+ function logAndWait(message, ms = 100) {
16
+ console.log(message);
17
+ return wait(ms);
18
+ }
12
19
  const cleanArgv = process.argv.filter((arg) => arg !== "--");
13
20
  const args = yargs(cleanArgv);
14
21
  prompts.override(args);
@@ -31,6 +38,8 @@ async function main() {
31
38
  logger.debug("Verbose logging turned on");
32
39
  console.log(`
33
40
  ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
41
+ console.log(`Lets walk through setting up your new Astro project.
42
+ `);
34
43
  let cwd = args["_"][2];
35
44
  if (cwd && isEmpty(cwd)) {
36
45
  let acknowledgeProjectDir = ora({
@@ -48,7 +57,7 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
48
57
  const dirResponse = await prompts({
49
58
  type: "text",
50
59
  name: "directory",
51
- message: "Where would you like to create your app?",
60
+ message: "Where would you like to create your new project?",
52
61
  initial: "./my-astro-site",
53
62
  validate(value) {
54
63
  if (!isEmpty(value)) {
@@ -66,7 +75,7 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
66
75
  {
67
76
  type: "select",
68
77
  name: "template",
69
- message: "Which app template would you like to use?",
78
+ message: "Which template would you like to use?",
70
79
  choices: TEMPLATES
71
80
  }
72
81
  ]);
@@ -86,7 +95,7 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
86
95
  force: true,
87
96
  verbose: defaultLogLevel === "debug" ? true : false
88
97
  });
89
- if (!args.dryrun) {
98
+ if (!args.dryRun) {
90
99
  try {
91
100
  emitter.on("info", (info) => {
92
101
  logger.debug(info.message);
@@ -121,10 +130,9 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
121
130
  message: `Would you like us to run "${pkgManager} install?"`,
122
131
  initial: true
123
132
  });
124
- if (!installResponse) {
125
- process.exit(0);
126
- }
127
- if (installResponse.install && !args.dryrun) {
133
+ if (args.dryRun) {
134
+ ora().info(dim(`--dry-run enabled, skipping.`));
135
+ } else if (installResponse.install) {
128
136
  const installExec = execa(pkgManager, ["install"], { cwd });
129
137
  const installingPackagesMsg = `Installing packages${emojiWithFallback(" \u{1F4E6}", "...")}`;
130
138
  const installSpinner = await loadWithRocketGradient(installingPackagesMsg);
@@ -139,48 +147,37 @@ ${bold(`[${pkgManager}]`)} ${data}`;
139
147
  });
140
148
  installSpinner.text = green("Packages installed!");
141
149
  installSpinner.succeed();
142
- }
143
- const astroAddCommand = installResponse.install ? "astro add --yes" : `${pkgManagerExecCommand(pkgManager)} astro@latest add --yes`;
144
- const astroAddResponse = await prompts({
145
- type: "confirm",
146
- name: "astroAdd",
147
- message: `Run "${astroAddCommand}?" This lets you optionally add component frameworks (ex. React), CSS frameworks (ex. Tailwind), and more.`,
148
- initial: true
149
- });
150
- if (!astroAddResponse) {
151
- process.exit(0);
152
- }
153
- if (!astroAddResponse.astroAdd) {
154
- ora().info(`No problem. You can always run "${pkgManagerExecCommand(pkgManager)} astro add" later!`);
155
- }
156
- if (astroAddResponse.astroAdd && !args.dryrun) {
157
- await execaCommand(astroAddCommand, astroAddCommand === "astro add --yes" ? { cwd, stdio: "inherit", localDir: cwd, preferLocal: true } : { cwd, stdio: "inherit" });
150
+ } else {
151
+ ora().info(dim(`No problem! You can install dependencies yourself after setup.`));
158
152
  }
159
153
  const gitResponse = await prompts({
160
154
  type: "confirm",
161
155
  name: "git",
162
- message: "Initialize a git repository?",
156
+ message: `Initialize a new git repository? ${dim("This can be useful to track changes.")}`,
163
157
  initial: true
164
158
  });
165
- if (!gitResponse) {
166
- process.exit(0);
167
- }
168
- if (gitResponse.git && !args.dryrun) {
159
+ if (args.dryRun) {
160
+ ora().info(dim(`--dry-run enabled, skipping.`));
161
+ } else if (gitResponse.git) {
169
162
  await execaCommand("git init", { cwd });
163
+ } else {
164
+ ora().info(dim(`Sounds good! You can come back and run ${cyan(`git init`)} later.`));
170
165
  }
171
- ora({ text: green("Done. Ready for liftoff!") }).succeed();
166
+ ora().succeed("Setup complete.");
167
+ ora({ text: green("Ready for liftoff!") }).succeed();
168
+ await wait(300);
172
169
  console.log(`
173
170
  ${bgCyan(black(" Next steps "))}
174
171
  `);
175
- const projectDir = path.relative(process.cwd(), cwd);
172
+ let projectDir = path.relative(process.cwd(), cwd);
176
173
  const devCmd = pkgManager === "npm" ? "npm run dev" : `${pkgManager} dev`;
177
- console.log(`You can now ${bold(cyan("cd"))} into the ${bold(cyan(projectDir))} project directory.`);
178
- console.log(`Run ${bold(cyan(devCmd))} to start the Astro dev server. ${bold(cyan("CTRL-C"))} to close.`);
179
- if (!installResponse.install) {
180
- console.log(yellow(`Remember to install dependencies first!`));
181
- }
182
- console.log(`
183
- Stuck? Come join us at ${bold(cyan("https://astro.build/chat"))}`);
174
+ await logAndWait(`You can now ${bold(cyan("cd"))} into the ${bold(cyan(projectDir))} project directory.`);
175
+ await logAndWait(`Run ${bold(cyan(devCmd))} to start the Astro dev server. ${bold(cyan("CTRL-C"))} to close.`);
176
+ await logAndWait(`Add frameworks like ${bold(cyan("react"))} and ${bold(cyan("tailwind"))} to your project using ${bold(cyan("astro add"))}`);
177
+ await logAndWait("");
178
+ await logAndWait(`Stuck? Come join us at ${bold(cyan("https://astro.build/chat"))}`, 1e3);
179
+ await logAndWait(dim("Good luck out there, astronaut."));
180
+ await logAndWait("", 300);
184
181
  }
185
182
  function emojiWithFallback(char, fallback) {
186
183
  return process.platform !== "win32" ? char : fallback;
package/dist/logger.js CHANGED
@@ -1,20 +1,10 @@
1
- import { bold, blue, dim, red, yellow } from "kleur/colors";
1
+ import { blue, bold, dim, red, yellow } from "kleur/colors";
2
2
  import { Writable } from "stream";
3
3
  import { format as utilFormat } from "util";
4
- function getLoggerLocale() {
5
- const defaultLocale = "en-US";
6
- if (process.env.LANG) {
7
- const extractedLocale = process.env.LANG.split(".")[0].replace(/_/g, "-");
8
- if (extractedLocale.length < 2)
9
- return defaultLocale;
10
- else
11
- return extractedLocale;
12
- } else
13
- return defaultLocale;
14
- }
15
- const dt = new Intl.DateTimeFormat(getLoggerLocale(), {
4
+ const dt = new Intl.DateTimeFormat([], {
16
5
  hour: "2-digit",
17
- minute: "2-digit"
6
+ minute: "2-digit",
7
+ second: "2-digit"
18
8
  });
19
9
  const defaultLogDestination = new Writable({
20
10
  objectMode: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "0.12.1",
3
+ "version": "0.12.4",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "@types/chai": "^4.3.1",
37
37
  "@types/mocha": "^9.1.1",
38
38
  "@types/yargs-parser": "^21.0.0",
39
- "astro-scripts": "0.0.3",
39
+ "astro-scripts": "0.0.5",
40
40
  "chai": "^4.3.6",
41
41
  "mocha": "^9.2.2",
42
42
  "uvu": "^0.5.3"