farseer-cli 1.7.1 → 1.7.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.
@@ -32,6 +32,8 @@ __export(syncService_exports, {
32
32
  MERGE_MARKER_REMOTE_END: () => MERGE_MARKER_REMOTE_END,
33
33
  MERGE_MARKER_SEPARATOR: () => MERGE_MARKER_SEPARATOR,
34
34
  SyncService: () => SyncService,
35
+ buildHiddenDirSkipper: () => buildHiddenDirSkipper,
36
+ classifyIgnoredFile: () => classifyIgnoredFile,
35
37
  isHiddenFile: () => import_helpers2.isHiddenFile,
36
38
  isOsMetadataFile: () => import_helpers2.isOsMetadataFile,
37
39
  shouldIncludeFile: () => shouldIncludeFile
@@ -45,7 +47,38 @@ var import_helpers = require("../utils/helpers");
45
47
  var import_logger = require("../utils/logger");
46
48
  var import_fileValidation = require("../utils/fileValidation");
47
49
  var import_errorFormatter = require("../utils/errorFormatter");
50
+ var import_syncReporting = require("../utils/syncReporting");
48
51
  var import_helpers2 = require("../utils/helpers");
52
+ const IGNORED_FOLDER_BLOCKLIST = ["node_modules", "dist", "build", "bower_components", "coverage", "__pycache__"];
53
+ function classifyIgnoredFile(filePath) {
54
+ const segments = filePath.split("/");
55
+ for (const seg of segments) {
56
+ if (IGNORED_FOLDER_BLOCKLIST.includes(seg)) return "blocklistedFolder";
57
+ }
58
+ return "unsupportedExtension";
59
+ }
60
+ function buildHiddenDirSkipper(options, configFolders) {
61
+ const normalize = (f) => f.split(path.sep).join("/").replace(/^\/+|\/+$/g, "");
62
+ const includeFolders = [...options?.includeFolders ?? [], ...configFolders].map(
63
+ (f) => f.split(path.sep).join("/").replace(/\/+$/, "")
64
+ );
65
+ const onlyFilesPosix = (options?.onlyFiles ?? []).map(normalize);
66
+ return (relPath) => {
67
+ const posix = relPath.split(path.sep).join("/");
68
+ if (!(0, import_helpers.isHiddenFile)(posix)) return false;
69
+ for (const include of includeFolders) {
70
+ if (posix === include) return false;
71
+ if (posix.startsWith(include + "/")) return false;
72
+ if (include.startsWith(posix + "/")) return false;
73
+ }
74
+ for (const only of onlyFilesPosix) {
75
+ if (only === posix) return false;
76
+ if (only.startsWith(posix + "/")) return false;
77
+ if (posix.startsWith(only + "/")) return false;
78
+ }
79
+ return true;
80
+ };
81
+ }
49
82
  function shouldIncludeFile(filePath, tenant, options) {
50
83
  if ((0, import_helpers.isOsMetadataFile)(filePath)) return false;
51
84
  if (options?.onlyFiles && options.onlyFiles.length > 0) {
@@ -53,8 +86,10 @@ function shouldIncludeFile(filePath, tenant, options) {
53
86
  }
54
87
  const ext = path.extname(filePath).toLowerCase();
55
88
  const persistent = (0, import_configService.getSyncIncludes)(tenant);
56
- const matchesIncludes = (options?.includeExtensions?.includes(ext) ?? false) || (options?.includeFolders?.some((f) => filePath.startsWith(f + "/") || filePath === f) ?? false) || (persistent?.extensions?.includes(ext) ?? false) || (persistent?.folders?.some((f) => filePath.startsWith(f + "/") || filePath === f) ?? false);
57
- if ((0, import_helpers.isHiddenFile)(filePath)) return matchesIncludes;
89
+ const folderMatches = (options?.includeFolders?.some((f) => filePath.startsWith(f + "/") || filePath === f) ?? false) || (persistent?.folders?.some((f) => filePath.startsWith(f + "/") || filePath === f) ?? false);
90
+ if ((0, import_helpers.isHiddenFile)(filePath)) return folderMatches;
91
+ const extensionMatches = (options?.includeExtensions?.includes(ext) ?? false) || (persistent?.extensions?.includes(ext) ?? false);
92
+ const matchesIncludes = folderMatches || extensionMatches;
58
93
  if (options?.all) return true;
59
94
  if (import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.includes(ext)) return true;
60
95
  return matchesIncludes;
@@ -69,7 +104,10 @@ function emptyStatus(deepCompare) {
69
104
  deletedRemotely: [],
70
105
  inSync: [],
71
106
  conflicts: [],
72
- deepCompare
107
+ deepCompare,
108
+ ignoredLocal: [],
109
+ ignoredLocalTotal: 0,
110
+ ignoredLocalTotalByReason: { unsupportedExtension: 0, blocklistedFolder: 0 }
73
111
  };
74
112
  }
75
113
  const MERGE_MARKER_LOCAL_START = "<<<<<<< LOCAL (your version)";
@@ -119,7 +157,28 @@ class SyncService {
119
157
  const deep = options?.deep === true;
120
158
  const syncState = this.loadSyncState();
121
159
  const filesDir = (0, import_helpers.getTenantFilesDir)(this.tenant);
122
- const localFiles = (0, import_helpers.getAllFilesInDir)(filesDir).filter((f) => shouldIncludeFile(f, this.tenant, options));
160
+ const includeFoldersFromConfig = (0, import_configService.getSyncIncludes)(this.tenant)?.folders ?? [];
161
+ const skipHiddenDir = buildHiddenDirSkipper(options, includeFoldersFromConfig);
162
+ const allLocalFiles = (0, import_helpers.getAllFilesInDir)(filesDir, { shouldSkipDir: skipHiddenDir });
163
+ const localFiles = [];
164
+ const ignoredLocal = [];
165
+ let ignoredLocalTotal = 0;
166
+ const ignoredLocalTotalByReason = { unsupportedExtension: 0, blocklistedFolder: 0 };
167
+ const suppressIgnoredLocal = (options?.onlyFiles?.length ?? 0) > 0;
168
+ for (const f of allLocalFiles) {
169
+ if (shouldIncludeFile(f, this.tenant, options)) {
170
+ localFiles.push(f);
171
+ continue;
172
+ }
173
+ if ((0, import_helpers.isOsMetadataFile)(f) || (0, import_helpers.isHiddenFile)(f)) continue;
174
+ if (suppressIgnoredLocal) continue;
175
+ ignoredLocalTotal++;
176
+ const reason = classifyIgnoredFile(f);
177
+ ignoredLocalTotalByReason[reason]++;
178
+ if (ignoredLocal.length < import_syncReporting.IGNORED_LOCAL_CAP) {
179
+ ignoredLocal.push({ path: f, reason });
180
+ }
181
+ }
123
182
  const localHashes = /* @__PURE__ */ new Map();
124
183
  for (const file of localFiles) {
125
184
  const fullPath = (0, import_helpers.safeResolveWithinBase)(filesDir, file);
@@ -165,6 +224,9 @@ class SyncService {
165
224
  onlyFiles: options?.onlyFiles
166
225
  });
167
226
  const status = emptyStatus(deep);
227
+ status.ignoredLocal = ignoredLocal;
228
+ status.ignoredLocalTotal = ignoredLocalTotal;
229
+ status.ignoredLocalTotalByReason = ignoredLocalTotalByReason;
168
230
  if (deep) {
169
231
  status.remoteHashes = remoteHashes;
170
232
  }
@@ -483,16 +545,36 @@ ${remoteContent}${remoteContent.endsWith("\n") ? "" : "\n"}${MERGE_MARKER_REMOTE
483
545
  // own atomic operation, and `syncState` is saved in `finally` so
484
546
  // already-successful items aren't re-uploaded next run. The
485
547
  // caller surfaces this list and exits non-zero on non-empty.
486
- failed: []
548
+ failed: [],
549
+ ignoredLocal: [],
550
+ ignoredLocalTotal: 0,
551
+ ignoredLocalTotalByReason: { unsupportedExtension: 0, blocklistedFolder: 0 }
487
552
  };
488
553
  const remoteFiles = (await this.farseerClient.listFiles()).filter((f) => !(0, import_helpers.isOsMetadataFile)(f.path));
489
554
  const remoteFileMap = /* @__PURE__ */ new Map();
490
555
  for (const file of remoteFiles) {
491
556
  remoteFileMap.set(file.path, file);
492
557
  }
493
- const allLocalFiles = (0, import_helpers.getAllFilesInDir)(filesDir);
558
+ const includeFoldersFromConfig = (0, import_configService.getSyncIncludes)(this.tenant)?.folders ?? [];
559
+ const skipHiddenDir = buildHiddenDirSkipper(options, includeFoldersFromConfig);
560
+ const allLocalFiles = (0, import_helpers.getAllFilesInDir)(filesDir, { shouldSkipDir: skipHiddenDir });
494
561
  const localPresenceSet = new Set(allLocalFiles);
495
- const inScopeFiles = allLocalFiles.filter((f) => shouldIncludeFile(f, this.tenant, options));
562
+ const inScopeFiles = [];
563
+ const suppressIgnoredLocal = (options?.onlyFiles?.length ?? 0) > 0;
564
+ for (const f of allLocalFiles) {
565
+ if (shouldIncludeFile(f, this.tenant, options)) {
566
+ inScopeFiles.push(f);
567
+ continue;
568
+ }
569
+ if (suppressIgnoredLocal) continue;
570
+ if ((0, import_helpers.isOsMetadataFile)(f) || (0, import_helpers.isHiddenFile)(f)) continue;
571
+ result.ignoredLocalTotal++;
572
+ const reason = classifyIgnoredFile(f);
573
+ result.ignoredLocalTotalByReason[reason]++;
574
+ if (result.ignoredLocal.length < import_syncReporting.IGNORED_LOCAL_CAP) {
575
+ result.ignoredLocal.push({ path: f, reason });
576
+ }
577
+ }
496
578
  const localContents = /* @__PURE__ */ new Map();
497
579
  for (const file of inScopeFiles) {
498
580
  const fullPath = (0, import_helpers.safeResolveWithinBase)(filesDir, file);
@@ -851,6 +933,8 @@ ${remoteContent}${remoteContent.endsWith("\n") ? "" : "\n"}${MERGE_MARKER_REMOTE
851
933
  MERGE_MARKER_REMOTE_END,
852
934
  MERGE_MARKER_SEPARATOR,
853
935
  SyncService,
936
+ buildHiddenDirSkipper,
937
+ classifyIgnoredFile,
854
938
  isHiddenFile,
855
939
  isOsMetadataFile,
856
940
  shouldIncludeFile