build the structure of the extension
This commit is contained in:
6
src/home.js
Normal file
6
src/home.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export default class SIHome {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
}
|
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();
|
||||
}
|
5
src/utils.js
Normal file
5
src/utils.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export function disposeSubscriptions(subscriptions) {
|
||||
while (subscriptions.length) {
|
||||
subscriptions.pop().dispose();
|
||||
}
|
||||
}
|
44
src/views/quick-access-tree.js
Normal file
44
src/views/quick-access-tree.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
class QuickItem extends vscode.TreeItem {
|
||||
constructor(label, command, args, collapsibleState, children) {
|
||||
super(label, collapsibleState);
|
||||
if (command) {
|
||||
this.command = {
|
||||
title: label,
|
||||
command,
|
||||
arguments: args,
|
||||
};
|
||||
}
|
||||
this.customChildren = children;
|
||||
}
|
||||
}
|
||||
|
||||
export default class QuickAccessTreeProvider {
|
||||
getChildren(element) {
|
||||
if (element && element.customChildren) {
|
||||
return element.customChildren;
|
||||
}
|
||||
|
||||
return [
|
||||
new QuickItem(
|
||||
'SuperIDE Home',
|
||||
undefined,
|
||||
undefined,
|
||||
vscode.TreeItemCollapsibleState.Expanded,
|
||||
[new QuickItem('Open', 'superide.showHome')]
|
||||
),
|
||||
new QuickItem(
|
||||
'Miscellaneous',
|
||||
undefined,
|
||||
undefined,
|
||||
vscode.TreeItemCollapsibleState.Expanded,
|
||||
[new QuickItem('hello', 'superide.hello')]
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
getTreeItem(element) {
|
||||
return element;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user