dashcam 0.6.2 → 0.7.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/README.md +51 -27
- package/index.js +16 -1
- package/lib.js +57 -5
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -18,36 +18,46 @@ Options:
|
|
|
18
18
|
-h, --help display help for command
|
|
19
19
|
|
|
20
20
|
Commands:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
auth <api-key> Authenticate the dashcam desktop using a team's apiKey
|
|
22
|
+
create [options] Create a clip and output the resulting url or markdown. Will launch desktop app for local editing before publishing.
|
|
23
|
+
record [options] Start a recording terminal to be included in your dashcam video recording
|
|
24
|
+
pipe Pipe command output to dashcam to be included in recorded video
|
|
24
25
|
track [options] Add a logs config to Dashcam
|
|
25
|
-
start
|
|
26
|
-
help [command]
|
|
26
|
+
start Start instant replay recording on dashcam
|
|
27
|
+
help [command] display help for command
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
## Table of contents
|
|
30
31
|
|
|
31
|
-
- [CLI](#cli)
|
|
32
|
-
|
|
33
|
-
- [
|
|
34
|
-
|
|
35
|
-
- [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
- [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
- [
|
|
47
|
-
- [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
- [Dashcam CLI](#dashcam-cli)
|
|
33
|
+
- [Manual](#manual)
|
|
34
|
+
- [Table of contents](#table-of-contents)
|
|
35
|
+
- [Examples](#examples)
|
|
36
|
+
- [CLI](#cli)
|
|
37
|
+
- [Setup](#setup)
|
|
38
|
+
- [Auth](#auth)
|
|
39
|
+
- [Record CLI](#record-cli)
|
|
40
|
+
- [Pipe command output into dashcam for recording](#pipe-command-output-into-dashcam-for-recording)
|
|
41
|
+
- [Create a Replay](#create-a-replay)
|
|
42
|
+
- [Return a rich markdown link](#return-a-rich-markdown-link)
|
|
43
|
+
- [Set a replay title](#set-a-replay-title)
|
|
44
|
+
- [Set a project to publish to](#set-a-project-to-publish-to)
|
|
45
|
+
- [Attach the last 20 CLI commands to the replay](#attach-the-last-20-cli-commands-to-the-replay)
|
|
46
|
+
- [Attach a logfile to the replay](#attach-a-logfile-to-the-replay)
|
|
47
|
+
- [GitHub CLI](#github-cli)
|
|
48
|
+
- [Create a github issue with a replay in the description](#create-a-github-issue-with-a-replay-in-the-description)
|
|
49
|
+
- [Create a github pull request with a replay in the description](#create-a-github-pull-request-with-a-replay-in-the-description)
|
|
50
|
+
- [Append a 30 second replay to a commit](#append-a-30-second-replay-to-a-commit)
|
|
51
|
+
- [Advanced Usage](#advanced-usage)
|
|
52
|
+
- [Web](#web)
|
|
53
|
+
- [Setup](#setup-1)
|
|
54
|
+
- [HTML Anchor Tag](#html-anchor-tag)
|
|
55
|
+
- [JS Error Handler](#js-error-handler)
|
|
56
|
+
- [NodeJS SDK](#nodejs-sdk)
|
|
57
|
+
- [Setup](#setup-2)
|
|
58
|
+
- [Create a Replay](#create-a-replay-1)
|
|
59
|
+
- [Error Handler](#error-handler)
|
|
60
|
+
- [Ideas](#ideas)
|
|
51
61
|
|
|
52
62
|
# Examples
|
|
53
63
|
|
|
@@ -61,7 +71,15 @@ Also see [the examples folder](https://github.com/replayableio/cli/tree/main/exa
|
|
|
61
71
|
npm install dashcam -g
|
|
62
72
|
```
|
|
63
73
|
|
|
64
|
-
|
|
74
|
+
### Auth
|
|
75
|
+
|
|
76
|
+
To authenticate the Dashcam desktop app using a team's Api key, Use the following command
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
dashcam auth <Api-Key>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Record CLI
|
|
65
83
|
|
|
66
84
|
To record the CLI in the Dashcam app, use the following command
|
|
67
85
|
|
|
@@ -91,7 +109,7 @@ To record the output of a command in the Dashcam app (In this example the `ping
|
|
|
91
109
|
ping 1.1.1.1 | dashcam pipe
|
|
92
110
|
```
|
|
93
111
|
|
|
94
|
-
|
|
112
|
+
## Create a Replay
|
|
95
113
|
|
|
96
114
|
```sh
|
|
97
115
|
$ dashcam
|
|
@@ -114,6 +132,12 @@ Watch [Dashcam - New Replay](https://dashcam.io/replay/123?share=xyz) on Dashcam
|
|
|
114
132
|
$ dashcam -t "My New Title"
|
|
115
133
|
```
|
|
116
134
|
|
|
135
|
+
### Set a project to publish to
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
$ dashcam -k wef8we72h23012j
|
|
139
|
+
```
|
|
140
|
+
|
|
117
141
|
### Attach the last 20 CLI commands to the replay
|
|
118
142
|
|
|
119
143
|
```sh
|
package/index.js
CHANGED
|
@@ -22,6 +22,17 @@ program
|
|
|
22
22
|
|
|
23
23
|
program.showHelpAfterError();
|
|
24
24
|
|
|
25
|
+
program
|
|
26
|
+
.command("auth")
|
|
27
|
+
.argument("<api-key>", "The team's ApiKey")
|
|
28
|
+
.description("Authenticate the dashcam desktop using a team's apiKey")
|
|
29
|
+
.action(async function (apiKey) {
|
|
30
|
+
await lib
|
|
31
|
+
.sendApiKey(apiKey)
|
|
32
|
+
.then(() => process.exit())
|
|
33
|
+
.catch(() => process.exit(1));
|
|
34
|
+
});
|
|
35
|
+
|
|
25
36
|
program
|
|
26
37
|
.command("create", { isDefault: true })
|
|
27
38
|
.description(
|
|
@@ -41,6 +52,10 @@ program
|
|
|
41
52
|
"-p, --publish",
|
|
42
53
|
"Whether to publish the clip instantly after creation or not."
|
|
43
54
|
)
|
|
55
|
+
.option(
|
|
56
|
+
"-k, --project [string]",
|
|
57
|
+
"The project id to which to publish the replay"
|
|
58
|
+
)
|
|
44
59
|
.action(async function (str, options) {
|
|
45
60
|
try {
|
|
46
61
|
let description = this.opts().description;
|
|
@@ -51,11 +66,11 @@ program
|
|
|
51
66
|
let result = await lib.createClip({
|
|
52
67
|
title: this.opts().title,
|
|
53
68
|
description,
|
|
54
|
-
private: this.opts().private,
|
|
55
69
|
md: this.opts().md,
|
|
56
70
|
publish: this.opts().publish,
|
|
57
71
|
capture: !this.opts().replay,
|
|
58
72
|
png: this.opts().png,
|
|
73
|
+
project: this.opts().project,
|
|
59
74
|
});
|
|
60
75
|
console.log(result);
|
|
61
76
|
} catch (e) {
|
package/lib.js
CHANGED
|
@@ -12,10 +12,17 @@ const persistantIPC = new ipc.IPC();
|
|
|
12
12
|
persistantIPC.config.retry = 500;
|
|
13
13
|
persistantIPC.config.silent = true;
|
|
14
14
|
|
|
15
|
-
const connectToIpc = function () {
|
|
15
|
+
const connectToIpc = function (timeout) {
|
|
16
16
|
return new Promise((resolve, reject) => {
|
|
17
|
+
let timeoutToClean;
|
|
17
18
|
ipc.connectTo("dashcam");
|
|
18
|
-
ipc.of.dashcam.on("connect",
|
|
19
|
+
ipc.of.dashcam.on("connect", () => {
|
|
20
|
+
console.log(
|
|
21
|
+
clc.green("Connected to Dashcam!")
|
|
22
|
+
);
|
|
23
|
+
resolve();
|
|
24
|
+
if (timeoutToClean) clearTimeout(timeoutToClean);
|
|
25
|
+
});
|
|
19
26
|
ipc.of.dashcam.on("error", (e) => {
|
|
20
27
|
if (e.code === "ENOENT") {
|
|
21
28
|
console.log(
|
|
@@ -26,11 +33,28 @@ const connectToIpc = function () {
|
|
|
26
33
|
"You may need to download and install the app from https://bit.ly/3ipoQLJ"
|
|
27
34
|
)
|
|
28
35
|
);
|
|
36
|
+
reject();
|
|
37
|
+
} else {
|
|
38
|
+
console.log(e);
|
|
29
39
|
}
|
|
30
40
|
});
|
|
31
41
|
ipc.of.dashcam.on("disconnect", function () {
|
|
32
|
-
console.log("Disconnected from Dashcam");
|
|
42
|
+
console.log(clc.red("Disconnected from Dashcam"));
|
|
43
|
+
reject();
|
|
33
44
|
});
|
|
45
|
+
if (timeout && typeof timeout === "number") {
|
|
46
|
+
timeoutToClean = setTimeout(() => {
|
|
47
|
+
console.log(
|
|
48
|
+
clc.red("Could not connect to Dashcam Desktop App. Is it running?")
|
|
49
|
+
);
|
|
50
|
+
console.log(
|
|
51
|
+
clc.yellow(
|
|
52
|
+
"You may need to download and install the app from https://bit.ly/3ipoQLJ"
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
reject();
|
|
56
|
+
}, timeout);
|
|
57
|
+
}
|
|
34
58
|
});
|
|
35
59
|
};
|
|
36
60
|
|
|
@@ -54,17 +78,23 @@ const createClip = async function (options = {}) {
|
|
|
54
78
|
}
|
|
55
79
|
}
|
|
56
80
|
);
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
ipc.of.dashcam.on("error", (e) => {
|
|
84
|
+
console.log(e);
|
|
85
|
+
});
|
|
57
86
|
|
|
58
87
|
setTimeout(() => {
|
|
59
88
|
reject(
|
|
60
89
|
"Dashcam Desktop App did not respond in time. Did you publish a clip?"
|
|
61
90
|
);
|
|
62
|
-
}, 60000 *
|
|
91
|
+
}, 60000 * 10);
|
|
63
92
|
|
|
64
93
|
const replay = {
|
|
65
94
|
title: options.title,
|
|
66
95
|
description: options.description,
|
|
67
96
|
publish: options.publish,
|
|
97
|
+
project: options.project,
|
|
68
98
|
capture: options.capture,
|
|
69
99
|
};
|
|
70
100
|
|
|
@@ -93,6 +123,25 @@ const startRecording = async function (isCapture = false) {
|
|
|
93
123
|
});
|
|
94
124
|
};
|
|
95
125
|
|
|
126
|
+
const sendApiKey = async function (apiKey) {
|
|
127
|
+
return new Promise(async (resolve, reject) => {
|
|
128
|
+
await connectToIpc(5000).catch(reject);
|
|
129
|
+
ipc.of.dashcam.emit("auth", { apiKey });
|
|
130
|
+
ipc.of.dashcam.on("auth-state", ({success, user}) => {
|
|
131
|
+
if (success) {
|
|
132
|
+
console.log(clc.green(`Connected as: ${user?.sub}!`));
|
|
133
|
+
return resolve();
|
|
134
|
+
}
|
|
135
|
+
console.log(clc.red("Could not authenticate using the ApiKey"));
|
|
136
|
+
reject();
|
|
137
|
+
});
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
console.log(clc.red("Could not authenticate using the ApiKey"));
|
|
140
|
+
reject();
|
|
141
|
+
}, 10000);
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
|
|
96
145
|
let singleInstance = null;
|
|
97
146
|
class PersistantDashcamIPC {
|
|
98
147
|
#isConnected = false;
|
|
@@ -110,9 +159,11 @@ class PersistantDashcamIPC {
|
|
|
110
159
|
this.onConnected();
|
|
111
160
|
});
|
|
112
161
|
persistantIPC.of.dashcam.on("disconnect", () => {
|
|
162
|
+
console.log('disconnected')
|
|
113
163
|
this.#isConnected = false;
|
|
114
164
|
});
|
|
115
|
-
persistantIPC.of.dashcam.on("error", () => {
|
|
165
|
+
persistantIPC.of.dashcam.on("error", (e) => {
|
|
166
|
+
console.log(e)
|
|
116
167
|
this.#isConnected = false;
|
|
117
168
|
});
|
|
118
169
|
}
|
|
@@ -136,6 +187,7 @@ const addLogsConfig = async (options) => {
|
|
|
136
187
|
};
|
|
137
188
|
|
|
138
189
|
module.exports = {
|
|
190
|
+
sendApiKey,
|
|
139
191
|
createClip,
|
|
140
192
|
addLogsConfig,
|
|
141
193
|
getLogFilePath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dashcam",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Fix bugs, close pulls, and update your team with desktop instant replay.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,5 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"husky": "^7.0.0"
|
|
26
|
+
},
|
|
27
|
+
"volta": {
|
|
28
|
+
"node": "16.20.2"
|
|
26
29
|
}
|
|
27
30
|
}
|