-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·56 lines (46 loc) · 1.86 KB
/
index.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
#!/usr/bin/env node
var chalk = require('chalk');
var figlet = require('figlet');
var commander = require('commander');
var treeify = require('treeify');
var path = require("path");
const packageJSONFile = require(path.join(__dirname, 'package.json'));
var getComponentDetails = require('./src/GetComponentDetails');
var createComponentSkeleton = require('./src/CreateComponent');
var updateVersionNumber = require('./src/UpdateVersionNumber');
var runGITCommand = require('./src/RunGitCommand');
var spinner = require('./src/Spinner');
commander
.version(packageJSONFile.version)
.option('-c, --createcomponent', 'use to create component')
.option('-u, --updateversion', 'use to bump up version number')
.parse(process.argv);
if (commander.createcomponent) {
getComponentDetails()
.then((arguments) => {
let userEnteredComponentName = arguments.componentname;
let componentName = userEnteredComponentName.charAt(0).toUpperCase() + userEnteredComponentName.slice(1)
let location = arguments.location;
const baseURL = 'src/Components/';
createComponentSkeleton(componentName, location, baseURL).then((data) => {
spinner(() => {
console.log(chalk.green("\n\nFollowing structure has been generated--\n"));
console.log(treeify.asTree(data, true));
console.log(chalk.yellow(figlet.textSync("done", { horizontalLayout: 'full' })));
})
});
}).catch((err) => {
console.log(chalk.red(err))
});
}
else if (commander.updateversion) {
updateVersionNumber()
.then((data) => {
console.log(chalk.yellow(figlet.textSync(data, { horizontalLayout: 'full' })));
}).catch((err) => {
console.log(chalk.red(err))
})
}
else {
commander.help()
}