@@ -17,7 +17,10 @@ import {
1717 CONFIG_FILE_NAME_TS ,
1818 PACKAGE_JSON_FILE_NAME ,
1919 PLATFORMS_DIR_NAME ,
20+ PlatformTypes ,
2021 PREPARE_READY_EVENT_NAME ,
22+ SCOPED_ANDROID_RUNTIME_NAME ,
23+ SCOPED_IOS_RUNTIME_NAME ,
2124 SupportedPlatform ,
2225 TrackActionNames ,
2326 WEBPACK_COMPILATION_COMPLETE ,
@@ -36,6 +39,7 @@ import {
3639 IProjectDataService ,
3740 IProjectService ,
3841} from "../definitions/project" ;
42+ import { resolvePackageJSONPath } from "@rigor789/resolve-package-path" ;
3943
4044interface IPlatformWatcherData {
4145 hasWebpackCompilerProcess : boolean ;
@@ -444,30 +448,72 @@ export class PrepareController extends EventEmitter {
444448 this . $logger . info (
445449 "Updating runtime package.json with configuration values..."
446450 ) ;
447- const nsConfig = this . $projectConfigService . readConfig (
451+
452+
453+ const { hooks, ignoredNativeDependencies, webpackPackageName, webpackConfigPath, appResourcesPath, buildPath, appPath, ...nsConfig } = this . $projectConfigService . readConfig (
448454 projectData . projectDir
449455 ) ;
456+
457+ const platform = platformData . platformNameLowerCase ;
458+ let installedRuntimePackageJSON ;
459+ let runtimePackageName : string ;
460+ if ( platform === PlatformTypes . ios ) {
461+ runtimePackageName = projectData . nsConfig . ios ?. runtimePackageName || SCOPED_IOS_RUNTIME_NAME ;
462+ } else if ( platform === PlatformTypes . android ) {
463+ runtimePackageName = projectData . nsConfig . android ?. runtimePackageName || SCOPED_ANDROID_RUNTIME_NAME ;
464+ }
465+ // try reading from installed runtime first before reading from the npm registry...
466+ const installedRuntimePackageJSONPath = resolvePackageJSONPath (
467+ runtimePackageName ,
468+ {
469+ paths : [ projectData . projectDir ] ,
470+ }
471+ ) ;
472+
473+ if ( installedRuntimePackageJSONPath ) {
474+ installedRuntimePackageJSON = this . $fs . readJson (
475+ installedRuntimePackageJSONPath
476+ ) ;
477+ }
450478 const packageData : any = {
451479 ..._ . pick ( projectData . packageJsonData , [ "name" ] ) ,
452480 ...nsConfig ,
453481 main : "bundle" ,
482+ ...( installedRuntimePackageJSON ? { } :{ } )
454483 } ;
455-
456484 if (
457- platformData . platformNameLowerCase === "ios" &&
458- packageData . ios &&
459- packageData . ios . discardUncaughtJsExceptions
485+ platform === PlatformTypes . ios
460486 ) {
461- packageData . discardUncaughtJsExceptions =
487+ if ( installedRuntimePackageJSON ) {
488+ packageData . ios = packageData . ios || { } ;
489+ packageData . ios . runtime = {
490+ version : installedRuntimePackageJSON . version
491+ } ;
492+ }
493+ if ( packageData . ios &&
494+ packageData . ios . discardUncaughtJsExceptions ) {
495+ packageData . discardUncaughtJsExceptions =
462496 packageData . ios . discardUncaughtJsExceptions ;
497+ }
498+ delete packageData . android ;
463499 }
464500 if (
465- platformData . platformNameLowerCase === "android" &&
466- packageData . android &&
467- packageData . android . discardUncaughtJsExceptions
501+ platform === PlatformTypes . android
468502 ) {
469- packageData . discardUncaughtJsExceptions =
470- packageData . android . discardUncaughtJsExceptions ;
503+ if ( installedRuntimePackageJSON ) {
504+ packageData . android = packageData . android || { } ;
505+ packageData . android . runtime = {
506+ version : installedRuntimePackageJSON . version ,
507+ version_info : installedRuntimePackageJSON . version_info ,
508+ gradle :installedRuntimePackageJSON . gradle
509+ } ;
510+ }
511+ if ( packageData . android &&
512+ packageData . android . discardUncaughtJsExceptions ) {
513+ packageData . discardUncaughtJsExceptions =
514+ packageData . android . discardUncaughtJsExceptions ;
515+ }
516+ delete packageData . ios ;
471517 }
472518 let packagePath : string ;
473519 if (
0 commit comments