@@ -25,6 +25,7 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
25
25
private $cloudBuildOutputFilter : ICloudBuildOutputFilter ,
26
26
private $mobileHelper : Mobile . IMobileHelper ,
27
27
private $projectHelper : IProjectHelper ,
28
+ private $projectDataService : IProjectDataService ,
28
29
private $qr : IQrCodeGenerator ) {
29
30
super ( ) ;
30
31
}
@@ -51,7 +52,13 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
51
52
52
53
await this . waitForBuildToFinish ( buildResponse ) ;
53
54
55
+ const runtimePropertyName = `tns-${ platform . toLowerCase ( ) } ` ;
56
+ if ( ! this . $projectDataService . getNSValue ( projectSettings . projectDir , runtimePropertyName ) ) {
57
+ this . $projectDataService . setNSValue ( projectSettings . projectDir , runtimePropertyName , { version : buildProps . properties . runtimeVersion } ) ;
58
+ }
59
+
54
60
const buildResult : IBuildResult = await this . getObjectFromS3File < IBuildResult > ( buildResponse . resultUrl ) ;
61
+
55
62
this . $logger . trace ( "Build result:" ) ;
56
63
this . $logger . trace ( buildResult ) ;
57
64
@@ -474,7 +481,7 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
474
481
if ( ! runtimeVersion && coreModulesVersion ) {
475
482
// no runtime added. Let's find out which one we need based on the tns-core-modules.
476
483
if ( semver . valid ( coreModulesVersion ) ) {
477
- runtimeVersion = ` ${ semver . major ( coreModulesVersion ) } . ${ semver . minor ( coreModulesVersion ) } .*` ;
484
+ runtimeVersion = await this . getLatestMatchingVersion ( runtimePackageName , this . getVersionRangeWithTilde ( coreModulesVersion ) ) ;
478
485
} else if ( semver . validRange ( coreModulesVersion ) ) {
479
486
// In case tns-core-modules in package.json are referred as `~x.x.x` - this is not a valid version, but is valid range.
480
487
runtimeVersion = await this . getLatestMatchingVersion ( runtimePackageName , coreModulesVersion ) ;
@@ -486,7 +493,7 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
486
493
487
494
private async getCliVersion ( runtimeVersion : string ) : Promise < string > {
488
495
try {
489
- const latestMatchingVersion = await this . getLatestMatchingVersion ( "nativescript" , `~ ${ runtimeVersion } ` ) ;
496
+ const latestMatchingVersion = await this . getLatestMatchingVersion ( "nativescript" , this . getVersionRangeWithTilde ( runtimeVersion ) ) ;
490
497
return latestMatchingVersion || CloudBuildService . DEFAULT_VERSION ;
491
498
} catch ( err ) {
492
499
this . $logger . trace ( `Unable to get information about CLI versions. Error is: ${ err . message } ` ) ;
@@ -514,6 +521,10 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
514
521
}
515
522
}
516
523
524
+ private getVersionRangeWithTilde ( versionString : string ) : string {
525
+ return `~${ semver . major ( versionString ) } .${ semver . minor ( versionString ) } .0` ;
526
+ }
527
+
517
528
private getCertificateInfo ( certificatePath : string , certificatePassword : string ) : ICertificateInfo {
518
529
const certificateAbsolutePath = path . resolve ( certificatePath ) ;
519
530
const certificateContents : any = this . $fs . readFile ( certificateAbsolutePath , { encoding : 'binary' } ) ;
0 commit comments