From 9d64da93d08ac7511537d0603a80a35994d2460b Mon Sep 17 00:00:00 2001 From: FrozenPandaz Date: Mon, 23 Jan 2023 16:09:29 -0500 Subject: [PATCH] fix(misc): refine the prompts in create-nx-workspace --- .../packages/node/generators/application.json | 2 +- .../bin/create-nx-workspace.ts | 33 ++++++++++++++----- .../src/generators/application/schema.d.ts | 7 +--- .../src/generators/application/schema.json | 2 +- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/docs/generated/packages/node/generators/application.json b/docs/generated/packages/node/generators/application.json index 0dd6d1ee16f89..2d45bfd014e40 100644 --- a/docs/generated/packages/node/generators/application.json +++ b/docs/generated/packages/node/generators/application.json @@ -87,7 +87,7 @@ "framework": { "description": "Generate the node application using a framework", "type": "string", - "enum": ["express", "koa", "fastify", "connect", "none"], + "enum": ["express", "koa", "fastify", "none"], "default": "none", "x-prompt": "Which framework do you want to use?", "x-priority": "important" diff --git a/packages/create-nx-workspace/bin/create-nx-workspace.ts b/packages/create-nx-workspace/bin/create-nx-workspace.ts index 9bca8980573ba..2c7e9ae8f9382 100644 --- a/packages/create-nx-workspace/bin/create-nx-workspace.ts +++ b/packages/create-nx-workspace/bin/create-nx-workspace.ts @@ -486,7 +486,7 @@ function determineMonorepoStyle(): Promise { { name: 'react', message: - 'Standalone React app: Nx configures Vite, Vitest, ESLint, and Cypress.', + 'Standalone React app: Nx configures Vite (or Webpack), ESLint, and Cypress.', }, { name: 'angular', @@ -496,7 +496,7 @@ function determineMonorepoStyle(): Promise { { name: 'node-server', message: - 'Standalone Node Server app: Nx configures your framework of choice (e.g. Express) along with esbuild, Eslint and Jest.', + 'Standalone Node Server app: Nx configures a framework (ex. Express), esbuild, ESlint and Jest.', }, ], }, @@ -690,14 +690,27 @@ async function determineFramework( return Promise.resolve(''); } - const frameworkChoices = ['express', 'koa', 'fastify', 'connect']; + const frameworkChoices = [ + { + name: 'express', + message: 'Express [https://expressjs.com/]', + }, + { + name: 'koa', + message: 'koa [https://koajs.com/]', + }, + { + name: 'fastify', + message: 'fastify [https://www.fastify.io/]', + }, + ]; if (!parsedArgs.framework) { return enquirer .prompt([ { message: 'What framework should be used?', - type: 'select', + type: 'autocomplete', name: 'framework', choices: frameworkChoices, }, @@ -705,15 +718,17 @@ async function determineFramework( .then((a: { framework: string }) => a.framework); } - const foundFramework = frameworkChoices.indexOf(parsedArgs.framework); + const foundFramework = frameworkChoices + .map(({ name }) => name) + .indexOf(parsedArgs.framework); if (foundFramework < 0) { output.error({ - title: 'Invalid framwork', + title: 'Invalid framework', bodyLines: [ `It must be one of the following:`, '', - ...frameworkChoices.map((choice) => choice), + ...frameworkChoices.map(({ name }) => name), ], }); @@ -855,11 +870,11 @@ async function determineBundler( const choices = [ { name: 'vite', - message: 'Vite [ https://vitejs.dev/ ]', + message: 'Vite [ https://vitejs.dev/ ]', }, { name: 'webpack', - message: 'Webpack [ https://webpack.js.org/ ]', + message: 'Webpack [ https://webpack.js.org/ ]', }, ]; diff --git a/packages/node/src/generators/application/schema.d.ts b/packages/node/src/generators/application/schema.d.ts index a2de32706631b..2503ef9016405 100644 --- a/packages/node/src/generators/application/schema.d.ts +++ b/packages/node/src/generators/application/schema.d.ts @@ -22,9 +22,4 @@ export interface Schema { docker?: boolean; } -export type NodeJsFrameWorks = - | 'express' - | 'koa' - | 'fastify' - | 'connect' - | 'none'; +export type NodeJsFrameWorks = 'express' | 'koa' | 'fastify' | 'none'; diff --git a/packages/node/src/generators/application/schema.json b/packages/node/src/generators/application/schema.json index 3bfda4f5e7f8a..a70e62cac6aa5 100644 --- a/packages/node/src/generators/application/schema.json +++ b/packages/node/src/generators/application/schema.json @@ -87,7 +87,7 @@ "framework": { "description": "Generate the node application using a framework", "type": "string", - "enum": ["express", "koa", "fastify", "connect", "none"], + "enum": ["express", "koa", "fastify", "none"], "default": "none", "x-prompt": "Which framework do you want to use?", "x-priority": "important"