|
1 | 1 | import * as iOSDevice from "../common/mobile/ios/device/ios-device";
|
2 | 2 | import * as net from "net";
|
3 | 3 | import * as path from "path";
|
4 |
| -import * as semver from "semver"; |
5 | 4 | import {ChildProcess} from "child_process";
|
6 | 5 | import byline = require("byline");
|
7 | 6 |
|
8 | 7 | const inspectorBackendPort = 18181;
|
9 | 8 | const inspectorAppName = "NativeScript Inspector.app";
|
10 |
| -const inspectorZipName = "NativeScript Inspector.zip"; |
11 | 9 | const inspectorNpmPackageName = "tns-ios-inspector";
|
12 | 10 | const inspectorUiDir = "WebInspectorUI/";
|
13 | 11 | const TIMEOUT_SECONDS = 90;
|
@@ -203,75 +201,15 @@ class IOSDebugService implements IDebugService {
|
203 | 201 |
|
204 | 202 | private openDebuggingClient(fileDescriptor: string): IFuture<void> {
|
205 | 203 | 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); |
229 | 207 |
|
| 208 | + let cmd = `open -a '${inspectorApplicationPath}' --args '${inspectorSourceLocation}' '${this.$projectData.projectName}' '${fileDescriptor}'`; |
230 | 209 | this.$childProcess.exec(cmd).wait();
|
231 | 210 | }).future<void>()();
|
232 | 211 | }
|
233 | 212 |
|
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 |
| - |
275 | 213 | private getReadyForAttachTimeout(timeoutInMilliseconds?: number): number {
|
276 | 214 | let timeout = timeoutInMilliseconds || this.$utils.getMilliSecondsTimeout(TIMEOUT_SECONDS);
|
277 | 215 | let readyForAttachTimeout = timeout / 10;
|
|
0 commit comments