Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit 0410a4a

Browse files
nadyaADimitar Kerezov
authored and
Dimitar Kerezov
committed
Add runtime version in local package.json
We need to know what runtime version is used for build as incremental builds have no logic of detecting one.
1 parent e9f1652 commit 0410a4a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/services/cloud-build-service.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
2525
private $cloudBuildOutputFilter: ICloudBuildOutputFilter,
2626
private $mobileHelper: Mobile.IMobileHelper,
2727
private $projectHelper: IProjectHelper,
28+
private $projectDataService: IProjectDataService,
2829
private $qr: IQrCodeGenerator) {
2930
super();
3031
}
@@ -51,7 +52,13 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
5152

5253
await this.waitForBuildToFinish(buildResponse);
5354

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+
5460
const buildResult: IBuildResult = await this.getObjectFromS3File<IBuildResult>(buildResponse.resultUrl);
61+
5562
this.$logger.trace("Build result:");
5663
this.$logger.trace(buildResult);
5764

@@ -471,7 +478,7 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
471478
if (!runtimeVersion && coreModulesVersion) {
472479
// no runtime added. Let's find out which one we need based on the tns-core-modules.
473480
if (semver.valid(coreModulesVersion)) {
474-
runtimeVersion = `${semver.major(coreModulesVersion)}.${semver.minor(coreModulesVersion)}.*`;
481+
runtimeVersion = await this.getLatestMatchingVersion(runtimePackageName, this.getVersionRangeWithTilde(coreModulesVersion));
475482
} else if (semver.validRange(coreModulesVersion)) {
476483
// In case tns-core-modules in package.json are referred as `~x.x.x` - this is not a valid version, but is valid range.
477484
runtimeVersion = await this.getLatestMatchingVersion(runtimePackageName, coreModulesVersion);
@@ -483,7 +490,7 @@ export class CloudBuildService extends EventEmitter implements ICloudBuildServic
483490

484491
private async getCliVersion(runtimeVersion: string): Promise<string> {
485492
try {
486-
const latestMatchingVersion = await this.getLatestMatchingVersion("nativescript", `~${runtimeVersion}`);
493+
const latestMatchingVersion = await this.getLatestMatchingVersion("nativescript", this.getVersionRangeWithTilde(runtimeVersion));
487494
return latestMatchingVersion || CloudBuildService.DEFAULT_VERSION;
488495
} catch (err) {
489496
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
511518
}
512519
}
513520

521+
private getVersionRangeWithTilde(versionString: string): string {
522+
return `~${semver.major(versionString)}.${semver.minor(versionString)}.0`;
523+
}
524+
514525
private getCertificateInfo(certificatePath: string, certificatePassword: string): ICertificateInfo {
515526
const certificateAbsolutePath = path.resolve(certificatePath);
516527
const certificateContents: any = this.$fs.readFile(certificateAbsolutePath, { encoding: 'binary' });

0 commit comments

Comments
 (0)