Skip to content

Commit 6667830

Browse files
committed
Support frameworkPath when installing tns-ios-inspector
Remove obsolete code
1 parent 3aa3f2b commit 6667830

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;
@@ -203,75 +201,15 @@ class IOSDebugService implements IDebugService {
203201

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

208+
let cmd = `open -a '${inspectorApplicationPath}' --args '${inspectorSourceLocation}' '${this.$projectData.projectName}' '${fileDescriptor}'`;
230209
this.$childProcess.exec(cmd).wait();
231210
}).future<void>()();
232211
}
233212

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

lib/services/platform-service.ts

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

80-
if (this.$options.frameworkPath) {
81-
packageToInstall = this.$options.frameworkPath;
82-
} else {
80+
if (!this.$options.frameworkPath) {
8381
packageToInstall = platformData.frameworkPackageName;
8482
npmOptions["version"] = version;
8583
}

0 commit comments

Comments
 (0)