cordova-plugin-firebasex icon indicating copy to clipboard operation
cordova-plugin-firebasex copied to clipboard

[FEATURE] Configure multiple projects

Open sahyun1 opened this issue 5 years ago • 4 comments

Feature request

It'd be good to be able to configure multiple projects. Will need to load different plist/json file.

https://firebase.google.com/docs/projects/multiprojects

sahyun1 avatar Jan 28 '20 00:01 sahyun1

I think you can do a little workaround. You can create two files for example in your environment folder, *--dev.json, *--prod.json and use cordova hooks to copy enviroment file before build app.

https://cordova.apache.org/docs/en/latest/guide/appdev/hooks/

or you can add scripts in your package.json :)

kszczygiel avatar Jan 28 '20 09:01 kszczygiel

As part of our Angular build process, we use asset copy to leave an artifact of the build type for the firebase-config script to check. Ideally there's a cleaner way to do this first step; we wanted to maintain the ability to mix and match QA/Prod while still doing a signed cordova release build.

config.xml

<hook src="scripts/firebase-config.js" type="after_prepare" />

scripts/firebase-config.js

var path = require('path');
var fs = require('fs');

module.exports = function(context) {
  var isProd = fs.existsSync(path.join(context.opts.projectRoot, 'www/assets/environment.prod.ts'));

  var configSrc;
  if (isProd) {
    configSrc = ['src/environments/google-services.prod.json', 'src/environments/GoogleService-Info.prod.plist'];
  } else {
    configSrc = ['src/environments/google-services.qa.json', 'src/environments/GoogleService-Info.qa.plist'];
  }

  fs.copyFileSync(
    path.join(context.opts.projectRoot, configSrc[0]),
    path.join(context.opts.projectRoot, 'google-services.json'),
  );
  fs.copyFileSync(
    path.join(context.opts.projectRoot, configSrc[1]),
    path.join(context.opts.projectRoot, 'GoogleService-Info.plist'),
  );
  console.log('firebase-config:', ...configSrc);

  return true;
};

zmoshansky avatar Jun 17 '20 20:06 zmoshansky

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 12 '21 14:05 stale[bot]

Reopening as stalebot incorrectly closed it

dpa99c avatar Jul 23 '21 11:07 dpa99c