|
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; |
@@ -209,75 +207,15 @@ class IOSDebugService implements IDebugService { |
209 | 207 |
|
210 | 208 | private openDebuggingClient(fileDescriptor: string): IFuture<void> { |
211 | 209 | 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); |
235 | 213 |
|
| 214 | + let cmd = `open -a '${inspectorApplicationPath}' --args '${inspectorSourceLocation}' '${this.$projectData.projectName}' '${fileDescriptor}'`; |
236 | 215 | this.$childProcess.exec(cmd).wait(); |
237 | 216 | }).future<void>()(); |
238 | 217 | } |
239 | 218 |
|
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 | | - |
281 | 219 | private getReadyForAttachTimeout(timeoutInMilliseconds?: number): number { |
282 | 220 | let timeout = timeoutInMilliseconds || this.$utils.getMilliSecondsTimeout(TIMEOUT_SECONDS); |
283 | 221 | let readyForAttachTimeout = timeout / 10; |
|
0 commit comments