backend-manager 3.2.119 → 3.2.121

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "3.2.119",
3
+ "version": "3.2.121",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
package/src/cli/cli.js CHANGED
@@ -419,6 +419,23 @@ Main.prototype.setup = async function () {
419
419
  return !!pass;
420
420
  }, fix_runtimeConfig);
421
421
 
422
+ // await self.test('using proper env', async function () {
423
+ // let runtimeconfig = JSON.parse(jetpack.read(`${self.firebaseProjectPath}/functions/.runtimeconfig.json`) || '{}');
424
+ // let ogPaths = getObjectPaths(runtimeconfigTemplate).split('\n');
425
+ // let pass = true;
426
+
427
+ // for (var i = 0, l = ogPaths.length; i < l; i++) {
428
+ // let item = ogPaths[i];
429
+ // if (!item) {continue}
430
+ // pass = _.get(runtimeconfig, item, undefined);
431
+ // if (typeof pass === 'undefined') {
432
+ // break;
433
+ // }
434
+ // }
435
+
436
+ // return !!pass;
437
+ // }, fix_runtimeConfig);
438
+
422
439
  await self.test('using proper backend-manager-config.json', async function () {
423
440
  const bemConfig = JSON.parse(self.bemConfigJSON);
424
441
 
@@ -31,6 +31,7 @@ function Manager(exporter, options) {
31
31
  // Setup EventEmitter
32
32
  EventEmitter.call(self);
33
33
 
34
+ // Return
34
35
  return self;
35
36
  }
36
37
 
@@ -97,8 +98,11 @@ Manager.prototype.init = function (exporter, options) {
97
98
 
98
99
  // Load config
99
100
  self.config = merge(
101
+ // Load basic config
100
102
  requireJSON5(self.project.backendManagerConfigPath),
101
- manuallyLoadRuntimeConfig(self.cwd),
103
+ // Load ENV config as a fallback
104
+ requireJSON5(path.resolve(self.cwd, '.runtimeconfig.json'), false),
105
+ // Finally, load the functions config
102
106
  self.libraries.functions
103
107
  ? self.libraries.functions.config()
104
108
  : {},
@@ -980,22 +984,18 @@ function resolveProjectPackage() {
980
984
  } catch (e) {}
981
985
  }
982
986
 
983
- function requireJSON5(p) {
984
- try {
985
- return JSON5.parse(jetpack.read(p))
986
- } catch (e) {
987
- console.error(`Failed to load JSON at ${p}:`, e)
988
- throw e;
989
- }
990
- }
987
+ function requireJSON5(file, log) {
988
+ // Set log
989
+ log = typeof log === 'undefined' ? true : log;
991
990
 
992
- function manuallyLoadRuntimeConfig(cwd) {
991
+ // Load JSON5
993
992
  try {
994
- console.log('=====+++', jetpack.list(cwd));
995
- console.log('=====+++', require(path.resolve(cwd, '.runtimeconfig.json')));
996
- return require(path.resolve(cwd, '.runtimeconfig.json'));
993
+ return JSON5.parse(jetpack.read(file))
997
994
  } catch (e) {
998
- return {};
995
+ if (log) {
996
+ console.error(`Failed to load JSON at ${file}:`, e);
997
+ }
998
+ throw e;
999
999
  }
1000
1000
  }
1001
1001