Skip to content

fix(doctor): cannot read property 'filter' of null #5374

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

Merged
merged 1 commit into from
Sep 6, 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
1 change: 1 addition & 0 deletions lib/services/doctor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class DoctorService implements IDoctorService {
);
}

// todo: check for deprecated imports from `tns-core-modules`
this.checkForDeprecatedShortImportsInAppDir(configOptions.projectDir);

await this.$injector
Expand Down
2 changes: 1 addition & 1 deletion lib/services/marking-mode-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class MarkingModeService implements IMarkingModeService {
PlatformTypes.android
);
const isMarkingModeFullDefault =
version && semver.lt(version, "7.0.0-rc.5");
version && semver.lt(semver.coerce(version), "7.0.0-rc.5");

if (isMarkingModeFullDefault) {
this.showMarkingModeFullWarning();
Expand Down
65 changes: 38 additions & 27 deletions lib/services/versions-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,39 +151,47 @@ class VersionsService implements IVersionsService {
}

public async getAllComponentsVersions(): Promise<IVersionInformation[]> {
let allComponents: IVersionInformation[] = [];

const nativescriptCliInformation: IVersionInformation = await this.getNativescriptCliVersion();
if (nativescriptCliInformation) {
allComponents.push(nativescriptCliInformation);
}
try {
let allComponents: IVersionInformation[] = [];

if (this.projectData) {
const nativescriptCoreModulesInformation: IVersionInformation[] = await this.getTnsCoreModulesVersion();
if (nativescriptCoreModulesInformation) {
allComponents.push(...nativescriptCoreModulesInformation);
const nativescriptCliInformation: IVersionInformation = await this.getNativescriptCliVersion();
if (nativescriptCliInformation) {
allComponents.push(nativescriptCliInformation);
}

const runtimesVersions: IVersionInformation[] = await this.getRuntimesVersions();
allComponents = allComponents.concat(runtimesVersions);
}
if (this.projectData) {
const nativescriptCoreModulesInformation: IVersionInformation[] = await this.getTnsCoreModulesVersion();
if (nativescriptCoreModulesInformation) {
allComponents.push(...nativescriptCoreModulesInformation);
}

const runtimesVersions: IVersionInformation[] = await this.getRuntimesVersions();
allComponents = allComponents.concat(runtimesVersions);
}

return allComponents.map((componentInformation) => {
if (componentInformation.currentVersion) {
if (this.hasUpdate(componentInformation)) {
componentInformation.type = VersionInformationType.UpdateAvailable;
componentInformation.message = `${VersionsService.UPDATE_AVAILABLE_MESSAGE} for component ${componentInformation.componentName}. Your current version is ${componentInformation.currentVersion} and the latest available version is ${componentInformation.latestVersion}.`;
return allComponents.map((componentInformation) => {
if (componentInformation.currentVersion) {
if (this.hasUpdate(componentInformation)) {
componentInformation.type = VersionInformationType.UpdateAvailable;
componentInformation.message = `${VersionsService.UPDATE_AVAILABLE_MESSAGE} for component ${componentInformation.componentName}. Your current version is ${componentInformation.currentVersion} and the latest available version is ${componentInformation.latestVersion}.`;
} else {
componentInformation.type = VersionInformationType.UpToDate;
componentInformation.message = `Component ${componentInformation.componentName} has ${componentInformation.currentVersion} version and is ${VersionsService.UP_TO_DATE_MESSAGE}.`;
}
} else {
componentInformation.type = VersionInformationType.UpToDate;
componentInformation.message = `Component ${componentInformation.componentName} has ${componentInformation.currentVersion} version and is ${VersionsService.UP_TO_DATE_MESSAGE}.`;
componentInformation.type = VersionInformationType.NotInstalled;
componentInformation.message = `Component ${componentInformation.componentName} is ${VersionsService.NOT_INSTALLED_MESSAGE}.`;
}
} else {
componentInformation.type = VersionInformationType.NotInstalled;
componentInformation.message = `Component ${componentInformation.componentName} is ${VersionsService.NOT_INSTALLED_MESSAGE}.`;
}

return componentInformation;
});
return componentInformation;
});
} catch (error) {
this.$logger.trace(
"Error while trying to get component information. Error is: ",
error
);
return [];
}
}

public async printVersionsInformation(): Promise<void> {
Expand Down Expand Up @@ -231,7 +239,10 @@ class VersionsService implements IVersionsService {
}

private hasUpdate(component: IVersionInformation): boolean {
return semver.lt(component.currentVersion, component.latestVersion);
return !semver.satisfies(
component.latestVersion,
semver.validRange(component.currentVersion)
);
}
}

Expand Down
Loading