Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
Consuming new vscode-chrome-debug-core npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
jalissia committed Apr 15, 2016
1 parent dc50874 commit d0ce8b1
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 80 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
node_modules/
out/
lib/
typings/
*.vsix
46 changes: 20 additions & 26 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

var gulp = require('gulp');
var path = require('path');
var ts = require('gulp-typescript');
var log = require('gulp-util').log;
var typescript = require('typescript');
var sourcemaps = require('gulp-sourcemaps');
var mocha = require('gulp-mocha');
var merge = require('merge2');
const gulp = require('gulp');
const path = require('path');
const ts = require('gulp-typescript');
const log = require('gulp-util').log;
const typescript = require('typescript');
const sourcemaps = require('gulp-sourcemaps');
const mocha = require('gulp-mocha');
const tslint = require('gulp-tslint');

var sources = [
'src',
'test',
'typings',
'node_modules/debugger-for-chrome/lib'
'typings'
].map(function(tsFolder) { return tsFolder + '/**/*.ts'; });

var bins = [
'node_modules/debugger-for-chrome/out'
].map(function(tsFolder) { return tsFolder + '/**/*.js'; });

var projectConfig = {
noImplicitAny: false,
target: 'ES5',
Expand All @@ -32,18 +27,11 @@ var projectConfig = {
};

gulp.task('build', function () {
var tsResult = gulp.src(sources, { base: '.' })
.pipe(sourcemaps.init())
.pipe(ts(projectConfig));

return merge([
tsResult.js
.pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: 'file:///' + __dirname }))
.pipe(gulp.dest('out'))
,
gulp.src(bins)
.pipe(gulp.dest('out/src/node_modules/debugger-for-chrome'))
]);
return gulp.src(sources, { base: '.' })
.pipe(sourcemaps.init())
.pipe(ts(projectConfig)).js
.pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: 'file:///' + __dirname }))
.pipe(gulp.dest('out'));
});

gulp.task('watch', ['build'], function(cb) {
Expand All @@ -53,6 +41,12 @@ gulp.task('watch', ['build'], function(cb) {

gulp.task('default', ['build']);

gulp.task('tslint', function() {
return gulp.src(lintSources, { base: '.' })
.pipe(tslint())
.pipe(tslint.report('verbose'));
});

function test() {
return gulp.src('out/test/**/*.test.js', { read: false })
.pipe(mocha({ ui: 'tdd' }))
Expand Down
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,24 @@
"categories": ["Debuggers"],
"license": "SEE LICENSE IN LICENSE.txt",
"dependencies": {
"source-map": "^0.5.3",
"ws": "0.8.0"
"vscode-chrome-debug-core": "0.0.2"
},
"optionalDependencies": {
"vs-libimobile" : "^0.0.3"
},
"devDependencies": {
"debugger-for-chrome": "Microsoft/vscode-chrome-debug#f3912e2",
"gulp": "^3.9.0",
"gulp": "^3.9.1",
"gulp-mocha": "^2.1.3",
"gulp-sourcemaps": "^1.5.2",
"gulp-tslint": "^3.3.1",
"gulp-typescript": "^2.8.0",
"gulp-typescript": "^2.12.1",
"gulp-util": "^3.0.5",
"merge2": "^1.0.1",
"mocha": "^2.3.3",
"mockery": "^1.4.0",
"sinon": "^1.17.2",
"tslint": "^2.5.1",
"typescript": "^1.6.2",
"typings": "^0.7.9"
"typescript": "^1.8.9",
"typings": "^0.7.12"
},
"scripts": {
"test": "node ./node_modules/mocha/bin/mocha --recursive -u tdd ./out/test/"
Expand Down
4 changes: 2 additions & 2 deletions src/iosDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import {WebKitDebugSession} from 'debugger-for-chrome';
import {ChromeDebugSession} from 'vscode-chrome-debug-core';
import {IOSDebugSession} from './iosDebugSession';

WebKitDebugSession.run(IOSDebugSession);
ChromeDebugSession.run(IOSDebugSession);
20 changes: 10 additions & 10 deletions src/iosDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import {WebKitDebugAdapter, Utilities} from 'debugger-for-chrome';
import {ChromeDebugAdapter, Utils} from 'vscode-chrome-debug-core';
import * as iosUtils from './utilities';
import {spawn, ChildProcess} from 'child_process';

export class IOSDebugAdapter extends WebKitDebugAdapter {
export class IOSDebugAdapter extends ChromeDebugAdapter {
private _proxyProc: ChildProcess;

public constructor() {
Expand All @@ -15,18 +15,18 @@ export class IOSDebugAdapter extends WebKitDebugAdapter {

public attach(args: any): Promise<void> {
if (args.port == null) {
return Utilities.errP('The "port" field is required in the attach config.');
return Utils.errP('The "port" field is required in the attach config.');
}

this.initializeLogging('attach-ios', args);

// Check exists?
const proxyPath = args.proxyExecutable || iosUtils.getProxyPath();
if (!proxyPath) {
if (Utilities.getPlatform() != Utilities.Platform.Windows) {
return Utilities.errP(`No iOS proxy was found. Install an iOS proxy (https://github.com/google/ios-webkit-debug-proxy) and specify a valid 'proxyExecutable' path`);
if (Utils.getPlatform() != Utils.Platform.Windows) {
return Utils.errP(`No iOS proxy was found. Install an iOS proxy (https://github.com/google/ios-webkit-debug-proxy) and specify a valid 'proxyExecutable' path`);
} else {
return Utilities.errP(`No iOS proxy was found. Run 'npm install -g vs-libimobile' and specify a valid 'proxyExecutable' path`);
return Utils.errP(`No iOS proxy was found. Run 'npm install -g vs-libimobile' and specify a valid 'proxyExecutable' path`);
}
}

Expand All @@ -50,15 +50,15 @@ export class IOSDebugAdapter extends WebKitDebugAdapter {
proxyArgs.push(...args.proxyArgs);
}

Utilities.Logger.log(`spawn('${proxyPath}', ${JSON.stringify(proxyArgs) })`);
Utils.Logger.log(`spawn('${proxyPath}', ${JSON.stringify(proxyArgs) })`);
this._proxyProc = spawn(proxyPath, proxyArgs, {
detached: true,
stdio: ['ignore']
});
(<any>this._proxyProc).unref();
this._proxyProc.on('error', (err) => {
Utilities.Logger.log('device proxy error: ' + err);
Utilities.Logger.log('Do you have the iTunes drivers installed?');
Utils.Logger.log('device proxy error: ' + err);
Utils.Logger.log('Do you have the iTunes drivers installed?');
this.terminateSession();
});

Expand All @@ -82,7 +82,7 @@ export class IOSDebugAdapter extends WebKitDebugAdapter {

private _attachToDevice(proxyPort: number, deviceName: string): Promise<number> {
// Attach to a device over the proxy
return Utilities.getURL(`http://localhost:${proxyPort}/json`).then(jsonResponse => {
return Utils.getURL(`http://localhost:${proxyPort}/json`).then(jsonResponse => {
let devicePort = proxyPort;

try {
Expand Down
4 changes: 2 additions & 2 deletions src/iosDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import {WebKitDebugSession} from 'debugger-for-chrome';
import {ChromeDebugSession} from 'vscode-chrome-debug-core';
import {IOSDebugAdapter} from './iosDebugAdapter';

export class IOSDebugSession extends WebKitDebugSession {
export class IOSDebugSession extends ChromeDebugSession {

public constructor(targetLinesStartAt1: boolean, isServer: boolean = false) {
let version = "iOS." + require('../../package.json').version;
Expand Down
8 changes: 4 additions & 4 deletions src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import {Utilities} from 'debugger-for-chrome';
import {Utils} from 'vscode-chrome-debug-core';
import * as path from 'path';

export function getProxyPath(): string {
const platform = Utilities.getPlatform();
if (platform === Utilities.Platform.Windows) {
const platform = Utils.getPlatform();
if (platform === Utils.Platform.Windows) {
var proxy = path.resolve(__dirname, "../../node_modules/vs-libimobile/lib/ios_webkit_debug_proxy.exe");
if (Utilities.existsSync(proxy)) {
if (Utils.existsSync(proxy)) {
return proxy;
}
}
Expand Down
20 changes: 10 additions & 10 deletions test/iosDebugAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as mockery from 'mockery';
import * as assert from 'assert';
import * as sinon from 'sinon';
import {Utilities, WebKitDebugAdapter} from 'debugger-for-chrome';
import {Utils, ChromeDebugAdapter} from 'vscode-chrome-debug-core';

/** Not mocked - use for type only */
import {IOSDebugAdapter as _IOSDebugAdapter} from '../src/iosDebugAdapter';
Expand Down Expand Up @@ -41,9 +41,9 @@ suite('IOSDebugAdapter', () => {
suite('attach()', () => {
suite('no port', () => {
test('if no port, rejects the attach promise', done => {
mockery.registerMock('debugger-for-chrome', {
WebKitDebugAdapter: () => { },
Utilities: Utilities
mockery.registerMock('vscode-chrome-debug-core', {
ChromeDebugAdapter: () => { },
Utils: Utils
});

const adapter = createAdapter();
Expand All @@ -67,9 +67,9 @@ suite('IOSDebugAdapter', () => {
Logger: { log: () => { } }
};

mockery.registerMock('debugger-for-chrome', {
WebKitDebugAdapter: MockAdapter,
Utilities: MockUtilities
mockery.registerMock('vscode-chrome-debug-core', {
ChromeDebugAdapter: MockAdapter,
Utils: MockUtilities
});
mockery.registerMock('child_process', MockChildProcess);

Expand Down Expand Up @@ -160,9 +160,9 @@ suite('IOSDebugAdapter', () => {
Logger: { log: () => { } }
};

mockery.registerMock('debugger-for-chrome', {
WebKitDebugAdapter: MockAdapter,
Utilities: MockUtilities
mockery.registerMock('vscode-chrome-debug-core', {
ChromeDebugAdapter: MockAdapter,
Utils: MockUtilities
});
mockery.registerMock('child_process', MockChildProcess);

Expand Down
26 changes: 13 additions & 13 deletions test/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import * as mockery from 'mockery';
import * as assert from 'assert';
import {Utilities} from 'debugger-for-chrome';
import {Utils} from 'vscode-chrome-debug-core';

/** Not mocked - use for type only */
import * as _Utilities from '../src/utilities';
Expand All @@ -27,10 +27,10 @@ suite('Utilities', () => {

suite('getProxyPath()', () => {
test('if windows and path exists, returns correct path', () => {
mockery.registerMock('debugger-for-chrome', {
Utilities: {
mockery.registerMock('vscode-chrome-debug-core', {
Utils: {
Platform: { Windows: 0, OSX: 1, Linux: 2 },
getPlatform: () => Utilities.Platform.Windows,
getPlatform: () => Utils.Platform.Windows,
existsSync: () => true
}
});
Expand All @@ -44,10 +44,10 @@ suite('Utilities', () => {
});

test('if windows and path not found, returns null', () => {
mockery.registerMock('debugger-for-chrome', {
Utilities: {
mockery.registerMock('vscode-chrome-debug-core', {
Utils: {
Platform: { Windows: 0, OSX: 1, Linux: 2 },
getPlatform: () => Utilities.Platform.Windows,
getPlatform: () => Utils.Platform.Windows,
existsSync: () => false
}
});
Expand All @@ -61,10 +61,10 @@ suite('Utilities', () => {
});

test('if osx, returns null', () => {
mockery.registerMock('debugger-for-chrome', {
Utilities: {
mockery.registerMock('vscode-chrome-debug-core', {
Utils: {
Platform: { Windows: 0, OSX: 1, Linux: 2 },
getPlatform: () => Utilities.Platform.OSX
getPlatform: () => Utils.Platform.OSX
}
});
mockery.registerMock('path', {});
Expand All @@ -74,10 +74,10 @@ suite('Utilities', () => {
});

test('if linux, returns null', () => {
mockery.registerMock('debugger-for-chrome', {
Utilities: {
mockery.registerMock('vscode-chrome-debug-core', {
Utils: {
Platform: { Windows: 0, OSX: 1, Linux: 2 },
getPlatform: () => Utilities.Platform.Linux
getPlatform: () => Utils.Platform.Linux
}
});
mockery.registerMock('path', {});
Expand Down
10 changes: 10 additions & 0 deletions typings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"ambientDependencies": {
"es6-collections": "registry:dt/es6-collections#0.5.1+20160316155526",
"es6-promise": "registry:dt/es6-promise#0.0.0+20160317120654",
"mocha": "registry:dt/mocha#2.2.5+20160317120654",
"mockery": "registry:dt/mockery#1.4.0+20160316155526",
"node": "registry:dt/node#4.0.0+20160412142033",
"sinon": "registry:dt/sinon#1.16.0+20160317120654"
}
}
5 changes: 0 additions & 5 deletions typings/debugger-for-chrome.d.ts

This file was deleted.

0 comments on commit d0ce8b1

Please sign in to comment.