dashcam 1.0.1-beta.2 → 1.0.1-beta.3
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 +29 -22
- package/package.json +1 -1
package/bin/dashcam.js
CHANGED
|
@@ -84,22 +84,27 @@ program
|
|
|
84
84
|
.option('-t, --title <title>', 'Title for the recording')
|
|
85
85
|
.option('-d, --description <description>', 'Description for the recording (supports markdown)')
|
|
86
86
|
.option('-p, --project <project>', 'Project ID to upload the recording to')
|
|
87
|
+
.option('-s, --silent', 'Silent mode - suppress all output')
|
|
87
88
|
.action(async (options, command) => {
|
|
88
89
|
try {
|
|
90
|
+
const silent = options.silent;
|
|
91
|
+
const log = (...args) => { if (!silent) console.log(...args); };
|
|
92
|
+
const logError = (...args) => { if (!silent) console.error(...args); };
|
|
93
|
+
|
|
89
94
|
// Check if recording is already active
|
|
90
95
|
if (processManager.isRecordingActive()) {
|
|
91
96
|
const status = processManager.getActiveStatus();
|
|
92
97
|
const duration = ((Date.now() - status.startTime) / 1000).toFixed(1);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
log('Recording already in progress');
|
|
99
|
+
log(`Duration: ${duration} seconds`);
|
|
100
|
+
log(`PID: ${status.pid}`);
|
|
101
|
+
log('Use "dashcam stop" to stop the recording');
|
|
97
102
|
process.exit(0);
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
// Check authentication
|
|
101
106
|
if (!await auth.isAuthenticated()) {
|
|
102
|
-
|
|
107
|
+
log('You need to login first. Run: dashcam auth <api-key>');
|
|
103
108
|
process.exit(1);
|
|
104
109
|
}
|
|
105
110
|
|
|
@@ -107,12 +112,12 @@ program
|
|
|
107
112
|
const { ensurePermissions } = await import('../lib/permissions.js');
|
|
108
113
|
const hasPermissions = await ensurePermissions();
|
|
109
114
|
if (!hasPermissions) {
|
|
110
|
-
|
|
115
|
+
log('\n⚠️ Cannot start recording without screen recording permission.');
|
|
111
116
|
process.exit(1);
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
// Always use background mode
|
|
115
|
-
|
|
120
|
+
log('Starting recording...');
|
|
116
121
|
|
|
117
122
|
try {
|
|
118
123
|
const result = await processManager.startRecording({
|
|
@@ -124,37 +129,37 @@ program
|
|
|
124
129
|
project: options.project
|
|
125
130
|
});
|
|
126
131
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
132
|
+
log(`Recording started successfully (PID: ${result.pid})`);
|
|
133
|
+
log(`Output: ${result.outputPath}`);
|
|
134
|
+
log('Use "dashcam status" to check progress');
|
|
135
|
+
log('Use "dashcam stop" to stop recording and upload');
|
|
131
136
|
|
|
132
137
|
// Keep this process alive for background recording
|
|
133
|
-
|
|
138
|
+
log('Recording is running in background...');
|
|
134
139
|
|
|
135
140
|
// Set up signal handlers for graceful shutdown
|
|
136
141
|
let isShuttingDown = false;
|
|
137
142
|
const handleShutdown = async (signal) => {
|
|
138
143
|
if (isShuttingDown) {
|
|
139
|
-
|
|
144
|
+
log('Shutdown already in progress...');
|
|
140
145
|
return;
|
|
141
146
|
}
|
|
142
147
|
isShuttingDown = true;
|
|
143
148
|
|
|
144
|
-
|
|
149
|
+
log(`\nReceived ${signal}, stopping background recording...`);
|
|
145
150
|
try {
|
|
146
151
|
// Stop the recording using the recorder directly (not processManager)
|
|
147
152
|
const { stopRecording } = await import('../lib/recorder.js');
|
|
148
153
|
const stopResult = await stopRecording();
|
|
149
154
|
|
|
150
155
|
if (stopResult) {
|
|
151
|
-
|
|
156
|
+
log('Recording stopped:', stopResult.outputPath);
|
|
152
157
|
|
|
153
158
|
// Import and call upload function with the correct format
|
|
154
159
|
const { upload } = await import('../lib/uploader.js');
|
|
155
160
|
|
|
156
|
-
|
|
157
|
-
await upload(stopResult.outputPath, {
|
|
161
|
+
log('Starting upload...');
|
|
162
|
+
const uploadResult = await upload(stopResult.outputPath, {
|
|
158
163
|
title: options.title || 'Dashcam Recording',
|
|
159
164
|
description: options.description || 'Recorded with Dashcam CLI',
|
|
160
165
|
project: options.project,
|
|
@@ -166,13 +171,14 @@ program
|
|
|
166
171
|
snapshotPath: stopResult.snapshotPath
|
|
167
172
|
});
|
|
168
173
|
|
|
169
|
-
|
|
174
|
+
log('✅ Upload complete!');
|
|
175
|
+
log('📹 Watch your recording:', uploadResult.shareLink);
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
// Clean up process files
|
|
173
179
|
processManager.cleanup();
|
|
174
180
|
} catch (error) {
|
|
175
|
-
|
|
181
|
+
logError('Error during shutdown:', error.message);
|
|
176
182
|
logger.error('Error during shutdown:', error);
|
|
177
183
|
}
|
|
178
184
|
process.exit(0);
|
|
@@ -184,12 +190,12 @@ program
|
|
|
184
190
|
// Keep the process alive
|
|
185
191
|
await new Promise(() => {});
|
|
186
192
|
} catch (error) {
|
|
187
|
-
|
|
193
|
+
logError('Failed to start recording:', error.message);
|
|
188
194
|
process.exit(1);
|
|
189
195
|
}
|
|
190
196
|
} catch (error) {
|
|
191
197
|
logger.error('Failed to start recording:', error);
|
|
192
|
-
console.error('Failed to start recording:', error.message);
|
|
198
|
+
if (!options.silent) console.error('Failed to start recording:', error.message);
|
|
193
199
|
process.exit(1);
|
|
194
200
|
}
|
|
195
201
|
});
|
|
@@ -315,7 +321,8 @@ program
|
|
|
315
321
|
snapshotPath: result.snapshotPath
|
|
316
322
|
});
|
|
317
323
|
|
|
318
|
-
console.log('✅ Upload complete!
|
|
324
|
+
console.log('✅ Upload complete!');
|
|
325
|
+
console.log('📹 Watch your recording:', uploadResult.shareLink);
|
|
319
326
|
} catch (uploadError) {
|
|
320
327
|
console.error('Upload failed:', uploadError.message);
|
|
321
328
|
console.log('Recording saved locally:', result.outputPath);
|