@@ -12,10 +12,7 @@ import {
1212 AnalyticsEventLabelDelimiter ,
1313 CONFIG_FILE_NAME_JS ,
1414 CONFIG_FILE_NAME_TS ,
15- SCOPED_IOS_RUNTIME_NAME ,
16- SCOPED_ANDROID_RUNTIME_NAME ,
17- TNS_IOS_RUNTIME_NAME ,
18- TNS_ANDROID_RUNTIME_NAME ,
15+ SupportedPlatform ,
1916} from "../constants" ;
2017import {
2118 IProjectDataService ,
@@ -79,6 +76,14 @@ export class PrepareController extends EventEmitter {
7976 await this . $markingModeService . handleMarkingModeFullDeprecation ( {
8077 projectDir : projectData . projectDir ,
8178 } ) ;
79+
80+ this . $projectConfigService . writeLegacyNSConfigIfNeeded (
81+ projectData . projectDir ,
82+ this . $projectDataService . getRuntimePackage (
83+ projectData . projectDir ,
84+ prepareData . platform as SupportedPlatform
85+ )
86+ ) ;
8287 }
8388
8489 await this . trackRuntimeVersion ( prepareData . platform , projectData ) ;
@@ -443,32 +448,22 @@ export class PrepareController extends EventEmitter {
443448 platform : string ,
444449 projectData : IProjectData
445450 ) : Promise < void > {
446- let runtimeVersion : string = null ;
447- try {
448- if ( projectData . devDependencies ) {
449- if ( platform . toLowerCase ( ) === "ios" ) {
450- runtimeVersion =
451- projectData . devDependencies [ SCOPED_IOS_RUNTIME_NAME ] ||
452- projectData . devDependencies [ TNS_IOS_RUNTIME_NAME ] ;
453- } else {
454- runtimeVersion =
455- projectData . devDependencies [ SCOPED_ANDROID_RUNTIME_NAME ] ||
456- projectData . devDependencies [ TNS_ANDROID_RUNTIME_NAME ] ;
457- }
458- }
459- } catch ( err ) {
451+ const { version } = this . $projectDataService . getRuntimePackage (
452+ projectData . projectDir ,
453+ platform as SupportedPlatform
454+ ) ;
455+
456+ if ( ! version ) {
460457 this . $logger . trace (
461- `Unable to get runtime version for project directory: ${ projectData . projectDir } and platform ${ platform } . Error is: ` ,
462- err
458+ `Unable to get runtime version for project directory: ${ projectData . projectDir } and platform ${ platform } .`
463459 ) ;
460+ return ;
464461 }
465462
466- if ( runtimeVersion ) {
467- await this . $analyticsService . trackEventActionInGoogleAnalytics ( {
468- action : TrackActionNames . UsingRuntimeVersion ,
469- additionalData : `${ platform . toLowerCase ( ) } ${ AnalyticsEventLabelDelimiter } ${ runtimeVersion } ` ,
470- } ) ;
471- }
463+ await this . $analyticsService . trackEventActionInGoogleAnalytics ( {
464+ action : TrackActionNames . UsingRuntimeVersion ,
465+ additionalData : `${ platform . toLowerCase ( ) } ${ AnalyticsEventLabelDelimiter } ${ version } ` ,
466+ } ) ;
472467 }
473468}
474469injector . register ( "prepareController" , PrepareController ) ;
0 commit comments