create-astro 4.1.0 → 4.2.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.
package/README.md CHANGED
@@ -47,13 +47,16 @@ May be provided in place of prompts
47
47
 
48
48
  | Name | Description |
49
49
  | :--------------------------- | :----------------------------------------------------- |
50
+ | `--help` (`-h`) | Display available flags. |
50
51
  | `--template <name>` | Specify your template. |
51
52
  | `--install` / `--no-install` | Install dependencies (or not). |
52
53
  | `--git` / `--no-git` | Initialize git repo (or not). |
53
- | `--yes` (`-y`) | Skip all prompt by accepting defaults. |
54
- | `--no` (`-n`) | Skip all prompt by declining defaults. |
54
+ | `--yes` (`-y`) | Skip all prompts by accepting defaults. |
55
+ | `--no` (`-n`) | Skip all prompts by declining defaults. |
55
56
  | `--dry-run` | Walk through steps without executing. |
56
57
  | `--skip-houston` | Skip Houston animation. |
58
+ | `--ref` | Specify an Astro branch (default: latest). |
59
+ | `--fancy` | Enable full Unicode support for Windows. |
57
60
  | `--typescript <option>` | TypeScript option: `strict` / `strictest` / `relaxed`. |
58
61
 
59
62
  [examples]: https://github.com/withastro/astro/tree/main/examples
@@ -1,2 +1,2 @@
1
1
  import type { Context } from './context.js';
2
- export declare function projectName(ctx: Pick<Context, 'cwd' | 'prompt' | 'projectName' | 'exit'>): Promise<void>;
2
+ export declare function projectName(ctx: Pick<Context, 'cwd' | 'yes' | 'dryRun' | 'prompt' | 'projectName' | 'exit'>): Promise<void>;
@@ -1,4 +1,4 @@
1
1
  import type { Context } from './context.js';
2
- export declare function template(ctx: Pick<Context, 'template' | 'prompt' | 'dryRun' | 'exit'>): Promise<void>;
2
+ export declare function template(ctx: Pick<Context, 'template' | 'prompt' | 'yes' | 'dryRun' | 'exit'>): 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>;
package/dist/index.js CHANGED
@@ -384,7 +384,7 @@ function printHelp({
384
384
  if (headline) {
385
385
  message.push(
386
386
  linebreak(),
387
- `${title(commandName)} ${color.green(`v${"4.1.0"}`)} ${headline}`
387
+ `${title(commandName)} ${color.green(`v${"4.2.1"}`)} ${headline}`
388
388
  );
389
389
  }
390
390
  if (usage) {
@@ -612,12 +612,12 @@ function help() {
612
612
  ["--template <name>", "Specify your template."],
613
613
  ["--install / --no-install", "Install dependencies (or not)."],
614
614
  ["--git / --no-git", "Initialize git repo (or not)."],
615
- ["--yes (-y)", "Skip all prompt by accepting defaults."],
616
- ["--no (-n)", "Skip all prompt by declining defaults."],
615
+ ["--yes (-y)", "Skip all prompts by accepting defaults."],
616
+ ["--no (-n)", "Skip all prompts by declining defaults."],
617
617
  ["--dry-run", "Walk through steps without executing."],
618
618
  ["--skip-houston", "Skip Houston animation."],
619
619
  ["--ref", "Choose astro branch (default: latest)."],
620
- ["--fancy", "Enable full unicode support for Windows."],
620
+ ["--fancy", "Enable full Unicode support for Windows."],
621
621
  ["--typescript <option>", "TypeScript option: strict | strictest | relaxed."]
622
622
  ]
623
623
  }
@@ -723,6 +723,12 @@ async function projectName(ctx) {
723
723
  if (!isEmpty(ctx.cwd)) {
724
724
  await info("Hmm...", `${color5.reset(`"${ctx.cwd}"`)}${color5.dim(` is not empty!`)}`);
725
725
  }
726
+ if (ctx.yes) {
727
+ ctx.projectName = generateProjectName();
728
+ ctx.cwd = `./${ctx.projectName}`;
729
+ await info("dir", `Project created at ./${ctx.projectName}`);
730
+ return;
731
+ }
726
732
  const { name } = await ctx.prompt({
727
733
  name: "name",
728
734
  type: "text",
@@ -740,6 +746,10 @@ async function projectName(ctx) {
740
746
  });
741
747
  ctx.cwd = name.trim();
742
748
  ctx.projectName = toValidName(name);
749
+ if (ctx.dryRun) {
750
+ await info("--dry-run", "Skipping project naming");
751
+ return;
752
+ }
743
753
  } else {
744
754
  let name = ctx.cwd;
745
755
  if (name === "." || name === "./") {
@@ -770,7 +780,11 @@ import { downloadTemplate } from "giget";
770
780
  import fs4 from "node:fs";
771
781
  import path5 from "node:path";
772
782
  async function template(ctx) {
773
- if (!ctx.template) {
783
+ if (!ctx.template && ctx.yes)
784
+ ctx.template = "basics";
785
+ if (ctx.template) {
786
+ await info("tmpl", `Using ${color6.reset(ctx.template)}${color6.dim(" as project template")}`);
787
+ } else {
774
788
  const { template: tmpl } = await ctx.prompt({
775
789
  name: "template",
776
790
  type: "select",
@@ -784,8 +798,6 @@ async function template(ctx) {
784
798
  ]
785
799
  });
786
800
  ctx.template = tmpl;
787
- } else {
788
- await info("tmpl", `Using ${color6.reset(ctx.template)}${color6.dim(" as project template")}`);
789
801
  }
790
802
  if (ctx.dryRun) {
791
803
  await info("--dry-run", `Skipping template copying`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "4.1.0",
3
+ "version": "4.2.1",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",