astro/packages/create-astro/README.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.5 KiB
Markdown
Raw Normal View History

# create-astro
2021-05-03 18:26:10 +00:00
## Scaffolding for Astro projects
**With NPM:**
2021-05-03 18:26:10 +00:00
```bash
npm create astro@latest
```
**With Yarn:**
2021-05-03 18:26:10 +00:00
```bash
yarn create astro
```
`create-astro` automatically runs in _interactive_ mode, but you can also specify your project name and template with command line arguments.
```bash
# npm 6.x
Refactor `create-astro` (#6082) * refactor: new version of create-astro * chore: update README * fix(create-astro): update project name logic * test(create-astro): fix test on windows * test(create-astro): fix test on windows * test(create-astro): remove unused import * chore: remove log * chore: increase test timeout * fix: message when skipping * fix: message for env.d.ts file * fix: always hard exit * fix: return from next-steps * chore: add message * refactor dependencies, bundle create-astro * chore: disable create-astro typings * chore: switch to arg * chore: update message * fix: split typescript into two steps, fix context test * chore: update wording * chore: update wording * Update packages/create-astro/src/actions/dependencies.ts Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> * refactor: move tests back to mocha/chai * chore: update cli-kit * update test script * chore: add comment about setStdout * chore: update cli-kit * Update packages/create-astro/src/messages.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/create-astro/src/messages.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * chore: update lockfile * fix(create-astro): support scoped package names, improve project-name tests * better git initialization * update cli-kit --------- Co-authored-by: Nate Moore <nate@astro.build> Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-02-06 16:19:37 +00:00
npm create astro@latest my-astro-project --template minimal
# npm 7+, extra double-dash is needed:
Refactor `create-astro` (#6082) * refactor: new version of create-astro * chore: update README * fix(create-astro): update project name logic * test(create-astro): fix test on windows * test(create-astro): fix test on windows * test(create-astro): remove unused import * chore: remove log * chore: increase test timeout * fix: message when skipping * fix: message for env.d.ts file * fix: always hard exit * fix: return from next-steps * chore: add message * refactor dependencies, bundle create-astro * chore: disable create-astro typings * chore: switch to arg * chore: update message * fix: split typescript into two steps, fix context test * chore: update wording * chore: update wording * Update packages/create-astro/src/actions/dependencies.ts Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> * refactor: move tests back to mocha/chai * chore: update cli-kit * update test script * chore: add comment about setStdout * chore: update cli-kit * Update packages/create-astro/src/messages.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/create-astro/src/messages.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * chore: update lockfile * fix(create-astro): support scoped package names, improve project-name tests * better git initialization * update cli-kit --------- Co-authored-by: Nate Moore <nate@astro.build> Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-02-06 16:19:37 +00:00
npm create astro@latest my-astro-project -- --template minimal
# yarn
Refactor `create-astro` (#6082) * refactor: new version of create-astro * chore: update README * fix(create-astro): update project name logic * test(create-astro): fix test on windows * test(create-astro): fix test on windows * test(create-astro): remove unused import * chore: remove log * chore: increase test timeout * fix: message when skipping * fix: message for env.d.ts file * fix: always hard exit * fix: return from next-steps * chore: add message * refactor dependencies, bundle create-astro * chore: disable create-astro typings * chore: switch to arg * chore: update message * fix: split typescript into two steps, fix context test * chore: update wording * chore: update wording * Update packages/create-astro/src/actions/dependencies.ts Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> * refactor: move tests back to mocha/chai * chore: update cli-kit * update test script * chore: add comment about setStdout * chore: update cli-kit * Update packages/create-astro/src/messages.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/create-astro/src/messages.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * chore: update lockfile * fix(create-astro): support scoped package names, improve project-name tests * better git initialization * update cli-kit --------- Co-authored-by: Nate Moore <nate@astro.build> Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-02-06 16:19:37 +00:00
yarn create astro my-astro-project --template minimal
```
Refactor `create-astro` (#6082) * refactor: new version of create-astro * chore: update README * fix(create-astro): update project name logic * test(create-astro): fix test on windows * test(create-astro): fix test on windows * test(create-astro): remove unused import * chore: remove log * chore: increase test timeout * fix: message when skipping * fix: message for env.d.ts file * fix: always hard exit * fix: return from next-steps * chore: add message * refactor dependencies, bundle create-astro * chore: disable create-astro typings * chore: switch to arg * chore: update message * fix: split typescript into two steps, fix context test * chore: update wording * chore: update wording * Update packages/create-astro/src/actions/dependencies.ts Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> * refactor: move tests back to mocha/chai * chore: update cli-kit * update test script * chore: add comment about setStdout * chore: update cli-kit * Update packages/create-astro/src/messages.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/create-astro/src/messages.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * chore: update lockfile * fix(create-astro): support scoped package names, improve project-name tests * better git initialization * update cli-kit --------- Co-authored-by: Nate Moore <nate@astro.build> Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-02-06 16:19:37 +00:00
[Check out the full list][examples] of example templates, available on GitHub.
You can also use any GitHub repo as a template:
```bash
npm create astro@latest my-astro-project -- --template cassidoo/shopify-react-astro
```
### CLI Flags
May be provided in place of prompts
| Name | Description |
|:-------------|:----------------------------------------------------|
Refactor `create-astro` (#6082) * refactor: new version of create-astro * chore: update README * fix(create-astro): update project name logic * test(create-astro): fix test on windows * test(create-astro): fix test on windows * test(create-astro): remove unused import * chore: remove log * chore: increase test timeout * fix: message when skipping * fix: message for env.d.ts file * fix: always hard exit * fix: return from next-steps * chore: add message * refactor dependencies, bundle create-astro * chore: disable create-astro typings * chore: switch to arg * chore: update message * fix: split typescript into two steps, fix context test * chore: update wording * chore: update wording * Update packages/create-astro/src/actions/dependencies.ts Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> * refactor: move tests back to mocha/chai * chore: update cli-kit * update test script * chore: add comment about setStdout * chore: update cli-kit * Update packages/create-astro/src/messages.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/create-astro/src/messages.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * chore: update lockfile * fix(create-astro): support scoped package names, improve project-name tests * better git initialization * update cli-kit --------- Co-authored-by: Nate Moore <nate@astro.build> Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-02-06 16:19:37 +00:00
| `--template <name> | Specify your template. |
| `--install / --no-install | Install dependencies (or not). |
| `--git / --no-git | Initialize git repo (or not). |
| `--yes (-y) | Skip all prompt by accepting defaults. |
| `--no (-n) | Skip all prompt by declining defaults. |
| `--dry-run | Walk through steps without executing. |
| `--skip-houston | Skip Houston animation. |
2021-11-23 22:47:05 +00:00
[examples]: https://github.com/withastro/astro/tree/main/examples
[typescript]: https://github.com/withastro/astro/tree/main/packages/astro/tsconfigs