@qaecy/cue-cli 0.0.8 → 0.0.9
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.
- package/main.js +24 -3
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -5151,6 +5151,7 @@ var import_app = require("firebase/app");
|
|
|
5151
5151
|
var CueFirebase = class _CueFirebase {
|
|
5152
5152
|
constructor(config, auth, muted = false) {
|
|
5153
5153
|
this._muted = true;
|
|
5154
|
+
this._emulator = false;
|
|
5154
5155
|
this._muted = muted;
|
|
5155
5156
|
this._init(config, auth);
|
|
5156
5157
|
}
|
|
@@ -5224,6 +5225,9 @@ var CueFirebase = class _CueFirebase {
|
|
|
5224
5225
|
get auth() {
|
|
5225
5226
|
return this._auth;
|
|
5226
5227
|
}
|
|
5228
|
+
get emulatorMode() {
|
|
5229
|
+
return this._emulator;
|
|
5230
|
+
}
|
|
5227
5231
|
_init(config, auth) {
|
|
5228
5232
|
const firebaseConfig = Object.assign(config, {
|
|
5229
5233
|
authDomain: `${APP_ID}.firebaseapp.com`,
|
|
@@ -5280,6 +5284,7 @@ var CueFirebase = class _CueFirebase {
|
|
|
5280
5284
|
this._collectionTiers = (0, import_firestore.collection)((0, import_firestore.getFirestore)(app), COLLECTION_TIERS);
|
|
5281
5285
|
this._auth = auth === void 0 ? (0, import_auth.getAuth)(app) : auth;
|
|
5282
5286
|
this._app = app;
|
|
5287
|
+
this._emulator = config.useEmulator || false;
|
|
5283
5288
|
if (config.useEmulator) {
|
|
5284
5289
|
this.attachEmulators();
|
|
5285
5290
|
}
|
|
@@ -8322,13 +8327,27 @@ async function publishMessage(topicName, data, useEmulator) {
|
|
|
8322
8327
|
if (useEmulator) {
|
|
8323
8328
|
process.env.PUBSUB_EMULATOR_HOST = process.env.PUBSUB_EMULATOR_HOST || "localhost:8085";
|
|
8324
8329
|
}
|
|
8325
|
-
const
|
|
8330
|
+
const projectId = useEmulator ? "demo-project" : PROJECT_ID;
|
|
8331
|
+
const pubSubClient = new import_pubsub.PubSub({ projectId });
|
|
8326
8332
|
const topic = pubSubClient.topic(topicName);
|
|
8327
8333
|
const dataBuffer = Buffer.from(JSON.stringify(data));
|
|
8328
8334
|
try {
|
|
8329
|
-
|
|
8335
|
+
if (useEmulator) {
|
|
8336
|
+
const publishPromise = topic.publishMessage({ data: dataBuffer });
|
|
8337
|
+
const timeoutPromise = new Promise(
|
|
8338
|
+
(_, reject) => setTimeout(() => reject(new Error("PubSub publish timeout")), 5e3)
|
|
8339
|
+
);
|
|
8340
|
+
await Promise.race([publishPromise, timeoutPromise]);
|
|
8341
|
+
} else {
|
|
8342
|
+
await topic.publishMessage({ data: dataBuffer });
|
|
8343
|
+
}
|
|
8330
8344
|
} catch (error) {
|
|
8331
8345
|
console.error(`Error publishing message: ${error.message}`);
|
|
8346
|
+
if (useEmulator) {
|
|
8347
|
+
console.warn("Continuing despite PubSub error in emulator mode...");
|
|
8348
|
+
} else {
|
|
8349
|
+
throw error;
|
|
8350
|
+
}
|
|
8332
8351
|
}
|
|
8333
8352
|
}
|
|
8334
8353
|
|
|
@@ -8433,7 +8452,9 @@ async function syncHandler(options) {
|
|
|
8433
8452
|
console.info(`Threw RDF_WRITING_IDLE topic \u2705`);
|
|
8434
8453
|
} catch (error) {
|
|
8435
8454
|
if (verbose)
|
|
8436
|
-
console.error(`Error throwing RDF_WRITING_IDLE topic: ${error}`);
|
|
8455
|
+
console.error(`Error throwing RDF_WRITING_IDLE topic: ${error.message}`);
|
|
8456
|
+
if (verbose)
|
|
8457
|
+
console.warn("Continuing despite PubSub error in emulator mode...");
|
|
8437
8458
|
}
|
|
8438
8459
|
}
|
|
8439
8460
|
await zipDeletePromise;
|