cloudsync-cli 2026.7.1

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.
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Logger - Shared operation logging for all CloudSync commands
3
+ * Writes structured JSON logs to .cloudsync/logs/
4
+ */
5
+
6
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync } from 'fs';
7
+ import { join } from 'path';
8
+
9
+ const LOGS_DIR = join(process.cwd(), '.cloudsync', 'logs');
10
+
11
+ function ensureLogsDir() {
12
+ if (!existsSync(LOGS_DIR)) {
13
+ mkdirSync(LOGS_DIR, { recursive: true });
14
+ }
15
+ }
16
+
17
+ /**
18
+ * Log an operation
19
+ */
20
+ export function logOperation(type, message, meta = {}) {
21
+ ensureLogsDir();
22
+
23
+ const timestamp = new Date().toISOString();
24
+ const logEntry = {
25
+ type,
26
+ message,
27
+ timestamp,
28
+ ...meta
29
+ };
30
+
31
+ const filename = `op-${Date.now()}-${Math.random().toString(36).slice(2, 6)}.json`;
32
+ writeFileSync(join(LOGS_DIR, filename), JSON.stringify(logEntry, null, 2));
33
+
34
+ return logEntry;
35
+ }
36
+
37
+ /**
38
+ * Get recent log entries
39
+ */
40
+ export function getRecentLogs(limit = 20, type = 'all') {
41
+ ensureLogsDir();
42
+
43
+ try {
44
+ const files = readdirSync(LOGS_DIR)
45
+ .filter(f => f.endsWith('.json'))
46
+ .sort()
47
+ .reverse()
48
+ .slice(0, limit * 2); // over-fetch to account for type filtering
49
+
50
+ const logs = [];
51
+ for (const file of files) {
52
+ try {
53
+ const log = JSON.parse(readFileSync(join(LOGS_DIR, file), 'utf8'));
54
+ if (type === 'all' || log.type === type) {
55
+ logs.push(log);
56
+ }
57
+ if (logs.length >= limit) break;
58
+ } catch (e) { /* skip */ }
59
+ }
60
+ return logs;
61
+ } catch (e) {
62
+ return [];
63
+ }
64
+ }
65
+
66
+ export default { logOperation, getRecentLogs };
@@ -0,0 +1 @@
1
+ export const VERSION = '2026.7.1';