farseer-cli 1.1.1 → 1.1.2

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 (36) hide show
  1. package/README.md +141 -26
  2. package/dist/commands/checkout.js +14 -2
  3. package/dist/commands/checkout.js.map +2 -2
  4. package/dist/commands/config.js +75 -0
  5. package/dist/commands/config.js.map +3 -3
  6. package/dist/commands/dimensions.js +12 -1
  7. package/dist/commands/dimensions.js.map +2 -2
  8. package/dist/commands/pull.js +17 -3
  9. package/dist/commands/pull.js.map +2 -2
  10. package/dist/commands/push.js +15 -3
  11. package/dist/commands/push.js.map +2 -2
  12. package/dist/commands/sheets.js +30 -6
  13. package/dist/commands/sheets.js.map +2 -2
  14. package/dist/commands/status.js +14 -2
  15. package/dist/commands/status.js.map +2 -2
  16. package/dist/commands/variables.js +11 -2
  17. package/dist/commands/variables.js.map +2 -2
  18. package/dist/index.js +22 -0
  19. package/dist/index.js.map +2 -2
  20. package/dist/mcp/tools/dataTools.js +84 -28
  21. package/dist/mcp/tools/dataTools.js.map +2 -2
  22. package/dist/mcp/tools/modelTools.js +53 -1
  23. package/dist/mcp/tools/modelTools.js.map +2 -2
  24. package/dist/mcp/tools/syncTools.js +14 -0
  25. package/dist/mcp/tools/syncTools.js.map +2 -2
  26. package/dist/services/configService.js +25 -0
  27. package/dist/services/configService.js.map +2 -2
  28. package/dist/services/farseerApi.js +58 -2
  29. package/dist/services/farseerApi.js.map +2 -2
  30. package/dist/services/farseerService.js +86 -2
  31. package/dist/services/farseerService.js.map +2 -2
  32. package/dist/services/syncService.js +44 -27
  33. package/dist/services/syncService.js.map +2 -2
  34. package/dist/utils/updateCheck.js +132 -0
  35. package/dist/utils/updateCheck.js.map +7 -0
  36. package/package.json +1 -1
@@ -28,14 +28,29 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var syncService_exports = {};
30
30
  __export(syncService_exports, {
31
- SyncService: () => SyncService
31
+ SyncService: () => SyncService,
32
+ shouldIncludeFile: () => shouldIncludeFile
32
33
  });
33
34
  module.exports = __toCommonJS(syncService_exports);
34
35
  var fs = __toESM(require("fs"));
35
36
  var path = __toESM(require("path"));
36
37
  var import_farseerFactory = require("./farseerFactory");
38
+ var import_configService = require("./configService");
37
39
  var import_helpers = require("../utils/helpers");
38
40
  var import_logger = require("../utils/logger");
41
+ function shouldIncludeFile(filePath, tenant, options) {
42
+ if (options?.all) return true;
43
+ const ext = path.extname(filePath).toLowerCase();
44
+ if (import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.includes(ext)) return true;
45
+ if (options?.includeExtensions?.includes(ext)) return true;
46
+ if (options?.includeFolders?.some((f) => filePath.startsWith(f + "/") || filePath === f)) return true;
47
+ const includes = (0, import_configService.getSyncIncludes)(tenant);
48
+ if (includes) {
49
+ if (includes.extensions?.includes(ext)) return true;
50
+ if (includes.folders?.some((f) => filePath.startsWith(f + "/") || filePath === f)) return true;
51
+ }
52
+ return false;
53
+ }
39
54
  class SyncService {
40
55
  constructor(tenant, farseerClient) {
41
56
  this.tenant = tenant;
@@ -74,15 +89,11 @@ class SyncService {
74
89
  const filesDir = (0, import_helpers.getTenantFilesDir)(this.tenant);
75
90
  let localFiles = (0, import_helpers.getAllFilesInDir)(filesDir);
76
91
  if (!options?.all) {
77
- localFiles = localFiles.filter(
78
- (f) => import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.toLowerCase().endsWith(ext))
79
- );
92
+ localFiles = localFiles.filter((f) => shouldIncludeFile(f, this.tenant, options));
80
93
  }
81
94
  let remoteFiles = await this.farseerClient.listFiles();
82
95
  if (!options?.all) {
83
- remoteFiles = remoteFiles.filter(
84
- (f) => import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext))
85
- );
96
+ remoteFiles = remoteFiles.filter((f) => shouldIncludeFile(f.path, this.tenant, options));
86
97
  }
87
98
  const remoteFilePaths = new Set(remoteFiles.map((f) => f.path));
88
99
  const status = {
@@ -137,9 +148,7 @@ class SyncService {
137
148
  const filesDir = (0, import_helpers.getTenantFilesDir)(this.tenant);
138
149
  let localFiles = (0, import_helpers.getAllFilesInDir)(filesDir);
139
150
  if (!options?.all) {
140
- localFiles = localFiles.filter(
141
- (f) => import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.toLowerCase().endsWith(ext))
142
- );
151
+ localFiles = localFiles.filter((f) => shouldIncludeFile(f, this.tenant, options));
143
152
  }
144
153
  const localHashes = /* @__PURE__ */ new Map();
145
154
  for (const file of localFiles) {
@@ -149,9 +158,7 @@ class SyncService {
149
158
  }
150
159
  let remoteFiles = await this.farseerClient.listFiles();
151
160
  if (!options?.all) {
152
- remoteFiles = remoteFiles.filter(
153
- (f) => import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext))
154
- );
161
+ remoteFiles = remoteFiles.filter((f) => shouldIncludeFile(f.path, this.tenant, options));
155
162
  }
156
163
  const remoteHashes = /* @__PURE__ */ new Map();
157
164
  const fileContents = await (0, import_helpers.fetchWithConcurrency)(
@@ -165,7 +172,14 @@ class SyncService {
165
172
  for (const { path: filePath, hash } of fileContents) {
166
173
  remoteHashes.set(filePath, hash);
167
174
  }
168
- const comparisons = this.compareFiles({ localHashes, remoteHashes, syncState, all: options?.all });
175
+ const comparisons = this.compareFiles({
176
+ localHashes,
177
+ remoteHashes,
178
+ syncState,
179
+ all: options?.all,
180
+ includeExtensions: options?.includeExtensions,
181
+ includeFolders: options?.includeFolders
182
+ });
169
183
  const status = {
170
184
  modifiedLocally: [],
171
185
  modifiedRemotely: [],
@@ -210,9 +224,7 @@ class SyncService {
210
224
  const syncState = this.loadSyncState();
211
225
  let remoteFiles = await this.farseerClient.listFiles();
212
226
  if (!options?.all) {
213
- remoteFiles = remoteFiles.filter(
214
- (f) => import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext))
215
- );
227
+ remoteFiles = remoteFiles.filter((f) => shouldIncludeFile(f.path, this.tenant, options));
216
228
  }
217
229
  remoteFiles = await this.fetchMetadataForFiles(remoteFiles);
218
230
  const result = {
@@ -247,14 +259,21 @@ class SyncService {
247
259
  const localFiles = (0, import_helpers.getAllFilesInDir)(filesDir);
248
260
  const localHashes = /* @__PURE__ */ new Map();
249
261
  for (const localFile of localFiles) {
250
- if (!options?.all && !import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => localFile.toLowerCase().endsWith(ext))) {
262
+ if (!options?.all && !shouldIncludeFile(localFile, this.tenant, options)) {
251
263
  continue;
252
264
  }
253
265
  const localPath = path.join(filesDir, localFile);
254
266
  const content = fs.readFileSync(localPath);
255
267
  localHashes.set(localFile, (0, import_helpers.calculateHash)(content));
256
268
  }
257
- const comparisons = this.compareFiles({ localHashes, remoteHashes, syncState, all: options?.all });
269
+ const comparisons = this.compareFiles({
270
+ localHashes,
271
+ remoteHashes,
272
+ syncState,
273
+ all: options?.all,
274
+ includeExtensions: options?.includeExtensions,
275
+ includeFolders: options?.includeFolders
276
+ });
258
277
  const resolutions = options?.conflictResolutions ?? {};
259
278
  for (const comparison of comparisons) {
260
279
  const { filePath, changeType } = comparison;
@@ -507,12 +526,10 @@ class SyncService {
507
526
  this.saveSyncState(syncState);
508
527
  return result;
509
528
  }
510
- async checkRemoteChanges() {
529
+ async checkRemoteChanges(options) {
511
530
  const syncState = this.loadSyncState();
512
531
  let remoteFiles = await this.farseerClient.listFiles();
513
- remoteFiles = remoteFiles.filter(
514
- (f) => import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext))
515
- );
532
+ remoteFiles = remoteFiles.filter((f) => shouldIncludeFile(f.path, this.tenant, options));
516
533
  for (const file of remoteFiles) {
517
534
  const syncInfo = syncState.files[file.path];
518
535
  if (!syncInfo) {
@@ -520,8 +537,7 @@ class SyncService {
520
537
  }
521
538
  }
522
539
  for (const filePath of Object.keys(syncState.files)) {
523
- const isScript = import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => filePath.toLowerCase().endsWith(ext));
524
- if (!isScript) continue;
540
+ if (!shouldIncludeFile(filePath, this.tenant, options)) continue;
525
541
  const exists = remoteFiles.some((f) => f.path === filePath);
526
542
  if (!exists && syncState.files[filePath].remoteHash) {
527
543
  return true;
@@ -557,7 +573,7 @@ class SyncService {
557
573
  const results = [];
558
574
  for (const filePath of allPaths) {
559
575
  if (!options.all) {
560
- if (!import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => filePath.toLowerCase().endsWith(ext))) {
576
+ if (!shouldIncludeFile(filePath, this.tenant, options)) {
561
577
  continue;
562
578
  }
563
579
  }
@@ -689,6 +705,7 @@ class SyncService {
689
705
  }
690
706
  // Annotate the CommonJS export names for ESM import in node:
691
707
  0 && (module.exports = {
692
- SyncService
708
+ SyncService,
709
+ shouldIncludeFile
693
710
  });
694
711
  //# sourceMappingURL=syncService.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/services/syncService.ts"],
4
- "sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { IFarseerClient, RemoteFile, DEFAULT_SCRIPT_EXTENSIONS } from './farseerFactory';\nimport {\n calculateHash,\n getTenantFilesDir,\n getSyncFilePath,\n ensureDirectoryExists,\n getAllFilesInDir,\n fetchWithConcurrency,\n} from '../utils/helpers';\nimport { logger } from '../utils/logger';\n\nexport interface SyncFileInfo {\n localHash: string;\n remoteHash: string;\n metadata?: {\n uploadTime?: string;\n uploaderEmail?: string;\n uploaderName?: string;\n lastFetched?: string;\n };\n}\n\nexport interface SyncState {\n lastSync: string;\n files: Record<string, SyncFileInfo>;\n}\n\nexport interface SyncStatus {\n modifiedLocally: string[];\n modifiedRemotely: string[];\n onlyLocal: string[];\n onlyRemote: string[];\n inSync: string[];\n conflicts?: SyncConflict[];\n}\n\n// Three-way comparison types\n\nexport type FileChangeType =\n | 'unchanged'\n | 'local_modified'\n | 'remote_modified'\n | 'remote_deleted'\n | 'local_deleted'\n | 'local_new'\n | 'remote_new'\n | 'conflict_both_modified'\n | 'conflict_local_modified_remote_deleted'\n | 'conflict_local_deleted_remote_modified'\n | 'conflict_both_new';\n\nexport interface FileCompareResult {\n filePath: string;\n changeType: FileChangeType;\n currentLocalHash: string | null;\n currentRemoteHash: string | null;\n baselineLocalHash: string | null;\n baselineRemoteHash: string | null;\n}\n\nexport interface SyncConflict {\n filePath: string;\n type: 'both_modified' | 'local_modified_remote_deleted' | 'local_deleted_remote_modified' | 'both_new';\n description: string;\n}\n\nexport type ConflictResolution = 'keep_local' | 'keep_remote' | 'keep_both';\nexport type ConflictResolutions = Record<string, ConflictResolution>;\n\nexport class SyncService {\n private tenant: string;\n private farseerClient: IFarseerClient;\n\n constructor(tenant: string, farseerClient: IFarseerClient) {\n this.tenant = tenant;\n this.farseerClient = farseerClient;\n }\n\n loadSyncState(): SyncState {\n const syncFilePath = getSyncFilePath(this.tenant);\n\n if (!fs.existsSync(syncFilePath)) {\n return {\n lastSync: '',\n files: {},\n };\n }\n\n try {\n const content = fs.readFileSync(syncFilePath, 'utf-8');\n return JSON.parse(content) as SyncState;\n } catch {\n return {\n lastSync: '',\n files: {},\n };\n }\n }\n\n saveSyncState(state: SyncState): void {\n const syncFilePath = getSyncFilePath(this.tenant);\n ensureDirectoryExists(path.dirname(syncFilePath));\n fs.writeFileSync(syncFilePath, JSON.stringify(state, null, 2), 'utf-8');\n }\n\n /**\n * Fast status check that uses sync state instead of downloading remote file content.\n * This is much faster than getStatus() but may miss changes made by others since last pull.\n * Use this for push operations where we trust the sync state.\n */\n async getStatusFast(options?: { all?: boolean }): Promise<SyncStatus> {\n const syncState = this.loadSyncState();\n const filesDir = getTenantFilesDir(this.tenant);\n\n // Get local files\n let localFiles = getAllFilesInDir(filesDir);\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n localFiles = localFiles.filter((f) =>\n DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.toLowerCase().endsWith(ext)),\n );\n }\n\n // Get remote file list only (no content download)\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n remoteFiles = remoteFiles.filter((f) =>\n DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext)),\n );\n }\n\n const remoteFilePaths = new Set(remoteFiles.map((f) => f.path));\n\n const status: SyncStatus = {\n modifiedLocally: [],\n modifiedRemotely: [],\n onlyLocal: [],\n onlyRemote: [],\n inSync: [],\n conflicts: [],\n };\n\n // Check local files\n for (const localFile of localFiles) {\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n const localHash = calculateHash(content);\n const syncInfo = syncState.files[localFile];\n\n if (remoteFilePaths.has(localFile)) {\n // File exists both locally and remotely\n if (syncInfo && localHash === syncInfo.localHash) {\n // Local file hasn't changed since last sync\n status.inSync.push(localFile);\n } else {\n // Local file changed (or no sync info)\n status.modifiedLocally.push(localFile);\n }\n } else {\n // File only exists locally\n if (syncInfo && syncInfo.remoteHash) {\n // Was synced before, deleted on remote\n if (localHash !== syncInfo.localHash) {\n // Local also modified - CONFLICT\n status.conflicts!.push({\n filePath: localFile,\n type: 'local_modified_remote_deleted',\n description: 'File modified locally but deleted on remote',\n });\n } else {\n // Local unchanged, safe to mark as remote change\n status.modifiedRemotely.push(localFile);\n }\n } else {\n status.onlyLocal.push(localFile);\n }\n }\n }\n\n // Check remote files that don't exist locally\n for (const remoteFile of remoteFiles) {\n if (!localFiles.includes(remoteFile.path)) {\n const syncInfo = syncState.files[remoteFile.path];\n if (syncInfo && syncInfo.localHash) {\n // Was synced before, deleted locally\n status.modifiedLocally.push(remoteFile.path);\n } else {\n status.onlyRemote.push(remoteFile.path);\n }\n }\n }\n\n return status;\n }\n\n async getStatus(options?: { all?: boolean }): Promise<SyncStatus> {\n const syncState = this.loadSyncState();\n const filesDir = getTenantFilesDir(this.tenant);\n\n // Get local files and their hashes\n let localFiles = getAllFilesInDir(filesDir);\n if (!options?.all) {\n localFiles = localFiles.filter((f) =>\n DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.toLowerCase().endsWith(ext)),\n );\n }\n\n const localHashes = new Map<string, string>();\n for (const file of localFiles) {\n const fullPath = path.join(filesDir, file);\n const content = fs.readFileSync(fullPath);\n localHashes.set(file, calculateHash(content));\n }\n\n // Get remote files and their hashes\n let remoteFiles = await this.farseerClient.listFiles();\n if (!options?.all) {\n remoteFiles = remoteFiles.filter((f) =>\n DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext)),\n );\n }\n\n const remoteHashes = new Map<string, string>();\n const fileContents = await fetchWithConcurrency(\n remoteFiles,\n async (file) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n return { path: file.path, hash: calculateHash(content) };\n },\n 15,\n );\n for (const { path: filePath, hash } of fileContents) {\n remoteHashes.set(filePath, hash);\n }\n\n // Three-way comparison\n const comparisons = this.compareFiles({ localHashes, remoteHashes, syncState, all: options?.all });\n\n const status: SyncStatus = {\n modifiedLocally: [],\n modifiedRemotely: [],\n onlyLocal: [],\n onlyRemote: [],\n inSync: [],\n conflicts: [],\n };\n\n for (const c of comparisons) {\n switch (c.changeType) {\n case 'unchanged':\n status.inSync.push(c.filePath);\n break;\n case 'local_modified':\n status.modifiedLocally.push(c.filePath);\n break;\n case 'remote_modified':\n status.modifiedRemotely.push(c.filePath);\n break;\n case 'local_new':\n status.onlyLocal.push(c.filePath);\n break;\n case 'remote_new':\n status.onlyRemote.push(c.filePath);\n break;\n case 'remote_deleted':\n status.modifiedRemotely.push(c.filePath);\n break;\n case 'local_deleted':\n status.modifiedLocally.push(c.filePath);\n break;\n default:\n // All conflict types\n status.conflicts!.push(SyncService.buildConflicts([c])[0]);\n break;\n }\n }\n\n return status;\n }\n\n async pull(options?: { all?: boolean; force?: boolean; conflictResolutions?: ConflictResolutions }): Promise<{\n downloaded: string[];\n deleted: string[];\n unchanged: string[];\n conflicts: SyncConflict[];\n conflictFilesWritten: string[];\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n ensureDirectoryExists(filesDir);\n\n const syncState = this.loadSyncState();\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n remoteFiles = remoteFiles.filter((f) =>\n DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext)),\n );\n }\n\n // Batch fetch metadata for all files\n remoteFiles = await this.fetchMetadataForFiles(remoteFiles);\n\n const result = {\n downloaded: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n conflicts: [] as SyncConflict[],\n conflictFilesWritten: [] as string[],\n };\n\n // Download file contents in parallel with concurrency limit\n logger.dim(`Fetching ${remoteFiles.length} files in parallel...`);\n const fileContents = await fetchWithConcurrency(\n remoteFiles,\n async (file, index) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n // Show progress every 10 files\n if ((index + 1) % 10 === 0 || index === remoteFiles.length - 1) {\n process.stdout.write(`\\r Progress: ${index + 1}/${remoteFiles.length} files`);\n }\n return { file, content };\n },\n 15,\n );\n // Clear progress line\n if (remoteFiles.length > 0) {\n process.stdout.write('\\r' + ' '.repeat(50) + '\\r');\n }\n\n // Build remote content map with hashes\n const remoteContentMap = new Map<string, { file: RemoteFile; content: Buffer; hash: string }>();\n const remoteHashes = new Map<string, string>();\n for (const { file, content } of fileContents) {\n const hash = calculateHash(content);\n remoteContentMap.set(file.path, { file, content, hash });\n remoteHashes.set(file.path, hash);\n }\n\n // Build local hashes\n const localFiles = getAllFilesInDir(filesDir);\n const localHashes = new Map<string, string>();\n for (const localFile of localFiles) {\n if (!options?.all && !DEFAULT_SCRIPT_EXTENSIONS.some((ext) => localFile.toLowerCase().endsWith(ext))) {\n continue;\n }\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n localHashes.set(localFile, calculateHash(content));\n }\n\n // Three-way comparison\n const comparisons = this.compareFiles({ localHashes, remoteHashes, syncState, all: options?.all });\n const resolutions = options?.conflictResolutions ?? {};\n\n for (const comparison of comparisons) {\n const { filePath, changeType } = comparison;\n const localPath = path.join(filesDir, filePath);\n const remoteInfo = remoteContentMap.get(filePath);\n\n switch (changeType) {\n case 'unchanged':\n case 'local_modified':\n case 'local_new':\n result.unchanged.push(filePath);\n // Update sync state for remote side if we have remote info\n if (remoteInfo) {\n const existingSync = syncState.files[filePath];\n if (existingSync) {\n existingSync.remoteHash = remoteInfo.hash;\n existingSync.metadata = this.buildMetadata(remoteInfo.file);\n }\n }\n break;\n\n case 'local_deleted':\n // Local deleted, remote unchanged - skip (push will handle)\n result.unchanged.push(filePath);\n break;\n\n case 'remote_modified':\n case 'remote_new':\n // Safe to write\n ensureDirectoryExists(path.dirname(localPath));\n fs.writeFileSync(localPath, remoteInfo!.content);\n result.downloaded.push(filePath);\n syncState.files[filePath] = {\n localHash: remoteInfo!.hash,\n remoteHash: remoteInfo!.hash,\n metadata: this.buildMetadata(remoteInfo!.file),\n };\n break;\n\n case 'remote_deleted':\n // Safe to delete (local is unchanged)\n if (fs.existsSync(localPath)) {\n fs.unlinkSync(localPath);\n }\n result.deleted.push(filePath);\n delete syncState.files[filePath];\n break;\n\n case 'conflict_both_modified':\n case 'conflict_local_modified_remote_deleted':\n case 'conflict_local_deleted_remote_modified':\n case 'conflict_both_new': {\n if (options?.force) {\n // Force: apply remote state\n if (remoteInfo) {\n ensureDirectoryExists(path.dirname(localPath));\n fs.writeFileSync(localPath, remoteInfo.content);\n result.downloaded.push(filePath);\n syncState.files[filePath] = {\n localHash: remoteInfo.hash,\n remoteHash: remoteInfo.hash,\n metadata: this.buildMetadata(remoteInfo.file),\n };\n } else {\n // Remote deleted, force means delete local\n if (fs.existsSync(localPath)) {\n fs.unlinkSync(localPath);\n result.deleted.push(filePath);\n }\n delete syncState.files[filePath];\n }\n break;\n }\n\n const resolution = resolutions[filePath];\n if (!resolution) {\n // No resolution provided - report conflict, skip file\n result.conflicts.push(SyncService.buildConflicts([comparison])[0]);\n break;\n }\n\n switch (resolution) {\n case 'keep_local':\n // Keep local as-is, update sync state to mark conflict resolved\n if (fs.existsSync(localPath)) {\n const localContent = fs.readFileSync(localPath);\n const localHash = calculateHash(localContent);\n syncState.files[filePath] = {\n localHash,\n remoteHash: comparison.currentRemoteHash ?? '',\n metadata: remoteInfo ? this.buildMetadata(remoteInfo.file) : undefined,\n };\n } else {\n // Local was deleted, user wants to keep that decision\n delete syncState.files[filePath];\n }\n result.unchanged.push(filePath);\n break;\n\n case 'keep_remote':\n if (remoteInfo) {\n ensureDirectoryExists(path.dirname(localPath));\n fs.writeFileSync(localPath, remoteInfo.content);\n result.downloaded.push(filePath);\n syncState.files[filePath] = {\n localHash: remoteInfo.hash,\n remoteHash: remoteInfo.hash,\n metadata: this.buildMetadata(remoteInfo.file),\n };\n } else {\n // Remote deleted\n if (fs.existsSync(localPath)) {\n fs.unlinkSync(localPath);\n result.deleted.push(filePath);\n }\n delete syncState.files[filePath];\n }\n break;\n\n case 'keep_both':\n if (remoteInfo) {\n // Write remote version as .remote file alongside local\n const ext = path.extname(filePath);\n const base = filePath.slice(0, -ext.length || undefined);\n const conflictFileName = `${base}.remote${ext}`;\n const conflictPath = path.join(filesDir, conflictFileName);\n ensureDirectoryExists(path.dirname(conflictPath));\n fs.writeFileSync(conflictPath, remoteInfo.content);\n result.conflictFilesWritten.push(conflictFileName);\n }\n // Keep local, update sync state\n if (fs.existsSync(localPath)) {\n const localContent = fs.readFileSync(localPath);\n const localHash = calculateHash(localContent);\n syncState.files[filePath] = {\n localHash,\n remoteHash: comparison.currentRemoteHash ?? '',\n metadata: remoteInfo ? this.buildMetadata(remoteInfo.file) : undefined,\n };\n }\n result.unchanged.push(filePath);\n break;\n }\n break;\n }\n }\n }\n\n syncState.lastSync = new Date().toISOString();\n this.saveSyncState(syncState);\n\n return result;\n }\n\n private buildMetadata(file: RemoteFile): SyncFileInfo['metadata'] {\n if (!file.metadata) return undefined;\n return {\n uploadTime: file.metadata.uploadTime,\n uploaderEmail: file.metadata.uploader?.email,\n uploaderName: file.metadata.uploader\n ? `${file.metadata.uploader.firstName} ${file.metadata.uploader.lastName}`.trim()\n : undefined,\n lastFetched: new Date().toISOString(),\n };\n }\n\n async push(options?: { force?: boolean }): Promise<{\n uploaded: string[];\n updated: string[];\n deleted: string[];\n unchanged: string[];\n conflicts: SyncConflict[];\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n const syncState = this.loadSyncState();\n\n const result = {\n uploaded: [] as string[],\n updated: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n conflicts: [] as SyncConflict[],\n };\n\n // Get current remote files (just the list, not content)\n const remoteFiles = await this.farseerClient.listFiles();\n const remoteFileMap = new Map<string, RemoteFile>();\n for (const file of remoteFiles) {\n remoteFileMap.set(file.path, file);\n }\n\n // Get local files and hashes\n const localFiles = getAllFilesInDir(filesDir);\n const localHashes = new Map<string, string>();\n const localContents = new Map<string, Buffer>();\n for (const localFile of localFiles) {\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n localHashes.set(localFile, calculateHash(content));\n localContents.set(localFile, content);\n }\n\n // Identify candidates that need remote content check for conflict detection\n const candidateFiles: string[] = [];\n for (const localFile of localFiles) {\n const syncInfo = syncState.files[localFile];\n const localHash = localHashes.get(localFile)!;\n if (!syncInfo || localHash !== syncInfo.localHash) {\n // Changed or new locally\n if (remoteFileMap.has(localFile)) {\n candidateFiles.push(localFile);\n }\n }\n }\n // Also check files in sync state that no longer exist locally (local deletions)\n const locallyDeletedFiles = Object.keys(syncState.files).filter(\n (f) => !localFiles.includes(f) && remoteFileMap.has(f),\n );\n const filesToFetchRemote = [...new Set([...candidateFiles, ...locallyDeletedFiles])];\n\n // Fetch remote content for conflict detection\n const remoteHashes = new Map<string, string>();\n if (filesToFetchRemote.length > 0 && !options?.force) {\n const toFetch = filesToFetchRemote.filter((f) => remoteFileMap.has(f)).map((f) => remoteFileMap.get(f)!);\n\n const fetched = await fetchWithConcurrency(\n toFetch,\n async (file) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n return { file, hash: calculateHash(content) };\n },\n 15,\n );\n\n for (const { file, hash } of fetched) {\n remoteHashes.set(file.path, hash);\n }\n }\n\n // Three-way comparison for conflict detection\n const comparisons = this.compareFiles({ localHashes, remoteHashes, syncState, all: true });\n const conflictPaths = new Set<string>();\n\n if (!options?.force) {\n for (const c of comparisons) {\n if (c.changeType.startsWith('conflict_')) {\n const conflict = SyncService.buildConflicts([c])[0];\n result.conflicts.push(conflict);\n conflictPaths.add(c.filePath);\n }\n }\n }\n\n // Process non-conflicting files\n for (const localFile of localFiles) {\n if (conflictPaths.has(localFile)) continue;\n\n const localPath = path.join(filesDir, localFile);\n const content = localContents.get(localFile)!;\n const localHash = localHashes.get(localFile)!;\n\n const remoteFile = remoteFileMap.get(localFile);\n const syncInfo = syncState.files[localFile];\n\n if (remoteFile) {\n // File exists on remote - check if local changed since last sync\n if (syncInfo && localHash === syncInfo.localHash) {\n result.unchanged.push(localFile);\n } else {\n // Local file changed - needs update\n await this.farseerClient.updateFile(remoteFile.reference, content, path.basename(localFile));\n result.updated.push(localFile);\n syncState.files[localFile] = {\n localHash: localHash,\n remoteHash: localHash,\n };\n }\n } else {\n // File doesn't exist on remote\n if (syncInfo && localHash === syncInfo.localHash) {\n // Local unchanged, was deleted on remote - skip (don't re-upload)\n result.unchanged.push(localFile);\n } else {\n // New or modified local file - upload\n const pathParts = localFile.split('/');\n const fileName = pathParts.pop()!;\n const folderPath = ['Files', ...pathParts];\n await this.farseerClient.createFile(content, fileName, folderPath);\n result.uploaded.push(localFile);\n syncState.files[localFile] = {\n localHash: localHash,\n remoteHash: localHash,\n };\n }\n }\n }\n\n // Delete files on remote that were deleted locally (non-conflicting only)\n const localFileSet = new Set(localFiles);\n for (const [remotePath, remoteFile] of remoteFileMap) {\n if (!localFileSet.has(remotePath) && !conflictPaths.has(remotePath)) {\n const syncInfo = syncState.files[remotePath];\n if (syncInfo) {\n // Was synced before, now deleted locally - delete on remote\n await this.farseerClient.deleteFile(remoteFile.reference);\n result.deleted.push(remotePath);\n delete syncState.files[remotePath];\n }\n }\n }\n\n syncState.lastSync = new Date().toISOString();\n this.saveSyncState(syncState);\n\n return result;\n }\n\n async checkRemoteChanges(): Promise<boolean> {\n const syncState = this.loadSyncState();\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only (same as pull/status) to avoid false positives\n // from non-script files like .json, .png, etc.\n remoteFiles = remoteFiles.filter((f) =>\n DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext)),\n );\n\n // Quick check: new files on remote that we don't have in sync state\n for (const file of remoteFiles) {\n const syncInfo = syncState.files[file.path];\n if (!syncInfo) {\n return true; // New file on remote\n }\n }\n\n // Quick check: files deleted on remote that we have in sync state\n for (const filePath of Object.keys(syncState.files)) {\n // Only check script files\n const isScript = DEFAULT_SCRIPT_EXTENSIONS.some((ext) => filePath.toLowerCase().endsWith(ext));\n if (!isScript) continue;\n\n const exists = remoteFiles.some((f) => f.path === filePath);\n if (!exists && syncState.files[filePath].remoteHash) {\n return true; // File was deleted on remote\n }\n }\n\n // Note: We don't check for content changes here anymore for performance.\n // After a pull, sync state is accurate. Content changes by others\n // between pull and push are a rare edge case - user should pull first.\n return false;\n }\n\n async getFileDiff(filePath: string): Promise<{\n localContent: string | null;\n remoteContent: string | null;\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n const localPath = path.join(filesDir, filePath);\n\n let localContent: string | null = null;\n let remoteContent: string | null = null;\n\n if (fs.existsSync(localPath)) {\n // For diff, read as text (diff only makes sense for text files)\n localContent = fs.readFileSync(localPath, 'utf-8');\n }\n\n const remoteFile = await this.farseerClient.getFileByPath(filePath);\n if (remoteFile) {\n remoteContent = await this.farseerClient.getFileContent(remoteFile.reference);\n }\n\n return { localContent, remoteContent };\n }\n\n /**\n * Three-way comparison of all files.\n * Compares current local state, current remote state, and baseline from sync state.\n */\n compareFiles(options: {\n localHashes: Map<string, string>;\n remoteHashes: Map<string, string>;\n syncState: SyncState;\n all?: boolean;\n }): FileCompareResult[] {\n const { localHashes, remoteHashes, syncState } = options;\n\n // Union of all known file paths\n const allPaths = new Set<string>([\n ...localHashes.keys(),\n ...remoteHashes.keys(),\n ...Object.keys(syncState.files),\n ]);\n\n const results: FileCompareResult[] = [];\n\n for (const filePath of allPaths) {\n // Filter non-script files unless --all\n if (!options.all) {\n if (!DEFAULT_SCRIPT_EXTENSIONS.some((ext) => filePath.toLowerCase().endsWith(ext))) {\n continue;\n }\n }\n\n const currentLocalHash = localHashes.get(filePath) ?? null;\n const currentRemoteHash = remoteHashes.get(filePath) ?? null;\n const baseline = syncState.files[filePath];\n const baselineLocalHash = baseline?.localHash ?? null;\n const baselineRemoteHash = baseline?.remoteHash ?? null;\n\n const localExists = currentLocalHash !== null;\n const remoteExists = currentRemoteHash !== null;\n const hadBaseline = baseline != null;\n\n let changeType: FileChangeType;\n\n if (localExists && remoteExists) {\n // Both exist\n if (currentLocalHash === currentRemoteHash) {\n changeType = 'unchanged';\n } else if (!hadBaseline) {\n changeType = 'conflict_both_new';\n } else {\n const localChanged = currentLocalHash !== baselineLocalHash;\n const remoteChanged = currentRemoteHash !== baselineRemoteHash;\n\n if (localChanged && remoteChanged) {\n changeType = 'conflict_both_modified';\n } else if (localChanged) {\n changeType = 'local_modified';\n } else if (remoteChanged) {\n changeType = 'remote_modified';\n } else {\n changeType = 'unchanged';\n }\n }\n } else if (localExists && !remoteExists) {\n // Only local exists\n if (!hadBaseline) {\n changeType = 'local_new';\n } else {\n const localChanged = currentLocalHash !== baselineLocalHash;\n if (localChanged) {\n changeType = 'conflict_local_modified_remote_deleted';\n } else {\n changeType = 'remote_deleted';\n }\n }\n } else if (!localExists && remoteExists) {\n // Only remote exists\n if (!hadBaseline) {\n changeType = 'remote_new';\n } else {\n const remoteChanged = currentRemoteHash !== baselineRemoteHash;\n if (remoteChanged) {\n changeType = 'conflict_local_deleted_remote_modified';\n } else {\n changeType = 'local_deleted';\n }\n }\n } else {\n // Neither exists - both deleted since baseline, clean up\n continue;\n }\n\n results.push({\n filePath,\n changeType,\n currentLocalHash,\n currentRemoteHash,\n baselineLocalHash,\n baselineRemoteHash,\n });\n }\n\n return results;\n }\n\n /**\n * Extract SyncConflict[] from FileCompareResult[].\n */\n static buildConflicts(comparisons: FileCompareResult[]): SyncConflict[] {\n const conflicts: SyncConflict[] = [];\n for (const c of comparisons) {\n switch (c.changeType) {\n case 'conflict_both_modified':\n conflicts.push({\n filePath: c.filePath,\n type: 'both_modified',\n description: 'Both local and remote versions modified since last sync',\n });\n break;\n case 'conflict_local_modified_remote_deleted':\n conflicts.push({\n filePath: c.filePath,\n type: 'local_modified_remote_deleted',\n description: 'File modified locally but deleted on remote',\n });\n break;\n case 'conflict_local_deleted_remote_modified':\n conflicts.push({\n filePath: c.filePath,\n type: 'local_deleted_remote_modified',\n description: 'File deleted locally but modified on remote',\n });\n break;\n case 'conflict_both_new':\n conflicts.push({\n filePath: c.filePath,\n type: 'both_new',\n description: 'File exists both locally and remotely with different content (no sync baseline)',\n });\n break;\n }\n }\n return conflicts;\n }\n\n /**\n * Batch fetch metadata for multiple files in parallel.\n * Fetches metadata in batches of 10 to avoid overwhelming the API.\n * Non-critical operation - failures are silently ignored.\n */\n private async fetchMetadataForFiles(files: RemoteFile[]): Promise<RemoteFile[]> {\n const batchSize = 10;\n\n for (let i = 0; i < files.length; i += batchSize) {\n const batch = files.slice(i, i + batchSize);\n\n await Promise.all(\n batch.map(async (file) => {\n try {\n const metadata = await this.farseerClient.getFileMetadata(file.reference);\n if (metadata) {\n file.metadata = metadata;\n }\n } catch {\n // Silently ignore metadata fetch errors - non-critical\n }\n }),\n );\n }\n\n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* as fs from 'fs';\nimport * as path from 'path';\nimport { IFarseerClient, RemoteFile, DEFAULT_SCRIPT_EXTENSIONS } from './farseerFactory';\nimport { getSyncIncludes } from './configService';\nimport {\n calculateHash,\n getTenantFilesDir,\n getSyncFilePath,\n ensureDirectoryExists,\n getAllFilesInDir,\n fetchWithConcurrency,\n} from '../utils/helpers';\nimport { logger } from '../utils/logger';\n\nexport interface SyncOptions {\n all?: boolean;\n force?: boolean;\n includeExtensions?: string[];\n includeFolders?: string[];\n conflictResolutions?: ConflictResolutions;\n}\n\n/**\n * Determines if a file should be included in sync operations.\n * A file is included if ANY of:\n * 1. --all flag is passed\n * 2. Has a default script extension (.ts, .js, .mjs, .cjs)\n * 3. Has an extension from inline includeExtensions option\n * 4. Lives under a folder from inline includeFolders option\n * 5. Has an extension from persistent syncIncludes config\n * 6. Lives under a folder from persistent syncIncludes config\n */\nexport function shouldIncludeFile(\n filePath: string,\n tenant: string,\n options?: Pick<SyncOptions, 'all' | 'includeExtensions' | 'includeFolders'>,\n): boolean {\n if (options?.all) return true;\n\n const ext = path.extname(filePath).toLowerCase();\n\n // Default script extensions always included\n if (DEFAULT_SCRIPT_EXTENSIONS.includes(ext)) return true;\n\n // Inline extensions\n if (options?.includeExtensions?.includes(ext)) return true;\n\n // Inline folders\n if (options?.includeFolders?.some((f) => filePath.startsWith(f + '/') || filePath === f)) return true;\n\n // Persistent config\n const includes = getSyncIncludes(tenant);\n if (includes) {\n if (includes.extensions?.includes(ext)) return true;\n if (includes.folders?.some((f) => filePath.startsWith(f + '/') || filePath === f)) return true;\n }\n\n return false;\n}\n\nexport interface SyncFileInfo {\n localHash: string;\n remoteHash: string;\n metadata?: {\n uploadTime?: string;\n uploaderEmail?: string;\n uploaderName?: string;\n lastFetched?: string;\n };\n}\n\nexport interface SyncState {\n lastSync: string;\n files: Record<string, SyncFileInfo>;\n}\n\nexport interface SyncStatus {\n modifiedLocally: string[];\n modifiedRemotely: string[];\n onlyLocal: string[];\n onlyRemote: string[];\n inSync: string[];\n conflicts?: SyncConflict[];\n}\n\n// Three-way comparison types\n\nexport type FileChangeType =\n | 'unchanged'\n | 'local_modified'\n | 'remote_modified'\n | 'remote_deleted'\n | 'local_deleted'\n | 'local_new'\n | 'remote_new'\n | 'conflict_both_modified'\n | 'conflict_local_modified_remote_deleted'\n | 'conflict_local_deleted_remote_modified'\n | 'conflict_both_new';\n\nexport interface FileCompareResult {\n filePath: string;\n changeType: FileChangeType;\n currentLocalHash: string | null;\n currentRemoteHash: string | null;\n baselineLocalHash: string | null;\n baselineRemoteHash: string | null;\n}\n\nexport interface SyncConflict {\n filePath: string;\n type: 'both_modified' | 'local_modified_remote_deleted' | 'local_deleted_remote_modified' | 'both_new';\n description: string;\n}\n\nexport type ConflictResolution = 'keep_local' | 'keep_remote' | 'keep_both';\nexport type ConflictResolutions = Record<string, ConflictResolution>;\n\nexport class SyncService {\n private tenant: string;\n private farseerClient: IFarseerClient;\n\n constructor(tenant: string, farseerClient: IFarseerClient) {\n this.tenant = tenant;\n this.farseerClient = farseerClient;\n }\n\n loadSyncState(): SyncState {\n const syncFilePath = getSyncFilePath(this.tenant);\n\n if (!fs.existsSync(syncFilePath)) {\n return {\n lastSync: '',\n files: {},\n };\n }\n\n try {\n const content = fs.readFileSync(syncFilePath, 'utf-8');\n return JSON.parse(content) as SyncState;\n } catch {\n return {\n lastSync: '',\n files: {},\n };\n }\n }\n\n saveSyncState(state: SyncState): void {\n const syncFilePath = getSyncFilePath(this.tenant);\n ensureDirectoryExists(path.dirname(syncFilePath));\n fs.writeFileSync(syncFilePath, JSON.stringify(state, null, 2), 'utf-8');\n }\n\n /**\n * Fast status check that uses sync state instead of downloading remote file content.\n * This is much faster than getStatus() but may miss changes made by others since last pull.\n * Use this for push operations where we trust the sync state.\n */\n async getStatusFast(options?: SyncOptions): Promise<SyncStatus> {\n const syncState = this.loadSyncState();\n const filesDir = getTenantFilesDir(this.tenant);\n\n // Get local files\n let localFiles = getAllFilesInDir(filesDir);\n\n // Filter files based on includes\n if (!options?.all) {\n localFiles = localFiles.filter((f) => shouldIncludeFile(f, this.tenant, options));\n }\n\n // Get remote file list only (no content download)\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter files based on includes\n if (!options?.all) {\n remoteFiles = remoteFiles.filter((f) => shouldIncludeFile(f.path, this.tenant, options));\n }\n\n const remoteFilePaths = new Set(remoteFiles.map((f) => f.path));\n\n const status: SyncStatus = {\n modifiedLocally: [],\n modifiedRemotely: [],\n onlyLocal: [],\n onlyRemote: [],\n inSync: [],\n conflicts: [],\n };\n\n // Check local files\n for (const localFile of localFiles) {\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n const localHash = calculateHash(content);\n const syncInfo = syncState.files[localFile];\n\n if (remoteFilePaths.has(localFile)) {\n // File exists both locally and remotely\n if (syncInfo && localHash === syncInfo.localHash) {\n // Local file hasn't changed since last sync\n status.inSync.push(localFile);\n } else {\n // Local file changed (or no sync info)\n status.modifiedLocally.push(localFile);\n }\n } else {\n // File only exists locally\n if (syncInfo && syncInfo.remoteHash) {\n // Was synced before, deleted on remote\n if (localHash !== syncInfo.localHash) {\n // Local also modified - CONFLICT\n status.conflicts!.push({\n filePath: localFile,\n type: 'local_modified_remote_deleted',\n description: 'File modified locally but deleted on remote',\n });\n } else {\n // Local unchanged, safe to mark as remote change\n status.modifiedRemotely.push(localFile);\n }\n } else {\n status.onlyLocal.push(localFile);\n }\n }\n }\n\n // Check remote files that don't exist locally\n for (const remoteFile of remoteFiles) {\n if (!localFiles.includes(remoteFile.path)) {\n const syncInfo = syncState.files[remoteFile.path];\n if (syncInfo && syncInfo.localHash) {\n // Was synced before, deleted locally\n status.modifiedLocally.push(remoteFile.path);\n } else {\n status.onlyRemote.push(remoteFile.path);\n }\n }\n }\n\n return status;\n }\n\n async getStatus(options?: SyncOptions): Promise<SyncStatus> {\n const syncState = this.loadSyncState();\n const filesDir = getTenantFilesDir(this.tenant);\n\n // Get local files and their hashes\n let localFiles = getAllFilesInDir(filesDir);\n if (!options?.all) {\n localFiles = localFiles.filter((f) => shouldIncludeFile(f, this.tenant, options));\n }\n\n const localHashes = new Map<string, string>();\n for (const file of localFiles) {\n const fullPath = path.join(filesDir, file);\n const content = fs.readFileSync(fullPath);\n localHashes.set(file, calculateHash(content));\n }\n\n // Get remote files and their hashes\n let remoteFiles = await this.farseerClient.listFiles();\n if (!options?.all) {\n remoteFiles = remoteFiles.filter((f) => shouldIncludeFile(f.path, this.tenant, options));\n }\n\n const remoteHashes = new Map<string, string>();\n const fileContents = await fetchWithConcurrency(\n remoteFiles,\n async (file) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n return { path: file.path, hash: calculateHash(content) };\n },\n 15,\n );\n for (const { path: filePath, hash } of fileContents) {\n remoteHashes.set(filePath, hash);\n }\n\n // Three-way comparison\n const comparisons = this.compareFiles({\n localHashes,\n remoteHashes,\n syncState,\n all: options?.all,\n includeExtensions: options?.includeExtensions,\n includeFolders: options?.includeFolders,\n });\n\n const status: SyncStatus = {\n modifiedLocally: [],\n modifiedRemotely: [],\n onlyLocal: [],\n onlyRemote: [],\n inSync: [],\n conflicts: [],\n };\n\n for (const c of comparisons) {\n switch (c.changeType) {\n case 'unchanged':\n status.inSync.push(c.filePath);\n break;\n case 'local_modified':\n status.modifiedLocally.push(c.filePath);\n break;\n case 'remote_modified':\n status.modifiedRemotely.push(c.filePath);\n break;\n case 'local_new':\n status.onlyLocal.push(c.filePath);\n break;\n case 'remote_new':\n status.onlyRemote.push(c.filePath);\n break;\n case 'remote_deleted':\n status.modifiedRemotely.push(c.filePath);\n break;\n case 'local_deleted':\n status.modifiedLocally.push(c.filePath);\n break;\n default:\n // All conflict types\n status.conflicts!.push(SyncService.buildConflicts([c])[0]);\n break;\n }\n }\n\n return status;\n }\n\n async pull(options?: SyncOptions): Promise<{\n downloaded: string[];\n deleted: string[];\n unchanged: string[];\n conflicts: SyncConflict[];\n conflictFilesWritten: string[];\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n ensureDirectoryExists(filesDir);\n\n const syncState = this.loadSyncState();\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter files based on includes\n if (!options?.all) {\n remoteFiles = remoteFiles.filter((f) => shouldIncludeFile(f.path, this.tenant, options));\n }\n\n // Batch fetch metadata for all files\n remoteFiles = await this.fetchMetadataForFiles(remoteFiles);\n\n const result = {\n downloaded: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n conflicts: [] as SyncConflict[],\n conflictFilesWritten: [] as string[],\n };\n\n // Download file contents in parallel with concurrency limit\n logger.dim(`Fetching ${remoteFiles.length} files in parallel...`);\n const fileContents = await fetchWithConcurrency(\n remoteFiles,\n async (file, index) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n // Show progress every 10 files\n if ((index + 1) % 10 === 0 || index === remoteFiles.length - 1) {\n process.stdout.write(`\\r Progress: ${index + 1}/${remoteFiles.length} files`);\n }\n return { file, content };\n },\n 15,\n );\n // Clear progress line\n if (remoteFiles.length > 0) {\n process.stdout.write('\\r' + ' '.repeat(50) + '\\r');\n }\n\n // Build remote content map with hashes\n const remoteContentMap = new Map<string, { file: RemoteFile; content: Buffer; hash: string }>();\n const remoteHashes = new Map<string, string>();\n for (const { file, content } of fileContents) {\n const hash = calculateHash(content);\n remoteContentMap.set(file.path, { file, content, hash });\n remoteHashes.set(file.path, hash);\n }\n\n // Build local hashes\n const localFiles = getAllFilesInDir(filesDir);\n const localHashes = new Map<string, string>();\n for (const localFile of localFiles) {\n if (!options?.all && !shouldIncludeFile(localFile, this.tenant, options)) {\n continue;\n }\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n localHashes.set(localFile, calculateHash(content));\n }\n\n // Three-way comparison\n const comparisons = this.compareFiles({\n localHashes,\n remoteHashes,\n syncState,\n all: options?.all,\n includeExtensions: options?.includeExtensions,\n includeFolders: options?.includeFolders,\n });\n const resolutions = options?.conflictResolutions ?? {};\n\n for (const comparison of comparisons) {\n const { filePath, changeType } = comparison;\n const localPath = path.join(filesDir, filePath);\n const remoteInfo = remoteContentMap.get(filePath);\n\n switch (changeType) {\n case 'unchanged':\n case 'local_modified':\n case 'local_new':\n result.unchanged.push(filePath);\n // Update sync state for remote side if we have remote info\n if (remoteInfo) {\n const existingSync = syncState.files[filePath];\n if (existingSync) {\n existingSync.remoteHash = remoteInfo.hash;\n existingSync.metadata = this.buildMetadata(remoteInfo.file);\n }\n }\n break;\n\n case 'local_deleted':\n // Local deleted, remote unchanged - skip (push will handle)\n result.unchanged.push(filePath);\n break;\n\n case 'remote_modified':\n case 'remote_new':\n // Safe to write\n ensureDirectoryExists(path.dirname(localPath));\n fs.writeFileSync(localPath, remoteInfo!.content);\n result.downloaded.push(filePath);\n syncState.files[filePath] = {\n localHash: remoteInfo!.hash,\n remoteHash: remoteInfo!.hash,\n metadata: this.buildMetadata(remoteInfo!.file),\n };\n break;\n\n case 'remote_deleted':\n // Safe to delete (local is unchanged)\n if (fs.existsSync(localPath)) {\n fs.unlinkSync(localPath);\n }\n result.deleted.push(filePath);\n delete syncState.files[filePath];\n break;\n\n case 'conflict_both_modified':\n case 'conflict_local_modified_remote_deleted':\n case 'conflict_local_deleted_remote_modified':\n case 'conflict_both_new': {\n if (options?.force) {\n // Force: apply remote state\n if (remoteInfo) {\n ensureDirectoryExists(path.dirname(localPath));\n fs.writeFileSync(localPath, remoteInfo.content);\n result.downloaded.push(filePath);\n syncState.files[filePath] = {\n localHash: remoteInfo.hash,\n remoteHash: remoteInfo.hash,\n metadata: this.buildMetadata(remoteInfo.file),\n };\n } else {\n // Remote deleted, force means delete local\n if (fs.existsSync(localPath)) {\n fs.unlinkSync(localPath);\n result.deleted.push(filePath);\n }\n delete syncState.files[filePath];\n }\n break;\n }\n\n const resolution = resolutions[filePath];\n if (!resolution) {\n // No resolution provided - report conflict, skip file\n result.conflicts.push(SyncService.buildConflicts([comparison])[0]);\n break;\n }\n\n switch (resolution) {\n case 'keep_local':\n // Keep local as-is, update sync state to mark conflict resolved\n if (fs.existsSync(localPath)) {\n const localContent = fs.readFileSync(localPath);\n const localHash = calculateHash(localContent);\n syncState.files[filePath] = {\n localHash,\n remoteHash: comparison.currentRemoteHash ?? '',\n metadata: remoteInfo ? this.buildMetadata(remoteInfo.file) : undefined,\n };\n } else {\n // Local was deleted, user wants to keep that decision\n delete syncState.files[filePath];\n }\n result.unchanged.push(filePath);\n break;\n\n case 'keep_remote':\n if (remoteInfo) {\n ensureDirectoryExists(path.dirname(localPath));\n fs.writeFileSync(localPath, remoteInfo.content);\n result.downloaded.push(filePath);\n syncState.files[filePath] = {\n localHash: remoteInfo.hash,\n remoteHash: remoteInfo.hash,\n metadata: this.buildMetadata(remoteInfo.file),\n };\n } else {\n // Remote deleted\n if (fs.existsSync(localPath)) {\n fs.unlinkSync(localPath);\n result.deleted.push(filePath);\n }\n delete syncState.files[filePath];\n }\n break;\n\n case 'keep_both':\n if (remoteInfo) {\n // Write remote version as .remote file alongside local\n const ext = path.extname(filePath);\n const base = filePath.slice(0, -ext.length || undefined);\n const conflictFileName = `${base}.remote${ext}`;\n const conflictPath = path.join(filesDir, conflictFileName);\n ensureDirectoryExists(path.dirname(conflictPath));\n fs.writeFileSync(conflictPath, remoteInfo.content);\n result.conflictFilesWritten.push(conflictFileName);\n }\n // Keep local, update sync state\n if (fs.existsSync(localPath)) {\n const localContent = fs.readFileSync(localPath);\n const localHash = calculateHash(localContent);\n syncState.files[filePath] = {\n localHash,\n remoteHash: comparison.currentRemoteHash ?? '',\n metadata: remoteInfo ? this.buildMetadata(remoteInfo.file) : undefined,\n };\n }\n result.unchanged.push(filePath);\n break;\n }\n break;\n }\n }\n }\n\n syncState.lastSync = new Date().toISOString();\n this.saveSyncState(syncState);\n\n return result;\n }\n\n private buildMetadata(file: RemoteFile): SyncFileInfo['metadata'] {\n if (!file.metadata) return undefined;\n return {\n uploadTime: file.metadata.uploadTime,\n uploaderEmail: file.metadata.uploader?.email,\n uploaderName: file.metadata.uploader\n ? `${file.metadata.uploader.firstName} ${file.metadata.uploader.lastName}`.trim()\n : undefined,\n lastFetched: new Date().toISOString(),\n };\n }\n\n async push(options?: { force?: boolean }): Promise<{\n uploaded: string[];\n updated: string[];\n deleted: string[];\n unchanged: string[];\n conflicts: SyncConflict[];\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n const syncState = this.loadSyncState();\n\n const result = {\n uploaded: [] as string[],\n updated: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n conflicts: [] as SyncConflict[],\n };\n\n // Get current remote files (just the list, not content)\n const remoteFiles = await this.farseerClient.listFiles();\n const remoteFileMap = new Map<string, RemoteFile>();\n for (const file of remoteFiles) {\n remoteFileMap.set(file.path, file);\n }\n\n // Get local files and hashes\n const localFiles = getAllFilesInDir(filesDir);\n const localHashes = new Map<string, string>();\n const localContents = new Map<string, Buffer>();\n for (const localFile of localFiles) {\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n localHashes.set(localFile, calculateHash(content));\n localContents.set(localFile, content);\n }\n\n // Identify candidates that need remote content check for conflict detection\n const candidateFiles: string[] = [];\n for (const localFile of localFiles) {\n const syncInfo = syncState.files[localFile];\n const localHash = localHashes.get(localFile)!;\n if (!syncInfo || localHash !== syncInfo.localHash) {\n // Changed or new locally\n if (remoteFileMap.has(localFile)) {\n candidateFiles.push(localFile);\n }\n }\n }\n // Also check files in sync state that no longer exist locally (local deletions)\n const locallyDeletedFiles = Object.keys(syncState.files).filter(\n (f) => !localFiles.includes(f) && remoteFileMap.has(f),\n );\n const filesToFetchRemote = [...new Set([...candidateFiles, ...locallyDeletedFiles])];\n\n // Fetch remote content for conflict detection\n const remoteHashes = new Map<string, string>();\n if (filesToFetchRemote.length > 0 && !options?.force) {\n const toFetch = filesToFetchRemote.filter((f) => remoteFileMap.has(f)).map((f) => remoteFileMap.get(f)!);\n\n const fetched = await fetchWithConcurrency(\n toFetch,\n async (file) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n return { file, hash: calculateHash(content) };\n },\n 15,\n );\n\n for (const { file, hash } of fetched) {\n remoteHashes.set(file.path, hash);\n }\n }\n\n // Three-way comparison for conflict detection\n const comparisons = this.compareFiles({ localHashes, remoteHashes, syncState, all: true });\n const conflictPaths = new Set<string>();\n\n if (!options?.force) {\n for (const c of comparisons) {\n if (c.changeType.startsWith('conflict_')) {\n const conflict = SyncService.buildConflicts([c])[0];\n result.conflicts.push(conflict);\n conflictPaths.add(c.filePath);\n }\n }\n }\n\n // Process non-conflicting files\n for (const localFile of localFiles) {\n if (conflictPaths.has(localFile)) continue;\n\n const localPath = path.join(filesDir, localFile);\n const content = localContents.get(localFile)!;\n const localHash = localHashes.get(localFile)!;\n\n const remoteFile = remoteFileMap.get(localFile);\n const syncInfo = syncState.files[localFile];\n\n if (remoteFile) {\n // File exists on remote - check if local changed since last sync\n if (syncInfo && localHash === syncInfo.localHash) {\n result.unchanged.push(localFile);\n } else {\n // Local file changed - needs update\n await this.farseerClient.updateFile(remoteFile.reference, content, path.basename(localFile));\n result.updated.push(localFile);\n syncState.files[localFile] = {\n localHash: localHash,\n remoteHash: localHash,\n };\n }\n } else {\n // File doesn't exist on remote\n if (syncInfo && localHash === syncInfo.localHash) {\n // Local unchanged, was deleted on remote - skip (don't re-upload)\n result.unchanged.push(localFile);\n } else {\n // New or modified local file - upload\n const pathParts = localFile.split('/');\n const fileName = pathParts.pop()!;\n const folderPath = ['Files', ...pathParts];\n await this.farseerClient.createFile(content, fileName, folderPath);\n result.uploaded.push(localFile);\n syncState.files[localFile] = {\n localHash: localHash,\n remoteHash: localHash,\n };\n }\n }\n }\n\n // Delete files on remote that were deleted locally (non-conflicting only)\n const localFileSet = new Set(localFiles);\n for (const [remotePath, remoteFile] of remoteFileMap) {\n if (!localFileSet.has(remotePath) && !conflictPaths.has(remotePath)) {\n const syncInfo = syncState.files[remotePath];\n if (syncInfo) {\n // Was synced before, now deleted locally - delete on remote\n await this.farseerClient.deleteFile(remoteFile.reference);\n result.deleted.push(remotePath);\n delete syncState.files[remotePath];\n }\n }\n }\n\n syncState.lastSync = new Date().toISOString();\n this.saveSyncState(syncState);\n\n return result;\n }\n\n async checkRemoteChanges(options?: SyncOptions): Promise<boolean> {\n const syncState = this.loadSyncState();\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter files based on includes to avoid false positives\n remoteFiles = remoteFiles.filter((f) => shouldIncludeFile(f.path, this.tenant, options));\n\n // Quick check: new files on remote that we don't have in sync state\n for (const file of remoteFiles) {\n const syncInfo = syncState.files[file.path];\n if (!syncInfo) {\n return true; // New file on remote\n }\n }\n\n // Quick check: files deleted on remote that we have in sync state\n for (const filePath of Object.keys(syncState.files)) {\n // Only check included files\n if (!shouldIncludeFile(filePath, this.tenant, options)) continue;\n\n const exists = remoteFiles.some((f) => f.path === filePath);\n if (!exists && syncState.files[filePath].remoteHash) {\n return true; // File was deleted on remote\n }\n }\n\n // Note: We don't check for content changes here anymore for performance.\n // After a pull, sync state is accurate. Content changes by others\n // between pull and push are a rare edge case - user should pull first.\n return false;\n }\n\n async getFileDiff(filePath: string): Promise<{\n localContent: string | null;\n remoteContent: string | null;\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n const localPath = path.join(filesDir, filePath);\n\n let localContent: string | null = null;\n let remoteContent: string | null = null;\n\n if (fs.existsSync(localPath)) {\n // For diff, read as text (diff only makes sense for text files)\n localContent = fs.readFileSync(localPath, 'utf-8');\n }\n\n const remoteFile = await this.farseerClient.getFileByPath(filePath);\n if (remoteFile) {\n remoteContent = await this.farseerClient.getFileContent(remoteFile.reference);\n }\n\n return { localContent, remoteContent };\n }\n\n /**\n * Three-way comparison of all files.\n * Compares current local state, current remote state, and baseline from sync state.\n */\n compareFiles(options: {\n localHashes: Map<string, string>;\n remoteHashes: Map<string, string>;\n syncState: SyncState;\n all?: boolean;\n includeExtensions?: string[];\n includeFolders?: string[];\n }): FileCompareResult[] {\n const { localHashes, remoteHashes, syncState } = options;\n\n // Union of all known file paths\n const allPaths = new Set<string>([\n ...localHashes.keys(),\n ...remoteHashes.keys(),\n ...Object.keys(syncState.files),\n ]);\n\n const results: FileCompareResult[] = [];\n\n for (const filePath of allPaths) {\n // Filter files based on includes\n if (!options.all) {\n if (!shouldIncludeFile(filePath, this.tenant, options)) {\n continue;\n }\n }\n\n const currentLocalHash = localHashes.get(filePath) ?? null;\n const currentRemoteHash = remoteHashes.get(filePath) ?? null;\n const baseline = syncState.files[filePath];\n const baselineLocalHash = baseline?.localHash ?? null;\n const baselineRemoteHash = baseline?.remoteHash ?? null;\n\n const localExists = currentLocalHash !== null;\n const remoteExists = currentRemoteHash !== null;\n const hadBaseline = baseline != null;\n\n let changeType: FileChangeType;\n\n if (localExists && remoteExists) {\n // Both exist\n if (currentLocalHash === currentRemoteHash) {\n changeType = 'unchanged';\n } else if (!hadBaseline) {\n changeType = 'conflict_both_new';\n } else {\n const localChanged = currentLocalHash !== baselineLocalHash;\n const remoteChanged = currentRemoteHash !== baselineRemoteHash;\n\n if (localChanged && remoteChanged) {\n changeType = 'conflict_both_modified';\n } else if (localChanged) {\n changeType = 'local_modified';\n } else if (remoteChanged) {\n changeType = 'remote_modified';\n } else {\n changeType = 'unchanged';\n }\n }\n } else if (localExists && !remoteExists) {\n // Only local exists\n if (!hadBaseline) {\n changeType = 'local_new';\n } else {\n const localChanged = currentLocalHash !== baselineLocalHash;\n if (localChanged) {\n changeType = 'conflict_local_modified_remote_deleted';\n } else {\n changeType = 'remote_deleted';\n }\n }\n } else if (!localExists && remoteExists) {\n // Only remote exists\n if (!hadBaseline) {\n changeType = 'remote_new';\n } else {\n const remoteChanged = currentRemoteHash !== baselineRemoteHash;\n if (remoteChanged) {\n changeType = 'conflict_local_deleted_remote_modified';\n } else {\n changeType = 'local_deleted';\n }\n }\n } else {\n // Neither exists - both deleted since baseline, clean up\n continue;\n }\n\n results.push({\n filePath,\n changeType,\n currentLocalHash,\n currentRemoteHash,\n baselineLocalHash,\n baselineRemoteHash,\n });\n }\n\n return results;\n }\n\n /**\n * Extract SyncConflict[] from FileCompareResult[].\n */\n static buildConflicts(comparisons: FileCompareResult[]): SyncConflict[] {\n const conflicts: SyncConflict[] = [];\n for (const c of comparisons) {\n switch (c.changeType) {\n case 'conflict_both_modified':\n conflicts.push({\n filePath: c.filePath,\n type: 'both_modified',\n description: 'Both local and remote versions modified since last sync',\n });\n break;\n case 'conflict_local_modified_remote_deleted':\n conflicts.push({\n filePath: c.filePath,\n type: 'local_modified_remote_deleted',\n description: 'File modified locally but deleted on remote',\n });\n break;\n case 'conflict_local_deleted_remote_modified':\n conflicts.push({\n filePath: c.filePath,\n type: 'local_deleted_remote_modified',\n description: 'File deleted locally but modified on remote',\n });\n break;\n case 'conflict_both_new':\n conflicts.push({\n filePath: c.filePath,\n type: 'both_new',\n description: 'File exists both locally and remotely with different content (no sync baseline)',\n });\n break;\n }\n }\n return conflicts;\n }\n\n /**\n * Batch fetch metadata for multiple files in parallel.\n * Fetches metadata in batches of 10 to avoid overwhelming the API.\n * Non-critical operation - failures are silently ignored.\n */\n private async fetchMetadataForFiles(files: RemoteFile[]): Promise<RemoteFile[]> {\n const batchSize = 10;\n\n for (let i = 0; i < files.length; i += batchSize) {\n const batch = files.slice(i, i + batchSize);\n\n await Promise.all(\n batch.map(async (file) => {\n try {\n const metadata = await this.farseerClient.getFileMetadata(file.reference);\n if (metadata) {\n file.metadata = metadata;\n }\n } catch {\n // Silently ignore metadata fetch errors - non-critical\n }\n }),\n );\n }\n\n return files;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,4BAAsE;AACtE,2BAAgC;AAChC,qBAOO;AACP,oBAAuB;AAoBhB,SAAS,kBACZ,UACA,QACA,SACO;AACP,MAAI,SAAS,IAAK,QAAO;AAEzB,QAAM,MAAM,KAAK,QAAQ,QAAQ,EAAE,YAAY;AAG/C,MAAI,gDAA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AAO;AAAA,EACX;AACJ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var updateCheck_exports = {};
30
+ __export(updateCheck_exports, {
31
+ checkForUpdates: () => checkForUpdates
32
+ });
33
+ module.exports = __toCommonJS(updateCheck_exports);
34
+ var https = __toESM(require("https"));
35
+ var fs = __toESM(require("fs"));
36
+ var path = __toESM(require("path"));
37
+ var os = __toESM(require("os"));
38
+ var import_chalk = __toESM(require("chalk"));
39
+ var import_constants = require("./constants");
40
+ const CONFIG_DIR = path.join(os.homedir(), ".farseer");
41
+ const CACHE_FILE = path.join(CONFIG_DIR, "update-check.json");
42
+ const CACHE_TTL_MS = 4 * 60 * 60 * 1e3;
43
+ const FETCH_TIMEOUT_MS = 3e3;
44
+ const REGISTRY_URL = "https://registry.npmjs.org/farseer-cli/latest";
45
+ function isNewerVersion(latest, current) {
46
+ const latestParts = latest.split(".").map(Number);
47
+ const currentParts = current.split(".").map(Number);
48
+ for (let i = 0; i < 3; i++) {
49
+ const l = latestParts[i] || 0;
50
+ const c = currentParts[i] || 0;
51
+ if (l > c) return true;
52
+ if (l < c) return false;
53
+ }
54
+ return false;
55
+ }
56
+ function readCache() {
57
+ try {
58
+ const data = JSON.parse(fs.readFileSync(CACHE_FILE, "utf-8"));
59
+ if (typeof data.lastCheck === "number" && typeof data.latestVersion === "string") {
60
+ return data;
61
+ }
62
+ } catch {
63
+ }
64
+ return null;
65
+ }
66
+ function writeCache(latestVersion) {
67
+ try {
68
+ if (!fs.existsSync(CONFIG_DIR)) {
69
+ fs.mkdirSync(CONFIG_DIR, { recursive: true });
70
+ }
71
+ const data = { lastCheck: Date.now(), latestVersion };
72
+ fs.writeFileSync(CACHE_FILE, JSON.stringify(data), "utf-8");
73
+ } catch {
74
+ }
75
+ }
76
+ function fetchLatestVersion() {
77
+ return new Promise((resolve) => {
78
+ const req = https.get(REGISTRY_URL, { timeout: FETCH_TIMEOUT_MS }, (res) => {
79
+ if (res.statusCode !== 200) {
80
+ res.resume();
81
+ resolve(null);
82
+ return;
83
+ }
84
+ let body = "";
85
+ res.setEncoding("utf-8");
86
+ res.on("data", (chunk) => body += chunk);
87
+ res.on("end", () => {
88
+ try {
89
+ const json = JSON.parse(body);
90
+ resolve(typeof json.version === "string" ? json.version : null);
91
+ } catch {
92
+ resolve(null);
93
+ }
94
+ });
95
+ });
96
+ req.on("error", () => resolve(null));
97
+ req.on("timeout", () => {
98
+ req.destroy();
99
+ resolve(null);
100
+ });
101
+ });
102
+ }
103
+ async function checkForUpdates() {
104
+ try {
105
+ let latestVersion = null;
106
+ const cache = readCache();
107
+ if (cache && Date.now() - cache.lastCheck < CACHE_TTL_MS) {
108
+ latestVersion = cache.latestVersion;
109
+ } else {
110
+ latestVersion = await fetchLatestVersion();
111
+ if (latestVersion) {
112
+ writeCache(latestVersion);
113
+ }
114
+ }
115
+ if (latestVersion && isNewerVersion(latestVersion, import_constants.CLI_VERSION)) {
116
+ return [
117
+ "",
118
+ import_chalk.default.yellow(` Update available: ${import_constants.CLI_VERSION} \u2192 ${import_chalk.default.green(latestVersion)}`),
119
+ import_chalk.default.yellow(` Run ${import_chalk.default.cyan("npm install -g farseer-cli@latest")} to update`),
120
+ ""
121
+ ].join("\n");
122
+ }
123
+ return null;
124
+ } catch {
125
+ return null;
126
+ }
127
+ }
128
+ // Annotate the CommonJS export names for ESM import in node:
129
+ 0 && (module.exports = {
130
+ checkForUpdates
131
+ });
132
+ //# sourceMappingURL=updateCheck.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/updateCheck.ts"],
4
+ "sourcesContent": ["import * as https from 'https';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as os from 'os';\nimport chalk from 'chalk';\nimport { CLI_VERSION } from './constants';\n\nconst CONFIG_DIR = path.join(os.homedir(), '.farseer');\nconst CACHE_FILE = path.join(CONFIG_DIR, 'update-check.json');\nconst CACHE_TTL_MS = 4 * 60 * 60 * 1000; // 4 hours\nconst FETCH_TIMEOUT_MS = 3000;\nconst REGISTRY_URL = 'https://registry.npmjs.org/farseer-cli/latest';\n\ninterface UpdateCache {\n lastCheck: number;\n latestVersion: string;\n}\n\nfunction isNewerVersion(latest: string, current: string): boolean {\n const latestParts = latest.split('.').map(Number);\n const currentParts = current.split('.').map(Number);\n for (let i = 0; i < 3; i++) {\n const l = latestParts[i] || 0;\n const c = currentParts[i] || 0;\n if (l > c) return true;\n if (l < c) return false;\n }\n return false;\n}\n\nfunction readCache(): UpdateCache | null {\n try {\n const data = JSON.parse(fs.readFileSync(CACHE_FILE, 'utf-8'));\n if (typeof data.lastCheck === 'number' && typeof data.latestVersion === 'string') {\n return data as UpdateCache;\n }\n } catch {\n // Cache missing or corrupt \u2014 ignore\n }\n return null;\n}\n\nfunction writeCache(latestVersion: string): void {\n try {\n if (!fs.existsSync(CONFIG_DIR)) {\n fs.mkdirSync(CONFIG_DIR, { recursive: true });\n }\n const data: UpdateCache = { lastCheck: Date.now(), latestVersion };\n fs.writeFileSync(CACHE_FILE, JSON.stringify(data), 'utf-8');\n } catch {\n // Non-critical \u2014 ignore write errors\n }\n}\n\nfunction fetchLatestVersion(): Promise<string | null> {\n return new Promise((resolve) => {\n const req = https.get(REGISTRY_URL, { timeout: FETCH_TIMEOUT_MS }, (res) => {\n if (res.statusCode !== 200) {\n res.resume(); // drain response\n resolve(null);\n return;\n }\n let body = '';\n res.setEncoding('utf-8');\n res.on('data', (chunk) => (body += chunk));\n res.on('end', () => {\n try {\n const json = JSON.parse(body);\n resolve(typeof json.version === 'string' ? json.version : null);\n } catch {\n resolve(null);\n }\n });\n });\n req.on('error', () => resolve(null));\n req.on('timeout', () => {\n req.destroy();\n resolve(null);\n });\n });\n}\n\nexport async function checkForUpdates(): Promise<string | null> {\n try {\n let latestVersion: string | null = null;\n\n const cache = readCache();\n if (cache && Date.now() - cache.lastCheck < CACHE_TTL_MS) {\n latestVersion = cache.latestVersion;\n } else {\n latestVersion = await fetchLatestVersion();\n if (latestVersion) {\n writeCache(latestVersion);\n }\n }\n\n if (latestVersion && isNewerVersion(latestVersion, CLI_VERSION)) {\n return [\n '',\n chalk.yellow(` Update available: ${CLI_VERSION} \u2192 ${chalk.green(latestVersion)}`),\n chalk.yellow(` Run ${chalk.cyan('npm install -g farseer-cli@latest')} to update`),\n '',\n ].join('\\n');\n }\n\n return null;\n } catch {\n // Graceful failure \u2014 never let update check break the CLI\n return null;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,SAAoB;AACpB,WAAsB;AACtB,S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- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "CLI tool for syncing Farseer App scripts between local folder and Farseer instances",
5
5
  "main": "dist/index.js",
6
6
  "bin": {