@qaecy/cue-cli 0.0.8 → 0.0.10

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 (2) hide show
  1. package/main.js +28 -4
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -4743,6 +4743,8 @@ var init_worker_pool = __esm({
4743
4743
 
4744
4744
  // apps/desktop/cue-cli/src/main.ts
4745
4745
  var import_commander = require("commander");
4746
+ var import_fs12 = require("fs");
4747
+ var import_path7 = require("path");
4746
4748
 
4747
4749
  // apps/desktop/cue-cli/src/cue-cli-artefacts.ts
4748
4750
  var import_fs3 = require("fs");
@@ -5151,6 +5153,7 @@ var import_app = require("firebase/app");
5151
5153
  var CueFirebase = class _CueFirebase {
5152
5154
  constructor(config, auth, muted = false) {
5153
5155
  this._muted = true;
5156
+ this._emulator = false;
5154
5157
  this._muted = muted;
5155
5158
  this._init(config, auth);
5156
5159
  }
@@ -5224,6 +5227,9 @@ var CueFirebase = class _CueFirebase {
5224
5227
  get auth() {
5225
5228
  return this._auth;
5226
5229
  }
5230
+ get emulatorMode() {
5231
+ return this._emulator;
5232
+ }
5227
5233
  _init(config, auth) {
5228
5234
  const firebaseConfig = Object.assign(config, {
5229
5235
  authDomain: `${APP_ID}.firebaseapp.com`,
@@ -5280,6 +5286,7 @@ var CueFirebase = class _CueFirebase {
5280
5286
  this._collectionTiers = (0, import_firestore.collection)((0, import_firestore.getFirestore)(app), COLLECTION_TIERS);
5281
5287
  this._auth = auth === void 0 ? (0, import_auth.getAuth)(app) : auth;
5282
5288
  this._app = app;
5289
+ this._emulator = config.useEmulator || false;
5283
5290
  if (config.useEmulator) {
5284
5291
  this.attachEmulators();
5285
5292
  }
@@ -8322,13 +8329,27 @@ async function publishMessage(topicName, data, useEmulator) {
8322
8329
  if (useEmulator) {
8323
8330
  process.env.PUBSUB_EMULATOR_HOST = process.env.PUBSUB_EMULATOR_HOST || "localhost:8085";
8324
8331
  }
8325
- const pubSubClient = new import_pubsub.PubSub({ projectId: PROJECT_ID });
8332
+ const projectId = useEmulator ? "demo-project" : PROJECT_ID;
8333
+ const pubSubClient = new import_pubsub.PubSub({ projectId });
8326
8334
  const topic = pubSubClient.topic(topicName);
8327
8335
  const dataBuffer = Buffer.from(JSON.stringify(data));
8328
8336
  try {
8329
- await topic.publishMessage({ data: dataBuffer });
8337
+ if (useEmulator) {
8338
+ const publishPromise = topic.publishMessage({ data: dataBuffer });
8339
+ const timeoutPromise = new Promise(
8340
+ (_, reject) => setTimeout(() => reject(new Error("PubSub publish timeout")), 5e3)
8341
+ );
8342
+ await Promise.race([publishPromise, timeoutPromise]);
8343
+ } else {
8344
+ await topic.publishMessage({ data: dataBuffer });
8345
+ }
8330
8346
  } catch (error) {
8331
8347
  console.error(`Error publishing message: ${error.message}`);
8348
+ if (useEmulator) {
8349
+ console.warn("Continuing despite PubSub error in emulator mode...");
8350
+ } else {
8351
+ throw error;
8352
+ }
8332
8353
  }
8333
8354
  }
8334
8355
 
@@ -8433,7 +8454,9 @@ async function syncHandler(options) {
8433
8454
  console.info(`Threw RDF_WRITING_IDLE topic \u2705`);
8434
8455
  } catch (error) {
8435
8456
  if (verbose)
8436
- console.error(`Error throwing RDF_WRITING_IDLE topic: ${error}`);
8457
+ console.error(`Error throwing RDF_WRITING_IDLE topic: ${error.message}`);
8458
+ if (verbose)
8459
+ console.warn("Continuing despite PubSub error in emulator mode...");
8437
8460
  }
8438
8461
  }
8439
8462
  await zipDeletePromise;
@@ -8450,8 +8473,9 @@ async function syncHandler(options) {
8450
8473
  }
8451
8474
 
8452
8475
  // apps/desktop/cue-cli/src/main.ts
8476
+ var packageJson = JSON.parse((0, import_fs12.readFileSync)((0, import_path7.join)(__dirname, "../package.json"), "utf8"));
8453
8477
  var program = new import_commander.Command();
8454
- program.name("cue-cli").description("Cue Command Line Interface").version("0.0.7");
8478
+ program.name("cue-cli").description("Cue Command Line Interface").version(packageJson.version);
8455
8479
  program.command("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("-k, --key <api-key>", "Specify the API key (or set CUE_API_KEY env variable)").option("--provider <provider ID>", "Specify the provider ID (eg. sharepoint, drive, dropbox) or leave empty for default provider", "").option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).option("-z, --zip", 'Include zipped content (will be unzipped to path "<zip_path>_unzipped". Max uncompressed size: 500 MB, max recursion depth: 3)', false).action(syncHandler);
8456
8480
  program.command("dump").description("Dump Cue Knowledge Graph data to file\n Examples:\n $ cue-cli dump -s <space_id> -l -v\n $ cue-cli dump -s <space_id> -j -v").requiredOption("-s, --space <id>", "Specify the space ID (required)").option("-k, --key <api-key>", "Specify the API key (or set CUE_API_KEY env variable)").option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).option("-q, --query", "Uses a construct query to get the dump rather than using the /data endpoint", false).option("-j, --jelly", "Downloads a Jelly file rather than the standard Gzipped NQuads format", false).option("-l, --load", "Loads the dumped file into a local triplestore (requires emulators)", false).action(dumpHandler);
8457
8481
  program.command("compare").description("Compares folder content to files already updated to Cue").requiredOption("-s, --space <id>", "Specify the space ID (required)").requiredOption("-p, --path <id>", "Specify the folder path (required)").option("-k, --key <api-key>", "Specify the API key (or set CUE_API_KEY env variable)").option("--provider <provider ID>", "Specify the provider ID (eg. sharepoint, drive, dropbox) or leave empty for default provider", "").option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).option("-z, --zip", "Include zipped content (will temporarily unzip files with same logic as when syncing and delete them again after the comparison)", false).action(compareHandler);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qaecy/cue-cli",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Cue CLI for QAECY platform",
5
5
  "main": "main.js",
6
6
  "bin": {