commit aee853f236ad57c5ac1600e3275e011367119825 Author: Rob Lourens Date: Mon Jun 13 20:44:34 2016 -0700 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cf836a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +node_modules/ +out/ +lib/ +*.vsix +vscode-chrome-debug.txt +typings/ +.browse.VC.db \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f305a5a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + "version": "0.1.0", + "configurations": [ + { + "name": "launch as server", + "type": "node", + "request": "launch", + "cwd": "${workspaceRoot}", + "program": "${workspaceRoot}/out/src/nodeDebug.js", + "runtimeArgs": ["--harmony"], + "stopOnEntry": false, + "args": [ "--server=4712" ], + "sourceMaps": true, + "outDir": "${workspaceRoot}/out" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7c3a67a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "editor.insertSpaces": true, + "files.trimTrailingWhitespace": true, + "files.exclude": { + ".git": true, + "bin": true, + "node_modules": false + }, + "search.exclude": { + ".git": true, + "node_modules": true, + "bin": true, + "out": true + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..0b6433d --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,21 @@ +{ + "version": "0.1.0", + "command": "gulp", + "isShellCommand": true, + "tasks": [ + { + "taskName": "watch", + "args": [], + "isBuildCommand": true, + "isWatching": true, + "problemMatcher": [ + "$tsc" + ] + }, + { + "taskName": "watch-build-test", + "isWatching": true, + "isTestCommand": true + } + ] +} \ No newline at end of file diff --git a/.vscodeignore b/.vscodeignore new file mode 100644 index 0000000..4253891 --- /dev/null +++ b/.vscodeignore @@ -0,0 +1,19 @@ +**/*.ts +**/*.map +.vscode/** +typings/** +*.vsix +gulpfile.js +tsconfig.json +tsd.json +tslint.json +vscode-chrome-debug.txt + +node_modules/.bin/** +node_modules/bufferutil/** +node_modules/utf-8-validate/** +node_modules/vscode-chrome-debug-core/node_modules/ws/node_modules/bufferutil/** +node_modules/vscode-chrome-debug-core/node_modules/ws/node_modules/utf-8-validate/** + +node_modules/vscode-chrome-debug-core/out/test/** +node_modules/vscode-chrome-debug-core/typings/** \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..b38c41a --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,13 @@ +VS Code - Debugger for Chrome + +Copyright (c) Microsoft Corporation + +All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..7e00c3b --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# vscode-node-cdp-debug +This is a prototype of a debug adapter for VS Code that can target Node, using the Chrome Debugging Protocol. At the moment, this is only supported in Node v7. It's based on the vscode-debug-chrome-core library. + +## How to run +Clone this repo, run npm install. Open the directory in Code and press ctrl+shift+b to build and F5 to run as a debug server. + +Open your app's directory in Code and set up a launch config. It should look something like this: + +``` +{ + "version": "0.2.0", + "debugServer": "4712", // To use the vscode-node-cdp-debug server, instead of vscode's built in Node debugger + "configurations": [ + { + "name": "Node", + "type": "chrome", + "request": "attach", + "port": 9229, + "sourceMaps": true, + "webRoot": "${workspaceRoot}" + // "diagnosticLogging": true // May be useful for debugging + } + ] +} +``` + +Start your app using "node --inspect". Press F5 in Code to attach. \ No newline at end of file diff --git a/ThirdPartyNotices.txt b/ThirdPartyNotices.txt new file mode 100644 index 0000000..995a3cf --- /dev/null +++ b/ThirdPartyNotices.txt @@ -0,0 +1,13 @@ +This project may use or incorporate third party material from the projects listed below. The original copyright notice and the license under which Microsoft received such third party material are set forth below. Microsoft reserves all other rights not expressly granted, whether by implication, estoppel or otherwise. + +websockets-ws + +(The MIT License) + +Copyright (c) 2011 Einar Otto Stangvik + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..d485e16 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,55 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +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 tslint = require('gulp-tslint'); + +const sources = [ + 'src', + 'typings/main' +].map(function(tsFolder) { return tsFolder + '/**/*.ts'; }); + +const lintSources = [ + 'src' +].map(function(tsFolder) { return tsFolder + '/**/*.ts'; }); + +const projectConfig = { + noImplicitAny: false, + target: 'ES5', + module: 'commonjs', + declaration: true, + typescript, + outDir: 'out' +}; + +function computeSourceRoot(file) { + return path.relative(path.dirname(file.path), __dirname); +} + +const tsProject = ts.createProject(projectConfig); +gulp.task('build', function () { + return gulp.src(sources, { base: '.' }) + .pipe(sourcemaps.init()) + .pipe(ts(projectConfig)).js + .pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: computeSourceRoot })) + .pipe(gulp.dest('out')); +}); + +gulp.task('watch', ['build'], function(cb) { + log('Watching build sources...'); + return gulp.watch(sources, ['build']); +}); + +gulp.task('default', ['build']); + +gulp.task('tslint', function() { + return gulp.src(lintSources, { base: '.' }) + .pipe(tslint()) + .pipe(tslint.report('verbose')); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..d415f49 --- /dev/null +++ b/package.json @@ -0,0 +1,103 @@ +{ + "name": "vscode-node-cdp-debug", + "displayName": "Node Debugger via CDP", + "version": "0.0.1", + "description": "Debug Node using the Chrome Debug Protocol", + "publisher": "microsoft", + "engines": { + "vscode": "*" + }, + "categories": [ + "Debuggers" + ], + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "vscode-chrome-debug-core": "0.1.2" + }, + "devDependencies": { + "gulp": "^3.9.1", + "gulp-sourcemaps": "^1.5.2", + "gulp-tslint": "^3.3.1", + "gulp-typescript": "^2.12.1", + "gulp-util": "^3.0.5", + "tslint": "^2.5.1", + "typescript": "^1.8.9", + "typings": "^0.7.12" + }, + "scripts": { + "postinstall": "typings install" + }, + "contributes": { + "debuggers": [ + { + "type": "node", + "label": "Node.js via CDP", + "enableBreakpointsFor": { + "languageIds": [ + "javascript", + "typescriptreact", + "javascriptreact" + ] + }, + "program": "./out/src/nodeDebug.js", + "runtime": "node", + "initialConfigurations": [ + ], + "configurationAttributes": { + "launch": { + "required": [], + "properties": { + "port": { + "type": "number", + "description": "Debug port to attach to.", + "default": 9222 + }, + "sourceMaps": { + "type": "boolean", + "description": "Use JavaScript source maps (if they exist).", + "default": true + }, + "diagnosticLogging": { + "type": "boolean", + "description": "When true, the adapter logs its own diagnostic info to the console", + "default": true + }, + "verboseDiagnosticLogging": { + "type": "boolean", + "description": "When true, the adapter logs all traffic with the client and target (as well as the info logged by 'diagnosticLogging')", + "default": true + } + } + }, + "attach": { + "required": [ + "port" + ], + "properties": { + "port": { + "type": "number", + "description": "Debug port to attach to.", + "default": 9222 + }, + "sourceMaps": { + "type": "boolean", + "description": "Use JavaScript source maps (if they exist).", + "default": true + }, + "diagnosticLogging": { + "type": "boolean", + "description": "When true, the adapter logs its own diagnostic info to the console", + "default": true + }, + "verboseDiagnosticLogging": { + "type": "boolean", + "description": "When true, the adapter logs all traffic with the client and target (as well as the info logged by 'diagnosticLogging')", + "default": true + } + } + } + } + } + ] + } +} diff --git a/src/nodeDebug.ts b/src/nodeDebug.ts new file mode 100644 index 0000000..83ac59c --- /dev/null +++ b/src/nodeDebug.ts @@ -0,0 +1,7 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import {ChromeDebugSession} from 'vscode-chrome-debug-core'; + +ChromeDebugSession.run(ChromeDebugSession); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..a1dc18c --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "module": "commonjs", + "noImplicitAny": false, + "removeComments": false, + "target": "ES5", + "sourceMap": true, + "outDir": "out" + }, + "exclude": [ + "node_modules", + "testapp/node_modules", + "typings/browser" + ] +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..6db6c9d --- /dev/null +++ b/tslint.json @@ -0,0 +1,111 @@ +{ + "rules": { + "align": [ + true, + "parameters", + "statements" + ], + "ban": false, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": false, + "forin": true, + "indent": [ + true, + "spaces" + ], + "jsdoc-format": true, + "label-position": true, + "label-undefined": true, + "max-line-length": [ + false, + 140 + ], + "member-access": true, + "member-ordering": [ + true, + "variables-before-functions" + ], + "no-any": false, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-eval": true, + "no-inferrable-types": false, + "no-internal-module": true, + "no-keyword-named-variables": true, + "no-require-imports": false, + "no-shadowed-variable": true, + "no-string-literal": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unreachable": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "no-var-requires": true, + "object-literal-sort-keys": true, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [ + true, + "single" + ], + "radix": true, + "semicolon": true, + "switch-default": true, + "trailing-comma": [ + true, + { + "multiline": "always", + "singleline": "never" + } + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} + diff --git a/typings.json b/typings.json new file mode 100644 index 0000000..59e509f --- /dev/null +++ b/typings.json @@ -0,0 +1,7 @@ +{ + "ambientDependencies": { + "es6-collections": "registry:dt/es6-collections#0.5.1+20160316155526", + "es6-promise": "registry:dt/es6-promise#0.0.0+20160423074304", + "node": "registry:dt/node#4.0.0+20160423143914" + } +}