Skip to content

Commit 026def9

Browse files
committed
fix: ns update version null
fixes NativeScript#5440
1 parent 799bb76 commit 026def9

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

lib/controllers/update-controller.ts

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import { IPluginsService } from "../definitions/plugins";
1616
import { IFileSystem, IErrors, IDictionary } from "../common/declarations";
1717
import { injector } from "../common/yok";
18+
import { PackageVersion } from "../constants";
1819

1920
interface IPackage {
2021
name: string;
@@ -160,17 +161,12 @@ export class UpdateController
160161
lowercasePlatform,
161162
projectData
162163
);
163-
const templatePlatformData = this.$projectDataService.getNSValueFromContent(
164-
templateManifest,
165-
platformData.frameworkPackageName
166-
);
167-
const templateRuntimeVersion =
168-
templatePlatformData && templatePlatformData.version;
164+
169165
if (
170166
await this.shouldUpdateRuntimeVersion(
171167
// templateRuntimeVersion is only set if the template has the legacy nativescript key in package.json
172168
// in other cases, we are just going to default to using the latest
173-
templateRuntimeVersion || "*",
169+
PackageVersion.LATEST,
174170
platformData.frameworkPackageName,
175171
platform,
176172
projectData
@@ -241,7 +237,7 @@ export class UpdateController
241237
this.$logger.info("Finished updating devDependencies.");
242238

243239
this.$logger.info("Start updating runtimes.");
244-
await this.updateRuntimes(templateManifest, projectData);
240+
await this.updateRuntimes(projectData);
245241
this.$logger.info("Finished updating runtimes.");
246242

247243
this.$logger.info("Install packages.");
@@ -425,38 +421,28 @@ export class UpdateController
425421
}
426422
}
427423

428-
private async updateRuntimes(
429-
templateManifest: Object,
430-
projectData: IProjectData
431-
) {
424+
private async updateRuntimes(projectData: IProjectData) {
432425
for (const platform in this.$devicePlatformsConstants) {
433426
const lowercasePlatform = platform.toLowerCase();
434427
const platformData = this.$platformsDataService.getPlatformData(
435428
lowercasePlatform,
436429
projectData
437430
);
438-
const templatePlatformData = this.$projectDataService.getNSValueFromContent(
439-
templateManifest,
440-
platformData.frameworkPackageName
441-
);
442-
const templateRuntimeVersion =
443-
templatePlatformData && templatePlatformData.version;
431+
444432
if (
445433
await this.shouldUpdateRuntimeVersion(
446434
// templateRuntimeVersion is only set if the template has the legacy nativescript key in package.json
447435
// in other cases, we are just going to default to using the latest
448-
templateRuntimeVersion || "*",
436+
PackageVersion.LATEST,
449437
platformData.frameworkPackageName,
450438
platform,
451439
projectData
452440
)
453441
) {
454-
const version =
455-
templateRuntimeVersion ||
456-
(await this.$packageInstallationManager.getMaxSatisfyingVersionSafe(
457-
platformData.frameworkPackageName,
458-
"*"
459-
));
442+
const version = await this.$packageInstallationManager.getMaxSatisfyingVersionSafe(
443+
platformData.frameworkPackageName,
444+
PackageVersion.LATEST
445+
);
460446

461447
this.$logger.info(
462448
`Updating ${platform} platform to version '${version}'.`
@@ -465,7 +451,7 @@ export class UpdateController
465451
await this.$addPlatformService.setPlatformVersion(
466452
platformData,
467453
projectData,
468-
templateRuntimeVersion
454+
version
469455
);
470456
}
471457
}

lib/definitions/project.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ interface IProjectDataService {
289289
* @param {string} jsonData The project directory - the place where the root package.json is located.
290290
* @param {string} propertyName The name of the property to be checked in `nativescript` key.
291291
* @returns {any} The value of the property.
292+
* @deprecated no longer used - will be removed in 8.0.
292293
*/
293294
getNSValueFromContent(jsonData: Object, propertyName: string): any;
294295
}

0 commit comments

Comments
 (0)