create-astro 3.1.13 → 3.2.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 +52 -29
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -176,8 +176,7 @@ import detectPackageManager2 from "which-pm-runs";
|
|
|
176
176
|
|
|
177
177
|
// src/messages.ts
|
|
178
178
|
import { color, say as houston, label, spinner as load } from "@astrojs/cli-kit";
|
|
179
|
-
import { align, sleep } from "@astrojs/cli-kit/utils";
|
|
180
|
-
import { execa } from "execa";
|
|
179
|
+
import { align, sleep as sleep2 } from "@astrojs/cli-kit/utils";
|
|
181
180
|
import fetch from "node-fetch-native";
|
|
182
181
|
import { exec } from "node:child_process";
|
|
183
182
|
|
|
@@ -201,11 +200,42 @@ function stripAnsi(string) {
|
|
|
201
200
|
|
|
202
201
|
// src/messages.ts
|
|
203
202
|
import detectPackageManager from "which-pm-runs";
|
|
203
|
+
|
|
204
|
+
// src/shell.ts
|
|
205
|
+
import { spawn } from "node:child_process";
|
|
206
|
+
import { text as textFromStream } from "node:stream/consumers";
|
|
207
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
208
|
+
var text = (stream) => stream ? textFromStream(stream).then((t) => t.trimEnd()) : "";
|
|
209
|
+
async function shell(command, flags, opts = {}) {
|
|
210
|
+
const controller = opts.timeout ? new AbortController() : void 0;
|
|
211
|
+
const child = spawn(command, flags, {
|
|
212
|
+
cwd: opts.cwd,
|
|
213
|
+
shell: true,
|
|
214
|
+
stdio: opts.stdio,
|
|
215
|
+
signal: controller == null ? void 0 : controller.signal
|
|
216
|
+
});
|
|
217
|
+
const stdout2 = await text(child.stdout);
|
|
218
|
+
const stderr = await text(child.stderr);
|
|
219
|
+
if (opts.timeout) {
|
|
220
|
+
sleep(opts.timeout).then(() => {
|
|
221
|
+
controller.abort();
|
|
222
|
+
throw { stdout: stdout2, stderr, exitCode: 1 };
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
await new Promise((resolve) => child.on("exit", resolve));
|
|
226
|
+
const { exitCode } = child;
|
|
227
|
+
if (exitCode !== 0) {
|
|
228
|
+
throw { stdout: stdout2, stderr, exitCode };
|
|
229
|
+
}
|
|
230
|
+
return { stdout: stdout2, stderr, exitCode };
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/messages.ts
|
|
204
234
|
async function getRegistry() {
|
|
205
235
|
var _a, _b;
|
|
206
236
|
const packageManager = ((_a = detectPackageManager()) == null ? void 0 : _a.name) || "npm";
|
|
207
237
|
try {
|
|
208
|
-
const { stdout: stdout2 } = await
|
|
238
|
+
const { stdout: stdout2 } = await shell(packageManager, ["config", "get", "registry"]);
|
|
209
239
|
return ((_b = stdout2 == null ? void 0 : stdout2.trim()) == null ? void 0 : _b.replace(/\/$/, "")) || "https://registry.npmjs.org";
|
|
210
240
|
} catch (e) {
|
|
211
241
|
return "https://registry.npmjs.org";
|
|
@@ -221,7 +251,7 @@ async function say(messages, { clear = false, hat = "" } = {}) {
|
|
|
221
251
|
async function spinner(args) {
|
|
222
252
|
await load(args, { stdout });
|
|
223
253
|
}
|
|
224
|
-
var title = (
|
|
254
|
+
var title = (text2) => align(label(text2), "end", 7) + " ";
|
|
225
255
|
var welcome = [
|
|
226
256
|
`Let's claim your corner of the internet.`,
|
|
227
257
|
`I'll be your assistant today.`,
|
|
@@ -272,39 +302,39 @@ var banner = async (version) => log(
|
|
|
272
302
|
`
|
|
273
303
|
${label("astro", color.bgGreen, color.black)} ${version ? color.green(color.bold(`v${version}`)) : ""} ${color.bold("Launch sequence initiated.")}`
|
|
274
304
|
);
|
|
275
|
-
var info = async (prefix,
|
|
276
|
-
await
|
|
305
|
+
var info = async (prefix, text2) => {
|
|
306
|
+
await sleep2(100);
|
|
277
307
|
if (stdout.columns < 80) {
|
|
278
308
|
log(`${" ".repeat(5)} ${color.cyan("\u25FC")} ${color.cyan(prefix)}`);
|
|
279
|
-
log(`${" ".repeat(9)}${color.dim(
|
|
309
|
+
log(`${" ".repeat(9)}${color.dim(text2)}`);
|
|
280
310
|
} else {
|
|
281
|
-
log(`${" ".repeat(5)} ${color.cyan("\u25FC")} ${color.cyan(prefix)} ${color.dim(
|
|
311
|
+
log(`${" ".repeat(5)} ${color.cyan("\u25FC")} ${color.cyan(prefix)} ${color.dim(text2)}`);
|
|
282
312
|
}
|
|
283
313
|
};
|
|
284
|
-
var error = async (prefix,
|
|
314
|
+
var error = async (prefix, text2) => {
|
|
285
315
|
if (stdout.columns < 80) {
|
|
286
316
|
log(`${" ".repeat(5)} ${color.red("\u25B2")} ${color.red(prefix)}`);
|
|
287
|
-
log(`${" ".repeat(9)}${color.dim(
|
|
317
|
+
log(`${" ".repeat(9)}${color.dim(text2)}`);
|
|
288
318
|
} else {
|
|
289
|
-
log(`${" ".repeat(5)} ${color.red("\u25B2")} ${color.red(prefix)} ${color.dim(
|
|
319
|
+
log(`${" ".repeat(5)} ${color.red("\u25B2")} ${color.red(prefix)} ${color.dim(text2)}`);
|
|
290
320
|
}
|
|
291
321
|
};
|
|
292
322
|
var typescriptByDefault = async () => {
|
|
293
323
|
await info(`No worries!`, "TypeScript is supported in Astro by default,");
|
|
294
324
|
log(`${" ".repeat(9)}${color.dim("but you are free to continue writing JavaScript instead.")}`);
|
|
295
|
-
await
|
|
325
|
+
await sleep2(1e3);
|
|
296
326
|
};
|
|
297
327
|
var nextSteps = async ({ projectDir, devCmd }) => {
|
|
298
328
|
const max = stdout.columns;
|
|
299
329
|
const prefix = max < 80 ? " " : " ".repeat(9);
|
|
300
|
-
await
|
|
330
|
+
await sleep2(200);
|
|
301
331
|
log(
|
|
302
332
|
`
|
|
303
333
|
${color.bgCyan(` ${color.black("next")} `)} ${color.bold(
|
|
304
334
|
"Liftoff confirmed. Explore your project!"
|
|
305
335
|
)}`
|
|
306
336
|
);
|
|
307
|
-
await
|
|
337
|
+
await sleep2(100);
|
|
308
338
|
if (projectDir !== "") {
|
|
309
339
|
projectDir = projectDir.includes(" ") ? `"./${projectDir}"` : `./${projectDir}`;
|
|
310
340
|
const enter = [
|
|
@@ -318,16 +348,16 @@ ${prefix}Enter your project directory using`,
|
|
|
318
348
|
log(
|
|
319
349
|
`${prefix}Run ${color.cyan(devCmd)} to start the dev server. ${color.cyan("CTRL+C")} to stop.`
|
|
320
350
|
);
|
|
321
|
-
await
|
|
351
|
+
await sleep2(100);
|
|
322
352
|
log(
|
|
323
353
|
`${prefix}Add frameworks like ${color.cyan(`react`)} or ${color.cyan(
|
|
324
354
|
"tailwind"
|
|
325
355
|
)} using ${color.cyan("astro add")}.`
|
|
326
356
|
);
|
|
327
|
-
await
|
|
357
|
+
await sleep2(100);
|
|
328
358
|
log(`
|
|
329
359
|
${prefix}Stuck? Join us at ${color.cyan(`https://astro.build/chat`)}`);
|
|
330
|
-
await
|
|
360
|
+
await sleep2(200);
|
|
331
361
|
};
|
|
332
362
|
function printHelp({
|
|
333
363
|
commandName,
|
|
@@ -355,7 +385,7 @@ function printHelp({
|
|
|
355
385
|
if (headline) {
|
|
356
386
|
message.push(
|
|
357
387
|
linebreak(),
|
|
358
|
-
`${title(commandName)} ${color.green(`v${"3.
|
|
388
|
+
`${title(commandName)} ${color.green(`v${"3.2.0"}`)} ${headline}`
|
|
359
389
|
);
|
|
360
390
|
}
|
|
361
391
|
if (usage) {
|
|
@@ -456,7 +486,6 @@ async function getContext(argv) {
|
|
|
456
486
|
|
|
457
487
|
// src/actions/dependencies.ts
|
|
458
488
|
import { color as color2 } from "@astrojs/cli-kit";
|
|
459
|
-
import { execa as execa2 } from "execa";
|
|
460
489
|
import fs from "node:fs";
|
|
461
490
|
import path from "node:path";
|
|
462
491
|
async function dependencies(ctx) {
|
|
@@ -500,12 +529,7 @@ async function dependencies(ctx) {
|
|
|
500
529
|
async function install({ pkgManager, cwd }) {
|
|
501
530
|
if (pkgManager === "yarn")
|
|
502
531
|
await ensureYarnLock({ cwd });
|
|
503
|
-
|
|
504
|
-
return new Promise((resolve, reject) => {
|
|
505
|
-
setTimeout(() => reject(`Request timed out after 1m 30s`), 9e4);
|
|
506
|
-
installExec.on("error", (e) => reject(e));
|
|
507
|
-
installExec.on("close", () => resolve());
|
|
508
|
-
});
|
|
532
|
+
return shell(pkgManager, ["install"], { cwd, timeout: 9e4, stdio: "ignore" });
|
|
509
533
|
}
|
|
510
534
|
async function ensureYarnLock({ cwd }) {
|
|
511
535
|
const yarnLock = path.join(cwd, "yarn.lock");
|
|
@@ -518,7 +542,6 @@ async function ensureYarnLock({ cwd }) {
|
|
|
518
542
|
import fs2 from "node:fs";
|
|
519
543
|
import path2 from "node:path";
|
|
520
544
|
import { color as color3 } from "@astrojs/cli-kit";
|
|
521
|
-
import { execa as execa3 } from "execa";
|
|
522
545
|
async function git(ctx) {
|
|
523
546
|
if (fs2.existsSync(path2.join(ctx.cwd, ".git"))) {
|
|
524
547
|
await info("Nice!", `Git has already been initialized`);
|
|
@@ -555,9 +578,9 @@ async function git(ctx) {
|
|
|
555
578
|
}
|
|
556
579
|
async function init({ cwd }) {
|
|
557
580
|
try {
|
|
558
|
-
await
|
|
559
|
-
await
|
|
560
|
-
await
|
|
581
|
+
await shell("git", ["init"], { cwd, stdio: "ignore" });
|
|
582
|
+
await shell("git", ["add", "-A"], { cwd, stdio: "ignore" });
|
|
583
|
+
await shell(
|
|
561
584
|
"git",
|
|
562
585
|
[
|
|
563
586
|
"commit",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astro",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,15 +26,14 @@
|
|
|
26
26
|
"//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@astrojs/cli-kit": "^0.2.3",
|
|
29
|
-
"
|
|
30
|
-
"execa": "^6.1.0",
|
|
31
|
-
"giget": "1.0.0",
|
|
32
|
-
"mocha": "^9.2.2",
|
|
29
|
+
"giget": "^1.1.2",
|
|
33
30
|
"node-fetch-native": "^1.2.0",
|
|
34
31
|
"which-pm-runs": "^1.1.0"
|
|
35
32
|
},
|
|
36
33
|
"devDependencies": {
|
|
37
34
|
"@types/which-pm-runs": "^1.0.0",
|
|
35
|
+
"chai": "^4.3.7",
|
|
36
|
+
"mocha": "^9.2.2",
|
|
38
37
|
"arg": "^5.0.2",
|
|
39
38
|
"strip-ansi": "^7.1.0",
|
|
40
39
|
"strip-json-comments": "^5.0.0",
|