Skip to content

Commit 5d115f4

Browse files
committed
extension: use new extension terminal api
VS Code 1.39 introduced a new terminal API that does everything the shell helper program did. So, now we can drop the standalone executable and the shell helper program.
1 parent 5bb6e05 commit 5d115f4

File tree

14 files changed

+47
-283
lines changed

14 files changed

+47
-283
lines changed

.gitattributes

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
native/win32/helper.exe filter=lfs diff=lfs merge=lfs -text
2-
31
* text eol=lf
42
*.png binary
5-
native/**/* binary

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
out
22
node_modules
3-
.nexe
43

54
# built extension packages
65
*.vsix

.vscodeignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
.README/
2-
.nexe/**
32
.vscode/**
43
.vscode-test/**
54
out/test/**
65
src/**
76
.gitattributes
87
.gitignore
9-
build-native.*
108
vsc-extension-quickstart.md
119
**/tsconfig.json
1210
**/tslint.json

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to the "ev3dev-browser" extension will be documented in this
33

44
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
55

6+
## Unreleased
7+
### Changed
8+
- SSH shell no longer requires native executable on Windows
9+
610
## 1.0.4 - 2019-04-26
711
### Fixed
812
- Fix "Timed out while waiting for handshake" error

build-native.bat

Lines changed: 0 additions & 13 deletions
This file was deleted.

build-native.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

native/win32/helper.exe

Lines changed: 0 additions & 3 deletions
This file was deleted.

package-lock.json

Lines changed: 1 addition & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"url": "https://github.com/ev3dev/vscode-ev3dev-browser/issues"
1515
},
1616
"engines": {
17-
"vscode": "^1.30.0"
17+
"vscode": "^1.39.0"
1818
},
1919
"categories": [
2020
"Other"
@@ -394,7 +394,6 @@
394394
"bonjour": "^3.5.0",
395395
"compare-versions": "^3.0.1",
396396
"dbus-native": "^0.2.2",
397-
"dnode": "^1.2.2",
398397
"ssh2": "~0.5.5",
399398
"ssh2-streams": "~0.1.19",
400399
"temp": "^0.8.3",

src/device.ts

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
import * as dnode from 'dnode';
2-
import * as net from 'net';
31
import * as path from 'path';
42
import * as os from 'os';
53
import * as readline from 'readline';
64
import * as ssh2 from 'ssh2';
75
import * as ssh2Streams from 'ssh2-streams';
8-
import * as stream from 'stream';
96
import * as vscode from 'vscode';
107
import * as Observable from 'zen-observable';
118

129
import { Brickd } from './brickd';
1310
import * as dnssd from './dnssd';
14-
import { Shell } from './native-helper/shell';
1511

1612
/**
1713
* Object that represents a remote ev3dev device.
1814
*/
1915
export class Device extends vscode.Disposable {
2016
private readonly client: ssh2.Client;
2117
private sftp?: ssh2.SFTPWrapper;
22-
private shellServer?: net.Server;
2318
private _homeDirectoryAttr?: ssh2Streams.Attributes;
2419
private _isConnecting = false;
2520
private _isConnected = false;
@@ -92,7 +87,6 @@ export class Device extends vscode.Disposable {
9287
try {
9388
this.sftp = await this.getSftp();
9489
this._homeDirectoryAttr = await this.stat(this.homeDirectoryPath);
95-
this.shellServer = await this.createServer();
9690
this._isConnecting = false;
9791
this._isConnected = true;
9892
this._onDidConnect.fire();
@@ -152,64 +146,11 @@ export class Device extends vscode.Disposable {
152146
});
153147
}
154148

155-
private createServer(): Promise<net.Server> {
156-
return new Promise((resolve, reject) => {
157-
const server = net.createServer(socket => {
158-
const d = dnode<Shell>({
159-
shell: (ttySettings, dataOut, dataErr, ready, exit) => {
160-
this.shell(ttySettings).then(ch => {
161-
(<stream.Readable>ch.stdout).on('data', data => {
162-
dataOut(data.toString('base64'));
163-
});
164-
ch.stderr.on('data', data => {
165-
dataErr((<Buffer> data).toString('base64'));
166-
});
167-
ch.on('error', (err: any) => {
168-
vscode.window.showErrorMessage(`SSH connection error: ${err.message}`);
169-
exit();
170-
ch.destroy();
171-
d.destroy();
172-
});
173-
ch.on('close', () => {
174-
exit();
175-
ch.destroy();
176-
d.destroy();
177-
});
178-
ready((rows, cols) => {
179-
// resize callback
180-
ch.setWindow(rows, cols, 0, 0);
181-
}, data => {
182-
// dataIn callback
183-
ch.stdin.write(Buffer.from(data, 'base64'));
184-
});
185-
});
186-
}
187-
}, {
188-
// weak requires native module, which we can't use in vscode
189-
weak: false
190-
});
191-
socket.on('error', err => {
192-
// TODO: not sure what to do here.
193-
// The default dnode implementation only ignores EPIPE.
194-
// On Windows, we can also get ECONNRESET when a client disconnects.
195-
});
196-
socket.pipe(d).pipe(socket);
197-
});
198-
server.listen(0, '127.0.0.1');
199-
server.once('listening', () => resolve(server));
200-
server.once('error', reject);
201-
});
202-
}
203-
204149
/**
205150
* Disconnect from the device.
206151
*/
207152
public disconnect(): void {
208153
this._isConnected = false;
209-
if (this.shellServer) {
210-
this.shellServer.close();
211-
this.shellServer = undefined;
212-
}
213154
if (this.sftp) {
214155
this.sftp.end();
215156
this.sftp = undefined;
@@ -256,16 +197,6 @@ export class Device extends vscode.Disposable {
256197
return this.service.txt['ev3dev.robot.home'] || `/home/${this.username}`;
257198
}
258199

259-
/**
260-
* Gets the TCP port where the shell server is listening.
261-
*/
262-
public get shellPort(): number {
263-
if (!this.shellServer) {
264-
throw new Error('Not connected');
265-
}
266-
return this.shellServer.address().port;
267-
}
268-
269200
/**
270201
* Sets file permissions.
271202
* @param path The path to a file or directory

0 commit comments

Comments
 (0)