Skip to content

Commit

Permalink
fix(misc): refine the prompts in create-nx-workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Jan 23, 2023
1 parent 077b559 commit ad06330
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions packages/create-nx-workspace/bin/create-nx-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ function determineMonorepoStyle(): Promise<string> {
{
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',
Expand All @@ -493,7 +493,7 @@ function determineMonorepoStyle(): Promise<string> {
{
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.',
},
],
},
Expand Down Expand Up @@ -687,30 +687,45 @@ 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,
},
])
.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),
],
});

Expand Down Expand Up @@ -852,11 +867,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/ ]',
},
];

Expand Down

0 comments on commit ad06330

Please sign in to comment.