backend-manager 2.0.7 → 2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "2.0.7",
3
+ "version": "2.0.10",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -64,4 +64,4 @@
64
64
  "src/",
65
65
  "templates/"
66
66
  ]
67
- }
67
+ }
package/src/cli/cli.js CHANGED
@@ -273,8 +273,8 @@ Main.prototype.setup = async function () {
273
273
  // }, fix_projpackage);
274
274
 
275
275
  await this.test('functions level package.json exists', async function () {
276
- return !!self.package && !!self.package.dependencies && !!self.package.devDependencies;
277
- }, fix_deps);
276
+ return !!self.package && !!self.package.dependencies && !!self.package.devDependencies && !!self.package.version;
277
+ }, fix_functionspackage);
278
278
 
279
279
  // await this.test('functions level package.json has updated version', async function () {
280
280
  // return self.package.version === self.projectPackage.version;
@@ -695,10 +695,11 @@ function fix_projpackage(self) {
695
695
  });
696
696
  };
697
697
 
698
- function fix_deps(self) {
698
+ function fix_functionspackage(self) {
699
699
  return new Promise(function(resolve, reject) {
700
700
  self.package.dependencies = self.package.dependencies || {};
701
701
  self.package.devDependencies = self.package.devDependencies || {};
702
+ self.package.version = self.package.version || '0.0.1';
702
703
 
703
704
  fs.write(`${self.firebaseProjectPath}/functions/package.json`, JSON.stringify(self.package, null, 2) );
704
705
  resolve();
@@ -36,10 +36,13 @@ Module.prototype.main = function () {
36
36
  }
37
37
  } else if (payload.data.payload.version === '4') {
38
38
  result = uuid.v4();
39
+ } else {
40
+ return reject(assistant.errorManager(`v${payload.data.payload.version} is not a valid version.`, {code: 400, sentry: false, send: false, log: false}).error)
39
41
  }
40
42
 
41
43
  assistant.log('UUID Generated', payload.data.payload, result, {environment: 'production'});
42
44
 
45
+ // Return the timestamp so electron-manager can save an http request >:)
43
46
  return resolve({data: {uuid: result, timestamp: new Date().toISOString()}});
44
47
 
45
48
  });
@@ -57,7 +57,7 @@ Manager.prototype.init = function (exporter, options) {
57
57
  self.options = options;
58
58
  self.project = options.firebaseConfig || JSON.parse(process.env.FIREBASE_CONFIG);
59
59
  self.cwd = process.cwd();
60
- self.package = require(path.resolve(self.cwd, 'package.json'));
60
+ self.package = resolveProjectPackage();
61
61
  self.config = merge(
62
62
  require(path.resolve(self.cwd, 'backend-manager-config.json')),
63
63
  self.libraries.functions.config()
@@ -464,4 +464,14 @@ Manager.prototype.debug = function () {
464
464
  }
465
465
  }
466
466
 
467
+ function resolveProjectPackage() {
468
+ try {
469
+ return require(path.resolve(process.cwd(), 'functions', 'package.json'));
470
+ } catch (e) {}
471
+
472
+ try {
473
+ return require(path.resolve(process.cwd(), 'package.json'));
474
+ } catch (e) {}
475
+ }
476
+
467
477
  module.exports = Manager;