create-astro 0.12.2 → 0.12.3
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 +1 -1
- package/dist/index.js +40 -43
- package/dist/logger.js +1 -1
- package/package.json +2 -2
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 =
|
|
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
|
|
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
|
|
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.
|
|
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 (
|
|
125
|
-
|
|
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
|
-
|
|
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:
|
|
156
|
+
message: `Initialize a new git repository? ${dim("This can be useful to track changes.")}`,
|
|
163
157
|
initial: true
|
|
164
158
|
});
|
|
165
|
-
if (
|
|
166
|
-
|
|
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(
|
|
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
|
-
|
|
172
|
+
let projectDir = path.relative(process.cwd(), cwd);
|
|
176
173
|
const devCmd = pkgManager === "npm" ? "npm run dev" : `${pkgManager} dev`;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astro",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3",
|
|
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.
|
|
39
|
+
"astro-scripts": "0.0.5",
|
|
40
40
|
"chai": "^4.3.6",
|
|
41
41
|
"mocha": "^9.2.2",
|
|
42
42
|
"uvu": "^0.5.3"
|