This commit is contained in:
Rob Lourens 2017-11-13 11:24:46 -08:00
Родитель 8a373384b1
Коммит 2b805be7a5
8 изменённых файлов: 210 добавлений и 61 удалений

Просмотреть файл

@ -2,9 +2,90 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
const ts = require('gulp-typescript');
const typescript = require('typescript');
const sourcemaps = require('gulp-sourcemaps');
const gulp = require('gulp');
const path = require('path');
const fs = require('fs');
const nls = require('vscode-nls-dev');
const vsce = require('vsce');
const transifexApiHostname = 'www.transifex.com'
const transifexApiName = 'api';
const transifexApiToken = process.env.TRANSIFEX_API_TOKEN;
const transifexProjectName = 'vscode-extensions';
const transifexExtensionName = 'vscode-chrome-debug';
const vscodeLanguages = [
'zh-hans',
'zh-hant',
'ja',
'ko',
'de',
'fr',
'es',
'ru',
'it',
'pt-br',
'hu',
'tr'
];
const watchedSources = [
'src/**/*',
'test/**/*'
];
const scripts = [
'src/terminateProcess.sh'
];
const lintSources = [
'src'
].map(function (tsFolder) { return tsFolder + '/**/*.ts'; });
const tsProject = ts.createProject('tsconfig.json', { typescript });
function doBuild(buildNls) {
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject()).js
.pipe(buildNls ? nls.rewriteLocalizeCalls() : es.through())
.pipe(buildNls ? nls.createAdditionalLanguageFiles(nls.coreLanguages, 'i18n', 'out') : es.through())
.pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: '..' })) // .. to compensate for TS returning paths from 'out'
.pipe(gulp.dest('out'));
}
gulp.task('build', ['copy-scripts'], function () {
doBuild(true);
});
gulp.task('dev-build', ['copy-scripts'], function () {
doBuild(false);
});
gulp.task('copy-scripts', () => {
return gulp.src(scripts, { base: '.' })
.pipe(gulp.dest('out'));
});
gulp.task('watch', ['dev-build'], function (cb) {
log('Watching build sources...');
return gulp.watch(watchedSources, ['dev-build']);
});
gulp.task('default', ['build']);
gulp.task('tslint', function () {
return gulp.src(lintSources, { base: '.' })
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tslint.report({ emitError: false }));
});
gulp.task('clean', function () {
return del(['out/**', 'package.nls.*.json', 'vscode-chrome-debug-*.vsix']);
});
function verifyNotALinkedModule(modulePath) {
return new Promise((resolve, reject) => {
@ -30,3 +111,41 @@ function verifyNoLinkedModules() {
}
gulp.task('verify-no-linked-modules', cb => verifyNoLinkedModules().then(() => cb, cb));
gulp.task('vsce-publish', function () {
return vsce.publish();
});
gulp.task('vsce-package', function () {
return vsce.createVSIX();
});
gulp.task('publish', function (callback) {
runSequence('build', 'add-i18n', 'vsce-publish', callback);
});
gulp.task('package', function (callback) {
runSequence('build', 'add-i18n', 'vsce-package', callback);
});
gulp.task('add-i18n', function () {
return gulp.src(['package.nls.json'])
.pipe(nls.createAdditionalLanguageFiles(nls.coreLanguages, 'i18n'))
.pipe(gulp.dest('.'));
});
gulp.task('transifex-push', function () {
return gulp.src('**/*.nls.json')
.pipe(nls.prepareXlfFiles(transifexProjectName, transifexExtensionName))
.pipe(nls.pushXlfFiles(transifexApiHostname, transifexApiName, transifexApiToken));
});
gulp.task('transifex-pull', function () {
return nls.pullXlfFiles(transifexApiHostname, transifexApiName, transifexApiToken, vscodeLanguages, [{ name: transifexExtensionName, project: transifexProjectName }])
.pipe(gulp.dest(`../${transifexExtensionName}-localization`));
});
gulp.task('i18n-import', function () {
return gulp.src(`../${transifexExtensionName}-localization/**/*.xlf`)
.pipe(nls.prepareJsonFiles())
.pipe(gulp.dest('./i18n'));
});

Просмотреть файл

@ -3,7 +3,7 @@
"displayName": "Debugger for Chrome",
"version": "3.5.0",
"icon": "images/icon.png",
"description": "Debug your JavaScript code in the Chrome browser, or any other target that supports the Chrome Debugger protocol.",
"description": "%extension.description%",
"author": {
"name": "Microsoft Corporation"
},
@ -25,7 +25,8 @@
"license": "SEE LICENSE IN LICENSE.txt",
"dependencies": {
"vscode-chrome-debug-core": "3.18.4",
"vscode-debugadapter": "^1.24.0"
"vscode-debugadapter": "^1.24.0",
"vscode-nls": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-2.0.2.tgz"
},
"devDependencies": {
"@types/mocha": "^2.2.35",
@ -36,6 +37,8 @@
"concurrently": "^3.1.0",
"glob": "^7.1.1",
"gulp": "^3.9.1",
"gulp-sourcemaps": "^2.6.1",
"gulp-typescript": "^3.2.3",
"http-server": "^0.9.0",
"mocha": "^3.0.2",
"mockery": "^1.7.0",
@ -44,10 +47,12 @@
"tslint": "^3.15.1",
"typemoq": "^0.3.3",
"typescript": "^2.4.1",
"vsce": "^1.32.0",
"vscode": "^1.0.3",
"vscode-chrome-debug-core-testsupport": "^3.17.1",
"vscode-debugadapter-testsupport": "1.24.0",
"vscode-debugprotocol": "^1.24.0",
"vscode-nls-dev": "^2.1.5",
"webpack": "^2.2.0-rc.1",
"webpack-fail-plugin": "^1.0.5"
},
@ -130,32 +135,32 @@
"properties": {
"port": {
"type": "number",
"description": "Port to use for Chrome remote debugging.",
"description": "%chrome.port.description%",
"default": 9222
},
"address": {
"type": "string",
"description": "TCP/IP address of debug port",
"description": "%chrome.address.description%",
"default": "127.0.0.1"
},
"file": {
"type": "string",
"description": "A local html file to open in the browser",
"description": "%chrome.file.description%",
"default": "${workspaceRoot}/index.html"
},
"url": {
"type": "string",
"description": "A url to open in the browser",
"description": "%chrome.url.description%",
"default": "http://localhost:8080"
},
"webRoot": {
"type": "string",
"description": "When the 'url' field is specified, this specifies the workspace absolute path to the webserver root. Shorthand for a pathMapping for \"/\"",
"description": "%chrome.webRoot.description%",
"default": "${workspaceRoot}"
},
"pathMapping": {
"type": "object",
"description": "A mapping of URLs/paths to local folders, to resolve scripts in Chrome to scripts on disk",
"description": "%chrome.pathMapping.description%",
"default": {
"/": "${workspaceRoot}"
}
@ -165,12 +170,12 @@
"string",
"null"
],
"description": "Workspace absolute path to the runtime executable to be used. If not specified, Chrome will be used from the default install location.",
"description": "%chrome.runtimeExecutable.description%",
"default": null
},
"runtimeArgs": {
"type": "array",
"description": "Optional arguments passed to the runtime executable.",
"description": "%chrome.runtimeArgs.description%",
"items": {
"type": "string"
},
@ -178,28 +183,28 @@
},
"env": {
"type": "object",
"description": "Optional dictionary of environment key/value pairs.",
"description": "%chrome.env.description%",
"default": {}
},
"cwd": {
"type": "string",
"description": "Optional working directory for the runtime executable.",
"description": "%chrome.cwd.description%",
"default": null
},
"sourceMaps": {
"type": "boolean",
"description": "Use JavaScript source maps (if they exist).",
"description": "%chrome.sourceMaps.description%",
"default": true
},
"diagnosticLogging": {
"type": "boolean",
"description": "When true, the adapter logs its own diagnostic info to the console in a human readable format",
"description": "%chrome.diagnosticLogging.description%",
"default": true,
"deprecationMessage": "'diagnosticLogging' is deprecated. Use 'trace' instead."
},
"verboseDiagnosticLogging": {
"type": "boolean",
"description": "When true, the adapter logs all traffic with the client and target (as well as the info logged by 'diagnosticLogging')",
"description": "%chrome.verboseDiagnosticLogging.description%",
"default": true,
"deprecationMessage": "'verboseDiagnosticLogging' is deprecated. Use 'trace' instead."
},
@ -213,19 +218,19 @@
true
],
"default": true,
"description": "When 'true', the debugger will log tracing info to a file. When 'verbose', it will also show logs in the console."
"description": "%chrome.trace.description%"
},
"userDataDir": {
"type": [
"string",
"boolean"
],
"description": "By default, Chrome is launched with a separate user profile in a temp folder. Use this option to override it. Set to false to launch with your default user profile.",
"description": "%chrome.userDataDir.description%",
"default": ""
},
"sourceMapPathOverrides": {
"type": "object",
"description": "A set of mappings for rewriting the locations of source files from what the sourcemap says, to their locations on disk. See README for details.",
"description": "%chrome.sourceMapPathOverrides.description%",
"default": {
"webpack:///*": "*",
"webpack:///./*": "${webRoot}/*",
@ -235,32 +240,32 @@
},
"smartStep": {
"type": "boolean",
"description": "Automatically step through generated code that cannot be mapped back to the original source.",
"description": "%chrome.smartStep.description%",
"default": true
},
"skipFiles": {
"type": "array",
"description": "An array of file or folder names, or path globs, to skip when debugging.",
"description": "%chrome.skipFiles.description%",
"default": []
},
"timeout": {
"type": "number",
"description": "Retry for this number of milliseconds to connect to Chrome. Default is 10000 ms.",
"description": "%chrome.timeout.description%",
"default": 10000
},
"disableNetworkCache": {
"type": "boolean",
"description": "Controls whether to skip the network cache for each request",
"description": "%chrome.disableNetworkCache.description%",
"default": true
},
"urlFilter": {
"type": "string",
"description": "Will search for a page with this url and attach to it, if found. Can have * wildcards.",
"description": "%chrome.urlFilter.description%",
"default": ""
},
"showAsyncStacks": {
"type": "boolean",
"description": "Show the async calls that led to the current call stack",
"description": "%chrome.showAsyncStacks.description%",
"default": true
}
}
@ -272,28 +277,28 @@
"properties": {
"port": {
"type": "number",
"description": "Port to use for Chrome remote debugging.",
"description": "%chrome.port.description%",
"default": 9222
},
"address": {
"type": "string",
"description": "TCP/IP address of debug port",
"description": "%chrome.address.description%",
"default": "127.0.0.1"
},
"sourceMaps": {
"type": "boolean",
"description": "Use JavaScript source maps (if they exist).",
"description": "%chrome.sourceMaps.description%",
"default": true
},
"diagnosticLogging": {
"type": "boolean",
"description": "When true, the adapter logs its own diagnostic info to the console in a human readable format",
"description": "%chrome.diagnosticLogging.description%",
"default": true,
"deprecationMessage": "'diagnosticLogging' is deprecated. Use 'trace' instead."
},
"verboseDiagnosticLogging": {
"type": "boolean",
"description": "When true, the adapter logs all traffic with the client and target (as well as the info logged by 'diagnosticLogging')",
"description": "%chrome.verboseDiagnosticLogging.description%",
"default": true,
"deprecationMessage": "'verboseDiagnosticLogging' is deprecated. Use 'trace' instead."
},
@ -307,56 +312,56 @@
true
],
"default": true,
"description": "When 'true', the debugger will log tracing info to a file. When 'verbose', it will also show logs in the console."
"description": "%chrome.trace.description%"
},
"url": {
"type": "string",
"description": "Will search for a tab with this EXACT url and attach to it, if found",
"description": "%chrome.url.description%",
"default": "http://localhost:8080"
},
"webRoot": {
"type": "string",
"description": "This specifies the workspace absolute path to the webserver root. Used to resolve paths like `/app.js` to files on disk. Shorthand for a pathMapping for \"/\"",
"description": "%chrome.webRoot.description%",
"default": "${workspaceRoot}"
},
"pathMapping": {
"type": "object",
"description": "A mapping of URLs/paths to local folders, to resolve scripts in Chrome to scripts on disk",
"description": "%chrome.pathMapping.description%",
"default": {}
},
"sourceMapPathOverrides": {
"type": "object",
"description": "A set of mappings for rewriting the locations of source files from what the sourcemap says, to their locations on disk. See README for details.",
"description": "%chrome.sourceMapPathOverrides.description%",
"default": {}
},
"smartStep": {
"type": "boolean",
"description": "Automatically step through generated code that cannot be mapped back to the original source.",
"description": "%chrome.smartStep.description%",
"default": true
},
"skipFiles": {
"type": "array",
"description": "An array of file or folder names, or path globs, to skip when debugging.",
"description": "%chrome.skipFiles.description%",
"default": []
},
"timeout": {
"type": "number",
"description": "Retry for this number of milliseconds to connect to Chrome. Default is 10000 ms.",
"description": "%chrome.timeout.description%",
"default": 10000
},
"disableNetworkCache": {
"type": "boolean",
"description": "Controls whether to skip the network cache for each request",
"description": "%chrome.disableNetworkCache.description%",
"default": true
},
"urlFilter": {
"type": "string",
"description": "Will search for a page with this url and attach to it, if found. Can have * wildcards.",
"description": "%chrome.urlFilter.description%",
"default": ""
},
"showAsyncStacks": {
"type": "boolean",
"description": "Show the async calls that led to the current call stack",
"description": "%chrome.showAsyncStacks.description%",
"default": true
}
}
@ -376,7 +381,7 @@
"commands": [
{
"command": "extension.chrome-debug.toggleSkippingFile",
"title": "Toggle Skipping This File"
"title": "%chrome.toggleSkipping.title%"
}
],
"keybindings": [

28
package.nls.json Normal file
Просмотреть файл

@ -0,0 +1,28 @@
{
"extension.description": "Debug your JavaScript code in the Chrome browser, or any other target that supports the Chrome Debugger protocol.",
"chrome.toggleSkipping.title": "Toggle Skipping This File",
"chrome.port.description": "Port to use for Chrome remote debugging.",
"chrome.address.description": "TCP/IP address of debug port",
"chrome.file.description": "A local html file to open in the browser",
"chrome.url.description": "Will search for a tab with this EXACT url and attach to it, if found",
"chrome.webRoot.description": "This specifies the workspace absolute path to the webserver root. Used to resolve paths like `/app.js` to files on disk. Shorthand for a pathMapping for \"/\"",
"chrome.pathMapping.description": "A mapping of URLs/paths to local folders, to resolve scripts in Chrome to scripts on disk",
"chrome.runtimeExecutable.description": "Workspace absolute path to the runtime executable to be used. If not specified, Chrome will be used from the default install location.",
"chrome.runtimeArgs.description": "Optional arguments passed to the runtime executable.",
"chrome.env.description": "Optional dictionary of environment key/value pairs.",
"chrome.cwd.description": "Optional working directory for the runtime executable.",
"chrome.sourceMaps.description": "Use JavaScript source maps (if they exist).",
"chrome.diagnosticLogging.description": "When true, the adapter logs its own diagnostic info to the console in a human readable format",
"chrome.verboseDiagnosticLogging.description": "When true, the adapter logs all traffic with the client and target (as well as the info logged by 'diagnosticLogging')",
"chrome.trace.description": "When 'true', the debugger will log tracing info to a file. When 'verbose', it will also show logs in the console.",
"chrome.userDataDir.description": "By default, Chrome is launched with a separate user profile in a temp folder. Use this option to override it. Set to false to launch with your default user profile.",
"chrome.sourceMapPathOverrides.description": "A set of mappings for rewriting the locations of source files from what the sourcemap says, to their locations on disk. See README for details.",
"chrome.smartStep.description": "Automatically step through generated code that cannot be mapped back to the original source.",
"chrome.skipFiles.description": "An array of file or folder names, or path globs, to skip when debugging.",
"chrome.timeout.description": "Retry for this number of milliseconds to connect to Chrome. Default is 10000 ms.",
"chrome.disableNetworkCache.description": "Controls whether to skip the network cache for each request",
"chrome.urlFilter.description": "Will search for a page with this url and attach to it, if found. Can have * wildcards.",
"chrome.showAsyncStacks.description": "Show the async calls that led to the current call stack"
}

Просмотреть файл

@ -15,6 +15,9 @@ import {ILaunchRequestArgs, IAttachRequestArgs, ICommonRequestArgs} from './chro
import * as utils from './utils';
import * as errors from './errors';
import * as nls from 'vscode-nls';
const localize = nls.config(process.env.VSCODE_NLS_CONFIG)();
const DefaultWebSourceMapPathOverrides: ISourceMapPathOverrides = {
'webpack:///./~/*': '${webRoot}/node_modules/*',
'webpack:///./*': '${webRoot}/*',
@ -52,7 +55,7 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
runtimeExecutable = runtimeExecutable || utils.getBrowserPath();
if (!runtimeExecutable) {
return coreUtils.errP(`Can't find Chrome - install it or set the "runtimeExecutable" field in the launch config.`);
return coreUtils.errP(localize('attribute.chrome.missing', "Can't find Chrome - install it or set the \"runtimeExecutable\" field in the launch config."));
}
// Start with remote debugging enabled

Просмотреть файл

@ -4,7 +4,8 @@
import { DebugProtocol } from 'vscode-debugprotocol';
import { localize } from './utils';
import * as nls from 'vscode-nls';
const localize = nls.config(process.env.VSCODE_NLS_CONFIG)();
/**
* 'Path does not exist' error

Просмотреть файл

@ -7,6 +7,9 @@ import * as Core from 'vscode-chrome-debug-core';
import {targetFilter} from './utils';
import * as nls from 'vscode-nls';
const localize = nls.config(process.env.VSCODE_NLS_CONFIG)();
export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.commands.registerCommand('extension.chrome-debug.toggleSkippingFile', toggleSkippingFile));
@ -17,11 +20,11 @@ export function deactivate() {
}
const DEFAULT_CONFIG = {
type: "chrome",
request: "launch",
name: "Launch Chrome against localhost",
url: "http://localhost:8080",
webRoot: "${workspaceRoot}"
type: 'chrome',
request: 'launch',
name: localize('chrome.launch.name', "Launch Chrome against localhost"),
url: 'http://localhost:8080',
webRoot: '${workspaceRoot}'
};
export class ChromeConfigurationProvider implements vscode.DebugConfigurationProvider {
@ -87,7 +90,8 @@ async function pickTarget(targets: Core.chromeConnection.ITarget[]): Promise<ITa
websocketDebuggerUrl: target.webSocketDebuggerUrl
}));
const selected = await vscode.window.showQuickPick(items, { placeHolder: 'Select a tab', matchOnDescription: true, matchOnDetail: true });
const placeHolder = localize('chrome.targets.placeholder', "Select a tab");
const selected = await vscode.window.showQuickPick(items, { placeHolder, matchOnDescription: true, matchOnDetail: true });
return selected;
}

Просмотреть файл

@ -66,14 +66,3 @@ export class DebounceHelper {
export const targetFilter: chromeConnection.ITargetFilter =
target => target && (!target.type || target.type === 'page');
/**
* Placeholder localize function
*/
export function localize(id: string, msg: string, ...args: any[]): string {
args.forEach((arg, i) => {
msg = msg.replace(new RegExp(`\\{${i}\\}`, 'g'), arg);
});
return msg;
}

2
testapp/.vscode/tasks.json поставляемый
Просмотреть файл

@ -3,7 +3,7 @@
"tasks": [
{
"type": "gulp",
"task": "buildAndServe",
"task": "watch",
"group": {
"kind": "build",
"isDefault": true