forked from eduardokeneeth/oracle-commerce-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (69 loc) · 2.03 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env node
require('dotenv').config();
const program = require('commander');
const { setup } = require('./src/setup');
const { dev } = require('./src/dev');
const { occEnv } = require('./src/occEnv');
const { dcu } = require('./src/dcu');
const { ccw } = require('./src/ccw');
program
.version(require('./package.json').version)
.description('An application to help you with your daily OCC development.')
.option('-s, --start', 'start the environment setup')
.option('-d, --dev', 'start watcher + Browsersync')
.option('-c, --create <type>', 'create widget or element [widget|element]')
.option('-r, --refresh <path>', 'refresh path')
.option('-p, --putAll <path>', 'upload the entire path')
.option('-e, --env <operation>', 'start the environment manager [change|config|current]')
.option('-t, --transfer <path>', 'transfer widgets between current and target environment')
.option('-g, --grab', 'start grab on the current environment.')
.parse(process.argv);
if (program.start) {
setup.start();
} else {
if (occEnv.validate()) {
if (program.dev) {
dev.start();
}
if(program.grab) {
dcu.grab();
}
if (program.refresh) {
dcu.refresh(program.refresh);
}
if (program.putAll) {
dcu.putAll(program.putAll);
}
if (program.transfer) {
dcu.transfer(program.transfer);
}
if (program.create) {
switch (program.create) {
case 'widget':
ccw.createWidget();
break;
case 'element':
ccw.createElement();
break;
}
}
if (program.env) {
switch (program.env) {
case 'config':
occEnv.config();
break;
case 'change':
occEnv.change();
break;
case 'current':
const {
env, url, appKey
} = occEnv.get();
console.log(`Environment: ${env}\nURL: ${url}\nKEY: ${appKey}`);
break;
}
}
} else {
console.log('You need to start the project first.');
}
}