-
Notifications
You must be signed in to change notification settings - Fork 2
/
vg.js
68 lines (62 loc) · 1.99 KB
/
vg.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
#!/usr/bin/env node
const { program } = require('commander');
const CreateUnitTest = require('./handlers/CreateUnitTest');
program.version('0.0.1');
const CreateVueComponent = require('./handlers/CreateVueComponent');
const { CreateVuexModule } = require('./handlers/CreateVuexModule');
const CreateVuexStore = require('./handlers/CreateVuexStore');
const displayHelp = require('./handlers/DisplayHelp');
/**
* Handling the vg component command
*/
program
.command('component <filename>')
.description('Create a Vue component')
.option('-d, --data', 'Component should include data object')
.option('-m, --methods', 'Component should include methods')
.option('-s, --scss', 'Component should use SCSS')
.option('-x, --axios', 'Component should contain an axios import')
.option('-a, --all', 'All of the above options are added')
.option('-t, --test', 'Create a unit test for your component')
.action((filename, options) => {
if (options.help) {
return displayHelp();
}
CreateVueComponent(filename, options);
});
/**
* Handling the vg vuexmod command
*/
program
.command('vuexmod <modulename>')
.description('Creates a Vuex module')
.action(modulename => {
CreateVuexModule(modulename);
});
/**
* Handling the vg store command
*/
program
.command('store')
.description('Sets up a Vuex store, using the Vuex modules structure')
.option('-m, --module <name>', 'Lets the user enter name of a first module')
.action((options) => {
let modulename = options.module;
CreateVuexStore(modulename);
});
program
.command('test <unitname>')
.description('Sets up a unitname.spec.js file in the tests folder')
.action(unitname => {
CreateUnitTest(unitname);
})
/**
* Handling the vg help command
*/
program
.command('help')
.description('Displays all available commands and their flags')
.action(() => {
displayHelp();
});
program.parse(process.argv);