11import {
2- AddTemplateArgs , GoogleAnalytics , PackageManager ,
3- ProjectConfig , ProjectLibrary , Template , Util
2+ AddTemplateArgs , App , BaseTemplateManager , GoogleAnalytics , PackageManager ,
3+ ProjectConfig , ProjectLibrary , TEMPLATE_MANAGER , Template , Util
44} from "@igniteui/cli-core" ;
55import { PromptSession } from "./../PromptSession" ;
66import { AddCommandType , PositionalArgs } from "./types" ;
@@ -11,7 +11,6 @@ let yargsContext: Argv | undefined;
1111const command : AddCommandType = {
1212 command : "add [template] [name]" ,
1313 describe : "Adds a component or view template to the current project" ,
14- templateManager : null ,
1514 builder : ( yargs ) => {
1615 yargsContext = yargs ;
1716 return yargs
@@ -76,18 +75,19 @@ const command: AddCommandType = {
7675 Util . error ( "Showcases projects don't support the add command" , "red" ) ;
7776 return ;
7877 }
79- const framework = command . templateManager . getFrameworkById ( config . project . framework ) ;
78+ const templateManager = App . container . get < BaseTemplateManager > ( TEMPLATE_MANAGER ) ;
79+ const framework = templateManager . getFrameworkById ( config . project . framework ) ;
8080 if ( ! framework ) {
8181 Util . error ( "Framework not supported" , "red" ) ;
8282 return ;
8383 }
84- const frameworkLibrary = command . templateManager . getProjectLibrary (
84+ const frameworkLibrary = templateManager . getProjectLibrary (
8585 config . project . framework ,
8686 config . project . projectType
8787 ) as ProjectLibrary ;
8888
8989 if ( ! argv . template && ! argv . name ) {
90- const prompts = new PromptSession ( command . templateManager ) ;
90+ const prompts = new PromptSession ( ) ;
9191 await prompts . chooseActionLoop ( frameworkLibrary ) ;
9292 return ;
9393 }
@@ -123,7 +123,7 @@ const command: AddCommandType = {
123123 skipRoute : argv . skipRoute
124124 } ) ;
125125 await PackageManager . flushQueue ( true ) ;
126- await PackageManager . ensureIgniteUISource ( config . packagesInstalled , command . templateManager ) ;
126+ await PackageManager . ensureIgniteUISource ( config . packagesInstalled , templateManager ) ;
127127 }
128128 } ,
129129 async addTemplate ( fileName : string , template : Template , options ?: AddTemplateArgs ) : Promise < boolean > {
@@ -165,7 +165,7 @@ const command: AddCommandType = {
165165 }
166166 if ( ! fail && templatePaths . length ) {
167167 template . registerInProject ( process . cwd ( ) , fileName , options || { } ) ;
168- command . templateManager . updateProjectConfiguration ( template ) ;
168+ App . container . get < BaseTemplateManager > ( TEMPLATE_MANAGER ) . updateProjectConfiguration ( template ) ;
169169 template . packages . forEach ( x => PackageManager . queuePackage ( x ) ) ;
170170 Util . log ( `${ Util . greenCheck ( ) } View '${ name } ' added.` ) ;
171171 return true ;
0 commit comments