create-astro 4.6.0 โ†’ 4.7.1

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 } from '@astrojs/cli-kit';
1
+ import { prompt, type Task } from '@astrojs/cli-kit';
2
2
  export interface Context {
3
3
  help: boolean;
4
4
  prompt: typeof prompt;
@@ -19,6 +19,9 @@ export interface Context {
19
19
  stdin?: typeof process.stdin;
20
20
  stdout?: typeof process.stdout;
21
21
  exit(code: number): never;
22
+ welcome?: string;
22
23
  hat?: string;
24
+ tie?: string;
25
+ tasks: Task[];
23
26
  }
24
27
  export declare function getContext(argv: string[]): Promise<Context>;
@@ -1,2 +1,2 @@
1
1
  import type { Context } from './context.js';
2
- export declare function dependencies(ctx: Pick<Context, 'install' | 'yes' | 'prompt' | 'packageManager' | 'cwd' | 'dryRun'>): Promise<void>;
2
+ export declare function dependencies(ctx: Pick<Context, 'install' | 'yes' | 'prompt' | 'packageManager' | 'cwd' | 'dryRun' | 'tasks'>): Promise<void>;
@@ -1,2 +1,2 @@
1
1
  import type { Context } from './context.js';
2
- export declare function git(ctx: Pick<Context, 'cwd' | 'git' | 'yes' | 'prompt' | 'dryRun'>): Promise<void>;
2
+ export declare function git(ctx: Pick<Context, 'cwd' | 'git' | 'yes' | 'prompt' | 'dryRun' | 'tasks'>): Promise<void>;
@@ -1,2 +1,2 @@
1
1
  import type { Context } from './context.js';
2
- export declare function intro(ctx: Pick<Context, 'hat' | 'skipHouston' | 'version' | 'username' | 'fancy'>): Promise<void>;
2
+ export declare function intro(ctx: Pick<Context, 'skipHouston' | 'welcome' | 'hat' | 'tie' | 'version' | 'username' | 'fancy'>): Promise<void>;
@@ -1,2 +1,2 @@
1
1
  import type { Context } from './context.js';
2
- export declare function next(ctx: Pick<Context, 'hat' | 'cwd' | 'packageManager' | 'skipHouston'>): Promise<void>;
2
+ export declare function next(ctx: Pick<Context, 'hat' | 'tie' | 'cwd' | 'packageManager' | 'skipHouston'>): Promise<void>;
@@ -1,4 +1,4 @@
1
1
  import type { Context } from './context.js';
2
- export declare function template(ctx: Pick<Context, 'template' | 'prompt' | 'yes' | 'dryRun' | 'exit'>): Promise<void>;
2
+ export declare function template(ctx: Pick<Context, 'template' | 'prompt' | 'yes' | 'dryRun' | 'exit' | 'tasks'>): Promise<void>;
3
3
  export declare function getTemplateTarget(tmpl: string, ref?: string): string;
4
4
  export default function copyTemplate(tmpl: string, ctx: Context): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import type { Context } from './context.js';
2
- type PickedTypeScriptContext = Pick<Context, 'typescript' | 'yes' | 'prompt' | 'dryRun' | 'cwd' | 'exit' | 'packageManager' | 'install'>;
2
+ type PickedTypeScriptContext = Pick<Context, 'typescript' | 'yes' | 'prompt' | 'dryRun' | 'cwd' | 'exit' | 'packageManager' | 'install' | 'tasks'>;
3
3
  export declare function typescript(ctx: PickedTypeScriptContext): Promise<void>;
4
4
  export declare function setupTypeScript(value: string, ctx: PickedTypeScriptContext): Promise<void>;
5
5
  export {};
@@ -0,0 +1,9 @@
1
+ interface SeasonalHouston {
2
+ hats?: string[];
3
+ ties?: string[];
4
+ messages: string[];
5
+ }
6
+ export default function getSeasonalHouston({ fancy }: {
7
+ fancy?: boolean;
8
+ }): SeasonalHouston;
9
+ export {};
package/dist/index.js CHANGED
@@ -241,39 +241,10 @@ var stdout = process.stdout;
241
241
  function setStdout(writable) {
242
242
  stdout = writable;
243
243
  }
244
- async function say(messages, { clear = false, hat = "" } = {}) {
245
- return houston(messages, { clear, hat, stdout });
246
- }
247
- async function spinner(args) {
248
- await load(args, { stdout });
244
+ async function say(messages, { clear = false, hat = "", tie = "" } = {}) {
245
+ return houston(messages, { clear, hat, tie, stdout });
249
246
  }
250
247
  var title = (text2) => align(label(text2), "end", 7) + " ";
251
- var welcome = [
252
- // `Let's claim your corner of the internet.`,
253
- // `I'll be your assistant today.`,
254
- // `Let's build something awesome!`,
255
- // `Let's build something great!`,
256
- // `Let's build something fast!`,
257
- // `Let's build the web we want.`,
258
- // `Let's make the web weird!`,
259
- // `Let's make the web a better place!`,
260
- // `Let's create a new project!`,
261
- // `Let's create something unique!`,
262
- // `Time to build a new website.`,
263
- // `Time to build a faster website.`,
264
- // `Time to build a sweet new website.`,
265
- // `We're glad to have you on board.`,
266
- // `Keeping the internet weird since 2021.`,
267
- // `Initiating launch sequence...`,
268
- // `Initiating launch sequence... right... now!`,
269
- // `Awaiting further instructions.`,
270
- `Ho, ho, ho! 'Tis the season to code and create.`,
271
- `Jingle all the way through your web creation journey!`,
272
- `Let's unwrap the magic of the web together!`,
273
- `Bells are ringing, and so are your creative ideas!`,
274
- `It's starting to look a lot like Christmas on the internet.`,
275
- `It's time to decorate the web with your festive ideas!`
276
- ];
277
248
  var getName = () => new Promise((resolve) => {
278
249
  exec("git config user.name", { encoding: "utf-8" }, (_1, gitName) => {
279
250
  if (gitName.trim()) {
@@ -390,7 +361,7 @@ function printHelp({
390
361
  if (headline) {
391
362
  message.push(
392
363
  linebreak(),
393
- `${title(commandName)} ${color.green(`v${"4.6.0"}`)} ${headline}`
364
+ `${title(commandName)} ${color.green(`v${"4.7.1"}`)} ${headline}`
394
365
  );
395
366
  }
396
367
  if (usage) {
@@ -413,6 +384,110 @@ function printHelp({
413
384
  log(message.join("\n") + "\n");
414
385
  }
415
386
 
387
+ // src/data/seasonal.ts
388
+ function getSeasonalHouston({ fancy }) {
389
+ const season = getSeason();
390
+ switch (season) {
391
+ case "new-year": {
392
+ const year = (/* @__PURE__ */ new Date()).getFullYear();
393
+ return {
394
+ hats: rarity(0.5, ["\u{1F3A9}"]),
395
+ ties: rarity(0.25, ["\u{1F38A}", "\u{1F380}", "\u{1F389}"]),
396
+ messages: [
397
+ `New year, new Astro site!`,
398
+ `Kicking ${year} off with Astro?! What an honor!`,
399
+ `Happy ${year}! Let's make something cool.`,
400
+ `${year} is your year! Let's build something awesome.`,
401
+ `${year} is the year of Astro!`,
402
+ `${year} is clearly off to a great start!`,
403
+ `Thanks for starting ${year} with Astro!`
404
+ ]
405
+ };
406
+ }
407
+ case "spooky":
408
+ return {
409
+ hats: rarity(0.5, ["\u{1F383}", "\u{1F47B}", "\u2620\uFE0F", "\u{1F480}", "\u{1F577}\uFE0F", "\u{1F52E}"]),
410
+ ties: rarity(0.25, ["\u{1F9B4}", "\u{1F36C}", "\u{1F36B}"]),
411
+ messages: [
412
+ `I'm afraid I can't help you... Just kidding!`,
413
+ `Boo! Just kidding. Let's make a website!`,
414
+ `Let's haunt the internet. OooOooOOoo!`,
415
+ `No tricks here. Seeing you is always treat!`,
416
+ `Spiders aren't the only ones building the web!`,
417
+ `Let's conjure up some web magic!`,
418
+ `Let's harness the power of Astro to build a frightful new site!`,
419
+ `We're conjuring up a spooktacular website!`,
420
+ `Prepare for a web of spooky wonders to be woven.`,
421
+ `Chills and thrills await you on your new project!`
422
+ ]
423
+ };
424
+ case "holiday":
425
+ return {
426
+ hats: rarity(0.75, ["\u{1F381}", "\u{1F384}", "\u{1F332}"]),
427
+ ties: rarity(0.75, ["\u{1F9E3}"]),
428
+ messages: [
429
+ `'Tis the season to code and create.`,
430
+ `Jingle all the way through your web creation journey!`,
431
+ `Bells are ringing, and so are your creative ideas!`,
432
+ `Let's make the internet our own winter wonderland!`,
433
+ `It's time to decorate a brand new website!`,
434
+ `Let's unwrap the magic of the web together!`,
435
+ `Hope you're enjoying the holiday season!`,
436
+ `I'm dreaming of a brand new website!`,
437
+ `No better holiday gift than a new site!`,
438
+ `Your creativity is the gift that keeps on giving!`
439
+ ]
440
+ };
441
+ default:
442
+ return {
443
+ hats: fancy ? ["\u{1F3A9}", "\u{1F3A9}", "\u{1F3A9}", "\u{1F3A9}", "\u{1F393}", "\u{1F451}", "\u{1F9E2}", "\u{1F366}"] : void 0,
444
+ ties: fancy ? rarity(0.33, ["\u{1F380}", "\u{1F9E3}"]) : void 0,
445
+ messages: [
446
+ `Let's claim your corner of the internet.`,
447
+ `I'll be your assistant today.`,
448
+ `Let's build something awesome!`,
449
+ `Let's build something great!`,
450
+ `Let's build something fast!`,
451
+ `Let's build the web we want.`,
452
+ `Let's make the web weird!`,
453
+ `Let's make the web a better place!`,
454
+ `Let's create a new project!`,
455
+ `Let's create something unique!`,
456
+ `Time to build a new website.`,
457
+ `Time to build a faster website.`,
458
+ `Time to build a sweet new website.`,
459
+ `We're glad to have you on board.`,
460
+ `Keeping the internet weird since 2021.`,
461
+ `Initiating launch sequence...`,
462
+ `Initiating launch sequence... right... now!`,
463
+ `Awaiting further instructions.`
464
+ ]
465
+ };
466
+ }
467
+ }
468
+ function getSeason() {
469
+ const date = /* @__PURE__ */ new Date();
470
+ const month = date.getMonth() + 1;
471
+ const day = date.getDate() + 1;
472
+ if (month === 1 && day <= 7) {
473
+ return "new-year";
474
+ }
475
+ if (month === 10 && day > 7) {
476
+ return "spooky";
477
+ }
478
+ if (month === 12 && day > 7 && day < 25) {
479
+ return "holiday";
480
+ }
481
+ }
482
+ function rarity(frequency, emoji) {
483
+ if (frequency === 1)
484
+ return emoji;
485
+ if (frequency === 0)
486
+ return [""];
487
+ const empty = Array.from({ length: Math.round(emoji.length * frequency) }, () => "");
488
+ return [...emoji, ...empty];
489
+ }
490
+
416
491
  // src/actions/context.ts
417
492
  async function getContext(argv) {
418
493
  const flags = (0, import_arg.default)(
@@ -464,6 +539,7 @@ async function getContext(argv) {
464
539
  typescript2 = "strict";
465
540
  }
466
541
  skipHouston = (os.platform() === "win32" && !fancy || skipHouston) ?? [yes, no, install2, git2, typescript2].some((v2) => v2 !== void 0);
542
+ const { messages, hats, ties } = getSeasonalHouston({ fancy });
467
543
  const context = {
468
544
  help: help2,
469
545
  prompt,
@@ -476,8 +552,9 @@ async function getContext(argv) {
476
552
  projectName: projectName2,
477
553
  template: template2,
478
554
  ref: ref ?? "latest",
479
- hat: random(["\u2744\uFE0F", "\u{1F384}", "\u{1F381}"]),
480
- // fancy ? random(['๐ŸŽฉ', '๐ŸŽฉ', '๐ŸŽฉ', '๐ŸŽฉ', '๐ŸŽ“', '๐Ÿ‘‘', '๐Ÿงข', '๐Ÿฆ']) : undefined,
555
+ welcome: random(messages),
556
+ hat: hats ? random(hats) : void 0,
557
+ tie: ties ? random(ties) : void 0,
481
558
  yes,
482
559
  install: install2 ?? (noInstall ? false : void 0),
483
560
  git: git2 ?? (noGit ? false : void 0),
@@ -485,7 +562,8 @@ async function getContext(argv) {
485
562
  cwd,
486
563
  exit(code) {
487
564
  process.exit(code);
488
- }
565
+ },
566
+ tasks: []
489
567
  };
490
568
  return context;
491
569
  }
@@ -517,8 +595,9 @@ async function dependencies(ctx) {
517
595
  if (ctx.dryRun) {
518
596
  await info("--dry-run", `Skipping dependency installation`);
519
597
  } else if (deps) {
520
- await spinner({
521
- start: `Installing dependencies with ${ctx.packageManager}...`,
598
+ ctx.tasks.push({
599
+ pending: "Dependencies",
600
+ start: `Dependencies installing with ${ctx.packageManager}...`,
522
601
  end: "Dependencies installed",
523
602
  onError: (e) => {
524
603
  error("error", e);
@@ -573,7 +652,8 @@ async function git(ctx) {
573
652
  if (ctx.dryRun) {
574
653
  await info("--dry-run", `Skipping Git initialization`);
575
654
  } else if (_git) {
576
- await spinner({
655
+ ctx.tasks.push({
656
+ pending: "Git",
577
657
  start: "Git initializing...",
578
658
  end: "Git initialized",
579
659
  while: () => init({ cwd: ctx.cwd }).catch((e) => {
@@ -632,10 +712,10 @@ function help() {
632
712
 
633
713
  // src/actions/intro.ts
634
714
  import { color as color4, label as label2 } from "@astrojs/cli-kit";
635
- import { random as random2 } from "@astrojs/cli-kit/utils";
636
715
  async function intro(ctx) {
637
716
  banner();
638
717
  if (!ctx.skipHouston) {
718
+ const { welcome, hat, tie } = ctx;
639
719
  await say(
640
720
  [
641
721
  [
@@ -647,9 +727,9 @@ async function intro(ctx) {
647
727
  ),
648
728
  Promise.resolve(ctx.username).then((username) => `${username}!`)
649
729
  ],
650
- random2(welcome)
730
+ welcome ?? "Let's build something awesome!"
651
731
  ],
652
- { clear: true, hat: ctx.hat }
732
+ { clear: true, hat, tie }
653
733
  );
654
734
  }
655
735
  }
@@ -667,7 +747,7 @@ async function next(ctx) {
667
747
  const devCmd = commandMap[ctx.packageManager] || "npm run dev";
668
748
  await nextSteps({ projectDir, devCmd });
669
749
  if (!ctx.skipHouston) {
670
- await say(["Good luck out there, astronaut! \u{1F680}"], { hat: ctx.hat });
750
+ await say(["Good luck out there, astronaut! \u{1F680}"], { hat: ctx.hat, tie: ctx.tie });
671
751
  }
672
752
  return;
673
753
  }
@@ -808,7 +888,8 @@ async function template(ctx) {
808
888
  if (ctx.dryRun) {
809
889
  await info("--dry-run", `Skipping template copying`);
810
890
  } else if (ctx.template) {
811
- await spinner({
891
+ ctx.tasks.push({
892
+ pending: "Template",
812
893
  start: "Template copying...",
813
894
  end: "Template copied",
814
895
  while: () => copyTemplate(ctx.template, ctx).catch((e) => {
@@ -1033,7 +1114,8 @@ async function typescript(ctx) {
1033
1114
  if (ts === "relaxed" || ts === "default") {
1034
1115
  ts = "base";
1035
1116
  }
1036
- await spinner({
1117
+ ctx.tasks.push({
1118
+ pending: "TypeScript",
1037
1119
  start: "TypeScript customizing...",
1038
1120
  end: "TypeScript customized",
1039
1121
  while: () => setupTypeScript(ts, ctx).catch((e) => {
@@ -1157,6 +1239,7 @@ function parseGitURI(input) {
1157
1239
  }
1158
1240
 
1159
1241
  // src/index.ts
1242
+ import { tasks } from "@astrojs/cli-kit";
1160
1243
  var exit = () => process.exit(0);
1161
1244
  process.on("SIGINT", exit);
1162
1245
  process.on("SIGTERM", exit);
@@ -1176,12 +1259,18 @@ async function main() {
1176
1259
  dependencies,
1177
1260
  typescript,
1178
1261
  // Steps which write to files need to go above git
1179
- git,
1180
- next
1262
+ git
1181
1263
  ];
1182
1264
  for (const step of steps) {
1183
1265
  await step(ctx);
1184
1266
  }
1267
+ console.log("");
1268
+ const labels = {
1269
+ start: "Project initializing...",
1270
+ end: "Project initialized!"
1271
+ };
1272
+ await tasks(labels, ctx.tasks);
1273
+ await next(ctx);
1185
1274
  process.exit(0);
1186
1275
  }
1187
1276
  export {
@@ -1,6 +1,7 @@
1
- export declare function say(messages: string | string[], { clear, hat }?: {
1
+ export declare function say(messages: string | string[], { clear, hat, tie }?: {
2
2
  clear?: boolean | undefined;
3
3
  hat?: string | undefined;
4
+ tie?: string | undefined;
4
5
  }): Promise<void>;
5
6
  export declare function spinner(args: {
6
7
  start: string;
@@ -9,7 +10,6 @@ export declare function spinner(args: {
9
10
  while: (...args: any) => Promise<any>;
10
11
  }): Promise<void>;
11
12
  export declare const title: (text: string) => string;
12
- export declare const welcome: string[];
13
13
  export declare const getName: () => Promise<string>;
14
14
  export declare const getVersion: (packageManager: string) => Promise<string>;
15
15
  export declare const log: (message: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "4.6.0",
3
+ "version": "4.7.1",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "//a": "MOST PACKAGES SHOULD GO IN DEV_DEPENDENCIES! THEY WILL BE BUNDLED.",
26
26
  "//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES",
27
27
  "dependencies": {
28
- "@astrojs/cli-kit": "^0.3.1",
28
+ "@astrojs/cli-kit": "^0.4.1",
29
29
  "giget": "1.1.3"
30
30
  },
31
31
  "devDependencies": {