-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
141 lines (136 loc) · 5.5 KB
/
Copy pathindex.js
File metadata and controls
141 lines (136 loc) · 5.5 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
'use strict';
const {version} = require('./package.json');
const {init, createModel, createService, createList, createDetail, updateModel, updateDetail, deleteModel} = require('./gulpfile');
const {elementTypes} = require('./resources/helpers/index');
const AngularCommands = {
init: 'init',
i: 'i',
generate: 'generate',
g: 'g',
update: 'update',
u: 'u',
delete: 'delete',
d: 'd',
help: 'help',
version: 'version'
};
const command = {
command: 'angular <command>',
action: (command, args) => {
const path = args.parent.rawArgs[0];
const schematic = args.parent.rawArgs[4];
const modelName = args.parent.rawArgs[5];
if (command === AngularCommands.help) {
showHelp();
} else if (schematic === AngularCommands.help) {
showHelp(command);
} else {
switch (command) {
case AngularCommands.init:
case AngularCommands.i:
if (schematic) {
init(schematic.toLowerCase());
} else {
console.log(`You must specify a name for the project.`);
}
break;
case AngularCommands.generate:
case AngularCommands.g:
switch (schematic) {
case elementTypes.MODEL:
createModel(modelName);
break;
case elementTypes.SERVICE:
createService(modelName);
break;
case elementTypes.DETAIL:
createDetail(modelName);
break;
case elementTypes.LIST:
createList(modelName);
break;
case AngularCommands.help:
showHelp(schematic);
break;
default:
console.log(`\nSchematic '${schematic}' does not exist on winkit angular generate!\n`);
break;
}
break;
case AngularCommands.update:
case AngularCommands.u:
switch (schematic) {
case elementTypes.MODEL:
updateModel(modelName);
break;
case elementTypes.DETAIL:
updateDetail(modelName);
break;
case AngularCommands.help:
showHelp(schematic);
break;
default:
console.log(`\nSchematic '${schematic}' does not exist on winkit angular generate!\n`);
break;
}
break;
case AngularCommands.delete:
case AngularCommands.d:
deleteModel(modelName);
break;
case AngularCommands.help:
showHelp();
break;
case AngularCommands.version:
console.log(version);
break;
default:
console.log(`\nCommand '${command}' does not exist on WDK Angular CLI!\n`);
break;
}
}
},
onHelp: () => {
showHelp();
}
};
function showHelp(command) {
switch (command) {
case AngularCommands.init:
case AngularCommands.i:
console.log('Usage: angular init|i <projectName>');
console.log('\nInitialize a new WDK Angular application.\n');
break;
case AngularCommands.generate:
case AngularCommands.g:
console.log('Usage: angular generate <component> <modelName>\n');
console.log('Available components commands:');
console.log(' model|m <modelName> : Generates new model.');
console.log(' service|s <modelName> : Generates new service.');
console.log(' detail|d <modelName> : Generates new detail component.');
console.log(' list|l <modelName> : Generates new list component.\n');
break;
case AngularCommands.update:
case AngularCommands.u:
console.log('Usage: angular update <component> <modelName>\n');
console.log('Available components commands:');
console.log(' model|m <modelName> : Update model and its server model.\n');
break;
case AngularCommands.delete:
case AngularCommands.d:
console.log('Usage: angular delete <modelName>\n');
break;
case AngularCommands.version:
break;
default:
console.log('Usage: angular <command> <component> <modelName>\n');
console.log('Available Commands:');
console.log(' init|i <projectName> : Initialize a new WDK Angular application.');
console.log(' generate|g <component> <modelName> : Generates files based on a schematic.');
console.log(' update|u <component> <modelName> : Updates your application and its dependencies.');
console.log(' version : version Outputs WDK Angular CLI version.');
console.log(' <command> help : Help.\n');
break;
}
}
module.exports = {command};