@rpcbase/cli 0.64.0 → 0.66.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",
@@ -65,9 +60,14 @@ yargs(hideBin(process.argv))
65
60
  default: false,
66
61
  description: "Print output without writing any files"
67
62
  })
63
+ .option("all", {
64
+ type: "boolean",
65
+ default: false,
66
+ description: "Doesn't filter @rpcbase/ dependencies, updates everything"
67
+ })
68
68
  }, async(argv) => {
69
69
  if (argv.version) return print_versions()
70
- await update()
70
+ await update(argv)
71
71
  })
72
72
  // Increment pkg
73
73
  .command(["increment-pkg <files...>"], "Bump a package version if necessary by checking its source on github", (yargs) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/cli",
3
- "version": "0.64.0",
3
+ "version": "0.66.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
 
@@ -18,7 +18,8 @@ const get_package_files = () => {
18
18
  return files
19
19
  }
20
20
 
21
- const get_outdated = async(dir) => {
21
+
22
+ const get_outdated = async({dir, all}) => {
22
23
 
23
24
  const output = execSync("npm outdated --json || true", {cwd: dir})
24
25
  const outdated = JSON.parse(output.toString())
@@ -27,7 +28,7 @@ const get_outdated = async(dir) => {
27
28
 
28
29
  Object.keys(outdated)
29
30
  // get our rpcbase packages only
30
- .filter((name) => name.startsWith("@rpcbase"))
31
+ .filter((name) => all ? true : name.startsWith("@rpcbase"))
31
32
  // skip if package is linked but already at latest version
32
33
  .filter((name) => {
33
34
  const version_data = outdated[name]
@@ -45,7 +46,7 @@ const get_outdated = async(dir) => {
45
46
  }
46
47
 
47
48
 
48
- const update = async() => {
49
+ const update = async(args) => {
49
50
  const working_dir = process.cwd()
50
51
 
51
52
  const package_files = get_package_files()
@@ -56,7 +57,7 @@ const update = async() => {
56
57
 
57
58
  console.log("updating", path.relative(working_dir, dir) || ".")
58
59
 
59
- const outdated = await get_outdated(dir)
60
+ const outdated = await get_outdated({dir, all: args.all})
60
61
 
61
62
  const package_json = JSON.parse(fs.readFileSync(package_file, "utf8"))
62
63
 
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