@@ -37,26 +37,51 @@ class VersionsService implements IVersionsService {
37
37
} ;
38
38
}
39
39
40
- public async getTnsCoreModulesVersion ( ) : Promise < IVersionInformation > {
40
+ public async getTnsCoreModulesVersion ( ) : Promise < IVersionInformation [ ] > {
41
41
const latestTnsCoreModulesVersion = await this . $packageInstallationManager . getLatestVersion ( constants . TNS_CORE_MODULES_NAME ) ;
42
42
const nativescriptCoreModulesInfo : IVersionInformation = {
43
43
componentName : constants . TNS_CORE_MODULES_NAME ,
44
44
latestVersion : latestTnsCoreModulesVersion
45
45
} ;
46
46
47
+ const versionInformations : IVersionInformation [ ] = [ ] ;
48
+
47
49
if ( this . projectData ) {
48
50
const nodeModulesPath = path . join ( this . projectData . projectDir , constants . NODE_MODULES_FOLDER_NAME ) ;
51
+ const scopedPackagePath = path . join ( nodeModulesPath , constants . SCOPED_TNS_CORE_MODULES ) ;
49
52
const tnsCoreModulesPath = path . join ( nodeModulesPath , constants . TNS_CORE_MODULES_NAME ) ;
53
+
54
+ const dependsOnNonScopedPackage = ! ! this . projectData . dependencies [ constants . TNS_CORE_MODULES_NAME ] ;
55
+ const dependsOnScopedPackage = ! ! this . projectData . dependencies [ constants . SCOPED_TNS_CORE_MODULES ] ;
56
+
57
+ // ensure the dependencies are installed, so we can get their actual versions from node_modules
50
58
if ( ! this . $fs . exists ( nodeModulesPath ) ||
51
- ! this . $fs . exists ( tnsCoreModulesPath ) ) {
59
+ ( dependsOnNonScopedPackage && ! this . $fs . exists ( tnsCoreModulesPath ) ) ||
60
+ ( dependsOnScopedPackage && ! this . $fs . exists ( scopedPackagePath ) ) ) {
52
61
await this . $pluginsService . ensureAllDependenciesAreInstalled ( this . projectData ) ;
53
62
}
54
63
55
- const currentTnsCoreModulesVersion = this . $fs . readJson ( path . join ( tnsCoreModulesPath , constants . PACKAGE_JSON_FILE_NAME ) ) . version ;
56
- nativescriptCoreModulesInfo . currentVersion = currentTnsCoreModulesVersion ;
64
+ if ( dependsOnNonScopedPackage && this . $fs . exists ( tnsCoreModulesPath ) ) {
65
+ const currentTnsCoreModulesVersion = this . $fs . readJson ( path . join ( tnsCoreModulesPath , constants . PACKAGE_JSON_FILE_NAME ) ) . version ;
66
+ nativescriptCoreModulesInfo . currentVersion = currentTnsCoreModulesVersion ;
67
+ versionInformations . push ( nativescriptCoreModulesInfo ) ;
68
+ }
69
+
70
+ if ( dependsOnScopedPackage && this . $fs . exists ( scopedPackagePath ) ) {
71
+ const scopedModulesInformation : IVersionInformation = {
72
+ componentName : constants . SCOPED_TNS_CORE_MODULES ,
73
+ latestVersion : await this . $packageInstallationManager . getLatestVersion ( constants . SCOPED_TNS_CORE_MODULES )
74
+ } ;
75
+
76
+ const currentScopedPackageVersion = this . $fs . readJson ( path . join ( scopedPackagePath , constants . PACKAGE_JSON_FILE_NAME ) ) . version ;
77
+ scopedModulesInformation . currentVersion = currentScopedPackageVersion ;
78
+ versionInformations . push ( scopedModulesInformation ) ;
79
+ }
80
+ } else {
81
+ versionInformations . push ( nativescriptCoreModulesInfo ) ;
57
82
}
58
83
59
- return nativescriptCoreModulesInfo ;
84
+ return versionInformations ;
60
85
}
61
86
62
87
public async getRuntimesVersions ( ) : Promise < IVersionInformation [ ] > {
@@ -101,9 +126,9 @@ class VersionsService implements IVersionsService {
101
126
}
102
127
103
128
if ( this . projectData ) {
104
- const nativescriptCoreModulesInformation : IVersionInformation = await this . getTnsCoreModulesVersion ( ) ;
129
+ const nativescriptCoreModulesInformation : IVersionInformation [ ] = await this . getTnsCoreModulesVersion ( ) ;
105
130
if ( nativescriptCoreModulesInformation ) {
106
- allComponents . push ( nativescriptCoreModulesInformation ) ;
131
+ allComponents . push ( ... nativescriptCoreModulesInformation ) ;
107
132
}
108
133
109
134
const runtimesVersions : IVersionInformation [ ] = await this . getRuntimesVersions ( ) ;
0 commit comments