forked from Njs2/njs2-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·110 lines (92 loc) · 2.86 KB
/
cli.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
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
#!/usr/bin/env node
let CLI_KEYS = {};
let CLI_ARGS = [];
for (let i = 0; i < process.argv.slice(2).length; i++) {
if (process.argv.slice(2)[i].split("--").length > 1) {
CLI_KEYS[process.argv.slice(2)[i].split("--")[1]] =
process.argv.slice(2)[i + 1];
i++;
} else {
CLI_ARGS.push(process.argv.slice(2)[i]);
}
}
const CMD = CLI_ARGS[0];
CLI_ARGS = CLI_ARGS.slice(1);
switch (CMD) {
case "project":
// Create new project
require("./helper/new-project").execute(CLI_KEYS, CLI_ARGS);
break;
case "endpoint":
// Create new endpoint
require("./helper/create-endpoint").execute(CLI_KEYS, CLI_ARGS);
break;
case "run":
require("./helper/run").execute(CLI_KEYS, CLI_ARGS);
break;
case "plugin":
// Plugin related actions will be handled here
require("./helper/plugin-commands").execute(CLI_KEYS, CLI_ARGS);
break;
// create library files
case "library":
require("./helper/create-library").execute(CLI_KEYS, CLI_ARGS);
break;
case "upgrade":
require("./helper/upgrade-project").execute(CLI_KEYS, CLI_ARGS);
break;
// case "plugin-local":
// // Install Locally Developed Private plugins to project
// require("./helper/install-plugin-local-testing").execute(CLI_KEYS, CLI_ARGS);
// break;
// case "plugin":
// // Install plugins to project
// require("./helper/install-plugin").execute(CLI_KEYS, CLI_ARGS);
// break;
// case "rm-plugin":
// require("./helper/uninstall-plugin").execute(CLI_KEYS, CLI_ARGS);
// break;
// case "compile":
// // Complie plugins and create build
// require("./helper/compile-plugin").execute(CLI_KEYS, CLI_ARGS);
// break;
// case "compile-all":
// // Compile plugins and create build
// require("./helper/compile-all-plugin").execute(CLI_KEYS, CLI_ARGS);
// break;
// create plugin
// case "create-plugin":
// require("./helper/create-plugin").execute(CLI_KEYS, CLI_ARGS);
// break;
// case "install":
// require("./helper/install-private-plugin").execute(CLI_KEYS, CLI_ARGS);
// break;
case "help":
console.log(`
njs2 project <project-name> [version] [version-number]
njs2 endpoint <endpoint-name>
njs2 run serverless
njs2 run express
njs2 run nodemon
njs2 plugin <plugin-name>
njs2 plugin uninstall <plugin-name>
njs2 plugin compile
njs2 plugin install [<plugin-name>]
njs2 library <folder-name> <filename> <options : [sql,mongo]>
njs2 upgrade [version] [version-number]`);
break;
default:
console.log(`
njs2 project <project-name> [version] [version-number]
njs2 endpoint <endpoint-name>
njs2 run serverless
njs2 run express
njs2 run nodemon
njs2 plugin <plugin-name>
njs2 plugin uninstall <plugin-name>
njs2 plugin compile
njs2 plugin install [<plugin-name>]
njs2 library <folder-name> <filename> <options : [sql,mongo]>
njs2 upgrade [version] [version-number]`);
break;
}