@rpcbase/cli 0.11.0 → 0.14.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 +47 -22
- package/package.json +2 -2
- package/src/print_versions.js +15 -0
- package/src/{default_command.js → start_command.js} +14 -5
package/bin.js
CHANGED
|
@@ -1,39 +1,64 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* @flow */
|
|
3
3
|
process.title = "rb"
|
|
4
|
+
// load .env
|
|
4
5
|
const path = require("path")
|
|
5
|
-
require("dotenv").config({path: path.join(
|
|
6
|
+
require("dotenv").config({path: path.join(process.cwd(), "./.env")})
|
|
7
|
+
//
|
|
6
8
|
const yargs = require("yargs/yargs")
|
|
7
9
|
const {hideBin} = require("yargs/helpers")
|
|
8
10
|
|
|
9
|
-
const
|
|
11
|
+
const start_command = require("./src/start_command")
|
|
12
|
+
const print_versions = require("./src/print_versions")
|
|
10
13
|
const update = require("./src/update")
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
yargs(hideBin(process.argv))
|
|
16
|
+
.command(["start", "*"], "Starts client, server, and infrastructure", (yargs) => {
|
|
17
|
+
yargs
|
|
18
|
+
.option("coverage", {
|
|
19
|
+
alias: "c",
|
|
20
|
+
type: "boolean",
|
|
21
|
+
default: false,
|
|
22
|
+
description: "Adds coverage instrumentation (always disabled in production)"
|
|
23
|
+
})
|
|
24
|
+
.option("verbose", {
|
|
25
|
+
type: "boolean",
|
|
26
|
+
default: false,
|
|
27
|
+
description: "Run with verbose logging"
|
|
28
|
+
})
|
|
29
|
+
.option("debug", {
|
|
30
|
+
type: "boolean",
|
|
31
|
+
default: false,
|
|
32
|
+
description: "Run with debug logging"
|
|
33
|
+
})
|
|
34
|
+
}, (argv) => {
|
|
35
|
+
if (argv.version) return print_versions()
|
|
36
|
+
start_command(argv)
|
|
37
|
+
})
|
|
38
|
+
// Update
|
|
39
|
+
.command(["update", "up"], "Update rb dependencies to latest version", (yargs) => {
|
|
40
|
+
yargs
|
|
41
|
+
.option("dry-run", {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
default: false,
|
|
44
|
+
description: "Print output without writing any files"
|
|
45
|
+
})
|
|
46
|
+
}, async(argv) => {
|
|
47
|
+
if (argv.version) return print_versions()
|
|
17
48
|
await update()
|
|
18
49
|
})
|
|
50
|
+
// Ping
|
|
19
51
|
.command("ping", "Ping", () => {}, (argv) => {
|
|
20
|
-
|
|
52
|
+
if (argv.version) return print_versions()
|
|
21
53
|
console.log("PING")
|
|
22
54
|
})
|
|
23
|
-
|
|
24
|
-
|
|
55
|
+
// Global options
|
|
56
|
+
.version(false)
|
|
57
|
+
.option("version", {
|
|
58
|
+
alias: "v",
|
|
25
59
|
type: "boolean",
|
|
26
|
-
|
|
27
|
-
description: "Adds coverage instrumentation (always disabled in production)"
|
|
60
|
+
description: "Displays the @rpcbase/cli version"
|
|
28
61
|
})
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// type: "boolean",
|
|
32
|
-
// default: false,
|
|
33
|
-
// // description: "Displays CLI version"
|
|
34
|
-
// })
|
|
62
|
+
.help("h")
|
|
63
|
+
.alias("h", "help")
|
|
35
64
|
.parse()
|
|
36
|
-
|
|
37
|
-
if (!is_command) {
|
|
38
|
-
default_command(args)
|
|
39
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"license": "SSPL-1.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"rb": "./bin.js"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"bluebird": "3.7.2",
|
|
13
|
-
"concurrently": "7.
|
|
13
|
+
"concurrently": "7.3.0",
|
|
14
14
|
"debug": "4.3.4",
|
|
15
15
|
"dotenv": "16.0.1",
|
|
16
16
|
"picocolors": "1.0.0",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
const {execSync} = require("child_process")
|
|
3
|
+
|
|
4
|
+
const colors = require("picocolors")
|
|
5
|
+
|
|
6
|
+
const package = require("../package.json")
|
|
7
|
+
|
|
8
|
+
const print_versions = () => {
|
|
9
|
+
console.log(`${colors.cyan("rb")} v${package.version}`)
|
|
10
|
+
|
|
11
|
+
const node_out = execSync("node -v")
|
|
12
|
+
console.log(`${colors.green("node")} ${node_out.toString().trim()}`)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = print_versions
|
|
@@ -13,7 +13,7 @@ const verify_project = require("./verify_project")
|
|
|
13
13
|
// TODO: nuke this
|
|
14
14
|
// server native + docker + docker-native is way too complex
|
|
15
15
|
// either everything is native, or everything is in docker
|
|
16
|
-
const
|
|
16
|
+
const start_command = async(args) => {
|
|
17
17
|
const run_configs = get_run_configs()
|
|
18
18
|
|
|
19
19
|
const run_commands = []
|
|
@@ -39,11 +39,20 @@ const default_command = async(args) => {
|
|
|
39
39
|
prefixColor = "#4DB33D"
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
// pass through
|
|
43
|
-
if (["client", "server"].includes(cfg.type)
|
|
44
|
-
|
|
42
|
+
// pass through listed args to client and server
|
|
43
|
+
if (["client", "server"].includes(cfg.type)) {
|
|
44
|
+
if (args.coverage) {
|
|
45
|
+
command = `${command} --coverage`
|
|
46
|
+
}
|
|
47
|
+
if (args.debug) {
|
|
48
|
+
command = `${command} --debug`
|
|
49
|
+
}
|
|
50
|
+
if (args.verbose) {
|
|
51
|
+
command = `${command} --verbose`
|
|
52
|
+
}
|
|
45
53
|
}
|
|
46
54
|
|
|
55
|
+
|
|
47
56
|
// add command
|
|
48
57
|
run_commands.push({
|
|
49
58
|
name,
|
|
@@ -94,4 +103,4 @@ const default_command = async(args) => {
|
|
|
94
103
|
}
|
|
95
104
|
}
|
|
96
105
|
|
|
97
|
-
module.exports =
|
|
106
|
+
module.exports = start_command
|