create-astro 0.11.0 → 0.12.0
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 +30 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { bold, cyan, gray, green, red, yellow } from "kleur/colors";
|
|
3
|
+
import { bgCyan, black, bold, cyan, gray, green, red, yellow } from "kleur/colors";
|
|
4
4
|
import prompts from "prompts";
|
|
5
5
|
import degit from "degit";
|
|
6
6
|
import yargs from "yargs-parser";
|
|
@@ -125,21 +125,19 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
|
|
|
125
125
|
if (!installResponse) {
|
|
126
126
|
process.exit(0);
|
|
127
127
|
}
|
|
128
|
-
if (installResponse.install) {
|
|
128
|
+
if (installResponse.install && !args.dryrun) {
|
|
129
129
|
const installExec = execa(pkgManager, ["install"], { cwd });
|
|
130
130
|
const installingPackagesMsg = `Installing packages${emojiWithFallback(" \u{1F4E6}", "...")}`;
|
|
131
131
|
spinner = ora({ color: "green", text: installingPackagesMsg }).start();
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
spinner.text = `${installingPackagesMsg}
|
|
132
|
+
await new Promise((resolve, reject) => {
|
|
133
|
+
var _a;
|
|
134
|
+
(_a = installExec.stdout) == null ? void 0 : _a.on("data", function(data) {
|
|
135
|
+
spinner.text = `${installingPackagesMsg}
|
|
137
136
|
${bold(`[${pkgManager}]`)} ${data}`;
|
|
138
|
-
});
|
|
139
|
-
installExec.on("error", (error) => reject(error));
|
|
140
|
-
installExec.on("close", () => resolve());
|
|
141
137
|
});
|
|
142
|
-
|
|
138
|
+
installExec.on("error", (error) => reject(error));
|
|
139
|
+
installExec.on("close", () => resolve());
|
|
140
|
+
});
|
|
143
141
|
spinner.succeed();
|
|
144
142
|
}
|
|
145
143
|
const astroAddCommand = installResponse.install ? "astro add --yes" : `${pkgManagerExecCommand(pkgManager)} astro@latest add --yes`;
|
|
@@ -158,22 +156,34 @@ ${bold(`[${pkgManager}]`)} ${data}`;
|
|
|
158
156
|
if (astroAddResponse.astroAdd && !args.dryrun) {
|
|
159
157
|
await execaCommand(astroAddCommand, astroAddCommand === "astro add --yes" ? { cwd, stdio: "inherit", localDir: cwd, preferLocal: true } : { cwd, stdio: "inherit" });
|
|
160
158
|
}
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
const gitResponse = await prompts({
|
|
160
|
+
type: "confirm",
|
|
161
|
+
name: "git",
|
|
162
|
+
message: "Initialize a git repository?",
|
|
163
|
+
initial: true
|
|
164
|
+
});
|
|
165
|
+
if (!gitResponse) {
|
|
166
|
+
process.exit(0);
|
|
167
|
+
}
|
|
168
|
+
if (gitResponse.git && !args.dryrun) {
|
|
169
|
+
await execaCommand("git init", { cwd });
|
|
170
|
+
}
|
|
171
|
+
console.log(`
|
|
172
|
+
${bgCyan(black(" Next steps "))}
|
|
173
|
+
`);
|
|
163
174
|
const relative = path.relative(process.cwd(), cwd);
|
|
175
|
+
const startCommand = [];
|
|
164
176
|
if (relative !== "") {
|
|
165
|
-
|
|
177
|
+
startCommand.push(bold(cyan(`cd ${relative}`)));
|
|
166
178
|
}
|
|
167
179
|
if (!installResponse.install) {
|
|
168
|
-
|
|
180
|
+
startCommand.push(bold(cyan(`${pkgManager} install`)));
|
|
169
181
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
console.log(` ${i++}: ${bold(cyan(runCommand))}`);
|
|
182
|
+
startCommand.push(bold(cyan(pkgManager === "npm" ? "npm run dev" : `${pkgManager} dev`)));
|
|
183
|
+
console.log(startCommand.join(" && "));
|
|
173
184
|
console.log(`
|
|
174
185
|
To close the dev server, hit ${bold(cyan("Ctrl-C"))}`);
|
|
175
|
-
console.log(`
|
|
176
|
-
Stuck? Visit us at ${cyan("https://astro.build/chat")}
|
|
186
|
+
console.log(`Stuck? Visit us at ${cyan("https://astro.build/chat")}
|
|
177
187
|
`);
|
|
178
188
|
}
|
|
179
189
|
function emojiWithFallback(char, fallback) {
|