Skip to content

Commit dd09547

Browse files
authored
fix(doctor): cannot read property 'filter' of null (#5374)
fixes #5366
1 parent 57add5b commit dd09547

File tree

5 files changed

+3936
-78
lines changed

5 files changed

+3936
-78
lines changed

lib/services/doctor-service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export class DoctorService implements IDoctorService {
135135
);
136136
}
137137

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

140141
await this.$injector

lib/services/marking-mode-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class MarkingModeService implements IMarkingModeService {
4646
PlatformTypes.android
4747
);
4848
const isMarkingModeFullDefault =
49-
version && semver.lt(version, "7.0.0-rc.5");
49+
version && semver.lt(semver.coerce(version), "7.0.0-rc.5");
5050

5151
if (isMarkingModeFullDefault) {
5252
this.showMarkingModeFullWarning();

lib/services/versions-service.ts

+38-27
Original file line numberDiff line numberDiff line change
@@ -151,39 +151,47 @@ class VersionsService implements IVersionsService {
151151
}
152152

153153
public async getAllComponentsVersions(): Promise<IVersionInformation[]> {
154-
let allComponents: IVersionInformation[] = [];
155-
156-
const nativescriptCliInformation: IVersionInformation = await this.getNativescriptCliVersion();
157-
if (nativescriptCliInformation) {
158-
allComponents.push(nativescriptCliInformation);
159-
}
154+
try {
155+
let allComponents: IVersionInformation[] = [];
160156

161-
if (this.projectData) {
162-
const nativescriptCoreModulesInformation: IVersionInformation[] = await this.getTnsCoreModulesVersion();
163-
if (nativescriptCoreModulesInformation) {
164-
allComponents.push(...nativescriptCoreModulesInformation);
157+
const nativescriptCliInformation: IVersionInformation = await this.getNativescriptCliVersion();
158+
if (nativescriptCliInformation) {
159+
allComponents.push(nativescriptCliInformation);
165160
}
166161

167-
const runtimesVersions: IVersionInformation[] = await this.getRuntimesVersions();
168-
allComponents = allComponents.concat(runtimesVersions);
169-
}
162+
if (this.projectData) {
163+
const nativescriptCoreModulesInformation: IVersionInformation[] = await this.getTnsCoreModulesVersion();
164+
if (nativescriptCoreModulesInformation) {
165+
allComponents.push(...nativescriptCoreModulesInformation);
166+
}
167+
168+
const runtimesVersions: IVersionInformation[] = await this.getRuntimesVersions();
169+
allComponents = allComponents.concat(runtimesVersions);
170+
}
170171

171-
return allComponents.map((componentInformation) => {
172-
if (componentInformation.currentVersion) {
173-
if (this.hasUpdate(componentInformation)) {
174-
componentInformation.type = VersionInformationType.UpdateAvailable;
175-
componentInformation.message = `${VersionsService.UPDATE_AVAILABLE_MESSAGE} for component ${componentInformation.componentName}. Your current version is ${componentInformation.currentVersion} and the latest available version is ${componentInformation.latestVersion}.`;
172+
return allComponents.map((componentInformation) => {
173+
if (componentInformation.currentVersion) {
174+
if (this.hasUpdate(componentInformation)) {
175+
componentInformation.type = VersionInformationType.UpdateAvailable;
176+
componentInformation.message = `${VersionsService.UPDATE_AVAILABLE_MESSAGE} for component ${componentInformation.componentName}. Your current version is ${componentInformation.currentVersion} and the latest available version is ${componentInformation.latestVersion}.`;
177+
} else {
178+
componentInformation.type = VersionInformationType.UpToDate;
179+
componentInformation.message = `Component ${componentInformation.componentName} has ${componentInformation.currentVersion} version and is ${VersionsService.UP_TO_DATE_MESSAGE}.`;
180+
}
176181
} else {
177-
componentInformation.type = VersionInformationType.UpToDate;
178-
componentInformation.message = `Component ${componentInformation.componentName} has ${componentInformation.currentVersion} version and is ${VersionsService.UP_TO_DATE_MESSAGE}.`;
182+
componentInformation.type = VersionInformationType.NotInstalled;
183+
componentInformation.message = `Component ${componentInformation.componentName} is ${VersionsService.NOT_INSTALLED_MESSAGE}.`;
179184
}
180-
} else {
181-
componentInformation.type = VersionInformationType.NotInstalled;
182-
componentInformation.message = `Component ${componentInformation.componentName} is ${VersionsService.NOT_INSTALLED_MESSAGE}.`;
183-
}
184185

185-
return componentInformation;
186-
});
186+
return componentInformation;
187+
});
188+
} catch (error) {
189+
this.$logger.trace(
190+
"Error while trying to get component information. Error is: ",
191+
error
192+
);
193+
return [];
194+
}
187195
}
188196

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

233241
private hasUpdate(component: IVersionInformation): boolean {
234-
return semver.lt(component.currentVersion, component.latestVersion);
242+
return !semver.satisfies(
243+
component.latestVersion,
244+
semver.validRange(component.currentVersion)
245+
);
235246
}
236247
}
237248

0 commit comments

Comments
 (0)