@@ -66,17 +66,6 @@ export class PluginsService implements IPluginsService {
66
66
67
67
public remove ( pluginName : string ) : IFuture < void > {
68
68
return ( ( ) => {
69
- let isUninstallCommandExecuted = false ;
70
-
71
- let executeUninstallCommand = ( ) => {
72
- return ( ( ) => {
73
- if ( ! isUninstallCommandExecuted ) {
74
- this . executeNpmCommand ( PluginsService . UNINSTALL_COMMAND_NAME , pluginName ) . wait ( ) ;
75
- isUninstallCommandExecuted = true ;
76
- }
77
- } ) . future < void > ( ) ( ) ;
78
- } ;
79
-
80
69
let removePluginNativeCodeAction = ( modulesDestinationPath : string , platform : string , platformData : IPlatformData ) => {
81
70
return ( ( ) => {
82
71
let pluginData = this . convertToPluginData ( this . getNodeModuleData ( pluginName ) . wait ( ) ) ;
@@ -86,25 +75,7 @@ export class PluginsService implements IPluginsService {
86
75
// Remove the plugin and call merge for another plugins that have configuration file
87
76
let pluginConfigurationFilePath = this . getPluginConfigurationFilePath ( pluginData , platformData ) ;
88
77
if ( this . $fs . exists ( pluginConfigurationFilePath ) . wait ( ) ) {
89
- let tnsModulesDestinationPath = path . join ( platformData . appDestinationDirectoryPath , constants . APP_FOLDER_NAME , constants . TNS_MODULES_FOLDER_NAME ) ;
90
- let nodeModules = this . $broccoliBuilder . getChangedNodeModules ( tnsModulesDestinationPath , platform ) . wait ( ) ;
91
-
92
- _ ( nodeModules )
93
- . map ( nodeModule => this . getNodeModuleData ( pluginName ) . wait ( ) )
94
- . map ( nodeModuleData => this . convertToPluginData ( nodeModuleData ) )
95
- . filter ( data => data . isPlugin && this . $fs . exists ( this . getPluginConfigurationFilePath ( data , platformData ) ) . wait ( ) )
96
- . forEach ( ( data , index ) => {
97
- executeUninstallCommand ( ) . wait ( ) ;
98
-
99
- if ( index === 0 ) {
100
- this . initializeConfigurationFileFromCache ( platformData ) . wait ( ) ;
101
- }
102
-
103
- if ( data . name !== pluginName ) {
104
- this . merge ( data , platformData ) . wait ( ) ;
105
- }
106
- } )
107
- . value ( ) ;
78
+ this . merge ( pluginData , platformData , ( data : IPluginData ) => data . name !== pluginData . name ) . wait ( ) ;
108
79
}
109
80
110
81
if ( pluginData . pluginVariables ) {
@@ -114,7 +85,7 @@ export class PluginsService implements IPluginsService {
114
85
} ;
115
86
this . executeForAllInstalledPlatforms ( removePluginNativeCodeAction ) . wait ( ) ;
116
87
117
- executeUninstallCommand ( ) . wait ( ) ;
88
+ this . executeNpmCommand ( PluginsService . UNINSTALL_COMMAND_NAME , pluginName ) . wait ( ) ;
118
89
119
90
let showMessage = true ;
120
91
let action = ( modulesDestinationPath : string , platform : string , platformData : IPlatformData ) => {
@@ -137,15 +108,17 @@ export class PluginsService implements IPluginsService {
137
108
return ( ( ) => {
138
109
this . $projectDataService . initialize ( this . $projectData . projectDir ) ;
139
110
let frameworkVersion = this . $projectDataService . getValue ( platformData . frameworkPackageName ) . wait ( ) . version ;
140
- this . $npm . cache ( platformData . frameworkPackageName , frameworkVersion ) . wait ( ) ;
141
111
142
- let relativeConfigurationFilePath = path . relative ( platformData . projectRoot , platformData . configurationFilePath ) ;
143
112
// We need to resolve this manager here due to some restrictions from npm api and in order to load PluginsService.NPM_CONFIG config
144
113
let npmInstallationManager : INpmInstallationManager = this . $injector . resolve ( "npmInstallationManager" ) ;
114
+ npmInstallationManager . addToCache ( platformData . frameworkPackageName , frameworkVersion ) . wait ( ) ;
115
+
145
116
let cachedPackagePath = npmInstallationManager . getCachedPackagePath ( platformData . frameworkPackageName , frameworkVersion ) ;
146
- let cachedConfigurationFilePath = path . join ( cachedPackagePath , constants . PROJECT_FRAMEWORK_FOLDER_NAME , relativeConfigurationFilePath ) ;
117
+ let cachedConfigurationFilePath = path . join ( cachedPackagePath , constants . PROJECT_FRAMEWORK_FOLDER_NAME , platformData . relativeToFrameworkConfigurationFilePath ) ;
118
+ let cachedConfigurationFileContent = this . $fs . readText ( cachedConfigurationFilePath ) . wait ( ) ;
119
+ this . $fs . writeFile ( platformData . configurationFilePath , cachedConfigurationFileContent ) . wait ( ) ;
147
120
148
- shelljs . cp ( "-f" , cachedConfigurationFilePath , path . dirname ( platformData . configurationFilePath ) ) ;
121
+ platformData . platformProjectService . interpolateConfigurationFile ( ) . wait ( ) ;
149
122
} ) . future < void > ( ) ( ) ;
150
123
}
151
124
@@ -164,7 +137,6 @@ export class PluginsService implements IPluginsService {
164
137
shelljs . cp ( "-Rf" , pluginData . fullPath , pluginDestinationPath ) ;
165
138
166
139
let pluginConfigurationFilePath = this . getPluginConfigurationFilePath ( pluginData , platformData ) ;
167
-
168
140
if ( this . $fs . exists ( pluginConfigurationFilePath ) . wait ( ) ) {
169
141
this . merge ( pluginData , platformData ) . wait ( ) ;
170
142
}
@@ -347,7 +319,7 @@ export class PluginsService implements IPluginsService {
347
319
doc . parseFromString ( xml , 'text/xml' ) ;
348
320
}
349
321
350
- private merge ( pluginData : IPluginData , platformData : IPlatformData ) : IFuture < void > {
322
+ private mergeCore ( pluginData : IPluginData , platformData : IPlatformData ) : IFuture < void > {
351
323
return ( ( ) => {
352
324
let pluginConfigurationFilePath = this . getPluginConfigurationFilePath ( pluginData , platformData ) ;
353
325
let configurationFilePath = platformData . configurationFilePath ;
@@ -368,6 +340,30 @@ export class PluginsService implements IPluginsService {
368
340
} ) . future < void > ( ) ( ) ;
369
341
}
370
342
343
+ private merge ( pluginData : IPluginData , platformData : IPlatformData , mergeCondition ?: ( _pluginData : IPluginData ) => boolean ) : IFuture < void > {
344
+ return ( ( ) => {
345
+ let tnsModulesDestinationPath = path . join ( platformData . appDestinationDirectoryPath , constants . APP_FOLDER_NAME , constants . TNS_MODULES_FOLDER_NAME ) ;
346
+ let nodeModules = this . $broccoliBuilder . getChangedNodeModules ( tnsModulesDestinationPath , platformData . normalizedPlatformName . toLowerCase ( ) ) . wait ( ) ;
347
+
348
+ _ ( nodeModules )
349
+ . keys ( )
350
+ . map ( nodeModule => this . getNodeModuleData ( path . join ( nodeModule , "package.json" ) ) . wait ( ) )
351
+ . map ( nodeModuleData => this . convertToPluginData ( nodeModuleData ) )
352
+ . filter ( data => data . isPlugin && this . $fs . exists ( this . getPluginConfigurationFilePath ( data , platformData ) ) . wait ( ) )
353
+ . forEach ( ( data , index ) => {
354
+ if ( index === 0 ) {
355
+ this . initializeConfigurationFileFromCache ( platformData ) . wait ( ) ;
356
+ }
357
+
358
+ if ( ! mergeCondition || ( mergeCondition && mergeCondition ( data ) ) ) {
359
+ this . mergeCore ( data , platformData ) . wait ( ) ;
360
+ }
361
+ } )
362
+ . value ( ) ;
363
+
364
+ } ) . future < void > ( ) ( ) ;
365
+ }
366
+
371
367
private getPluginConfigurationFilePath ( pluginData : IPluginData , platformData : IPlatformData ) : string {
372
368
let pluginPlatformsFolderPath = pluginData . pluginPlatformsFolderPath ( platformData . normalizedPlatformName . toLowerCase ( ) ) ;
373
369
let pluginConfigurationFilePath = path . join ( pluginPlatformsFolderPath , platformData . configurationFileName ) ;
0 commit comments