Skip to content

Commit f4cf9c5

Browse files
author
damu1de
committed
format, e2e, competion, test, generate
1 parent b711509 commit f4cf9c5

File tree

2 files changed

+141
-133
lines changed

2 files changed

+141
-133
lines changed

package.json

Lines changed: 82 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,83 @@
11
{
2-
"name": "vsc-angular-cli",
3-
"displayName": "vsc-angular-cli",
4-
"description": "run angular-cli commands from command pannel",
5-
"version": "0.0.5",
6-
"publisher": "web-dave",
7-
"engines": {
8-
"vscode": "^1.0.0"
9-
},
10-
"categories": [
11-
"Other"
12-
],
13-
"activationEvents": [
14-
"onCommand:extension.ngNew",
15-
"onCommand:extension.ngInit",
16-
"onCommand:extension.ngDoc",
17-
"onCommand:extension.ngLint",
18-
"onCommand:extension.ngServe",
19-
"onCommand:extension.ngVersion"
20-
],
21-
"bugs": {
22-
"url": "https://github.com/web-dave/vsc-angular-cli/issues"
23-
},
24-
"homepage": "https://github.com/web-dave/vsc-angular-cli/blob/master/README.md",
25-
"repository": {
26-
"type": "git",
27-
"url": "https://github.com/web-dave/vsc-angular-cli.git"
28-
},
29-
"main": "./out/src/extension",
30-
"contributes": {
31-
"commands": [
32-
{
33-
"command": "extension.ngNew",
34-
"title": "ng new"
35-
},
36-
{
37-
"command": "extension.ngInit",
38-
"title": "ng init"
39-
},
40-
{
41-
"command": "extension.ngDoc",
42-
"title": "ng doc"
43-
},
44-
{
45-
"command": "extension.ngLint",
46-
"title": "ng lint"
47-
},
48-
{
49-
"command": "extension.ngServe",
50-
"title": "ng serve"
51-
},
52-
{
53-
"command": "extension.ngFormat",
54-
"title": "ng format"
55-
},
56-
{
57-
"command": "extension.ngE2e",
58-
"title": "ng e2e"
59-
},
60-
{
61-
"command": "extension.ngCompletion",
62-
"title": "ng completion"
63-
},
64-
{
65-
"command": "extension.ngVersion",
66-
"title": "ng version"
67-
}
68-
]
69-
},
70-
"scripts": {
71-
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
72-
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./",
73-
"postinstall": "node ./node_modules/vscode/bin/install"
74-
},
75-
"devDependencies": {
76-
"typescript": "^1.8.5",
77-
"vscode": "^0.11.0"
78-
},
79-
"dependencies": {
80-
"run-in-terminal": "^0.0.2"
81-
}
82-
}
2+
"name": "vsc-angular-cli",
3+
"displayName": "vsc-angular-cli",
4+
"description": "run angular-cli commands from command pannel",
5+
"version": "0.0.5",
6+
"publisher": "web-dave",
7+
"engines": {
8+
"vscode": "^1.0.0"
9+
},
10+
"categories": [
11+
"Other"
12+
],
13+
"activationEvents": [
14+
"onCommand:extension.ngNew",
15+
"onCommand:extension.ngInit",
16+
"onCommand:extension.ngDoc",
17+
"onCommand:extension.ngLint",
18+
"onCommand:extension.ngServe",
19+
"onCommand:extension.ngVersion",
20+
"onCommand:extension.ngFormat",
21+
"onCommand:extension.ngE2e",
22+
"onCommand:extension.ngCompletion",
23+
"onCommand:extension.ngTest",
24+
"onCommand:extension.ngGenerate"
25+
],
26+
"bugs": {
27+
"url": "https://github.com/web-dave/vsc-angular-cli/issues"
28+
},
29+
"homepage": "https://github.com/web-dave/vsc-angular-cli/blob/master/README.md",
30+
"repository": {
31+
"type": "git",
32+
"url": "https://github.com/web-dave/vsc-angular-cli.git"
33+
},
34+
"main": "./out/src/extension",
35+
"contributes": {
36+
"commands": [{
37+
"command": "extension.ngNew",
38+
"title": "ng new"
39+
}, {
40+
"command": "extension.ngInit",
41+
"title": "ng init"
42+
}, {
43+
"command": "extension.ngDoc",
44+
"title": "ng doc"
45+
}, {
46+
"command": "extension.ngLint",
47+
"title": "ng lint"
48+
}, {
49+
"command": "extension.ngServe",
50+
"title": "ng serve"
51+
}, {
52+
"command": "extension.ngVersion",
53+
"title": "ng version"
54+
}, {
55+
"command": "extension.ngFormat",
56+
"title": "ng format"
57+
}, {
58+
"command": "extension.ngE2e",
59+
"title": "ng e2e"
60+
}, {
61+
"command": "extension.ngCompletion",
62+
"title": "ng completion"
63+
}, {
64+
"command": "extension.ngGenerate",
65+
"title": "ng generate"
66+
}, {
67+
"command": "extension.ngTest",
68+
"title": "ng test"
69+
}]
70+
},
71+
"scripts": {
72+
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
73+
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./",
74+
"postinstall": "node ./node_modules/vscode/bin/install"
75+
},
76+
"devDependencies": {
77+
"typescript": "^1.8.5",
78+
"vscode": "^0.11.0"
79+
},
80+
"dependencies": {
81+
"run-in-terminal": "^0.0.2"
82+
}
83+
}

src/extension.ts

Lines changed: 59 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import { runInTerminal } from 'run-in-terminal';
77
let outputChannel: vscode.OutputChannel;
88

99
export function activate(context: vscode.ExtensionContext) {
10-
registerCommands(context);
11-
outputChannel = vscode.window.createOutputChannel('ng');
12-
context.subscriptions.push(outputChannel);
13-
}
1410

15-
function registerCommands(context: vscode.ExtensionContext) {
16-
let child;
11+
// registerCommands(context);
12+
// outputChannel = vscode.window.createOutputChannel('ng');
13+
// context.subscriptions.push(outputChannel);
14+
// }
15+
16+
// function registerCommands(context: vscode.ExtensionContext) {
1717

1818
let ngnew = vscode.commands.registerCommand('extension.ngNew', () => {
1919
let project = vscode.window.showInputBox({ placeHolder: 'name of your project' }).then(
@@ -32,7 +32,7 @@ function registerCommands(context: vscode.ExtensionContext) {
3232
});
3333

3434
let ngversion = vscode.commands.registerCommand('extension.ngVersion', () => {
35-
child = cp.exec('ng version');
35+
let child = cp.exec('ng version');
3636
child.stdout.on('data', (data) => {
3737
console.log(data);
3838
});
@@ -66,12 +66,25 @@ function registerCommands(context: vscode.ExtensionContext) {
6666
runNgCommand(['format'], true);
6767
});
6868

69-
// let nggenerate = vscode.commands.registerCommand('extension.ngGenerate', () => {
70-
// child = cp.exec('ng generate');
71-
// child.stdout.on('data', (data) => {
72-
// vscode.window.showInformationMessage(data);
73-
// });
74-
// });
69+
let nggenerate = vscode.commands.registerCommand('extension.ngGenerate', () => {
70+
let param: string[] = ['generate']
71+
let items = ['component', 'directive', 'route', 'pipe', 'service'];
72+
let options = { matchOnDescription: false, placeHolder: "select Type" };
73+
vscode.window.showQuickPick(items, options).then((data) => {
74+
// vscode.window.showInformationMessage(data);
75+
param.push(data);
76+
vscode.window.showInputBox({ placeHolder: 'name of the ' + data }).then(
77+
(name) => {
78+
param.push(name);
79+
runNgCommand(param, false);
80+
}
81+
)
82+
})
83+
});
84+
85+
let ngtest = vscode.commands.registerCommand('extension.ngTest', () => {
86+
runNgCommand(['test'], false);
87+
});
7588

7689
// let ngget = vscode.commands.registerCommand('extension.ngGet', () => {
7790
// child = cp.exec('ng get');
@@ -95,12 +108,6 @@ function registerCommands(context: vscode.ExtensionContext) {
95108
// });
96109

97110

98-
// let ngtest = vscode.commands.registerCommand('extension.ngTest', () => {
99-
// child = cp.exec('ng test');
100-
// child.stdout.on('data', (data) => {
101-
// vscode.window.showInformationMessage(data);
102-
// });
103-
// });
104111

105112
context.subscriptions.push(ngnew);
106113
context.subscriptions.push(nginit);
@@ -111,46 +118,46 @@ function registerCommands(context: vscode.ExtensionContext) {
111118
context.subscriptions.push(ngformat);
112119
context.subscriptions.push(nge2e);
113120
context.subscriptions.push(ngcompletion);
121+
context.subscriptions.push(nggenerate);
122+
context.subscriptions.push(ngtest);
114123

115-
// context.subscriptions.push(nggenerate);
116-
// context.subscriptions.push(ngget);
117-
// context.subscriptions.push(ngset);
118-
// context.subscriptions.push(ngdeploy);
119-
// context.subscriptions.push(ngtest);
124+
// context.subscriptions.push(ngget);
125+
// context.subscriptions.push(ngset);
126+
// context.subscriptions.push(ngdeploy);
120127

121128

122-
function runCommandInOutputWindow(args: string[], cwd: string) {
123-
let cmd = 'ng ' + args.join(' ');
124-
let p = cp.exec(cmd, { cwd: cwd, env: process.env });
125-
p.stderr.on('data', (data: string) => {
126-
outputChannel.append(data);
127-
});
128-
p.stdout.on('data', (data: string) => {
129-
outputChannel.append(data);
130-
});
131-
showOutput();
132-
}
129+
outputChannel = vscode.window.createOutputChannel('ng');
130+
context.subscriptions.push(outputChannel);
133131

134-
function showOutput(): void {
135-
outputChannel.show(vscode.ViewColumn.Three);
136-
}
132+
}
133+
134+
function runCommandInOutputWindow(args: string[], cwd: string) {
135+
let cmd = 'ng ' + args.join(' ');
136+
let p = cp.exec(cmd, { cwd: cwd, env: process.env });
137+
p.stderr.on('data', (data: string) => {
138+
outputChannel.append(data);
139+
});
140+
p.stdout.on('data', (data: string) => {
141+
outputChannel.append(data);
142+
});
143+
showOutput();
144+
}
145+
146+
function showOutput(): void {
147+
outputChannel.show(vscode.ViewColumn.Three);
148+
}
137149

138-
function runNgCommand(args: string[], useTerminal?: boolean): void {
150+
function runNgCommand(args: string[], useTerminal?: boolean): void {
139151

140-
let cwd = vscode.workspace.rootPath;
152+
let cwd = vscode.workspace.rootPath;
141153

142-
if (useTerminal) {
143-
runCommandInTerminal(args, cwd);
144-
} else {
145-
runCommandInOutputWindow(args, cwd);
146-
}
147-
}
148-
function runCommandInTerminal(args: string[], cwd: string): void {
149-
runInTerminal('ng', args, { cwd: cwd, env: process.env });
154+
if (useTerminal) {
155+
runCommandInTerminal(args, cwd);
156+
} else {
157+
runCommandInOutputWindow(args, cwd);
150158
}
151-
152159
}
153160

154-
// this method is called when your extension is deactivated
155-
export function deactivate() {
156-
}
161+
function runCommandInTerminal(args: string[], cwd: string): void {
162+
runInTerminal('ng', args, { cwd: cwd, env: process.env });
163+
}

0 commit comments

Comments
 (0)