From f014a325dbedc77a4f2768b21b2aec3f3cf281e2 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Fri, 28 Oct 2022 05:40:18 -0500 Subject: [PATCH] feat(create-astro): add --fancy flag --- .changeset/empty-feet-brush.md | 5 +++++ packages/create-astro/README.md | 1 + packages/create-astro/package.json | 2 +- packages/create-astro/src/index.ts | 10 ++++++++-- pnpm-lock.yaml | 8 ++++---- 5 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 .changeset/empty-feet-brush.md diff --git a/.changeset/empty-feet-brush.md b/.changeset/empty-feet-brush.md new file mode 100644 index 000000000000..1181f42594c3 --- /dev/null +++ b/.changeset/empty-feet-brush.md @@ -0,0 +1,5 @@ +--- +'create-astro': patch +--- + +Allow Windows users to pass `--fancy` to enable full unicode support diff --git a/packages/create-astro/README.md b/packages/create-astro/README.md index d8dca6c24ca3..661d56f480be 100644 --- a/packages/create-astro/README.md +++ b/packages/create-astro/README.md @@ -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 | ### Debugging diff --git a/packages/create-astro/package.json b/packages/create-astro/package.json index 7c2bd66612d1..d4445581ee02 100644 --- a/packages/create-astro/package.json +++ b/packages/create-astro/package.json @@ -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", diff --git a/packages/create-astro/src/index.ts b/packages/create-astro/src/index.ts index 2c9da9d66d5d..dcd5c98abe13 100644 --- a/packages/create-astro/src/index.ts +++ b/packages/create-astro/src/index.ts @@ -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'; @@ -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 }); @@ -99,7 +105,7 @@ export async function main() { `${username}!`, ], random(welcome), - ]); + ], { hat: args.fancy ? '🎩' : undefined }); await banner(version); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9a8638caeb3c..f0e3de730bdd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2434,7 +2434,7 @@ importers: packages/create-astro: specifiers: - '@astrojs/cli-kit': ^0.1.0 + '@astrojs/cli-kit': ^0.1.3 '@types/chai': ^4.3.1 '@types/degit': ^2.8.3 '@types/mocha': ^9.1.1 @@ -2456,7 +2456,7 @@ importers: which-pm-runs: ^1.1.0 yargs-parser: ^21.0.1 dependencies: - '@astrojs/cli-kit': 0.1.0 + '@astrojs/cli-kit': 0.1.3 chalk: 5.1.2 comment-json: 4.2.3 execa: 6.1.0 @@ -3795,8 +3795,8 @@ packages: lite-youtube-embed: 0.2.0 dev: false - /@astrojs/cli-kit/0.1.0: - resolution: {integrity: sha512-H/J6C1dHKoBlQD/+YVzgy723UMJ5AZEB5NJl4LiOyGdOT4tWFSyUaqEppgaUm/qQ8OnZ9Q5pA5Ce2fjvPww4Eg==} + /@astrojs/cli-kit/0.1.3: + resolution: {integrity: sha512-thLIdCggboKsOyYF5prn46tIpUH55Y+Y0fRN2NGD09WyxqqO5eA5aon0i4cELKTuzQrmSuu0Wl4d4xFin5OPvg==} dependencies: chalk: 5.1.2 log-update: 5.0.1