dashcam 0.4.4 → 0.5.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.
Files changed (4) hide show
  1. package/README.md +8 -0
  2. package/index.js +31 -1
  3. package/lib.js +9 -5
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -55,6 +55,14 @@ Anything you type in your terminal will appear in your dash. To exit, simply typ
55
55
  exit
56
56
  ```
57
57
 
58
+ ## Pipe command output into dashcam for recording
59
+
60
+ To record the output of a command in the Dashcam app (In this example the `ping 1.1.1.1` command ), use the following command
61
+
62
+ ```
63
+ ping 1.1.1.1 | dashcam pipe
64
+ ```
65
+
58
66
  ### Create a Replay
59
67
 
60
68
  ```sh
package/index.js CHANGED
@@ -36,6 +36,10 @@ program
36
36
  "Markdown body. This may also be piped in: `cat README.md | dashcam create`"
37
37
  )
38
38
  .option("--md", "Returns code for a rich markdown image link.")
39
+ .option(
40
+ "-p, --publish",
41
+ "Whether to publish the clip instantly after creation or not."
42
+ )
39
43
  .action(async function (str, options) {
40
44
  try {
41
45
  let description = this.opts().description;
@@ -48,8 +52,10 @@ program
48
52
  description,
49
53
  private: this.opts().private,
50
54
  md: this.opts().md,
55
+ publish: this.opts().publish,
51
56
  png: this.opts().png,
52
57
  });
58
+ console.log(result);
53
59
  } catch (e) {
54
60
  console.log("Error: ", e);
55
61
  }
@@ -77,6 +83,30 @@ program
77
83
  }
78
84
  });
79
85
 
86
+ program
87
+ .command("pipe")
88
+ .description(
89
+ "Pipe command output to dashcam to be included in recorded video"
90
+ )
91
+ .action(async function () {
92
+ try {
93
+ const dashcam = new lib.PersistantDashcamIPC();
94
+ const id = crypto.randomUUID();
95
+ const logFile = lib.getLogFilePath(id);
96
+
97
+ dashcam.onConnected = () => dashcam.emit("track-cli", logFile);
98
+ fs.appendFileSync(logFile, "");
99
+ process.stdin.on("data", (data) => {
100
+ process.stdout.write(data);
101
+ fs.appendFileSync(logFile, data);
102
+ });
103
+ process.stdin.on("close", () => process.exit());
104
+ process.stdin.on("error", () => process.exit(1));
105
+ } catch (e) {
106
+ console.log("Error: ", e);
107
+ }
108
+ });
109
+
80
110
  program
81
111
  .command("start")
82
112
  .description("Start instant replay recording on dashcam")
@@ -90,7 +120,7 @@ program
90
120
  }
91
121
  });
92
122
 
93
- if (process.stdin.isTTY) {
123
+ if (process.stdin.isTTY || process.argv[2] === "pipe") {
94
124
  program.parse(process.argv);
95
125
  } else {
96
126
  process.stdin.on("error", function () {});
package/lib.js CHANGED
@@ -36,6 +36,7 @@ const connectToIpc = function () {
36
36
 
37
37
  const createReplay = async function (options = {}) {
38
38
  options.md = options.md || false;
39
+ options.publish = options.publish || false;
39
40
 
40
41
  options.title = options.title || false;
41
42
  options.description = options.description || null;
@@ -46,7 +47,7 @@ const createReplay = async function (options = {}) {
46
47
  ipc.of.dashcam.on(
47
48
  "upload", //any event or message type your server listens for
48
49
  function (data) {
49
- if (options.md) {
50
+ if (options.md && !options.publish) {
50
51
  resolve(data.replay.markdown);
51
52
  } else {
52
53
  resolve(data.replay.shareLink);
@@ -63,11 +64,14 @@ const createReplay = async function (options = {}) {
63
64
  const replay = {
64
65
  title: options.title,
65
66
  description: options.description,
67
+ publish: options.publish,
66
68
  };
67
69
 
68
70
  ipc.of.dashcam.emit("create", replay);
69
-
70
- resolve(replay);
71
+
72
+ if (!options.publish) {
73
+ resolve(replay);
74
+ }
71
75
  });
72
76
  };
73
77
 
@@ -81,9 +85,9 @@ const startInstantReplay = async function (options = {}) {
81
85
  }, 60000 * 5);
82
86
 
83
87
  ipc.of.dashcam.emit("start-instant-replay");
84
-
88
+
85
89
  resolve({
86
- started: true
90
+ started: true,
87
91
  });
88
92
  });
89
93
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashcam",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
4
4
  "description": "Fix bugs, close pulls, and update your team with desktop instant replay.",
5
5
  "main": "index.js",
6
6
  "scripts": {