backend-manager 4.2.10 → 4.2.12

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/package.json +1 -1
  2. package/src/cli/cli.js +26 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "4.2.10",
3
+ "version": "4.2.12",
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
@@ -505,6 +505,11 @@ Main.prototype.setup = async function () {
505
505
  return self.firebaseJSON?.remoteconfig?.template === 'remoteconfig.template.json';
506
506
  }, fix_remoteconfigTemplate);
507
507
 
508
+ // Test: Does the project have bm_api in the hosting rewrites
509
+ await self.test('hosting rewrites have bm_api', () => {
510
+ return self.firebaseJSON?.hosting?.rewrites?.some(rewrite => rewrite.source === '{/backend-manager}' && rewrite.function === 'bm_api');
511
+ }, fix_hostingRewrites);
512
+
508
513
  // Test: Does the project have the indexes synced
509
514
  await self.test('firestore indexes synced', async function () {
510
515
  const tempPath = '_firestore.indexes.json'
@@ -975,6 +980,27 @@ function fix_remoteconfigTemplate(self) {
975
980
  });
976
981
  };
977
982
 
983
+ function fix_hostingRewrites(self) {
984
+ return new Promise(function(resolve, reject) {
985
+ const hosting = _.get(self.firebaseJSON, 'hosting', {});
986
+
987
+ // Set default
988
+ hosting.rewrites = hosting.rewrites || [];
989
+
990
+ // Add to top
991
+ hosting.rewrites.unshift({
992
+ source: '{/backend-manager}',
993
+ function: 'bm_api',
994
+ });
995
+
996
+ // Set
997
+ _.set(self.firebaseJSON, 'hosting.rewrites', hosting.rewrites);
998
+
999
+ // Write
1000
+ jetpack.write(`${self.firebaseProjectPath}/firebase.json`, JSON.stringify(self.firebaseJSON, null, 2));
1001
+ });
1002
+ };
1003
+
978
1004
  function fix_indexesSync(self) {
979
1005
  return new Promise(function(resolve, reject) {
980
1006
  inquirer.prompt([