@@ -17,7 +17,11 @@ import { readFileSync, writeFileSync } from 'fs';
1717import { dirname , relative } from 'path' ;
1818import { XmlDocument } from 'xmldoc' ;
1919
20- import { DotNetClient , dotnetNewOptions } from '@nx-dotnet/dotnet' ;
20+ import {
21+ DotNetClient ,
22+ dotnetNewOptions ,
23+ KnownDotnetTemplates ,
24+ } from '@nx-dotnet/dotnet' ;
2125import { findProjectFileInPath , isDryRun , resolve } from '@nx-dotnet/utils' ;
2226
2327import {
@@ -29,24 +33,27 @@ import {
2933import initSchematic from '../init/generator' ;
3034import { GenerateTestProject } from './generate-test-project' ;
3135import { addToSolutionFile } from './add-to-sln' ;
36+ import { promptForTemplate } from './prompt-for-template' ;
3237
33- export interface NormalizedSchema extends NxDotnetProjectGeneratorSchema {
38+ export interface NormalizedSchema
39+ extends Omit < NxDotnetProjectGeneratorSchema , 'template' > {
3440 projectName : string ;
3541 projectRoot : string ;
3642 projectDirectory : string ;
3743 projectLanguage : string ;
38- projectTemplate : string ;
44+ projectTemplate : KnownDotnetTemplates ;
3945 parsedTags : string [ ] ;
4046 className : string ;
4147 namespaceName : string ;
4248 projectType ?: ProjectType ;
4349}
4450
45- export function normalizeOptions (
51+ export async function normalizeOptions (
4652 host : Tree ,
4753 options : NxDotnetProjectGeneratorSchema ,
54+ client ?: DotNetClient ,
4855 projectType ?: ProjectType ,
49- ) : NormalizedSchema {
56+ ) : Promise < NormalizedSchema > {
5057 const name = names ( options . name ) . fileName ;
5158 const className = names ( options . name ) . className ;
5259 const projectDirectory = options . directory
@@ -62,6 +69,10 @@ export function normalizeOptions(
6269 ? options . tags . split ( ',' ) . map ( ( s ) => s . trim ( ) )
6370 : [ ] ;
6471
72+ const template = client
73+ ? await promptForTemplate ( client , options . template , options . language )
74+ : options . template ;
75+
6576 const npmScope = names (
6677 readWorkspaceConfiguration ( host ) . npmScope || '' ,
6778 ) . className ;
@@ -81,7 +92,7 @@ export function normalizeOptions(
8192 projectDirectory,
8293 parsedTags,
8394 projectLanguage : options . language ,
84- projectTemplate : options . template ,
95+ projectTemplate : template as KnownDotnetTemplates ,
8596 namespaceName,
8697 projectType : projectType ?? options . projectType ?? 'library' ,
8798 } ;
@@ -113,7 +124,12 @@ export async function GenerateProject(
113124
114125 options . testTemplate = options . testTemplate ?? 'none' ;
115126
116- const normalizedOptions = normalizeOptions ( host , options , projectType ) ;
127+ const normalizedOptions = await normalizeOptions (
128+ host ,
129+ options ,
130+ dotnetClient ,
131+ projectType ,
132+ ) ;
117133
118134 const projectConfiguration : ProjectConfiguration = {
119135 root : normalizedOptions . projectRoot ,
@@ -146,7 +162,7 @@ export async function GenerateProject(
146162 newParams [ 'dryRun' ] = true ;
147163 }
148164
149- dotnetClient . new ( normalizedOptions . template , newParams ) ;
165+ dotnetClient . new ( normalizedOptions . projectTemplate , newParams ) ;
150166 if ( ! isDryRun ( ) ) {
151167 addToSolutionFile (
152168 host ,
0 commit comments