Skip to content

Commit eb07ac1

Browse files
Change the definition files to enable the user to use the interfaces without importing them
1 parent 275cac4 commit eb07ac1

File tree

6 files changed

+282
-283
lines changed

6 files changed

+282
-283
lines changed

Gruntfile.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ module.exports = function (grunt) {
44
options: grunt.file.readJSON("tsconfig.json").compilerOptions,
55

66
devlib: {
7-
src: ["lib/**/*.ts"],
7+
src: ["lib/**/*.ts", "typings/**/*.ts"],
88
reference: "lib/.d.ts"
99
},
1010

1111
devall: {
12-
src: ["lib/**/*.ts", "test/**/*.ts"],
12+
src: ["lib/**/*.ts", "test/**/*.ts", "typings/**/*.ts"],
1313
reference: "lib/.d.ts"
1414
},
1515

1616
release_build: {
17-
src: ["lib/**/*.ts", "test/**/*.ts"],
17+
src: ["lib/**/*.ts", "test/**/*.ts", "typings/**/*.ts"],
1818
reference: "lib/.d.ts",
1919
options: {
2020
sourceMap: false,
@@ -26,7 +26,7 @@ module.exports = function (grunt) {
2626
tslint: {
2727
build: {
2828
files: {
29-
src: ["lib/**/*.ts", "test/**/*.ts", "!**/*.d.ts"]
29+
src: ["lib/**/*.ts", "test/**/*.ts", "typings/**/*.ts", "!**/*.d.ts"]
3030
},
3131
options: {
3232
configuration: grunt.file.readJSON("./tslint.json")

lib/doctor.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { HostInfo } from "./host-info";
55
import { AndroidLocalBuildRequirements } from "./local-build-requirements/android-local-build-requirements";
66
import { IosLocalBuildRequirements } from "./local-build-requirements/ios-local-build-requirements";
77
import { Helpers } from "./helpers";
8-
import { IWarning } from "../typings/nativescript-doctor";
98
import * as semver from "semver";
109

1110
export class Doctor {
@@ -29,8 +28,8 @@ export class Doctor {
2928
return false;
3029
}
3130

32-
public async getWarnings(): Promise<IWarning[]> {
33-
const result: IWarning[] = [];
31+
public async getWarnings(): Promise<NativeScriptDoctor.IWarning[]> {
32+
const result: NativeScriptDoctor.IWarning[] = [];
3433
const sysInfoData = await this.sysInfo.getSysInfo();
3534

3635
if (!sysInfoData.adbVer) {

lib/sys-info.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { ExecOptions } from "child_process";
55
import { WinReg } from "./winreg";
66
import { Helpers } from "./helpers";
77
import { platform } from "os";
8-
import { ISysInfoData } from "../typings/nativescript-doctor";
98
import * as path from "path";
109
import * as osenv from "osenv";
1110
import * as temp from "temp";
@@ -36,7 +35,7 @@ export class SysInfo {
3635
private monoVerCache: string;
3736
private gitVerCache: string;
3837
private gradleVerCache: string;
39-
private sysInfoCache: ISysInfoData;
38+
private sysInfoCache: NativeScriptDoctor.ISysInfoData;
4039
private isCocoaPodsWorkingCorrectlyCache: boolean = null;
4140
private nativeScriptCliVersion: string;
4241

@@ -219,15 +218,15 @@ export class SysInfo {
219218
const output = await this.execCommand("gradle -v");
220219
const matches = SysInfo.GRADLE_VERSION_REGEXP.exec(output);
221220

222-
this.gradleVerCache = matches && matches[1];
221+
this.gradleVerCache = matches && matches[1];
223222
}
224223

225224
return this.gradleVerCache;
226225
}
227226

228-
public async getSysInfo(): Promise<ISysInfoData> {
227+
public async getSysInfo(): Promise<NativeScriptDoctor.ISysInfoData> {
229228
if (!this.sysInfoCache) {
230-
const result: ISysInfoData = Object.create(null);
229+
const result: NativeScriptDoctor.ISysInfoData = Object.create(null);
231230

232231
// os stuff
233232
result.platform = platform();

test/sys-info.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as assert from "assert";
22
import * as path from "path";
33
import { SysInfo } from "../lib/sys-info";
44
import { ChildProcess } from "../lib/wrappers/child-process";
5-
import { ISysInfoData } from "../typings/nativescript-doctor";
65

76
const JavaHomeName = "JAVA_HOME";
87
const AndroidHomeName = "ANDROID_HOME";
@@ -198,7 +197,7 @@ describe("SysInfo unit tests", () => {
198197
});
199198

200199
describe("returns correct results when everything is installed", () => {
201-
let assertCommonValues = (result: ISysInfoData) => {
200+
let assertCommonValues = (result: NativeScriptDoctor.ISysInfoData) => {
202201
assert.deepEqual(result.npmVer, childProcessResult.npmV.result.stdout);
203202
assert.deepEqual(result.javaVer, "1.8.0");
204203
assert.deepEqual(result.javacVersion, "1.8.0_60");

typings/interfaces.ts

+267
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
declare module NativeScriptDoctor {
2+
/**
3+
* Describes methods which helps collecting system information.
4+
*/
5+
interface ISysInfo {
6+
/**
7+
* Returns the currently installed Java version.
8+
* @return {Promise<string>} The currently installed Java version.
9+
*/
10+
getJavaVersion(): Promise<string>;
11+
12+
/**
13+
* Returns the currently installed Java compiler version.
14+
* @return {Promise<string>} The currently installed Java compiler version.
15+
*/
16+
getJavaCompilerVersion(): Promise<string>;
17+
18+
/**
19+
* Returns the currently installed version of Xcode.
20+
* @return {Promise<string>} Returns the currently installed version of Xcode or null if Xcode is not installed or executed on Linux or Windows.
21+
*/
22+
getXcodeVersion(): Promise<string>;
23+
24+
/**
25+
* Returns the currently installed Node.js version.
26+
* @return {Promise<string>} Returns the currently installed Node.js version.
27+
*/
28+
getNodeVersion(): Promise<string>;
29+
30+
/**
31+
* Returns the currently installed node-gyp version.
32+
* @return {Promise<string>} Returns the currently installed node-gyp version. If node-gyp is not installed it will return null.
33+
*/
34+
getNodeGypVersion(): Promise<string>;
35+
36+
/**
37+
* Returns the xcodeproj gem location.
38+
* @return {Promise<string>} Returns the xcodeproj gem location. If the the xcodeproj gem is not installed it will return null.
39+
*/
40+
getXcodeprojGemLocation(): Promise<string>;
41+
42+
/**
43+
* Checks if iTunes is installed.
44+
* @return {Promise<string>} Returns true if iTunes is installed.
45+
*/
46+
isITunesInstalled(): Promise<boolean>;
47+
48+
/**
49+
* Returns the currently installed Cocoapods version.
50+
* @return {Promise<string>} Returns the currently installed Cocoapods version. It will return null if Cocoapods is not installed.
51+
*/
52+
getCocoaPodsVersion(): Promise<string>;
53+
54+
/**
55+
* Returns the os name.
56+
* @return {Promise<string>} Returns the os name.
57+
*/
58+
getOs(): Promise<string>;
59+
60+
/**
61+
* Returns the currently installed ADB version.
62+
* @return {Promise<string>} Returns the currently installed ADB version. It will return null if ADB is not installed.
63+
*/
64+
getAdbVersion(): Promise<string>;
65+
66+
/**
67+
* Checks if Android is installed.
68+
* @return {Promise<boolean>} Returns true if Android is installed.
69+
*/
70+
isAndroidInstalled(): Promise<boolean>;
71+
72+
/**
73+
* Returns the currently installed Mono version.
74+
* @return {Promise<string>} Returns the currently installed Mono version. It will return null if Mono is not installed.
75+
*/
76+
getMonoVersion(): Promise<string>;
77+
78+
/**
79+
* Returns the currently installed Git version.
80+
* @return {Promise<string>} Returns the currently installed Git version. It will return null if Git is not installed.
81+
*/
82+
getGitVersion(): Promise<string>;
83+
84+
/**
85+
* Returns the currently installed Gradle version.
86+
* @return {Promise<string>} Returns the currently installed Gradle version. It will return null if Gradle is not installed.
87+
*/
88+
getGradleVersion(): Promise<string>;
89+
90+
/**
91+
* Checks if CocoaPods is working correctly by trying to install one pod.
92+
* @return {Promise<boolean>} Returns true if CocoaPods is working correctly.
93+
*/
94+
isCocoaPodsWorkingCorrectly(): Promise<boolean>;
95+
96+
/**
97+
* Returns the version of the globally installed NativeScript CLI.
98+
* @return {Promise<string>} Returns the version of the globally installed NativeScript CLI.
99+
*/
100+
getNativeScriptCliVersion(): Promise<string>;
101+
102+
/**
103+
* Returns the whole system information.
104+
* @return {Promise<ISysInfoData>} The system information.
105+
*/
106+
getSysInfo(): Promise<ISysInfoData>;
107+
}
108+
109+
/**
110+
* Describes methods which help identifying if the environment can be used for development of {N} apps.
111+
*/
112+
interface IDoctor {
113+
/**
114+
* Checks if a local build can be executed on the current machine.
115+
* @param {string} platform The platform for which to check if local build is possible.
116+
* @return {Promise<boolean>} true if local build can be executed for the provided platform.
117+
*/
118+
canExecuteLocalBuild(platform: string): Promise<boolean>;
119+
120+
/**
121+
* Executes all checks for the current environment and returns the warnings from each check.
122+
* @return {Promise<IWarning[]>} Array of all the warnings from all checks. If there are no warnings will return empty array.
123+
*/
124+
getWarnings(): Promise<IWarning[]>;
125+
}
126+
127+
interface ISysInfoData {
128+
// os stuff
129+
/**
130+
* Os platform flavour, reported by os.platform.
131+
* @type {string}
132+
*/
133+
platform: string;
134+
135+
/**
136+
* Full os name, like `uname -a` on unix, registry query on win.
137+
* @type {string}
138+
*/
139+
os: string;
140+
141+
/**
142+
* .net version, applicable to windows only.
143+
* @type {string}
144+
*/
145+
dotNetVer: string;
146+
147+
/**
148+
* The command shell in use, usually bash or cmd.
149+
* @type {string}
150+
*/
151+
shell: string;
152+
153+
// node stuff
154+
/**
155+
* node.js version, returned by `process.version`.
156+
* @type {string}
157+
*/
158+
nodeVer: string;
159+
160+
/**
161+
* npm version, returned by `npm -v`.
162+
* @type {string}
163+
*/
164+
npmVer: string;
165+
166+
/**
167+
* Process architecture, returned by `process.arch`.
168+
* @type {string}
169+
*/
170+
procArch: string;
171+
172+
/**
173+
* node-gyp version as returned by `node-gyp -v`.
174+
* @type {string}
175+
*/
176+
nodeGypVer: string;
177+
178+
// dependencies
179+
/**
180+
* Version of java, as returned by `java -version`.
181+
* @type {string}
182+
*/
183+
javaVer: string;
184+
185+
/**
186+
* Xcode version string as returned by `xcodebuild -version`. Valid only on Mac.
187+
* @type {string}
188+
*/
189+
xcodeVer: string;
190+
191+
/**
192+
* Version string of adb, as returned by `adb version`.
193+
* @type {string}
194+
*/
195+
adbVer: string;
196+
197+
/**
198+
* Whether iTunes is installed on the machine.
199+
* @type {boolean}
200+
*/
201+
itunesInstalled: boolean;
202+
203+
/**
204+
* Whether `android` executable can be run.
205+
* @type {boolean}
206+
*/
207+
androidInstalled: boolean;
208+
209+
/**
210+
* mono version, relevant on Mac only.
211+
* @type {string}
212+
*/
213+
monoVer: string;
214+
215+
/**
216+
* git version string, as returned by `git --version`.
217+
* @type {string}
218+
*/
219+
gitVer: string;
220+
221+
/**
222+
* gradle version string as returned by `gradle -v`.
223+
* @type {string}
224+
*/
225+
gradleVer: string;
226+
227+
/**
228+
* javac version string as returned by `javac -version`.
229+
* @type {string}
230+
*/
231+
javacVersion: string;
232+
233+
/**
234+
* pod version string, as returned by `pod --version`.
235+
* @type {string}
236+
*/
237+
cocoaPodsVer: string;
238+
239+
/**
240+
* xcodeproj gem location, as returned by `which gem xcodeproj`.
241+
* @type {string}
242+
*/
243+
xcodeprojGemLocation: string;
244+
245+
/**
246+
* true id CocoaPods can successfully execute pod install.
247+
* @type {boolean}
248+
*/
249+
isCocoaPodsWorkingCorrectly: boolean;
250+
251+
/**
252+
* NativeScript CLI version string, as returned by `tns --version`.
253+
* @type {string}
254+
*/
255+
nativeScriptCliVersion: string;
256+
}
257+
258+
/**
259+
* Describes warning returned from nativescript-doctor check.
260+
*/
261+
interface IWarning {
262+
/** The warning. */
263+
warning: string;
264+
/** Additional information for the warning. */
265+
additionalInformation: string;
266+
}
267+
}

0 commit comments

Comments
 (0)