create-astro 4.7.2 → 4.7.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.
@@ -1,4 +1,4 @@
1
- import { prompt, type Task } from '@astrojs/cli-kit';
1
+ import { type Task, prompt } from '@astrojs/cli-kit';
2
2
  export interface Context {
3
3
  help: boolean;
4
4
  prompt: typeof prompt;
package/dist/index.js CHANGED
@@ -170,14 +170,118 @@ var require_arg = __commonJS({
170
170
 
171
171
  // src/actions/context.ts
172
172
  var import_arg = __toESM(require_arg(), 1);
173
+ import os from "node:os";
173
174
  import { prompt } from "@astrojs/cli-kit";
174
175
  import { random } from "@astrojs/cli-kit/utils";
175
- import os from "node:os";
176
+
177
+ // src/data/seasonal.ts
178
+ function getSeasonalHouston({ fancy }) {
179
+ const season = getSeason();
180
+ switch (season) {
181
+ case "new-year": {
182
+ const year = (/* @__PURE__ */ new Date()).getFullYear();
183
+ return {
184
+ hats: rarity(0.5, ["\u{1F3A9}"]),
185
+ ties: rarity(0.25, ["\u{1F38A}", "\u{1F380}", "\u{1F389}"]),
186
+ messages: [
187
+ `New year, new Astro site!`,
188
+ `Kicking ${year} off with Astro?! What an honor!`,
189
+ `Happy ${year}! Let's make something cool.`,
190
+ `${year} is your year! Let's build something awesome.`,
191
+ `${year} is the year of Astro!`,
192
+ `${year} is clearly off to a great start!`,
193
+ `Thanks for starting ${year} with Astro!`
194
+ ]
195
+ };
196
+ }
197
+ case "spooky":
198
+ return {
199
+ hats: rarity(0.5, ["\u{1F383}", "\u{1F47B}", "\u2620\uFE0F", "\u{1F480}", "\u{1F577}\uFE0F", "\u{1F52E}"]),
200
+ ties: rarity(0.25, ["\u{1F9B4}", "\u{1F36C}", "\u{1F36B}"]),
201
+ messages: [
202
+ `I'm afraid I can't help you... Just kidding!`,
203
+ `Boo! Just kidding. Let's make a website!`,
204
+ `Let's haunt the internet. OooOooOOoo!`,
205
+ `No tricks here. Seeing you is always treat!`,
206
+ `Spiders aren't the only ones building the web!`,
207
+ `Let's conjure up some web magic!`,
208
+ `Let's harness the power of Astro to build a frightful new site!`,
209
+ `We're conjuring up a spooktacular website!`,
210
+ `Prepare for a web of spooky wonders to be woven.`,
211
+ `Chills and thrills await you on your new project!`
212
+ ]
213
+ };
214
+ case "holiday":
215
+ return {
216
+ hats: rarity(0.75, ["\u{1F381}", "\u{1F384}", "\u{1F332}"]),
217
+ ties: rarity(0.75, ["\u{1F9E3}"]),
218
+ messages: [
219
+ `'Tis the season to code and create.`,
220
+ `Jingle all the way through your web creation journey!`,
221
+ `Bells are ringing, and so are your creative ideas!`,
222
+ `Let's make the internet our own winter wonderland!`,
223
+ `It's time to decorate a brand new website!`,
224
+ `Let's unwrap the magic of the web together!`,
225
+ `Hope you're enjoying the holiday season!`,
226
+ `I'm dreaming of a brand new website!`,
227
+ `No better holiday gift than a new site!`,
228
+ `Your creativity is the gift that keeps on giving!`
229
+ ]
230
+ };
231
+ default:
232
+ return {
233
+ hats: fancy ? ["\u{1F3A9}", "\u{1F3A9}", "\u{1F3A9}", "\u{1F3A9}", "\u{1F393}", "\u{1F451}", "\u{1F9E2}", "\u{1F366}"] : void 0,
234
+ ties: fancy ? rarity(0.33, ["\u{1F380}", "\u{1F9E3}"]) : void 0,
235
+ messages: [
236
+ `Let's claim your corner of the internet.`,
237
+ `I'll be your assistant today.`,
238
+ `Let's build something awesome!`,
239
+ `Let's build something great!`,
240
+ `Let's build something fast!`,
241
+ `Let's build the web we want.`,
242
+ `Let's make the web weird!`,
243
+ `Let's make the web a better place!`,
244
+ `Let's create a new project!`,
245
+ `Let's create something unique!`,
246
+ `Time to build a new website.`,
247
+ `Time to build a faster website.`,
248
+ `Time to build a sweet new website.`,
249
+ `We're glad to have you on board.`,
250
+ `Keeping the internet weird since 2021.`,
251
+ `Initiating launch sequence...`,
252
+ `Initiating launch sequence... right... now!`,
253
+ `Awaiting further instructions.`
254
+ ]
255
+ };
256
+ }
257
+ }
258
+ function getSeason() {
259
+ const date = /* @__PURE__ */ new Date();
260
+ const month = date.getMonth() + 1;
261
+ const day = date.getDate() + 1;
262
+ if (month === 1 && day <= 7) {
263
+ return "new-year";
264
+ }
265
+ if (month === 10 && day > 7) {
266
+ return "spooky";
267
+ }
268
+ if (month === 12 && day > 7 && day < 25) {
269
+ return "holiday";
270
+ }
271
+ }
272
+ function rarity(frequency, emoji) {
273
+ if (frequency === 1)
274
+ return emoji;
275
+ if (frequency === 0)
276
+ return [""];
277
+ const empty = Array.from({ length: Math.round(emoji.length * frequency) }, () => "");
278
+ return [...emoji, ...empty];
279
+ }
176
280
 
177
281
  // src/messages.ts
178
- import { color, say as houston, label, spinner as load } from "@astrojs/cli-kit";
179
- import { align, sleep } from "@astrojs/cli-kit/utils";
180
282
  import { exec } from "node:child_process";
283
+ import { color, label, say as houston, spinner as load } from "@astrojs/cli-kit";
284
+ import { align, sleep } from "@astrojs/cli-kit/utils";
181
285
 
182
286
  // ../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
183
287
  function ansiRegex({ onlyFirst = false } = {}) {
@@ -233,11 +337,14 @@ var _registry;
233
337
  async function getRegistry(packageManager) {
234
338
  if (_registry)
235
339
  return _registry;
340
+ const fallback = "https://registry.npmjs.org";
236
341
  try {
237
342
  const { stdout: stdout2 } = await shell(packageManager, ["config", "get", "registry"]);
238
- _registry = stdout2?.trim()?.replace(/\/$/, "") || "https://registry.npmjs.org";
343
+ _registry = stdout2?.trim()?.replace(/\/$/, "") || fallback;
344
+ if (!new URL(_registry).host)
345
+ _registry = fallback;
239
346
  } catch (e) {
240
- _registry = "https://registry.npmjs.org";
347
+ _registry = fallback;
241
348
  }
242
349
  return _registry;
243
350
  }
@@ -266,10 +373,7 @@ var getVersion = (packageManager, packageName, fallback = "") => new Promise(asy
266
373
  let registry = await getRegistry(packageManager);
267
374
  const { version } = await fetch(`${registry}/${packageName}/latest`, {
268
375
  redirect: "follow"
269
- }).then(
270
- (res) => res.json(),
271
- () => ({ version: fallback })
272
- );
376
+ }).then((res) => res.json()).catch(() => ({ version: fallback }));
273
377
  return resolve(version);
274
378
  });
275
379
  var log = (message) => stdout.write(message + "\n");
@@ -363,7 +467,7 @@ function printHelp({
363
467
  if (headline) {
364
468
  message.push(
365
469
  linebreak(),
366
- `${title(commandName)} ${color.green(`v${"4.7.2"}`)} ${headline}`
470
+ `${title(commandName)} ${color.green(`v${"4.7.4"}`)} ${headline}`
367
471
  );
368
472
  }
369
473
  if (usage) {
@@ -386,110 +490,6 @@ function printHelp({
386
490
  log(message.join("\n") + "\n");
387
491
  }
388
492
 
389
- // src/data/seasonal.ts
390
- function getSeasonalHouston({ fancy }) {
391
- const season = getSeason();
392
- switch (season) {
393
- case "new-year": {
394
- const year = (/* @__PURE__ */ new Date()).getFullYear();
395
- return {
396
- hats: rarity(0.5, ["\u{1F3A9}"]),
397
- ties: rarity(0.25, ["\u{1F38A}", "\u{1F380}", "\u{1F389}"]),
398
- messages: [
399
- `New year, new Astro site!`,
400
- `Kicking ${year} off with Astro?! What an honor!`,
401
- `Happy ${year}! Let's make something cool.`,
402
- `${year} is your year! Let's build something awesome.`,
403
- `${year} is the year of Astro!`,
404
- `${year} is clearly off to a great start!`,
405
- `Thanks for starting ${year} with Astro!`
406
- ]
407
- };
408
- }
409
- case "spooky":
410
- return {
411
- hats: rarity(0.5, ["\u{1F383}", "\u{1F47B}", "\u2620\uFE0F", "\u{1F480}", "\u{1F577}\uFE0F", "\u{1F52E}"]),
412
- ties: rarity(0.25, ["\u{1F9B4}", "\u{1F36C}", "\u{1F36B}"]),
413
- messages: [
414
- `I'm afraid I can't help you... Just kidding!`,
415
- `Boo! Just kidding. Let's make a website!`,
416
- `Let's haunt the internet. OooOooOOoo!`,
417
- `No tricks here. Seeing you is always treat!`,
418
- `Spiders aren't the only ones building the web!`,
419
- `Let's conjure up some web magic!`,
420
- `Let's harness the power of Astro to build a frightful new site!`,
421
- `We're conjuring up a spooktacular website!`,
422
- `Prepare for a web of spooky wonders to be woven.`,
423
- `Chills and thrills await you on your new project!`
424
- ]
425
- };
426
- case "holiday":
427
- return {
428
- hats: rarity(0.75, ["\u{1F381}", "\u{1F384}", "\u{1F332}"]),
429
- ties: rarity(0.75, ["\u{1F9E3}"]),
430
- messages: [
431
- `'Tis the season to code and create.`,
432
- `Jingle all the way through your web creation journey!`,
433
- `Bells are ringing, and so are your creative ideas!`,
434
- `Let's make the internet our own winter wonderland!`,
435
- `It's time to decorate a brand new website!`,
436
- `Let's unwrap the magic of the web together!`,
437
- `Hope you're enjoying the holiday season!`,
438
- `I'm dreaming of a brand new website!`,
439
- `No better holiday gift than a new site!`,
440
- `Your creativity is the gift that keeps on giving!`
441
- ]
442
- };
443
- default:
444
- return {
445
- hats: fancy ? ["\u{1F3A9}", "\u{1F3A9}", "\u{1F3A9}", "\u{1F3A9}", "\u{1F393}", "\u{1F451}", "\u{1F9E2}", "\u{1F366}"] : void 0,
446
- ties: fancy ? rarity(0.33, ["\u{1F380}", "\u{1F9E3}"]) : void 0,
447
- messages: [
448
- `Let's claim your corner of the internet.`,
449
- `I'll be your assistant today.`,
450
- `Let's build something awesome!`,
451
- `Let's build something great!`,
452
- `Let's build something fast!`,
453
- `Let's build the web we want.`,
454
- `Let's make the web weird!`,
455
- `Let's make the web a better place!`,
456
- `Let's create a new project!`,
457
- `Let's create something unique!`,
458
- `Time to build a new website.`,
459
- `Time to build a faster website.`,
460
- `Time to build a sweet new website.`,
461
- `We're glad to have you on board.`,
462
- `Keeping the internet weird since 2021.`,
463
- `Initiating launch sequence...`,
464
- `Initiating launch sequence... right... now!`,
465
- `Awaiting further instructions.`
466
- ]
467
- };
468
- }
469
- }
470
- function getSeason() {
471
- const date = /* @__PURE__ */ new Date();
472
- const month = date.getMonth() + 1;
473
- const day = date.getDate() + 1;
474
- if (month === 1 && day <= 7) {
475
- return "new-year";
476
- }
477
- if (month === 10 && day > 7) {
478
- return "spooky";
479
- }
480
- if (month === 12 && day > 7 && day < 25) {
481
- return "holiday";
482
- }
483
- }
484
- function rarity(frequency, emoji) {
485
- if (frequency === 1)
486
- return emoji;
487
- if (frequency === 0)
488
- return [""];
489
- const empty = Array.from({ length: Math.round(emoji.length * frequency) }, () => "");
490
- return [...emoji, ...empty];
491
- }
492
-
493
493
  // src/actions/context.ts
494
494
  async function getContext(argv) {
495
495
  const flags = (0, import_arg.default)(
@@ -547,7 +547,7 @@ async function getContext(argv) {
547
547
  prompt,
548
548
  packageManager,
549
549
  username: getName(),
550
- version: getVersion(packageManager, "astro"),
550
+ version: getVersion(packageManager, "astro", "4.4.15"),
551
551
  skipHouston,
552
552
  fancy,
553
553
  dryRun,
@@ -577,10 +577,13 @@ function detectPackageManager() {
577
577
  return name === "npminstall" ? "cnpm" : name;
578
578
  }
579
579
 
580
+ // src/index.ts
581
+ import { tasks } from "@astrojs/cli-kit";
582
+
580
583
  // src/actions/dependencies.ts
581
- import { color as color2 } from "@astrojs/cli-kit";
582
584
  import fs from "node:fs";
583
585
  import path from "node:path";
586
+ import { color as color2 } from "@astrojs/cli-kit";
584
587
  async function dependencies(ctx) {
585
588
  let deps = ctx.install ?? ctx.yes;
586
589
  if (deps === void 0) {
@@ -755,8 +758,8 @@ async function next(ctx) {
755
758
  }
756
759
 
757
760
  // src/actions/project-name.ts
758
- import { color as color5, generateProjectName } from "@astrojs/cli-kit";
759
761
  import path4 from "node:path";
762
+ import { color as color5, generateProjectName } from "@astrojs/cli-kit";
760
763
 
761
764
  // src/actions/shared.ts
762
765
  import fs3 from "node:fs";
@@ -863,10 +866,10 @@ async function checkCwd(cwd) {
863
866
  }
864
867
 
865
868
  // src/actions/template.ts
866
- import { color as color6 } from "@astrojs/cli-kit";
867
- import { downloadTemplate } from "giget";
868
869
  import fs4 from "node:fs";
869
870
  import path5 from "node:path";
871
+ import { color as color6 } from "@astrojs/cli-kit";
872
+ import { downloadTemplate } from "giget";
870
873
  async function template(ctx) {
871
874
  if (!ctx.template && ctx.yes)
872
875
  ctx.template = "basics";
@@ -976,9 +979,9 @@ async function copyTemplate(tmpl, ctx) {
976
979
  }
977
980
 
978
981
  // src/actions/typescript.ts
979
- import { color as color7 } from "@astrojs/cli-kit";
980
982
  import { readFile, rm, writeFile } from "node:fs/promises";
981
983
  import path6 from "node:path";
984
+ import { color as color7 } from "@astrojs/cli-kit";
982
985
 
983
986
  // ../../node_modules/.pnpm/strip-json-comments@5.0.1/node_modules/strip-json-comments/index.js
984
987
  var singleComment = Symbol("singleComment");
@@ -1139,8 +1142,8 @@ var FILES_TO_UPDATE2 = {
1139
1142
  parsedPackageJson.scripts.build = `astro check && ${buildScript}`;
1140
1143
  }
1141
1144
  const [astroCheckVersion, typescriptVersion] = await Promise.all([
1142
- getVersion(options.ctx.packageManager, "@astrojs/check"),
1143
- getVersion(options.ctx.packageManager, "typescript")
1145
+ getVersion(options.ctx.packageManager, "@astrojs/check", "0.3.1"),
1146
+ getVersion(options.ctx.packageManager, "typescript", "5.2.2")
1144
1147
  ]);
1145
1148
  parsedPackageJson.dependencies ??= {};
1146
1149
  parsedPackageJson.dependencies["@astrojs/check"] = `^${astroCheckVersion}`;
@@ -1186,8 +1189,8 @@ async function setupTypeScript(value, ctx) {
1186
1189
  }
1187
1190
 
1188
1191
  // src/actions/verify.ts
1189
- import { color as color8 } from "@astrojs/cli-kit";
1190
1192
  import dns from "node:dns/promises";
1193
+ import { color as color8 } from "@astrojs/cli-kit";
1191
1194
  async function verify(ctx) {
1192
1195
  if (!ctx.dryRun) {
1193
1196
  const online = await isOnline();
@@ -1243,7 +1246,6 @@ function parseGitURI(input) {
1243
1246
  }
1244
1247
 
1245
1248
  // src/index.ts
1246
- import { tasks } from "@astrojs/cli-kit";
1247
1249
  var exit = () => process.exit(0);
1248
1250
  process.on("SIGINT", exit);
1249
1251
  process.on("SIGTERM", exit);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "4.7.2",
3
+ "version": "4.7.4",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -30,8 +30,6 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "arg": "^5.0.2",
33
- "chai": "^4.3.7",
34
- "mocha": "^10.2.0",
35
33
  "strip-ansi": "^7.1.0",
36
34
  "strip-json-comments": "^5.0.1",
37
35
  "astro-scripts": "0.0.14"
@@ -46,6 +44,6 @@
46
44
  "build": "astro-scripts build \"src/index.ts\" --bundle && tsc",
47
45
  "build:ci": "astro-scripts build \"src/index.ts\" --bundle",
48
46
  "dev": "astro-scripts dev \"src/**/*.ts\"",
49
- "test": "mocha --exit --timeout 20000 --parallel"
47
+ "test": "astro-scripts test \"test/**/*.test.js\""
50
48
  }
51
49
  }