@rpcbase/cli 0.65.0 → 0.67.0-upgradefixes.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 CHANGED
@@ -26,11 +26,6 @@ yargs(hideBin(process.argv))
26
26
  default: false,
27
27
  description: "Adds coverage instrumentation (always disabled in production)"
28
28
  })
29
- .option("docker", {
30
- type: "boolean",
31
- default: false,
32
- description: "Run in docker"
33
- })
34
29
  .option("verbose", {
35
30
  type: "boolean",
36
31
  default: false,
@@ -46,7 +41,7 @@ yargs(hideBin(process.argv))
46
41
  start_command(argv)
47
42
  })
48
43
  .command(["agent"], "Run the agent", (yargs) => {
49
- yargs
44
+ // yargs
50
45
  // .option("option1", {
51
46
  // alias: "o",
52
47
  // type: "boolean",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/cli",
3
- "version": "0.65.0",
3
+ "version": "0.67.0-upgradefixes.0",
4
4
  "license": "SSPL-1.0",
5
5
  "bin": {
6
6
  "rb": "./bin.js"
@@ -10,15 +10,23 @@ const {hideBin} = require("yargs/helpers")
10
10
 
11
11
  const docker_runtime_check = require("./helpers/docker_runtime_check")
12
12
  const exit_with_message = require("./helpers/exit_with_message")
13
- const get_run_configs = require("./helpers/get_run_configs")
14
13
  const tailscale_tunnel = require("./helpers/tailscale_tunnel")
15
14
  const verify_project = require("./verify_project")
16
15
 
17
- // TODO: nuke this
18
- // server native + docker + docker-native is way too complex
19
- // either everything is native, or everything is in docker
16
+
20
17
  const start_command = async(args) => {
21
- const run_configs = get_run_configs(args)
18
+ const cwd = process.cwd()
19
+
20
+ const run_configs = [
21
+ {
22
+ type: "client",
23
+ working_dir: path.join(cwd, "./client")
24
+ },
25
+ {
26
+ type: "server",
27
+ working_dir: path.join(cwd, "./server/server")
28
+ },
29
+ ]
22
30
 
23
31
  const run_commands = []
24
32
 
@@ -61,18 +69,11 @@ const start_command = async(args) => {
61
69
  })
62
70
  })
63
71
 
64
- const has_server = run_configs.findIndex((c) => c.type === "server") > -1
72
+ // check if docker is installed and running
73
+ docker_runtime_check()
65
74
 
66
- // check if docker is running
67
- if (args.docker) {
68
- docker_runtime_check()
69
- }
70
-
71
- // check if we should run the tunnel
72
- // uses tailscale
73
- if (has_server) {
74
- tailscale_tunnel.start(run_configs)
75
- }
75
+ // start the tailscale tunnel
76
+ tailscale_tunnel.start(run_configs)
76
77
 
77
78
  let project_errors
78
79
 
@@ -110,14 +111,12 @@ const start_command = async(args) => {
110
111
  })
111
112
  }
112
113
 
113
-
114
114
  // server cmd to stop tailscale serve
115
115
  const server_command = commands.find((c) => c.name === "server")
116
- if (server_command) {
117
- server_command.process.on("close", () => {
118
- tailscale_tunnel.stop(run_configs)
119
- })
120
- }
116
+
117
+ server_command.process.on("close", () => {
118
+ tailscale_tunnel.stop(run_configs)
119
+ })
121
120
 
122
121
  }
123
122
 
@@ -66,8 +66,14 @@ const update = async(args) => {
66
66
  Object.keys(outdated).forEach((k) => {
67
67
  if (package_json.dependencies[k]) {
68
68
  package_json.dependencies[k] = outdated[k]
69
- console.log("updated", k, "to", outdated[k])
70
69
  has_updates = true
70
+ } else if (package_json.devDependencies[k]) {
71
+ package_json.devDependencies[k] = outdated[k]
72
+ has_updates = true
73
+ }
74
+
75
+ if (has_updates) {
76
+ console.log("updated", k, "to", outdated[k])
71
77
  }
72
78
  })
73
79
 
package/src/errors.js DELETED
@@ -1,8 +0,0 @@
1
- /* @flow */
2
- const colors = require("picocolors")
3
-
4
- const ERRORS = {
5
- INVALID_CWD: `expected to run in ${colors.cyan("client/")} or ${colors.cyan("server/server/")} or project root directory`
6
- }
7
-
8
- module.exports = ERRORS
@@ -1,76 +0,0 @@
1
- /* @flow */
2
- const path = require("path")
3
- const fs = require("fs")
4
-
5
- const ERRORS = require("../errors")
6
- const exit_with_message = require("./exit_with_message")
7
-
8
- // run type is client | server | both
9
- const get_run_configs = (args) => {
10
- const cwd = process.cwd()
11
-
12
- // check if running parent of rb project
13
- const dir_contents = fs.readdirSync(cwd)
14
- const is_parent_dir = dir_contents.includes("client") && dir_contents.includes("server")
15
-
16
- // check if rb is running in client or server
17
- const dir = path.basename(cwd)
18
- const is_rb_dir = ["client", "server"].includes(dir)
19
-
20
- if (!is_parent_dir && !is_rb_dir) {
21
- exit_with_message(ERRORS.INVALID_CWD)
22
- return
23
- }
24
-
25
- let run_configs
26
-
27
- if (is_parent_dir) {
28
- run_configs = [
29
- {
30
- type: "client",
31
- working_dir: path.join(cwd, "./client")
32
- },
33
- {
34
- type: "server",
35
- working_dir: path.join(cwd, "./server/server")
36
- },
37
- ]
38
- } else {
39
- // client
40
- if (dir === "client") {
41
- run_configs = [{
42
- type: "client",
43
- working_dir: cwd
44
- }]
45
- // check if parent dir is also server, because we are in server/server
46
- } else if (dir === "server" && path.basename(path.dirname(cwd)) === "server") {
47
- run_configs = [
48
- {
49
- type: "server",
50
- working_dir: cwd
51
- },
52
- ]
53
- } else {
54
- console.log("TODO: server get_run_configs:handle edge case here")
55
- console.log("process.cwd:", process.cwd())
56
- }
57
- }
58
-
59
- if (run_configs) {
60
- // check if there is server we add agent but in native mode only
61
- // in docker mode, the agent is a container
62
- const server = run_configs.find((rc) => rc.type === "server")
63
- if (server && !args.docker) {
64
- run_configs.push({
65
- type: "agent",
66
- working_dir: cwd,
67
- })
68
- }
69
- return run_configs
70
- }
71
-
72
- // fails when no match found
73
- exit_with_message(ERRORS.INVALID_CWD)
74
- }
75
-
76
- module.exports = get_run_configs