@@ -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
@@ -471,7 +478,7 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
471
478
if ( ! runtimeVersion && coreModulesVersion ) {
472
479
// no runtime added. Let's find out which one we need based on the tns-core-modules.
473
480
if ( semver . valid ( coreModulesVersion ) ) {
474
- runtimeVersion = ` ${ semver . major ( coreModulesVersion ) } . ${ semver . minor ( coreModulesVersion ) } .*` ;
481
+ runtimeVersion = await this . getLatestMatchingVersion ( runtimePackageName , this . getVersionRangeWithTilde ( coreModulesVersion ) ) ;
475
482
} else if ( semver . validRange ( coreModulesVersion ) ) {
476
483
// In case tns-core-modules in package.json are referred as `~x.x.x` - this is not a valid version, but is valid range.
477
484
runtimeVersion = await this . getLatestMatchingVersion ( runtimePackageName , coreModulesVersion ) ;
@@ -483,7 +490,7 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
483
490
484
491
private async getCliVersion ( runtimeVersion : string ) : Promise < string > {
485
492
try {
486
- const latestMatchingVersion = await this . getLatestMatchingVersion ( "nativescript" , `~ ${ runtimeVersion } ` ) ;
493
+ const latestMatchingVersion = await this . getLatestMatchingVersion ( "nativescript" , this . getVersionRangeWithTilde ( runtimeVersion ) ) ;
487
494
return latestMatchingVersion || CloudBuildService . DEFAULT_VERSION ;
488
495
} catch ( err ) {
489
496
this . $logger . trace ( `Unable to get information about CLI versions. Error is: ${ err . message } ` ) ;
@@ -511,6 +518,10 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
511
518
}
512
519
}
513
520
521
+ private getVersionRangeWithTilde ( versionString : string ) : string {
522
+ return `~${ semver . major ( versionString ) } .${ semver . minor ( versionString ) } .0` ;
523
+ }
524
+
514
525
private getCertificateInfo ( certificatePath : string , certificatePassword : string ) : ICertificateInfo {
515
526
const certificateAbsolutePath = path . resolve ( certificatePath ) ;
516
527
const certificateContents : any = this . $fs . readFile ( certificateAbsolutePath , { encoding : 'binary' } ) ;
0 commit comments