From 312e08d50f1042a7af28f3025c81ddf6ad0d9e36 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 11 Feb 2025 15:55:02 +0000 Subject: [PATCH 1/5] fix(add,init): improve default ux --- packages/nuxi/src/commands/init.ts | 13 +++++++++++-- packages/nuxi/src/commands/module/add.ts | 2 +- packages/nuxi/src/utils/logger.ts | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/nuxi/src/commands/init.ts b/packages/nuxi/src/commands/init.ts index 94cb899e8..9fbe6fae8 100644 --- a/packages/nuxi/src/commands/init.ts +++ b/packages/nuxi/src/commands/init.ts @@ -5,9 +5,11 @@ import { existsSync } from 'node:fs' import process from 'node:process' import { defineCommand } from 'citty' +import { colors } from 'consola/utils' import { downloadTemplate, startShell } from 'giget' import { installDependencies } from 'nypm' import { relative, resolve } from 'pathe' +import { hasTTY } from 'std-env' import { x } from 'tinyexec' import { logger } from '../utils/logger' @@ -78,6 +80,14 @@ export default defineCommand({ async run(ctx) { const cwd = resolve(ctx.args.cwd) + let templateDownloadPath = resolve(cwd, ctx.args.dir) + + if (hasTTY) { + logger.info(colors.greenBright(`Welcome to ${colors.bold(('Nuxt'))}!`)) + } + + logger.info(`Creating a new project in ${colors.cyan(relative(cwd, templateDownloadPath) || templateDownloadPath)}.`) + // Get template name const templateName = ctx.args.template || DEFAULT_TEMPLATE_NAME @@ -86,7 +96,6 @@ export default defineCommand({ process.exit(1) } - let templateDownloadPath = resolve(cwd, ctx.args.dir) let shouldForce = Boolean(ctx.args.force) // Prompt the user if the template download directory already exists @@ -94,7 +103,7 @@ export default defineCommand({ const shouldVerify = !shouldForce && existsSync(templateDownloadPath) if (shouldVerify) { const selectedAction = await logger.prompt( - `The directory \`${templateDownloadPath}\` already exists. What would you like to do?`, + `The directory ${colors.cyan(templateDownloadPath)} already exists. What would you like to do?`, { type: 'select', options: ['Override its contents', 'Select different directory', 'Abort'], diff --git a/packages/nuxi/src/commands/module/add.ts b/packages/nuxi/src/commands/module/add.ts index 2c9b03d5c..52148e3bb 100644 --- a/packages/nuxi/src/commands/module/add.ts +++ b/packages/nuxi/src/commands/module/add.ts @@ -309,7 +309,7 @@ async function resolveModule(moduleName: string, cwd: string): Promise Date: Tue, 11 Feb 2025 15:56:09 +0000 Subject: [PATCH 2/5] chore: always display --- packages/nuxi/src/commands/init.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/nuxi/src/commands/init.ts b/packages/nuxi/src/commands/init.ts index 9fbe6fae8..549b5076f 100644 --- a/packages/nuxi/src/commands/init.ts +++ b/packages/nuxi/src/commands/init.ts @@ -9,7 +9,6 @@ import { colors } from 'consola/utils' import { downloadTemplate, startShell } from 'giget' import { installDependencies } from 'nypm' import { relative, resolve } from 'pathe' -import { hasTTY } from 'std-env' import { x } from 'tinyexec' import { logger } from '../utils/logger' @@ -82,10 +81,7 @@ export default defineCommand({ let templateDownloadPath = resolve(cwd, ctx.args.dir) - if (hasTTY) { - logger.info(colors.greenBright(`Welcome to ${colors.bold(('Nuxt'))}!`)) - } - + logger.info(colors.greenBright(`Welcome to ${colors.bold(('Nuxt'))}!`)) logger.info(`Creating a new project in ${colors.cyan(relative(cwd, templateDownloadPath) || templateDownloadPath)}.`) // Get template name From b1d4a003c55f732e23ec5d0401310253109038e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 12 Feb 2025 10:41:26 +0100 Subject: [PATCH 3/5] fix: update commands and descriptions --- package.json | 4 ++-- packages/nuxi/package.json | 2 +- packages/nuxt-cli/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index ec176a738..62bfb46ac 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,8 @@ "build:stub": "pnpm -r dev:prepare", "lint": "eslint .", "lint:fix": "eslint --fix .", - "nuxi": "node ./bin/nuxi.mjs", - "nuxi-bun": "bun --bun ./bin/nuxi.mjs", + "nuxi": "node ./packages/nuxi/bin/nuxi.mjs", + "nuxi-bun": "bun --bun ./packages/nuxi/bin/nuxi.mjs", "prepack": "pnpm -r build", "test:types": "tsc --noEmit", "test:knip": "knip", diff --git a/packages/nuxi/package.json b/packages/nuxi/package.json index 17a12bacb..3a83fb171 100644 --- a/packages/nuxi/package.json +++ b/packages/nuxi/package.json @@ -2,7 +2,7 @@ "name": "nuxi", "type": "module", "version": "3.21.1", - "description": "⚡️ Nuxt Generation CLI Experience", + "description": "Nuxt CLI", "license": "MIT", "repository": { "type": "git", diff --git a/packages/nuxt-cli/package.json b/packages/nuxt-cli/package.json index 35d203d27..97cf99133 100644 --- a/packages/nuxt-cli/package.json +++ b/packages/nuxt-cli/package.json @@ -2,7 +2,7 @@ "name": "@nuxt/cli", "type": "module", "version": "3.21.1", - "description": "⚡️ Nuxt Generation CLI Experience", + "description": "Nuxt CLI", "license": "MIT", "repository": { "type": "git", From 30b3805793ebf922a9f5a48bea62dec980a40b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 12 Feb 2025 11:24:23 +0100 Subject: [PATCH 4/5] feat: add Nuxt ASCII --- packages/nuxi/src/main.ts | 5 +++++ packages/nuxi/src/utils/ascii.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 packages/nuxi/src/utils/ascii.ts diff --git a/packages/nuxi/src/main.ts b/packages/nuxi/src/main.ts index 6d41b67cb..810539476 100644 --- a/packages/nuxi/src/main.ts +++ b/packages/nuxi/src/main.ts @@ -7,6 +7,7 @@ import { provider } from 'std-env' import { description, name, version } from '../package.json' import { commands } from './commands' import { cwdArgs } from './commands/_shared' +import { nuxtAscii } from './utils/ascii' import { setupGlobalConsole } from './utils/console' import { checkEngines } from './utils/engines' import { logger } from './utils/logger' @@ -30,6 +31,10 @@ export const main = defineCommand({ const dev = command === 'dev' setupGlobalConsole({ dev }) + if (process.stdout.isTTY && (!command || command === 'init')) { + logger.log(nuxtAscii()) + } + // Check Node.js version and CLI updates in background let backgroundTasks: Promise | undefined if (command !== '_dev' && provider !== 'stackblitz') { diff --git a/packages/nuxi/src/utils/ascii.ts b/packages/nuxi/src/utils/ascii.ts new file mode 100644 index 000000000..e5db90e7a --- /dev/null +++ b/packages/nuxi/src/utils/ascii.ts @@ -0,0 +1,29 @@ +import { colors } from 'consola/utils' + +export function nuxtAscii() { + /** + * Thank you to Matt Eason for the proposal of this ASCII art + * https://bsky.app/profile/matteason.me/post/3lhwnl5e4g22l + */ + const icon = ` __ + / \\ __ + / /\\ \\/ \\ + / / \\ /\\ \\ + / /___/ / _\\ \\ +/_______/ /____\\ +` + + const wordmark = ` + +++ ++ ++ ++ ++ ++ ++++++ +++++ ++ ++ ++ ++++ ++ +++ ++++ ++ ++ ++++ ++ +++ +++ ++++ ++ ++ ++ +` + const iconLines = icon.split('\n') + const wordmarkLines = wordmark.split('\n') + + return iconLines.map((iconLine, index) => { + return `${colors.greenBright(iconLine)}${wordmarkLines[index]}` + }).join('\n') +} From a93a6844a2b95698169a557cc4d0beb19796be49 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 12 Feb 2025 10:39:04 +0000 Subject: [PATCH 5/5] refactor: remove wordmark --- packages/nuxi/src/main.ts | 8 +++---- packages/nuxi/src/utils/ascii.ts | 39 +++++++++++--------------------- 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/packages/nuxi/src/main.ts b/packages/nuxi/src/main.ts index 810539476..82197fa4f 100644 --- a/packages/nuxi/src/main.ts +++ b/packages/nuxi/src/main.ts @@ -2,12 +2,12 @@ import { resolve } from 'node:path' import process from 'node:process' import { defineCommand } from 'citty' -import { provider } from 'std-env' +import { hasTTY, provider } from 'std-env' import { description, name, version } from '../package.json' import { commands } from './commands' import { cwdArgs } from './commands/_shared' -import { nuxtAscii } from './utils/ascii' +import { nuxtIcon } from './utils/ascii' import { setupGlobalConsole } from './utils/console' import { checkEngines } from './utils/engines' import { logger } from './utils/logger' @@ -31,8 +31,8 @@ export const main = defineCommand({ const dev = command === 'dev' setupGlobalConsole({ dev }) - if (process.stdout.isTTY && (!command || command === 'init')) { - logger.log(nuxtAscii()) + if (hasTTY && (!command || command === 'init')) { + logger.log(`${nuxtIcon}\n`) } // Check Node.js version and CLI updates in background diff --git a/packages/nuxi/src/utils/ascii.ts b/packages/nuxi/src/utils/ascii.ts index e5db90e7a..4eb1e43a0 100644 --- a/packages/nuxi/src/utils/ascii.ts +++ b/packages/nuxi/src/utils/ascii.ts @@ -1,29 +1,16 @@ import { colors } from 'consola/utils' -export function nuxtAscii() { - /** - * Thank you to Matt Eason for the proposal of this ASCII art - * https://bsky.app/profile/matteason.me/post/3lhwnl5e4g22l - */ - const icon = ` __ - / \\ __ - / /\\ \\/ \\ - / / \\ /\\ \\ - / /___/ / _\\ \\ -/_______/ /____\\ -` +/** + * Thank you to Matt Eason for the proposal of this ASCII art + * https://bsky.app/profile/matteason.me/post/3lhwnl5e4g22l + */ +const icon = [ + ` __`, + ` / \\ __ `, + ` / /\\ \\/ \\ `, + ` / / \\ /\\ \\ `, + ` / /___/ / _\\ \\ `, + `/_______/ /____\\ `, +] - const wordmark = ` - -++ ++ ++ ++ ++ ++ ++++++ -++++ ++ ++ ++ ++++ ++ -++ ++++ ++ ++ ++++ ++ -++ +++ ++++ ++ ++ ++ -` - const iconLines = icon.split('\n') - const wordmarkLines = wordmark.split('\n') - - return iconLines.map((iconLine, index) => { - return `${colors.greenBright(iconLine)}${wordmarkLines[index]}` - }).join('\n') -} +export const nuxtIcon = icon.map(line => colors.greenBright(line)).join('\n')