Skip to content

perf: doctor cache runtimeVersion #5642

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 3 commits into from
Mar 7, 2022
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
9 changes: 8 additions & 1 deletion packages/doctor/src/android-tools-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
}
private pathToEmulatorExecutable: string;

private _cachedRuntimeVersion: string;

constructor(
private childProcess: ChildProcess,
private fs: FileSystem,
Expand Down Expand Up @@ -508,7 +510,7 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
}

private getSystemRequirementsLink(): string {
return Constants.SYSTEM_REQUIREMENTS_LINKS[process.platform] || "";
return Constants.SYSTEM_REQUIREMENTS_LINKS;
}

private isAndroidHomeValid(): boolean {
Expand Down Expand Up @@ -598,6 +600,10 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
runtimeVersion?: string;
projectDir?: string;
}): string {
if (this._cachedRuntimeVersion) {
return this._cachedRuntimeVersion;
}

let runtimePackage = {
name: Constants.ANDROID_SCOPED_RUNTIME,
version: runtimeVersion,
Expand Down Expand Up @@ -630,6 +636,7 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
);
}

this._cachedRuntimeVersion = runtimeVersion;
return runtimeVersion;
}

Expand Down
10 changes: 2 additions & 8 deletions packages/doctor/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ export class Constants {
Constants.ANDROID_PLATFORM_NAME,
Constants.IOS_PLATFORM_NAME,
];
public static SYSTEM_REQUIREMENTS_LINKS: IDictionary<string> = {
win32:
"http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-win.html#system-requirements",
linux:
"http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-linux.html#system-requirements",
darwin:
"http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-os-x.html#system-requirements",
};
public static SYSTEM_REQUIREMENTS_LINKS =
"https://docs.nativescript.org/environment-setup.html";
public static INFO_TYPE_NAME = "info";
public static WARNING_TYPE_NAME = "warning";

Expand Down
2 changes: 1 addition & 1 deletion packages/doctor/test/android-tools-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("androidToolsInfo", () => {
"To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as" +
EOL +
" described in " +
Constants.SYSTEM_REQUIREMENTS_LINKS[process.platform];
Constants.SYSTEM_REQUIREMENTS_LINKS;
before(() => {
process.env["ANDROID_HOME"] = "test";
});
Expand Down
16 changes: 5 additions & 11 deletions packages/doctor/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": true,
"declaration": false,
"removeComments": false,
"noImplicitAny": true,
"experimentalDecorators": true,
"skipLibCheck": true
},
"exclude": ["node_modules", "coverage"]
"extends": "../../tsconfig.json",
"include": [
"src/",
"test/"
]
}
8 changes: 1 addition & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,5 @@
"alwaysStrict": true,
"noUnusedLocals": true
},
"exclude": [
"node_modules",
"lib/common/node_modules",
"scratch",
"coverage",
"resources/test"
]
"include": ["lib/", "test/"]
}