Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(create-astro): add --fancy flag #5226

Merged
merged 2 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/empty-feet-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

Allow Windows users to pass `--fancy` to enable full unicode support
1 change: 1 addition & 0 deletions packages/create-astro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ May be provided in place of prompts
|:-------------|:----------------------------------------------------|
| `--template` | Specify the template name ([list][examples]) |
| `--commit` | Specify a specific Git commit or branch to use from this repo (by default, `main` branch of this repo will be used) |
| `--fancy` | For Windows users, `--fancy` will enable full unicode support |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we have a --help flag that would print this stuff in the CLI in a previous version? Out of scope for this PR, but could be helpful to add in the future.

Docs here look good though! Even if I guess this README doesn’t get a lot of eyes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we do have a --help flag, would be nice to follow-up with!


### Debugging

Expand Down
2 changes: 1 addition & 1 deletion packages/create-astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"tsconfigs"
],
"dependencies": {
"@astrojs/cli-kit": "^0.1.0",
"@astrojs/cli-kit": "^0.1.3",
"chalk": "^5.0.1",
"comment-json": "^4.2.3",
"execa": "^6.1.0",
Expand Down
10 changes: 8 additions & 2 deletions packages/create-astro/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint no-console: 'off' */
import { color, generateProjectName, label, say } from '@astrojs/cli-kit';
import { forceUnicode } from '@astrojs/cli-kit/utils';
import { random } from '@astrojs/cli-kit/utils';
import { assign, parse, stringify } from 'comment-json';
import { execa, execaCommand } from 'execa';
Expand Down Expand Up @@ -29,9 +30,14 @@ import { TEMPLATES } from './templates.js';
// broke our arg parser, since `--` is a special kind of flag. Filtering for `--` here
// fixes the issue so that create-astro now works on all npm version.
const cleanArgv = process.argv.filter((arg) => arg !== '--');
const args = yargs(cleanArgv);
const args = yargs(cleanArgv, { boolean: ['fancy']});
prompts.override(args);

// Enable full unicode support if the `--fancy` flag is passed
if (args.fancy) {
forceUnicode();
}

export function mkdirp(dir: string) {
try {
fs.mkdirSync(dir, { recursive: true });
Expand Down Expand Up @@ -99,7 +105,7 @@ export async function main() {
`${username}!`,
],
random(welcome),
]);
], { hat: args.fancy ? '🎩' : undefined });
await banner(version);
}

Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.