dashcam 1.0.1-beta.3 → 1.0.1-beta.5

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/dashcam.js CHANGED
@@ -171,12 +171,18 @@ program
171
171
  snapshotPath: stopResult.snapshotPath
172
172
  });
173
173
 
174
+ // Write upload result for stop command to read
175
+ processManager.writeUploadResult({
176
+ shareLink: uploadResult.shareLink,
177
+ replayId: uploadResult.replay?.id
178
+ });
179
+
174
180
  log('✅ Upload complete!');
175
181
  log('📹 Watch your recording:', uploadResult.shareLink);
176
182
  }
177
183
 
178
- // Clean up process files
179
- processManager.cleanup();
184
+ // Clean up process files, but preserve upload result for stop command
185
+ processManager.cleanup({ preserveResult: true });
180
186
  } catch (error) {
181
187
  logError('Error during shutdown:', error.message);
182
188
  logger.error('Error during shutdown:', error);
@@ -293,7 +299,6 @@ program
293
299
  }
294
300
 
295
301
  console.log('Recording stopped successfully');
296
- console.log('Output saved to:', result.outputPath);
297
302
 
298
303
  // Check if files still exist - if not, background process already uploaded
299
304
  const filesExist = fs.existsSync(result.outputPath) &&
@@ -301,8 +306,24 @@ program
301
306
  (!result.snapshotPath || fs.existsSync(result.snapshotPath));
302
307
 
303
308
  if (!filesExist) {
304
- console.log('✅ Recording was already uploaded by background process');
305
- console.log('✅ Recording stopped and uploaded');
309
+ // Files were deleted, meaning background process uploaded
310
+ // Wait for the upload result to be written
311
+ logger.debug('Waiting for upload result from background process');
312
+ await new Promise(resolve => setTimeout(resolve, 2000));
313
+
314
+ // Try to read the upload result from the background process
315
+ const uploadResult = processManager.readUploadResult();
316
+ logger.debug('Upload result read attempt', { found: !!uploadResult, shareLink: uploadResult?.shareLink });
317
+
318
+ if (uploadResult && uploadResult.shareLink) {
319
+ console.log('📹 Watch your recording:', uploadResult.shareLink);
320
+ // Clean up the result file now that we've read it
321
+ processManager.cleanup();
322
+ } else {
323
+ console.log('✅ Recording uploaded (share link not available)');
324
+ logger.warn('Upload result not available from background process');
325
+ }
326
+
306
327
  process.exit(0);
307
328
  }
308
329
 
@@ -321,7 +342,6 @@ program
321
342
  snapshotPath: result.snapshotPath
322
343
  });
323
344
 
324
- console.log('✅ Upload complete!');
325
345
  console.log('📹 Watch your recording:', uploadResult.shareLink);
326
346
  } catch (uploadError) {
327
347
  console.error('Upload failed:', uploadError.message);
@@ -8,6 +8,7 @@ import { logger } from './logger.js';
8
8
  const PROCESS_DIR = path.join(os.homedir(), '.dashcam-cli');
9
9
  const PID_FILE = path.join(PROCESS_DIR, 'recording.pid');
10
10
  const STATUS_FILE = path.join(PROCESS_DIR, 'status.json');
11
+ const RESULT_FILE = path.join(PROCESS_DIR, 'upload-result.json');
11
12
 
12
13
  // Ensure process directory exists
13
14
  if (!fs.existsSync(PROCESS_DIR)) {
@@ -47,6 +48,36 @@ class ProcessManager {
47
48
  }
48
49
  }
49
50
 
51
+ writeUploadResult(result) {
52
+ try {
53
+ logger.info('Writing upload result to file', { path: RESULT_FILE, shareLink: result.shareLink });
54
+ fs.writeFileSync(RESULT_FILE, JSON.stringify({
55
+ ...result,
56
+ timestamp: Date.now()
57
+ }, null, 2));
58
+ logger.info('Successfully wrote upload result to file');
59
+ // Verify it was written
60
+ if (fs.existsSync(RESULT_FILE)) {
61
+ logger.info('Verified upload result file exists');
62
+ } else {
63
+ logger.error('Upload result file does not exist after write!');
64
+ }
65
+ } catch (error) {
66
+ logger.error('Failed to write upload result file', { error });
67
+ }
68
+ }
69
+
70
+ readUploadResult() {
71
+ try {
72
+ if (!fs.existsSync(RESULT_FILE)) return null;
73
+ const data = fs.readFileSync(RESULT_FILE, 'utf8');
74
+ return JSON.parse(data);
75
+ } catch (error) {
76
+ logger.error('Failed to read upload result file', { error });
77
+ return null;
78
+ }
79
+ }
80
+
50
81
  writePid(pid = process.pid) {
51
82
  try {
52
83
  fs.writeFileSync(PID_FILE, pid.toString());
@@ -80,7 +111,8 @@ class ProcessManager {
80
111
  const status = this.readStatus();
81
112
 
82
113
  if (!pid || !this.isProcessRunning(pid)) {
83
- this.cleanup();
114
+ // Clean up but preserve upload result in case the background process just finished uploading
115
+ this.cleanup({ preserveResult: true });
84
116
  return false;
85
117
  }
86
118
 
@@ -92,10 +124,12 @@ class ProcessManager {
92
124
  return this.readStatus();
93
125
  }
94
126
 
95
- cleanup() {
127
+ cleanup(options = {}) {
128
+ const { preserveResult = false } = options;
96
129
  try {
97
130
  if (fs.existsSync(PID_FILE)) fs.unlinkSync(PID_FILE);
98
131
  if (fs.existsSync(STATUS_FILE)) fs.unlinkSync(STATUS_FILE);
132
+ if (!preserveResult && fs.existsSync(RESULT_FILE)) fs.unlinkSync(RESULT_FILE);
99
133
  } catch (error) {
100
134
  logger.error('Failed to cleanup process files', { error });
101
135
  }
@@ -149,8 +183,8 @@ class ProcessManager {
149
183
  hasApps: result.apps?.length > 0
150
184
  });
151
185
 
152
- // Cleanup process files
153
- this.cleanup();
186
+ // Cleanup process files but preserve upload result for stop command
187
+ this.cleanup({ preserveResult: true });
154
188
 
155
189
  return result;
156
190
  } catch (recorderError) {
@@ -168,7 +202,7 @@ class ProcessManager {
168
202
  logs: []
169
203
  };
170
204
 
171
- this.cleanup();
205
+ this.cleanup({ preserveResult: true });
172
206
  return result;
173
207
  }
174
208
  } else {
package/lib/uploader.js CHANGED
@@ -440,9 +440,13 @@ export async function upload(filePath, metadata = {}) {
440
440
  });
441
441
 
442
442
  logExit();
443
+
444
+ // Replace app.dashcam.io with app.testdriver.ai in the share link
445
+ const shareLink = newReplay.replay.shareLink?.replace('app.dashcam.io', 'app.testdriver.ai') || newReplay.replay.shareLink;
446
+
443
447
  return {
444
448
  replay: newReplay.replay,
445
- shareLink: newReplay.replay.shareLink
449
+ shareLink: shareLink
446
450
  };
447
451
  }
448
452
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashcam",
3
- "version": "1.0.1-beta.3",
3
+ "version": "1.0.1-beta.5",
4
4
  "description": "Minimal CLI version of Dashcam desktop app",
5
5
  "main": "bin/index.js",
6
6
  "bin": {