Skip to content

Commit 3063550

Browse files
authored
perf: doctor cache runtimeVersion (#5642)
* chore: cleanup build configs * chore: replace old docs link * perf: cache runtime version from npm view
1 parent 67fdd0a commit 3063550

File tree

5 files changed

+17
-28
lines changed

5 files changed

+17
-28
lines changed

packages/doctor/src/android-tools-info.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
5252
}
5353
private pathToEmulatorExecutable: string;
5454

55+
private _cachedRuntimeVersion: string;
56+
5557
constructor(
5658
private childProcess: ChildProcess,
5759
private fs: FileSystem,
@@ -508,7 +510,7 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
508510
}
509511

510512
private getSystemRequirementsLink(): string {
511-
return Constants.SYSTEM_REQUIREMENTS_LINKS[process.platform] || "";
513+
return Constants.SYSTEM_REQUIREMENTS_LINKS;
512514
}
513515

514516
private isAndroidHomeValid(): boolean {
@@ -598,6 +600,10 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
598600
runtimeVersion?: string;
599601
projectDir?: string;
600602
}): string {
603+
if (this._cachedRuntimeVersion) {
604+
return this._cachedRuntimeVersion;
605+
}
606+
601607
let runtimePackage = {
602608
name: Constants.ANDROID_SCOPED_RUNTIME,
603609
version: runtimeVersion,
@@ -630,6 +636,7 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
630636
);
631637
}
632638

639+
this._cachedRuntimeVersion = runtimeVersion;
633640
return runtimeVersion;
634641
}
635642

packages/doctor/src/constants.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@ export class Constants {
55
Constants.ANDROID_PLATFORM_NAME,
66
Constants.IOS_PLATFORM_NAME,
77
];
8-
public static SYSTEM_REQUIREMENTS_LINKS: IDictionary<string> = {
9-
win32:
10-
"http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-win.html#system-requirements",
11-
linux:
12-
"http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-linux.html#system-requirements",
13-
darwin:
14-
"http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-os-x.html#system-requirements",
15-
};
8+
public static SYSTEM_REQUIREMENTS_LINKS =
9+
"https://docs.nativescript.org/environment-setup.html";
1610
public static INFO_TYPE_NAME = "info";
1711
public static WARNING_TYPE_NAME = "warning";
1812

packages/doctor/test/android-tools-info.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("androidToolsInfo", () => {
2222
"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" +
2323
EOL +
2424
" described in " +
25-
Constants.SYSTEM_REQUIREMENTS_LINKS[process.platform];
25+
Constants.SYSTEM_REQUIREMENTS_LINKS;
2626
before(() => {
2727
process.env["ANDROID_HOME"] = "test";
2828
});

packages/doctor/tsconfig.json

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
{
2-
"compilerOptions": {
3-
"target": "es6",
4-
"module": "commonjs",
5-
"sourceMap": true,
6-
"declaration": false,
7-
"removeComments": false,
8-
"noImplicitAny": true,
9-
"experimentalDecorators": true,
10-
"skipLibCheck": true
11-
},
12-
"exclude": ["node_modules", "coverage"]
2+
"extends": "../../tsconfig.json",
3+
"include": [
4+
"src/",
5+
"test/"
6+
]
137
}

tsconfig.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,5 @@
1010
"alwaysStrict": true,
1111
"noUnusedLocals": true
1212
},
13-
"exclude": [
14-
"node_modules",
15-
"lib/common/node_modules",
16-
"scratch",
17-
"coverage",
18-
"resources/test"
19-
]
13+
"include": ["lib/", "test/"]
2014
}

0 commit comments

Comments
 (0)