build the structure of the extension
This commit is contained in:
80
src/main.js
Normal file
80
src/main.js
Normal file
@@ -0,0 +1,80 @@
|
||||
import * as utils from './utils';
|
||||
|
||||
import QuickAccessTreeProvider from './views/quick-access-tree';
|
||||
import vscode from 'vscode';
|
||||
|
||||
class SuperIDEExtension {
|
||||
constructor() {
|
||||
this.siHome = undefined;
|
||||
this.context = undefined;
|
||||
this.subscriptions = [];
|
||||
}
|
||||
|
||||
async activate(context) {
|
||||
this.context = context;
|
||||
|
||||
this.subscriptions.push(
|
||||
vscode.window.registerTreeDataProvider(
|
||||
'superide.quickAccess',
|
||||
new QuickAccessTreeProvider()
|
||||
)
|
||||
);
|
||||
|
||||
this.registerGlobalCommands();
|
||||
|
||||
this.startSuperIDEHome();
|
||||
}
|
||||
|
||||
async startSuperIDEHome() {
|
||||
vscode.commands.executeCommand('superide.showHome');
|
||||
}
|
||||
|
||||
firstConnect(host, username, password, port, publicKey) {
|
||||
const ssh = new NodeSSH();
|
||||
ssh.connect({
|
||||
host: host,
|
||||
username: username,
|
||||
password: password,
|
||||
port: port
|
||||
}).then(() => {
|
||||
console.log('Connected successfully');
|
||||
ssh.execCommand(`mkdir ~/.ssh &&
|
||||
touch ~/.ssh/authorized_keys &&
|
||||
echo ${publicKey} >> ~/.ssh/authorized_keys`, )
|
||||
.then(result => {
|
||||
if (result.stdout) console.log('STDOUT: ' + result.stdout);
|
||||
if (result.stderr) console.log('STDERR: ' + result.stderr);
|
||||
});
|
||||
}).catch(error => {
|
||||
console.log('Error: ', error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
registerGlobalCommands() {
|
||||
this.subscriptions.push(
|
||||
vscode.commands.registerCommand('superide.showHome', (startUrl) =>
|
||||
this.siHome.toggle(startUrl)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
disposeSubscriptions() {
|
||||
utils.disposeSubscriptions(this.subscriptions);
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
this.disposeSubscriptions();
|
||||
}
|
||||
}
|
||||
|
||||
export const extension = new SuperIDEExtension();
|
||||
|
||||
export function activate(context) {
|
||||
extension.activate(context);
|
||||
return extension;
|
||||
}
|
||||
|
||||
export function deactivate() {
|
||||
extension.deactivate();
|
||||
}
|
Reference in New Issue
Block a user