@@ -113,15 +113,15 @@ export class ProjectService implements IProjectService {
113
113
this . $logger . trace ( `Template version is ${ templateVersion } ` ) ;
114
114
let destinationDir = "" ;
115
115
switch ( templateVersion ) {
116
- case constants . TemplateVersions . v2 :
117
- destinationDir = projectDir ;
118
- break ;
119
116
case constants . TemplateVersions . v1 :
120
- default :
121
117
const appDestinationPath = this . $projectData . getAppDirectoryPath ( projectDir ) ;
122
118
this . $fs . createDirectory ( appDestinationPath ) ;
123
119
destinationDir = appDestinationPath ;
124
120
break ;
121
+ case constants . TemplateVersions . v2 :
122
+ default :
123
+ destinationDir = projectDir ;
124
+ break ;
125
125
}
126
126
127
127
this . $logger . trace ( `Copying application from '${ realTemplatePath } ' into '${ destinationDir } '.` ) ;
@@ -146,20 +146,25 @@ export class ProjectService implements IProjectService {
146
146
ignoreScripts : false
147
147
} ) ;
148
148
149
- const obsoleteAppResourcesPath = path . join ( projectDir ,
150
- constants . NODE_MODULES_FOLDER_NAME ,
151
- defaultTemplateName ,
152
- constants . APP_RESOURCES_FOLDER_NAME ) ;
153
-
154
- const defaultTemplateAppResourcesPath = path . join ( projectDir ,
155
- constants . NODE_MODULES_FOLDER_NAME ,
156
- defaultTemplateName ,
157
- constants . APP_FOLDER_NAME ,
158
- constants . APP_RESOURCES_FOLDER_NAME ) ;
149
+ const defaultTemplatePath = path . join ( projectDir , constants . NODE_MODULES_FOLDER_NAME , defaultTemplateName ) ;
150
+ const defaultTemplateVersion = this . $projectTemplatesService . getTemplateVersion ( defaultTemplatePath ) ;
151
+
152
+ let defaultTemplateAppResourcesPath : string = null ;
153
+ switch ( defaultTemplateVersion ) {
154
+ case constants . TemplateVersions . v1 :
155
+ defaultTemplateAppResourcesPath = path . join ( projectDir ,
156
+ constants . NODE_MODULES_FOLDER_NAME ,
157
+ defaultTemplateName ,
158
+ constants . APP_RESOURCES_FOLDER_NAME ) ;
159
+ break ;
160
+ case constants . TemplateVersions . v2 :
161
+ default :
162
+ const defaultTemplateProjectData = this . $projectDataService . getProjectData ( defaultTemplatePath ) ;
163
+ defaultTemplateAppResourcesPath = defaultTemplateProjectData . appResourcesDirectoryPath ;
164
+ }
159
165
160
- const pathToAppResources = this . $fs . exists ( defaultTemplateAppResourcesPath ) ? defaultTemplateAppResourcesPath : obsoleteAppResourcesPath ;
161
- if ( this . $fs . exists ( pathToAppResources ) ) {
162
- shelljs . cp ( '-R' , pathToAppResources , appPath ) ;
166
+ if ( defaultTemplateAppResourcesPath && this . $fs . exists ( defaultTemplateAppResourcesPath ) ) {
167
+ shelljs . cp ( '-R' , defaultTemplateAppResourcesPath , appPath ) ;
163
168
}
164
169
165
170
await this . $npm . uninstall ( defaultTemplateName , { save : true } , projectDir ) ;
0 commit comments