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 ef215e9 commit 9d64da9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/generated/packages/node/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
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 @@ -486,7 +486,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 @@ -496,7 +496,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 @@ -690,30 +690,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 @@ -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/ ]',
},
];

Expand Down
7 changes: 1 addition & 6 deletions packages/node/src/generators/application/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,4 @@ export interface Schema {
docker?: boolean;
}

export type NodeJsFrameWorks =
| 'express'
| 'koa'
| 'fastify'
| 'connect'
| 'none';
export type NodeJsFrameWorks = 'express' | 'koa' | 'fastify' | 'none';
2 changes: 1 addition & 1 deletion packages/node/src/generators/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9d64da9

Please sign in to comment.