Skip to content

Commit 8b1ea1f

Browse files
authored
Merge pull request #2068 from NativeScript/KristinaKoeva/InspectorVersion
Support frameworkPath when installing tns-ios-inspector
2 parents ed32769 + 6667830 commit 8b1ea1f

File tree

3 files changed

+6
-70
lines changed

3 files changed

+6
-70
lines changed

lib/npm-installation-manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export class NpmInstallationManager implements INpmInstallationManager {
181181
private installCore(packageName: string, pathToSave: string, version: string): IFuture<string> {
182182
return (() => {
183183
if (this.$options.frameworkPath) {
184-
this.npmInstall(packageName, pathToSave, version).wait();
184+
this.npmInstall(this.$options.frameworkPath, pathToSave, version).wait();
185185
let pathToNodeModules = path.join(pathToSave, "node_modules");
186186
let folders = this.$fs.readDirectory(pathToNodeModules).wait();
187187

lib/services/ios-debug-service.ts

+4-66
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import * as iOSDevice from "../common/mobile/ios/device/ios-device";
22
import * as net from "net";
33
import * as path from "path";
4-
import * as semver from "semver";
54
import {ChildProcess} from "child_process";
65
import byline = require("byline");
76

87
const inspectorBackendPort = 18181;
98
const inspectorAppName = "NativeScript Inspector.app";
10-
const inspectorZipName = "NativeScript Inspector.zip";
119
const inspectorNpmPackageName = "tns-ios-inspector";
1210
const inspectorUiDir = "WebInspectorUI/";
1311
const TIMEOUT_SECONDS = 90;
@@ -209,75 +207,15 @@ class IOSDebugService implements IDebugService {
209207

210208
private openDebuggingClient(fileDescriptor: string): IFuture<void> {
211209
return (() => {
212-
let frameworkVersion = this.getProjectFrameworkVersion().wait();
213-
let inspectorPath = this.getInspectorPath(frameworkVersion).wait();
214-
let inspectorSourceLocation: string;
215-
let cmd: string = null;
216-
217-
if (semver.lt(frameworkVersion, "1.2.0")) {
218-
cmd = `open -a Safari "${inspectorSourceLocation}"`;
219-
} else {
220-
let inspectorApplicationDir: string;
221-
if (semver.lt(frameworkVersion, "1.6.0")) {
222-
inspectorApplicationDir = inspectorPath;
223-
inspectorSourceLocation = path.join(inspectorPath, "Safari/Main.html");
224-
} else {
225-
inspectorApplicationDir = path.join(inspectorPath, "..");
226-
inspectorSourceLocation = path.join(inspectorPath, "Main.html");
227-
}
228-
229-
let inspectorApplicationPath = path.join(inspectorApplicationDir, inspectorAppName);
230-
if (!this.$fs.exists(inspectorApplicationPath).wait()) {
231-
this.$fs.unzip(path.join(inspectorApplicationDir, inspectorZipName), inspectorApplicationDir).wait();
232-
}
233-
cmd = `open -a '${inspectorApplicationPath}' --args '${inspectorSourceLocation}' '${this.$projectData.projectName}' '${fileDescriptor}'`;
234-
}
210+
let inspectorPath = this.$npmInstallationManager.install(inspectorNpmPackageName).wait();
211+
let inspectorSourceLocation = path.join(inspectorPath, inspectorUiDir, "Main.html");
212+
let inspectorApplicationPath = path.join(inspectorPath, inspectorAppName);
235213

214+
let cmd = `open -a '${inspectorApplicationPath}' --args '${inspectorSourceLocation}' '${this.$projectData.projectName}' '${fileDescriptor}'`;
236215
this.$childProcess.exec(cmd).wait();
237216
}).future<void>()();
238217
}
239218

240-
private getProjectFrameworkVersion(): IFuture<string> {
241-
return (() => {
242-
this.$projectDataService.initialize(this.$projectData.projectDir);
243-
let platformData = this.$platformsData.getPlatformData(this.platform);
244-
return this.$projectDataService.getValue(platformData.frameworkPackageName).wait().version;
245-
}).future<string>()();
246-
}
247-
248-
private getInspectorPath(frameworkVersion: string): IFuture<string> {
249-
if (semver.lt(frameworkVersion, "1.6.0")) {
250-
return this.getInspectorPathFromTnsIosPackage(frameworkVersion);
251-
} else {
252-
return this.getInspectorPathFromInspectorPackage();
253-
}
254-
}
255-
256-
private getInspectorPathFromInspectorPackage(): IFuture<string> {
257-
return (() => {
258-
let inspectorPackage = this.$npmInstallationManager.install(inspectorNpmPackageName).wait();
259-
let inspectorPath = path.join(inspectorPackage, inspectorUiDir);
260-
return inspectorPath;
261-
}).future<string>()();
262-
}
263-
264-
private getInspectorPathFromTnsIosPackage(frameworkVersion: string): IFuture<string> {
265-
return (() => {
266-
let tnsIosPackage = "";
267-
if (this.$options.frameworkPath) {
268-
if (this.$fs.getFsStats(this.$options.frameworkPath).wait().isFile()) {
269-
this.$errors.failWithoutHelp("frameworkPath option must be path to directory which contains tns-ios framework");
270-
}
271-
tnsIosPackage = path.resolve(this.$options.frameworkPath);
272-
} else {
273-
let platformData = this.$platformsData.getPlatformData(this.platform);
274-
tnsIosPackage = this.$npmInstallationManager.install(platformData.frameworkPackageName, { version: frameworkVersion }).wait();
275-
}
276-
let inspectorPath = path.join(tnsIosPackage, inspectorUiDir);
277-
return inspectorPath;
278-
}).future<string>()();
279-
}
280-
281219
private getReadyForAttachTimeout(timeoutInMilliseconds?: number): number {
282220
let timeout = timeoutInMilliseconds || this.$utils.getMilliSecondsTimeout(TIMEOUT_SECONDS);
283221
let readyForAttachTimeout = timeout / 10;

lib/services/platform-service.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ export class PlatformService implements IPlatformService {
8282
pathToSave: path.join(this.$projectData.platformsDir, platform)
8383
};
8484

85-
if (this.$options.frameworkPath) {
86-
packageToInstall = this.$options.frameworkPath;
87-
} else {
85+
if (!this.$options.frameworkPath) {
8886
packageToInstall = platformData.frameworkPackageName;
8987
npmOptions["version"] = version;
9088
}

0 commit comments

Comments
 (0)