@rpcbase/cli 0.5.0 → 0.8.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 +7 -2
- package/package.json +6 -5
- package/src/default_command.js +29 -7
- package/src/helpers/get_run_configs.js +17 -5
- package/src/update/index.js +0 -4
- package/src/auto/run_before.js +0 -3
- package/src/run_agent.js +0 -0
- 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
|
|
@@ -21,6 +20,12 @@ const args = yargs(hideBin(process.argv))
|
|
|
21
20
|
is_command = true
|
|
22
21
|
console.log("PING")
|
|
23
22
|
})
|
|
23
|
+
.option("coverage", {
|
|
24
|
+
alias: "c",
|
|
25
|
+
type: "boolean",
|
|
26
|
+
default: false,
|
|
27
|
+
description: "Adds coverage instrumentation (always disabled in production)"
|
|
28
|
+
})
|
|
24
29
|
// .option("version", {
|
|
25
30
|
// alias: "v",
|
|
26
31
|
// type: "boolean",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "SSPL-1.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"rb": "./bin.js"
|
|
@@ -11,10 +11,11 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"bluebird": "3.7.2",
|
|
13
13
|
"chalk": "4.1.2",
|
|
14
|
-
"concurrently": "7.
|
|
15
|
-
"
|
|
16
|
-
"
|
|
14
|
+
"concurrently": "7.2.1",
|
|
15
|
+
"debug": "4.3.4",
|
|
16
|
+
"dotenv": "16.0.1",
|
|
17
|
+
"semver": "7.3.7",
|
|
17
18
|
"validator": "13.7.0",
|
|
18
|
-
"yargs": "17.
|
|
19
|
+
"yargs": "17.5.1"
|
|
19
20
|
}
|
|
20
21
|
}
|
package/src/default_command.js
CHANGED
|
@@ -1,42 +1,59 @@
|
|
|
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")
|
|
5
6
|
const concurrently = require("concurrently")
|
|
6
7
|
|
|
8
|
+
const docker_runtime_check = require("./helpers/docker_runtime_check")
|
|
7
9
|
const exit_with_message = require("./helpers/exit_with_message")
|
|
8
10
|
const get_run_configs = require("./helpers/get_run_configs")
|
|
9
|
-
const docker_runtime_check = require("./helpers/docker_runtime_check")
|
|
10
11
|
const verify_project = require("./verify_project")
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
// TODO: nuke this
|
|
14
|
+
// server native + docker + docker-native is way too complex
|
|
15
|
+
// either everything is native, or everything is in docker
|
|
13
16
|
const default_command = async(args) => {
|
|
14
17
|
const run_configs = get_run_configs()
|
|
15
18
|
|
|
16
|
-
const run_commands =
|
|
19
|
+
const run_commands = []
|
|
20
|
+
run_configs.forEach((cfg) => {
|
|
17
21
|
let name
|
|
18
22
|
let command
|
|
19
23
|
let prefixColor
|
|
24
|
+
// client
|
|
20
25
|
if (cfg.type === "client") {
|
|
21
26
|
name = "client"
|
|
22
27
|
// command = "yarn dev"
|
|
23
28
|
command = "./node_modules/.bin/rb-webpack-browser dev"
|
|
24
29
|
prefixColor = "#C678DD"
|
|
30
|
+
// server
|
|
25
31
|
} else if (cfg.type === "server") {
|
|
26
32
|
name = "server"
|
|
27
33
|
command = "./node_modules/.bin/rb-server start"
|
|
28
34
|
prefixColor = "#61AFEF"
|
|
35
|
+
// agent
|
|
36
|
+
} else if (cfg.type === "agent") {
|
|
37
|
+
name = "agent"
|
|
38
|
+
command = "../server/node_modules/.bin/rb-server agent"
|
|
39
|
+
prefixColor = "#4DB33D"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// pass through coverage arg to client and server
|
|
43
|
+
if (["client", "server"].includes(cfg.type) && args.coverage) {
|
|
44
|
+
command = `${command} --coverage`
|
|
29
45
|
}
|
|
30
46
|
|
|
31
|
-
// command
|
|
32
|
-
|
|
47
|
+
// add command
|
|
48
|
+
run_commands.push({
|
|
33
49
|
name,
|
|
34
50
|
command,
|
|
35
51
|
prefixColor,
|
|
36
52
|
cwd: cfg.working_dir
|
|
37
|
-
}
|
|
53
|
+
})
|
|
38
54
|
})
|
|
39
55
|
|
|
56
|
+
// check if docker is running
|
|
40
57
|
if (run_configs.filter((c) => c.type === "server").length > 0) {
|
|
41
58
|
docker_runtime_check()
|
|
42
59
|
}
|
|
@@ -62,8 +79,13 @@ const default_command = async(args) => {
|
|
|
62
79
|
}
|
|
63
80
|
})
|
|
64
81
|
|
|
82
|
+
debug("run_configs", run_configs)
|
|
83
|
+
|
|
65
84
|
// asynchronously verify project config and kill process if any error
|
|
66
|
-
|
|
85
|
+
const configs = run_configs
|
|
86
|
+
.filter(({type}) => ["client", "server"].includes(type))
|
|
87
|
+
|
|
88
|
+
project_errors = await verify_project(configs)
|
|
67
89
|
|
|
68
90
|
if (project_errors.length > 0) {
|
|
69
91
|
commands.forEach((c) => {
|
|
@@ -5,11 +5,11 @@ const fs = require("fs")
|
|
|
5
5
|
const ERRORS = require("../errors")
|
|
6
6
|
const exit_with_message = require("./exit_with_message")
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
// run type is client | server | both
|
|
10
9
|
const get_run_configs = () => {
|
|
11
10
|
const cwd = process.cwd()
|
|
12
11
|
|
|
12
|
+
|
|
13
13
|
// check if running parent of rb project
|
|
14
14
|
const dir_contents = fs.readdirSync(cwd)
|
|
15
15
|
const is_parent_dir = dir_contents.includes("client") && dir_contents.includes("server")
|
|
@@ -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,18 @@ 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
|
+
]
|
|
60
|
+
} else {
|
|
61
|
+
console.log("TODO: server get_run_configs:handle edge case here")
|
|
50
62
|
}
|
|
51
63
|
}
|
|
52
64
|
|
package/src/update/index.js
CHANGED
package/src/auto/run_before.js
DELETED
package/src/run_agent.js
DELETED
|
File without changes
|
package/src/run_client.js
DELETED
package/src/run_server.js
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/* @flow */
|