@qaecy/cue-cli 0.0.5 → 0.0.6

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.
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
29
  mod
30
30
  ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
32
 
32
33
  // libs/js/sync-tools/src/lib/helpers/worker-pool.js
33
34
  var worker_pool_exports = {};
@@ -91,6 +92,13 @@ var init_worker_pool = __esm({
91
92
  }
92
93
  });
93
94
 
95
+ // apps/desktop/cue-cli/src/cue-cli-compare.ts
96
+ var cue_cli_compare_exports = {};
97
+ __export(cue_cli_compare_exports, {
98
+ compareHandler: () => compareHandler
99
+ });
100
+ module.exports = __toCommonJS(cue_cli_compare_exports);
101
+
94
102
  // apps/desktop/cue-cli/src/variables.ts
95
103
  var import_path = require("path");
96
104
  var TOKEN_ENDPOINT_EMULATOR = "http://localhost:8093/token";
@@ -696,9 +704,6 @@ async function deleteUnzipped(dir) {
696
704
  }
697
705
  }
698
706
 
699
- // apps/desktop/cue-cli/src/cue-cli-compare.ts
700
- var import_commander = require("commander");
701
-
702
707
  // apps/desktop/cue-cli/src/helpers/query-handler.ts
703
708
  var import_auth2 = require("firebase/auth");
704
709
  async function queryHandler(query, spaceId, useEmulator) {
@@ -784,120 +789,111 @@ async function authenticate(emulators, key, verbose = false) {
784
789
  }
785
790
 
786
791
  // apps/desktop/cue-cli/src/cue-cli-compare.ts
787
- var program = new import_commander.Command();
788
- program.name("cue-cli-compare").description("Compare to files in Cue").requiredOption("-s, --space <id>", "Specify the space ID (required)").requiredOption("-p, --path <id>", "Specify the folder path (required)").option(
789
- "-k, --key <api-key>",
790
- "Specify the API key (or set CUE_API_KEY env variable)"
791
- ).option(
792
- "--provider <provider ID>",
793
- "Specify the provider ID (eg. sharepoint, drive, dropbox) or leave empty for default provider",
794
- ""
795
- ).option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).option(
796
- "-z, --zip",
797
- "Include zipped content (will temporarily unzip files with same logic as when syncing and delete them again after the comparison)",
798
- false
799
- );
800
- program.parse(process.argv);
801
- async function main(options) {
792
+ async function compareHandler(options) {
802
793
  const { space, path, verbose, provider, emulators, zip } = options;
803
- await authenticate(emulators, options.key, verbose);
804
- if (verbose)
805
- console.info("Building compare base \u23F3");
806
- const qh = async (query) => queryHandler(query, space, emulators);
807
- const [localFiles, remoteFiles] = await Promise.all([
808
- listLocalFiles(
809
- path,
810
- provider,
811
- verbose,
812
- 5,
813
- IGNORED_LOCAL,
814
- HASH_WORKER_PATH,
815
- zip
816
- ),
817
- listRemoteFiles(space, provider, qh, verbose)
818
- ]);
819
- const unzipPromise = zip ? deleteUnzipped(path) : Promise.resolve();
820
- if (zip) {
794
+ try {
795
+ await authenticate(emulators, options.key, verbose);
821
796
  if (verbose)
822
- console.info("Started deletion of temp unzipped dirs \u23F3");
823
- }
824
- const report = await compareLocalRemote(localFiles, remoteFiles);
825
- await unzipPromise;
826
- if (zip && verbose)
827
- console.info("Cleaned up unzipped files \u2705");
828
- if (verbose)
829
- console.info("Built compare base \u2705");
830
- console.log("");
831
- console.log("--- Compare Report ---");
832
- console.log("");
833
- console.log(`Total files: ${report.totalCount}`);
834
- console.log(`Total size: ${fileSizePretty(report.totalSize || 0)}`);
835
- console.log("");
836
- console.log(
837
- `Files synchronized: ${report.syncCount} (${(report.synctPctCount * 100).toFixed(2)}%)`
838
- );
839
- console.log(
840
- `Synchronized size: ${fileSizePretty(report.syncSize || 0)} (${(report.synctPctSize * 100).toFixed(2)}%)`
841
- );
842
- console.log("");
843
- if (report.localNotOnRemote) {
844
- console.log(
845
- `${report.localNotOnRemote.length} files do not exist on remote`
846
- );
847
- if (verbose && report.localNotOnRemote.length > 0) {
848
- for (const f of report.localNotOnRemote) {
849
- console.log(
850
- " - " + f.relativePath + " (" + fileSizePretty(f.size || 0) + ")"
851
- );
852
- }
797
+ console.info("Building compare base \u23F3");
798
+ const qh = async (query) => queryHandler(query, space, emulators);
799
+ const [localFiles, remoteFiles] = await Promise.all([
800
+ listLocalFiles(
801
+ path,
802
+ provider,
803
+ verbose,
804
+ 5,
805
+ IGNORED_LOCAL,
806
+ HASH_WORKER_PATH,
807
+ zip
808
+ ),
809
+ listRemoteFiles(space, provider, qh, verbose)
810
+ ]);
811
+ const unzipPromise = zip ? deleteUnzipped(path) : Promise.resolve();
812
+ if (zip) {
813
+ if (verbose)
814
+ console.info("Started deletion of temp unzipped dirs \u23F3");
853
815
  }
816
+ const report = await compareLocalRemote(localFiles, remoteFiles);
817
+ await unzipPromise;
818
+ if (zip && verbose)
819
+ console.info("Cleaned up unzipped files \u2705");
820
+ if (verbose)
821
+ console.info("Built compare base \u2705");
854
822
  console.log("");
855
- }
856
- if (report.localNotOnRemotePathOnly) {
857
- console.log(
858
- `${report.localNotOnRemotePathOnly.length} file paths do not exist on remote on providerId "${provider}" (file duplicates)`
859
- );
860
- if (verbose && report.localNotOnRemotePathOnly.length > 0) {
861
- for (const f of report.localNotOnRemotePathOnly) {
862
- console.log(
863
- " - " + f.relativePath + " (" + fileSizePretty(f.size || 0) + ")"
864
- );
865
- }
866
- }
823
+ console.log("--- Compare Report ---");
867
824
  console.log("");
868
- }
869
- if (report.remoteNotOnLocal) {
870
- console.log(`${report.remoteNotOnLocal.length} files do not exist locally`);
871
- console.log(
872
- "This might expected if the files belong to another provider or have been deleted locally"
873
- );
874
- if (verbose && report.remoteNotOnLocal.length > 0) {
875
- for (const f of report.remoteNotOnLocal) {
876
- console.log(
877
- " - " + f.contentUUID + " (" + fileSizePretty(f.size || 0) + ")"
878
- );
879
- }
880
- }
825
+ console.log(`Total files: ${report.totalCount}`);
826
+ console.log(`Total size: ${fileSizePretty(report.totalSize || 0)}`);
881
827
  console.log("");
882
- }
883
- if (report.remoteNotOnLocalPathOnly) {
884
828
  console.log(
885
- `${report.remoteNotOnLocalPathOnly.length} file paths on providerId "${provider}" do not exist locally`
829
+ `Files synchronized: ${report.syncCount} (${(report.synctPctCount * 100).toFixed(2)}%)`
886
830
  );
887
831
  console.log(
888
- "This might expected if the files belong to another provider or have been deleted locally"
832
+ `Synchronized size: ${fileSizePretty(report.syncSize || 0)} (${(report.synctPctSize * 100).toFixed(2)}%)`
889
833
  );
890
- if (verbose && report.remoteNotOnLocalPathOnly.length > 0) {
891
- for (const f of report.remoteNotOnLocalPathOnly) {
892
- console.log(
893
- " - " + f.contentUUID + " (" + fileSizePretty(f.size || 0) + ")"
894
- );
834
+ console.log("");
835
+ if (report.localNotOnRemote) {
836
+ console.log(
837
+ `${report.localNotOnRemote.length} files do not exist on remote`
838
+ );
839
+ if (verbose && report.localNotOnRemote.length > 0) {
840
+ for (const f of report.localNotOnRemote) {
841
+ console.log(
842
+ " - " + f.relativePath + " (" + fileSizePretty(f.size || 0) + ")"
843
+ );
844
+ }
895
845
  }
846
+ console.log("");
896
847
  }
897
- console.log("");
848
+ if (report.localNotOnRemotePathOnly) {
849
+ console.log(
850
+ `${report.localNotOnRemotePathOnly.length} file paths do not exist on remote on providerId "${provider}" (file duplicates)`
851
+ );
852
+ if (verbose && report.localNotOnRemotePathOnly.length > 0) {
853
+ for (const f of report.localNotOnRemotePathOnly) {
854
+ console.log(
855
+ " - " + f.relativePath + " (" + fileSizePretty(f.size || 0) + ")"
856
+ );
857
+ }
858
+ }
859
+ console.log("");
860
+ }
861
+ if (report.remoteNotOnLocal) {
862
+ console.log(`${report.remoteNotOnLocal.length} files do not exist locally`);
863
+ console.log(
864
+ "This might expected if the files belong to another provider or have been deleted locally"
865
+ );
866
+ if (verbose && report.remoteNotOnLocal.length > 0) {
867
+ for (const f of report.remoteNotOnLocal) {
868
+ console.log(
869
+ " - " + f.contentUUID + " (" + fileSizePretty(f.size || 0) + ")"
870
+ );
871
+ }
872
+ }
873
+ console.log("");
874
+ }
875
+ if (report.remoteNotOnLocalPathOnly) {
876
+ console.log(
877
+ `${report.remoteNotOnLocalPathOnly.length} file paths on providerId "${provider}" do not exist locally`
878
+ );
879
+ console.log(
880
+ "This might expected if the files belong to another provider or have been deleted locally"
881
+ );
882
+ if (verbose && report.remoteNotOnLocalPathOnly.length > 0) {
883
+ for (const f of report.remoteNotOnLocalPathOnly) {
884
+ console.log(
885
+ " - " + f.contentUUID + " (" + fileSizePretty(f.size || 0) + ")"
886
+ );
887
+ }
888
+ }
889
+ console.log("");
890
+ }
891
+ } catch (err) {
892
+ console.error("Error:", err);
893
+ process.exit(1);
898
894
  }
899
895
  }
900
- main(program.opts()).catch((err) => {
901
- console.error("Error:", err);
902
- process.exit(1);
896
+ // Annotate the CommonJS export names for ESM import in node:
897
+ 0 && (module.exports = {
898
+ compareHandler
903
899
  });
package/cue-cli-sync.js CHANGED
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
29
  mod
30
30
  ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
32
 
32
33
  // libs/js/sync-tools/src/lib/helpers/worker-pool.js
33
34
  var worker_pool_exports = {};
@@ -91,6 +92,13 @@ var init_worker_pool = __esm({
91
92
  }
92
93
  });
93
94
 
95
+ // apps/desktop/cue-cli/src/cue-cli-sync.ts
96
+ var cue_cli_sync_exports = {};
97
+ __export(cue_cli_sync_exports, {
98
+ syncHandler: () => syncHandler
99
+ });
100
+ module.exports = __toCommonJS(cue_cli_sync_exports);
101
+
94
102
  // apps/desktop/cue-cli/src/variables.ts
95
103
  var import_path = require("path");
96
104
  var TOKEN_ENDPOINT_EMULATOR = "http://localhost:8093/token";
@@ -3942,9 +3950,6 @@ async function deleteUnzipped(dir) {
3942
3950
  }
3943
3951
  }
3944
3952
 
3945
- // apps/desktop/cue-cli/src/cue-cli-sync.ts
3946
- var import_commander = require("commander");
3947
-
3948
3953
  // apps/desktop/cue-cli/src/helpers/query-handler.ts
3949
3954
  var import_auth2 = require("firebase/auth");
3950
3955
  async function queryHandler(query, spaceId, useEmulator) {
@@ -5190,133 +5195,122 @@ async function authenticate(emulators, key, verbose = false) {
5190
5195
  }
5191
5196
 
5192
5197
  // apps/desktop/cue-cli/src/cue-cli-sync.ts
5193
- var program = new import_commander.Command();
5194
- program.name("cue-cli-sync").description("Sync files to Cue").requiredOption("-s, --space <id>", "Specify the space ID (required)").requiredOption("-p, --path <id>", "Specify the folder path (required)").option(
5195
- "-k, --key <api-key>",
5196
- "Specify the API key (or set CUE_API_KEY env variable)"
5197
- ).option(
5198
- "--provider <provider ID>",
5199
- "Specify the provider ID (eg. sharepoint, drive, dropbox) or leave empty for default provider",
5200
- ""
5201
- ).option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).option(
5202
- "-z, --zip",
5203
- 'Include zipped content (will be unzipped to path "<zip_path>_unzipped". Max uncompressed size: 500 MB, max recursion depth: 3)',
5204
- false
5205
- );
5206
- program.parse(process.argv);
5207
- async function main(options) {
5198
+ async function syncHandler(options) {
5208
5199
  const { space, path, verbose, provider, emulators, zip } = options;
5209
- const { userId } = await authenticate(emulators, options.key, verbose);
5210
- if (verbose)
5211
- console.info("Building sync base \u23F3");
5212
- const qh = async (query) => queryHandler(query, space, emulators);
5213
- const [localFiles, remoteFiles] = await Promise.all([
5214
- listLocalFiles(
5215
- path,
5216
- provider,
5217
- verbose,
5218
- 5,
5219
- IGNORED_LOCAL,
5220
- HASH_WORKER_PATH,
5221
- zip
5222
- ),
5223
- listRemoteFiles(space, provider, qh, verbose)
5224
- ]);
5225
- const report = await compareLocalRemote(localFiles, remoteFiles);
5226
- if (verbose) {
5227
- console.info("Built sync base \u2705");
5228
- console.info("");
5229
- console.info(`Total local files: ${localFiles.length}`);
5230
- console.info(`Total remote files: ${remoteFiles.length}`);
5231
- console.info(
5232
- `Total files to sync: ${report.localNotOnRemote.length + report.localNotOnRemotePathOnly.length}`
5233
- );
5234
- console.info("");
5235
- }
5236
- let syncCount = report.syncCount;
5237
- let syncSize = report.syncSize;
5238
- if (report.synctPctCount !== 0 && verbose) {
5239
- console.info(
5240
- `Synced percentage: ${Math.round(
5241
- report.synctPctCount * 100
5242
- )} % ( ${syncCount}/${report.totalCount} files )`
5243
- );
5244
- console.info(
5245
- `Synchronized size:: ${Math.round(
5246
- report.synctPctSize * 100
5247
- )}% ( ${fileSizePretty(syncSize)}/${fileSizePretty(report.totalSize)} )`
5248
- );
5249
- console.info("");
5250
- }
5251
- if (verbose && report.localNotOnRemote.length)
5252
- console.info("Syncing missing files \u23F3");
5253
- let rdfWritten = false;
5254
- for (const file of report.localNotOnRemote) {
5255
- const rawFileMetadata = await uploadFile(file, space, userId, provider);
5256
- await uploadFileRDF(file, rawFileMetadata, verbose);
5257
- syncCount += 1;
5258
- syncSize += file.size || 0;
5259
- const pct = Math.floor(syncCount / report.totalCount * 100);
5260
- if (verbose && report.totalCount > 0 && syncCount % Math.ceil(report.totalCount / 100) === 0) {
5200
+ try {
5201
+ const { userId } = await authenticate(emulators, options.key, verbose);
5202
+ if (verbose)
5203
+ console.info("Building sync base \u23F3");
5204
+ const qh = async (query) => queryHandler(query, space, emulators);
5205
+ const [localFiles, remoteFiles] = await Promise.all([
5206
+ listLocalFiles(
5207
+ path,
5208
+ provider,
5209
+ verbose,
5210
+ 5,
5211
+ IGNORED_LOCAL,
5212
+ HASH_WORKER_PATH,
5213
+ zip
5214
+ ),
5215
+ listRemoteFiles(space, provider, qh, verbose)
5216
+ ]);
5217
+ const report = await compareLocalRemote(localFiles, remoteFiles);
5218
+ if (verbose) {
5219
+ console.info("Built sync base \u2705");
5220
+ console.info("");
5221
+ console.info(`Total local files: ${localFiles.length}`);
5222
+ console.info(`Total remote files: ${remoteFiles.length}`);
5261
5223
  console.info(
5262
- `Progress: ${pct}% (${syncCount}/${report.totalCount} files, ${fileSizePretty(syncSize)}/${fileSizePretty(
5263
- report.totalSize
5264
- )})`
5224
+ `Total files to sync: ${report.localNotOnRemote.length + report.localNotOnRemotePathOnly.length}`
5265
5225
  );
5226
+ console.info("");
5266
5227
  }
5267
- rdfWritten = true;
5268
- }
5269
- const zipDeletePromise = zip ? deleteUnzipped(path) : Promise.resolve();
5270
- if (verbose && report.localNotOnRemotePathOnly.length)
5271
- console.info(
5272
- `Starting sync of missing file locations (on provider "${provider}") \u23F3`
5273
- );
5274
- for (const file of report.localNotOnRemotePathOnly) {
5275
- const rawFileMetadata = uploadedFileMetadata(
5276
- file.relativePath,
5277
- space,
5278
- userId,
5279
- file.md5,
5280
- provider
5281
- );
5282
- await uploadFileRDF(file, rawFileMetadata, verbose);
5283
- syncCount += 1;
5284
- syncSize += file.size || 0;
5285
- const pct = Math.floor(syncCount / report.totalCount * 100);
5286
- if (verbose && report.totalCount > 0 && syncCount % Math.ceil(report.totalCount / 100) === 0) {
5228
+ let syncCount = report.syncCount;
5229
+ let syncSize = report.syncSize;
5230
+ if (report.synctPctCount !== 0 && verbose) {
5287
5231
  console.info(
5288
- `Progress: ${pct}% (${syncCount}/${report.totalCount} files, ${fileSizePretty(syncSize)}/${fileSizePretty(
5289
- report.totalSize
5290
- )})`
5232
+ `Synced percentage: ${Math.round(
5233
+ report.synctPctCount * 100
5234
+ )} % ( ${syncCount}/${report.totalCount} files )`
5235
+ );
5236
+ console.info(
5237
+ `Synchronized size:: ${Math.round(
5238
+ report.synctPctSize * 100
5239
+ )}% ( ${fileSizePretty(syncSize)}/${fileSizePretty(report.totalSize)} )`
5291
5240
  );
5292
- }
5293
- rdfWritten = true;
5294
- }
5295
- if (rdfWritten && emulators) {
5296
- if (verbose) {
5297
5241
  console.info("");
5298
- console.info(`Throwing RDF_WRITING_IDLE topic (only in emulators) \u23F3`);
5299
5242
  }
5300
- try {
5301
- await emitIdle(space, 1, emulators);
5302
- if (verbose)
5303
- console.info(`Threw RDF_WRITING_IDLE topic \u2705`);
5304
- } catch (error) {
5305
- if (verbose)
5306
- console.error(`Error throwing RDF_WRITING_IDLE topic: ${error}`);
5243
+ if (verbose && report.localNotOnRemote.length)
5244
+ console.info("Syncing missing files \u23F3");
5245
+ let rdfWritten = false;
5246
+ for (const file of report.localNotOnRemote) {
5247
+ const rawFileMetadata = await uploadFile(file, space, userId, provider);
5248
+ await uploadFileRDF(file, rawFileMetadata, verbose);
5249
+ syncCount += 1;
5250
+ syncSize += file.size || 0;
5251
+ const pct = Math.floor(syncCount / report.totalCount * 100);
5252
+ if (verbose && report.totalCount > 0 && syncCount % Math.ceil(report.totalCount / 100) === 0) {
5253
+ console.info(
5254
+ `Progress: ${pct}% (${syncCount}/$${report.totalCount} files, ${fileSizePretty(syncSize)}/${fileSizePretty(
5255
+ report.totalSize
5256
+ )})`
5257
+ );
5258
+ }
5259
+ rdfWritten = true;
5307
5260
  }
5308
- }
5309
- await zipDeletePromise;
5310
- if (zip && verbose)
5311
- console.info("Cleaned up unzipped files \u2705");
5312
- {
5261
+ const zipDeletePromise = zip ? deleteUnzipped(path) : Promise.resolve();
5262
+ if (verbose && report.localNotOnRemotePathOnly.length)
5263
+ console.info(
5264
+ `Starting sync of missing file locations (on provider "${provider}") \u23F3`
5265
+ );
5266
+ for (const file of report.localNotOnRemotePathOnly) {
5267
+ const rawFileMetadata = uploadedFileMetadata(
5268
+ file.relativePath,
5269
+ space,
5270
+ userId,
5271
+ file.md5,
5272
+ provider
5273
+ );
5274
+ await uploadFileRDF(file, rawFileMetadata, verbose);
5275
+ syncCount += 1;
5276
+ syncSize += file.size || 0;
5277
+ const pct = Math.floor(syncCount / report.totalCount * 100);
5278
+ if (verbose && report.totalCount > 0 && syncCount % Math.ceil(report.totalCount / 100) === 0) {
5279
+ console.info(
5280
+ `Progress: ${pct}% (${syncCount}/$${report.totalCount} files, ${fileSizePretty(syncSize)}/${fileSizePretty(
5281
+ report.totalSize
5282
+ )})`
5283
+ );
5284
+ }
5285
+ rdfWritten = true;
5286
+ }
5287
+ if (rdfWritten && emulators) {
5288
+ if (verbose) {
5289
+ console.info("");
5290
+ console.info(`Throwing RDF_WRITING_IDLE topic (only in emulators) \u23F3`);
5291
+ }
5292
+ try {
5293
+ await emitIdle(space, 1, emulators);
5294
+ if (verbose)
5295
+ console.info(`Threw RDF_WRITING_IDLE topic \u2705`);
5296
+ } catch (error) {
5297
+ if (verbose)
5298
+ console.error(`Error throwing RDF_WRITING_IDLE topic: ${error}`);
5299
+ }
5300
+ }
5301
+ await zipDeletePromise;
5302
+ if (zip && verbose)
5303
+ console.info("Cleaned up unzipped files \u2705");
5313
5304
  if (verbose) {
5314
5305
  console.info("");
5315
5306
  console.info(`Sync finished \u{1F680}\u{1F680}\u{1F680}`);
5316
5307
  }
5308
+ } catch (err) {
5309
+ console.error("Error:", err);
5310
+ process.exit(1);
5317
5311
  }
5318
5312
  }
5319
- main(program.opts()).catch((err) => {
5320
- console.error("Error:", err);
5321
- process.exit(1);
5313
+ // Annotate the CommonJS export names for ESM import in node:
5314
+ 0 && (module.exports = {
5315
+ syncHandler
5322
5316
  });