Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ns update version null #5441

Merged
merged 1 commit into from
Nov 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 12 additions & 26 deletions lib/controllers/update-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { IPluginsService } from "../definitions/plugins";
import { IFileSystem, IErrors, IDictionary } from "../common/declarations";
import { injector } from "../common/yok";
import { PackageVersion } from "../constants";

interface IPackage {
name: string;
Expand Down Expand Up @@ -160,17 +161,12 @@ export class UpdateController
lowercasePlatform,
projectData
);
const templatePlatformData = this.$projectDataService.getNSValueFromContent(
templateManifest,
platformData.frameworkPackageName
);
const templateRuntimeVersion =
templatePlatformData && templatePlatformData.version;

if (
await this.shouldUpdateRuntimeVersion(
// templateRuntimeVersion is only set if the template has the legacy nativescript key in package.json
// in other cases, we are just going to default to using the latest
templateRuntimeVersion || "*",
PackageVersion.LATEST,
platformData.frameworkPackageName,
platform,
projectData
Expand Down Expand Up @@ -241,7 +237,7 @@ export class UpdateController
this.$logger.info("Finished updating devDependencies.");

this.$logger.info("Start updating runtimes.");
await this.updateRuntimes(templateManifest, projectData);
await this.updateRuntimes(projectData);
this.$logger.info("Finished updating runtimes.");

this.$logger.info("Install packages.");
Expand Down Expand Up @@ -425,38 +421,28 @@ export class UpdateController
}
}

private async updateRuntimes(
templateManifest: Object,
projectData: IProjectData
) {
private async updateRuntimes(projectData: IProjectData) {
for (const platform in this.$devicePlatformsConstants) {
const lowercasePlatform = platform.toLowerCase();
const platformData = this.$platformsDataService.getPlatformData(
lowercasePlatform,
projectData
);
const templatePlatformData = this.$projectDataService.getNSValueFromContent(
templateManifest,
platformData.frameworkPackageName
);
const templateRuntimeVersion =
templatePlatformData && templatePlatformData.version;

if (
await this.shouldUpdateRuntimeVersion(
// templateRuntimeVersion is only set if the template has the legacy nativescript key in package.json
// in other cases, we are just going to default to using the latest
templateRuntimeVersion || "*",
PackageVersion.LATEST,
platformData.frameworkPackageName,
platform,
projectData
)
) {
const version =
templateRuntimeVersion ||
(await this.$packageInstallationManager.getMaxSatisfyingVersionSafe(
platformData.frameworkPackageName,
"*"
));
const version = await this.$packageInstallationManager.getMaxSatisfyingVersionSafe(
platformData.frameworkPackageName,
PackageVersion.LATEST
);

this.$logger.info(
`Updating ${platform} platform to version '${version}'.`
Expand All @@ -465,7 +451,7 @@ export class UpdateController
await this.$addPlatformService.setPlatformVersion(
platformData,
projectData,
templateRuntimeVersion
version
);
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/definitions/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ interface IProjectDataService {
* @param {string} jsonData The project directory - the place where the root package.json is located.
* @param {string} propertyName The name of the property to be checked in `nativescript` key.
* @returns {any} The value of the property.
* @deprecated no longer used - will be removed in 8.0.
*/
getNSValueFromContent(jsonData: Object, propertyName: string): any;
}
Expand Down