-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathextension.js
74 lines (67 loc) · 2.72 KB
/
extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const os = require('os');
const path = require('path');
const vscode = require('vscode');
const VueTreeDataProvider = require('./lib/VueTreeDataProvider');
const ReactTreeDataProvider = require('./lib/ReactTreeDataProvider');
const DocTreeDataProvider = require('./lib/DocTreeDataProvider');
const DownLoad = require('./lib/DownLoad');
const downLoad = new DownLoad();
function createCommand(context, name, callback) {
const command = vscode.commands.registerCommand(name, callback);
context.subscriptions.push(command);
}
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context) {
vscode.window.showInformationMessage('🎉🎉🎉 welcome to easy ! here is the [documents](https://github.com/easy-team) !');
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
createCommand(context, 'easy-vs-cli.openLink', function(url) {
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(url));
});
createCommand(context, 'easy-vs-cli.init', function(args) {
const conf = vscode.workspace.getConfiguration('easy') || {};
const root = conf.home || path.resolve(os.homedir(), 'easy', args);
vscode.window
.showInputBox({ value: root })
.then(value => {
if (!value) {
vscode.window.showErrorMessage('please input project dir path!');
return;
}
const projectDir = value.split(path.sep);
const projectName = projectDir.pop();
console.log('[projectDir] ', projectDir);
console.log('[projectName] ', projectName);
downLoad.init(projectDir.length ? projectDir.join('/') : root, projectName, args)
.then(project => {
vscode.commands.executeCommand(
'vscode.openFolder',
vscode.Uri.file(project),
false,
);
})
.catch(error => {
vscode.window.showErrorMessage(error && error.message || 'errors occurred!');
})
});
});
vscode.window.registerTreeDataProvider(
'easy-vs-cli.vue',
new VueTreeDataProvider(),
);
vscode.window.registerTreeDataProvider(
'easy-vs-cli.react',
new ReactTreeDataProvider(),
);
vscode.window.registerTreeDataProvider(
'easy-vs-cli.doc',
new DocTreeDataProvider(),
);
}
exports.activate = activate;
// this method is called when your extension is deactivated
function deactivate() {}
exports.deactivate = deactivate;