@rpcbase/cli 0.3.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.js +1 -2
- package/package.json +2 -1
- package/src/default_command.js +14 -1
- package/src/helpers/get_run_configs.js +14 -4
- package/src/update/index.js +0 -4
- package/src/verify_project/verify_env.js +14 -14
- package/src/auto/run_before.js +0 -3
- package/src/run_client.js +0 -5
- package/src/run_server.js +0 -0
- package/src/watch/client/index.js +0 -1
package/bin.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* @flow */
|
|
3
|
+
process.title = "rb"
|
|
3
4
|
const path = require("path")
|
|
4
5
|
require("dotenv").config({path: path.join(__dirname, "./.env")})
|
|
5
6
|
const yargs = require("yargs/yargs")
|
|
6
7
|
const {hideBin} = require("yargs/helpers")
|
|
7
8
|
|
|
8
9
|
const default_command = require("./src/default_command")
|
|
9
|
-
const run_client = require("./src/run_client")
|
|
10
|
-
const run_server = require("./src/run_server")
|
|
11
10
|
const update = require("./src/update")
|
|
12
11
|
|
|
13
12
|
let is_command = false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "SSPL-1.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"rb": "./bin.js"
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"bluebird": "3.7.2",
|
|
13
13
|
"chalk": "4.1.2",
|
|
14
14
|
"concurrently": "7.0.0",
|
|
15
|
+
"debug": "4.3.4",
|
|
15
16
|
"dotenv": "16.0.0",
|
|
16
17
|
"semver": "7.3.5",
|
|
17
18
|
"validator": "13.7.0",
|
package/src/default_command.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
+
const debug = require("debug")("rb-cli")
|
|
2
3
|
const path = require("path")
|
|
3
4
|
const fs = require("fs")
|
|
4
5
|
const chalk = require("chalk")
|
|
@@ -17,15 +18,22 @@ const default_command = async(args) => {
|
|
|
17
18
|
let name
|
|
18
19
|
let command
|
|
19
20
|
let prefixColor
|
|
21
|
+
// client
|
|
20
22
|
if (cfg.type === "client") {
|
|
21
23
|
name = "client"
|
|
22
24
|
// command = "yarn dev"
|
|
23
25
|
command = "./node_modules/.bin/rb-webpack-browser dev"
|
|
24
26
|
prefixColor = "#C678DD"
|
|
27
|
+
// server
|
|
25
28
|
} else if (cfg.type === "server") {
|
|
26
29
|
name = "server"
|
|
27
30
|
command = "./node_modules/.bin/rb-server start"
|
|
28
31
|
prefixColor = "#61AFEF"
|
|
32
|
+
// agent
|
|
33
|
+
} else if (cfg.type === "agent") {
|
|
34
|
+
name = "agent"
|
|
35
|
+
command = "../server/node_modules/.bin/rb-server agent"
|
|
36
|
+
prefixColor = "#4DB33D"
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
// command, name, prefixColor, env, cwd
|
|
@@ -62,8 +70,13 @@ const default_command = async(args) => {
|
|
|
62
70
|
}
|
|
63
71
|
})
|
|
64
72
|
|
|
73
|
+
debug("run_configs", run_configs)
|
|
74
|
+
|
|
65
75
|
// asynchronously verify project config and kill process if any error
|
|
66
|
-
|
|
76
|
+
const configs = run_configs
|
|
77
|
+
.filter(({type}) => ["client", "server"].includes(type))
|
|
78
|
+
|
|
79
|
+
project_errors = await verify_project(configs)
|
|
67
80
|
|
|
68
81
|
if (project_errors.length > 0) {
|
|
69
82
|
commands.forEach((c) => {
|
|
@@ -33,6 +33,10 @@ const get_run_configs = () => {
|
|
|
33
33
|
type: "server",
|
|
34
34
|
working_dir: path.join(cwd, "./server/server")
|
|
35
35
|
},
|
|
36
|
+
{
|
|
37
|
+
type: "agent",
|
|
38
|
+
working_dir: path.join(cwd, "./server/infrastructure")
|
|
39
|
+
},
|
|
36
40
|
]
|
|
37
41
|
} else {
|
|
38
42
|
// client
|
|
@@ -43,10 +47,16 @@ const get_run_configs = () => {
|
|
|
43
47
|
}]
|
|
44
48
|
// check if parent dir is also server, because we are in server/server
|
|
45
49
|
} else if (dir === "server" && path.basename(path.dirname(cwd)) === "server") {
|
|
46
|
-
return [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
return [
|
|
51
|
+
{
|
|
52
|
+
type: "server",
|
|
53
|
+
working_dir: cwd
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: "agent",
|
|
57
|
+
working_dir: path.join(cwd, "../infrastructure")
|
|
58
|
+
},
|
|
59
|
+
]
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
62
|
|
package/src/update/index.js
CHANGED
|
@@ -26,9 +26,9 @@ const SERVICES = [
|
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
|
-
name: "
|
|
29
|
+
name: "database",
|
|
30
30
|
required_env: {
|
|
31
|
-
"
|
|
31
|
+
"DATABASE_PORT": validate_port,
|
|
32
32
|
"DATABASE_NAME": (val) => {
|
|
33
33
|
if (!/^[$A-Z_][0-9A-Z_$-]*$/i.test(val)) {
|
|
34
34
|
return `expected ${chalk.bold(`'${val}'`)} to be a valid database name`
|
|
@@ -36,18 +36,18 @@ const SERVICES = [
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
39
|
+
// {
|
|
40
|
+
// name: "worker-queue",
|
|
41
|
+
// required_env: {
|
|
42
|
+
// "WORKER_QUEUE_PORT": validate_port
|
|
43
|
+
// },
|
|
44
|
+
// },
|
|
45
|
+
// {
|
|
46
|
+
// name: "session-store",
|
|
47
|
+
// required_env: {
|
|
48
|
+
// "SESSION_STORE_PORT": validate_port
|
|
49
|
+
// },
|
|
50
|
+
// },
|
|
51
51
|
]
|
|
52
52
|
|
|
53
53
|
|
package/src/auto/run_before.js
DELETED
package/src/run_client.js
DELETED
package/src/run_server.js
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/* @flow */
|