feat(node): add nestjs support to node app plugin (#15484)
This commit is contained in:
parent
216b961be9
commit
79f5fc3108
@ -91,7 +91,7 @@
|
|||||||
"framework": {
|
"framework": {
|
||||||
"description": "Generate the node application using a framework",
|
"description": "Generate the node application using a framework",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["express", "fastify", "koa", "none"],
|
"enum": ["express", "fastify", "koa", "nest", "none"],
|
||||||
"default": "none",
|
"default": "none",
|
||||||
"x-prompt": "Which framework do you want to use?",
|
"x-prompt": "Which framework do you want to use?",
|
||||||
"x-priority": "important"
|
"x-priority": "important"
|
||||||
|
|||||||
@ -67,7 +67,7 @@
|
|||||||
"framework": {
|
"framework": {
|
||||||
"description": "The framework which the application is using",
|
"description": "The framework which the application is using",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["express", "koa", "fastify", "connect"]
|
"enum": ["express", "koa", "fastify", "nest", "none"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": true,
|
"additionalProperties": true,
|
||||||
|
|||||||
@ -72,7 +72,7 @@
|
|||||||
"framework": {
|
"framework": {
|
||||||
"description": "The framework which the application is using",
|
"description": "The framework which the application is using",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["express", "koa", "fastify", "connect"]
|
"enum": ["express", "koa", "fastify", "nest", "none"]
|
||||||
},
|
},
|
||||||
"bundler": {
|
"bundler": {
|
||||||
"description": "The bundler to use for building the application.",
|
"description": "The bundler to use for building the application.",
|
||||||
|
|||||||
@ -731,11 +731,15 @@ async function determineFramework(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'fastify',
|
name: 'fastify',
|
||||||
message: 'fastify [https://www.fastify.io/]',
|
message: 'Fastify [https://www.fastify.io/]',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'koa',
|
name: 'koa',
|
||||||
message: 'koa [https://koajs.com/]',
|
message: 'Koa [https://koajs.com/]',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'nest',
|
||||||
|
message: 'NestJs [https://nestjs.com/]',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -16,10 +16,12 @@ export function normalizeOptions(
|
|||||||
? `${names(projectDirectory).fileName}/${names(options.name).fileName}`
|
? `${names(projectDirectory).fileName}/${names(options.name).fileName}`
|
||||||
: names(options.name).fileName;
|
: names(options.name).fileName;
|
||||||
|
|
||||||
const appProjectRoot = joinPathFragments(
|
const appProjectRoot = options.rootProject
|
||||||
layoutDirectory ?? getWorkspaceLayout(tree).appsDir,
|
? '.'
|
||||||
appDirectory
|
: joinPathFragments(
|
||||||
);
|
layoutDirectory ?? getWorkspaceLayout(tree).appsDir,
|
||||||
|
appDirectory
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...options,
|
...options,
|
||||||
@ -43,6 +45,7 @@ export function toNodeApplicationGeneratorOptions(
|
|||||||
tags: options.tags,
|
tags: options.tags,
|
||||||
unitTestRunner: options.unitTestRunner,
|
unitTestRunner: options.unitTestRunner,
|
||||||
setParserOptionsProject: options.setParserOptionsProject,
|
setParserOptionsProject: options.setParserOptionsProject,
|
||||||
|
rootProject: options.rootProject,
|
||||||
bundler: 'webpack', // Some features require webpack plugins such as TS transformers
|
bundler: 'webpack', // Some features require webpack plugins such as TS transformers
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ export interface ApplicationGeneratorOptions {
|
|||||||
tags?: string;
|
tags?: string;
|
||||||
unitTestRunner?: UnitTestRunner;
|
unitTestRunner?: UnitTestRunner;
|
||||||
setParserOptionsProject?: boolean;
|
setParserOptionsProject?: boolean;
|
||||||
|
rootProject?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NormalizedOptions extends ApplicationGeneratorOptions {
|
interface NormalizedOptions extends ApplicationGeneratorOptions {
|
||||||
|
|||||||
@ -464,6 +464,7 @@ describe('app', () => {
|
|||||||
['fastify' as const, true],
|
['fastify' as const, true],
|
||||||
['express' as const, false],
|
['express' as const, false],
|
||||||
['koa' as const, false],
|
['koa' as const, false],
|
||||||
|
['nest' as const, false],
|
||||||
])('--unitTestRunner', (framework, checkSpecFile) => {
|
])('--unitTestRunner', (framework, checkSpecFile) => {
|
||||||
it('should generate test target and spec file by default', async () => {
|
it('should generate test target and spec file by default', async () => {
|
||||||
await applicationGenerator(tree, {
|
await applicationGenerator(tree, {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import {
|
|||||||
addDependenciesToPackageJson,
|
addDependenciesToPackageJson,
|
||||||
addProjectConfiguration,
|
addProjectConfiguration,
|
||||||
convertNxGenerator,
|
convertNxGenerator,
|
||||||
|
ensurePackage,
|
||||||
extractLayoutDirectory,
|
extractLayoutDirectory,
|
||||||
formatFiles,
|
formatFiles,
|
||||||
generateFiles,
|
generateFiles,
|
||||||
@ -353,6 +354,11 @@ export async function applicationGenerator(tree: Tree, schema: Schema) {
|
|||||||
const options = normalizeOptions(tree, schema);
|
const options = normalizeOptions(tree, schema);
|
||||||
const tasks: GeneratorCallback[] = [];
|
const tasks: GeneratorCallback[] = [];
|
||||||
|
|
||||||
|
if (options.framework === 'nest') {
|
||||||
|
const { applicationGenerator } = ensurePackage('@nrwl/nest', nxVersion);
|
||||||
|
return await applicationGenerator(tree, options);
|
||||||
|
}
|
||||||
|
|
||||||
const initTask = await initGenerator(tree, {
|
const initTask = await initGenerator(tree, {
|
||||||
...schema,
|
...schema,
|
||||||
skipFormat: true,
|
skipFormat: true,
|
||||||
|
|||||||
@ -22,4 +22,4 @@ export interface Schema {
|
|||||||
docker?: boolean;
|
docker?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NodeJsFrameWorks = 'express' | 'koa' | 'fastify' | 'none';
|
export type NodeJsFrameWorks = 'express' | 'koa' | 'fastify' | 'nest' | 'none';
|
||||||
|
|||||||
@ -91,7 +91,7 @@
|
|||||||
"framework": {
|
"framework": {
|
||||||
"description": "Generate the node application using a framework",
|
"description": "Generate the node application using a framework",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["express", "fastify", "koa", "none"],
|
"enum": ["express", "fastify", "koa", "nest", "none"],
|
||||||
"default": "none",
|
"default": "none",
|
||||||
"x-prompt": "Which framework do you want to use?",
|
"x-prompt": "Which framework do you want to use?",
|
||||||
"x-priority": "important"
|
"x-priority": "important"
|
||||||
|
|||||||
@ -70,7 +70,7 @@
|
|||||||
"framework": {
|
"framework": {
|
||||||
"description": "The framework which the application is using",
|
"description": "The framework which the application is using",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["express", "koa", "fastify", "connect"]
|
"enum": ["express", "koa", "fastify", "nest", "none"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": true
|
"additionalProperties": true
|
||||||
|
|||||||
@ -75,7 +75,7 @@
|
|||||||
"framework": {
|
"framework": {
|
||||||
"description": "The framework which the application is using",
|
"description": "The framework which the application is using",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["express", "koa", "fastify", "connect"]
|
"enum": ["express", "koa", "fastify", "nest", "none"]
|
||||||
},
|
},
|
||||||
"bundler": {
|
"bundler": {
|
||||||
"description": "The bundler to use for building the application.",
|
"description": "The bundler to use for building the application.",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user