@tenonhq/sincronia-core 0.0.71 → 0.0.72

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,9 +32,6 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
36
  exports.initScopesCommand = initScopesCommand;
40
37
  exports.watchAllScopesCommand = watchAllScopesCommand;
@@ -47,7 +44,6 @@ const commands_1 = require("./commands");
47
44
  const path = __importStar(require("path"));
48
45
  const fs = __importStar(require("fs"));
49
46
  const child_process_1 = require("child_process");
50
- const progress_1 = __importDefault(require("progress"));
51
47
  const fsp = fs.promises;
52
48
  // Custom function to process manifest with specific source directory
53
49
  async function processManifestForScope(manifest, sourceDirectory, forceWrite = false) {
@@ -62,20 +58,7 @@ async function processManifestForScope(manifest, sourceDirectory, forceWrite = f
62
58
  }
63
59
  const tables = manifest.tables || {};
64
60
  const tableNames = Object.keys(tables);
65
- var totalRecords = 0;
66
- for (var tn = 0; tn < tableNames.length; tn++) {
67
- totalRecords += Object.keys(tables[tableNames[tn]].records || {}).length;
68
- }
69
- var scopeLabel = sourceDirectory.split(path.sep).pop() || "scope";
70
- var progBar = null;
71
- if (Logger_1.logger.getLogLevel() === "info" && totalRecords > 0) {
72
- progBar = new progress_1.default(":scope :bar :current/:total (:percent)", {
73
- total: totalRecords,
74
- width: 40,
75
- complete: "=",
76
- incomplete: "-",
77
- });
78
- }
61
+ Logger_1.logger.info("Processing " + tableNames.length + " tables for " + sourceDirectory);
79
62
  for (const tableName of tableNames) {
80
63
  const tableRecords = tables[tableName];
81
64
  const tablePath = path.join(sourceDirectory, tableName);
@@ -119,10 +102,9 @@ async function processManifestForScope(manifest, sourceDirectory, forceWrite = f
119
102
  Logger_1.logger.error("Failed to write metadata: " + metadataFilePath);
120
103
  }
121
104
  }
122
- if (progBar)
123
- progBar.tick({ scope: scopeLabel });
124
105
  }
125
106
  }
107
+ Logger_1.logger.info("Files written to " + sourceDirectory);
126
108
  }
127
109
  catch (error) {
128
110
  Logger_1.logger.error("Error processing files for " + sourceDirectory + ": " + error);
package/dist/appUtils.js CHANGED
@@ -89,7 +89,7 @@ const processFilesInManRec = async (recPath, rec, forceWrite) => {
89
89
  return fileCopy;
90
90
  });
91
91
  };
92
- const processRecsInManTable = async (tablePath, table, forceWrite, onRecordProcessed) => {
92
+ const processRecsInManTable = async (tablePath, table, forceWrite) => {
93
93
  const { records } = table;
94
94
  const recKeys = Object.keys(records);
95
95
  const recKeyToPath = (key) => path_1.default.join(tablePath, records[key].name);
@@ -100,36 +100,23 @@ const processRecsInManTable = async (tablePath, table, forceWrite, onRecordProce
100
100
  const filePromises = recKeys.reduce((acc, recKey) => {
101
101
  return [
102
102
  ...acc,
103
- processFilesInManRec(recKeyToPath(recKey), records[recKey], forceWrite).then(function () {
104
- if (onRecordProcessed)
105
- onRecordProcessed();
106
- }),
103
+ processFilesInManRec(recKeyToPath(recKey), records[recKey], forceWrite),
107
104
  ];
108
105
  }, []);
109
106
  return Promise.all(filePromises);
110
107
  };
111
- const countRecordsInTables = (tables) => {
112
- return Object.keys(tables).reduce(function (sum, tableName) {
113
- return sum + Object.keys(tables[tableName].records).length;
114
- }, 0);
115
- };
116
- const processTablesInManifest = async (tables, forceWrite, sourcePath, onRecordProcessed) => {
108
+ const processTablesInManifest = async (tables, forceWrite, sourcePath) => {
117
109
  var basePath = sourcePath || ConfigManager.getSourcePath();
118
110
  const tableNames = Object.keys(tables);
119
111
  const tablePromises = tableNames.map((tableName) => {
120
- return processRecsInManTable(path_1.default.join(basePath, tableName), tables[tableName], forceWrite, onRecordProcessed);
112
+ return processRecsInManTable(path_1.default.join(basePath, tableName), tables[tableName], forceWrite);
121
113
  });
122
114
  await Promise.all(tablePromises);
123
115
  };
124
116
  const processManifest = async (manifest, forceWrite = false, sourcePath) => {
125
117
  const tableCount = Object.keys(manifest.tables).length;
126
118
  FileLogger_1.fileLogger.debug("Processing manifest: " + (manifest.scope || "legacy") + " (" + tableCount + " tables)");
127
- var recordCount = countRecordsInTables(manifest.tables);
128
- var progress = createScopeProgress(Logger_1.logger.getLogLevel(), {
129
- scope: manifest.scope || "default",
130
- total: recordCount,
131
- });
132
- await processTablesInManifest(manifest.tables, forceWrite, sourcePath, progress.tick);
119
+ await processTablesInManifest(manifest.tables, forceWrite, sourcePath);
133
120
  if (manifest.scope) {
134
121
  await fUtils.writeScopeManifest(manifest.scope, manifest);
135
122
  }
@@ -258,18 +245,13 @@ const processMissingFiles = async (newManifest, sourcePath) => {
258
245
  try {
259
246
  const missing = await (0, exports.findMissingFiles)(newManifest, sourcePath);
260
247
  const missingTableCount = Object.keys(missing).length;
261
- if (missingTableCount === 0)
262
- return;
263
- FileLogger_1.fileLogger.debug("Downloading missing files from " + missingTableCount + " tables");
248
+ if (missingTableCount > 0) {
249
+ FileLogger_1.fileLogger.debug("Downloading missing files from " + missingTableCount + " tables");
250
+ }
264
251
  const { tableOptions = {} } = ConfigManager.getConfig();
265
252
  const client = (0, snClient_1.defaultClient)();
266
253
  const filesToProcess = await (0, snClient_1.unwrapSNResponse)(client.getMissingFiles(missing, tableOptions));
267
- var recordCount = countRecordsInTables(filesToProcess);
268
- var progress = createScopeProgress(Logger_1.logger.getLogLevel(), {
269
- scope: newManifest.scope || "default",
270
- total: recordCount,
271
- });
272
- await processTablesInManifest(filesToProcess, false, sourcePath, progress.tick);
254
+ await processTablesInManifest(filesToProcess, false, sourcePath);
273
255
  }
274
256
  catch (e) {
275
257
  throw e;
@@ -393,25 +375,6 @@ const pushFiles = async (recs) => {
393
375
  exports.pushFiles = pushFiles;
394
376
  const summarizeRecord = (table, recDescriptor) => `${table} > ${recDescriptor}`;
395
377
  exports.summarizeRecord = summarizeRecord;
396
- const createScopeProgress = (logLevel, options) => {
397
- if (logLevel !== "info" || options.total === 0) {
398
- return { tick: function () { }, setTotal: function () { } };
399
- }
400
- var progBar = new progress_1.default(":scope :bar :current/:total (:percent)", {
401
- total: options.total,
402
- width: 40,
403
- complete: "=",
404
- incomplete: "-",
405
- });
406
- return {
407
- tick: function () {
408
- progBar.tick({ scope: options.scope });
409
- },
410
- setTotal: function (n) {
411
- progBar.total = n;
412
- },
413
- };
414
- };
415
378
  const getProgTick = (logLevel, total) => {
416
379
  if (logLevel === "info") {
417
380
  const progBar = new progress_1.default(":bar (:percent)", {
package/dist/commands.js CHANGED
@@ -233,6 +233,7 @@ async function downloadCommand(args) {
233
233
  });
234
234
  Logger_1.logger.info("Received " + tableCount + " tables, " + recordCount + " records");
235
235
  FileLogger_1.fileLogger.debug("Download manifest: " + tableCount + " tables, " + recordCount + " records");
236
+ Logger_1.logger.info("Writing files to disk...");
236
237
  await AppUtils.processManifest(man, true);
237
238
  Logger_1.logger.success("Download complete — " + recordCount + " records written");
238
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenonhq/sincronia-core",
3
- "version": "0.0.71",
3
+ "version": "0.0.72",
4
4
  "description": "Next-gen file syncer",
5
5
  "license": "GPL-3.0",
6
6
  "main": "./dist/index.js",