Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(misc): refine the prompts in create-nx-workspace #14562

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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