Skip to content

Commit

Permalink
Add initial testbed
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaeumer committed Nov 27, 2019
1 parent 12b8b96 commit 03e4f34
Show file tree
Hide file tree
Showing 9 changed files with 620 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/client-tests/lib/test/**/*.js"],
"preLaunchTask": "watch:client"
},
{
"type": "extensionHost",
"request": "launch",
"name": "Launch TestBed Client",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"outFiles": ["${workspaceRoot}/testbed/client/out/**/*.js"],
"sourceMaps": true
},
{
"type": "node",
"request": "attach",
"name": "Attach to Server",
"port": 6012,
"restart": true,
"outFiles": ["${workspaceRoot}/testbed/server/out/**/*.js"],
"sourceMaps": true
}
]
}
18 changes: 18 additions & 0 deletions testbed/client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "testbed-client",
"description": "Testbed client",
"version": "0.1.0",
"private": true,
"publisher": "vscode",
"engines": {
"vscode": "^1.40.0"
},
"scripts": {
"watch": "tsc -watch -b ./tsconfig.json",
"compile": "tsc -b ./tsconfig.json"
},
"dependencies": {
},
"devDependencies": {
}
}
70 changes: 70 additions & 0 deletions testbed/client/src/extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';

import * as path from 'path';
import { commands, ExtensionContext, Uri } from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from '../../../client/lib/main';

let client: LanguageClient;

export function activate(context: ExtensionContext) {
// We need to go one level up since an extension compile the js code into
// the output folder.
let module = path.join(__dirname, '..', '..', 'server', 'out', 'server.js');
let debugOptions = { execArgv: ["--nolazy", "--inspect=6012"] };
let serverOptions: ServerOptions = {
run: { module, transport: TransportKind.ipc },
debug: { module, /* runtime: 'node.exe', */ transport: TransportKind.ipc, options: debugOptions}
};

let clientOptions: LanguageClientOptions = {
documentSelector: [
'bat',
{ pattern: '**/.vscode/test.txt', scheme: 'file' }
],
synchronize: {
configurationSection: 'testbed'
// fileEvents: workspace.createFileSystemWatcher('**/*'),
},
diagnosticCollectionName: 'markers',
initializationOptions: 'Chris it gets passed to the server',
progressOnInitialization: true,
stdioEncoding: 'utf8',
uriConverters: {
code2Protocol: (value: Uri) => {
return `vscode-${value.toString()}`
},
protocol2Code: (value: string) => {
return Uri.parse(value.substring(7))
}
},
middleware: {
didOpen: (document, next) => {
next(document);
}
}
}

client = new LanguageClient('testbed', 'Testbed', serverOptions, clientOptions);
client.registerProposedFeatures();
// let not: NotificationType<string[], void> = new NotificationType<string[], void>('testbed/notification');
client.onReady().then(() => {
client.sendNotification('testbed/notification', ['dirk', 'baeumer']);
});
client.onTelemetry((data: any) => {
console.log(`Telemetry event received: ${JSON.stringify(data)}`);
});
client.start();
commands.registerCommand('testbed.myCommand.invoked', () => {
commands.executeCommand('testbed.myCommand').then(value => {
console.log(value);
});
});
}

export function deactivate() {
return client.stop();
}
14 changes: 14 additions & 0 deletions testbed/client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"outDir": "out",
"rootDir": "src",
"lib": ["es2017"],
"sourceMap": true,
"incremental": true,
"tsBuildInfoFile":"./out/tsconfig.tsbuildInfo",
},
"include": ["src"],
"exclude": ["node_modules", ".vscode-test"]
}
43 changes: 43 additions & 0 deletions testbed/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "testbed",
"description": "testbed",
"version": "0.1.0",
"publisher": "vscode",
"engines": {
"vscode": "^1.33.0"
},
"main": "./client/out/extension",
"activationEvents": [
"onLanguage:bat"
],
"enableProposedApi": true,
"contributes": {
"commands": [
{
"command": "testbed.helloWorld",
"title": "Hello World"
}
],
"configuration": {
"type": "object",
"title": "TestBed configuration",
"properties": {
"testbed.enable": {
"type": "boolean",
"default": true,
"description": "Control whether eslint is enabled for JavaScript files or not."
},
"testbed.options": {
"type": "object",
"default": {},
"description": "The eslint options object to provide args to the eslint command."
}
}
}
},
"scripts": {
"compile": "tsc -b",
"clean": "tsc -b --clean",
"watch": "tsc -b -w"
}
}
13 changes: 13 additions & 0 deletions testbed/server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "testbed-server",
"version": "0.1.0",
"description": "TestBed Server",
"private": true,
"engines": {
"node": "*"
},
"scripts": {
"compile": "tsc -b ./tsconfig.json",
"watch": "tsc --watch -b ./tsconfig.json"
}
}
Loading

0 comments on commit 03e4f34

Please sign in to comment.