Skip to content

Feature Request - ng deploy to read firebaseProject from .env vars #2482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
george43g opened this issue May 31, 2020 · 3 comments
Closed

Feature Request - ng deploy to read firebaseProject from .env vars #2482

george43g opened this issue May 31, 2020 · 3 comments

Comments

@george43g
Copy link
Contributor

So this is related to a PR I submitted recently, #2366 - I realised that there's a further feature possibly needed - let me know what you think.

I've realised that as well as being able to specify a firebaseProject, it should also be possible to configure it via environment. You might have several deploy configurations, one for development, one for staging, one for production. Although the firebaseProject for production will likely be the same between different environments, the development firebaseProject may differ between different internal teams. This can be problematic because atm, you'd have to change the firebaseProject target in angular.json which is usually checked into version control.

One way I thought about doing it was as follows:

  • "firebaseProject": "$staging_env" <-- if a $ is detected as the first char, the builder knows that its a shell variable name
  • run dotenvs config() first to read any .env found into process.env.
  • use process.env.staging_env as the firebaseProject.

Although this method seems simple, I'm not overly fond of it because it feels like a hack.

Another way would be to make it an object, like this
"firebaseProject": { "environmentVariable": "$staging_env"}

That seems annoyingly verbose, but a much more robust and clean way of doing it.

@vandres
Copy link

vandres commented Jun 1, 2020

Would this already help you? firebase deploy --project project-dev

In my project I am having a npm command like "deploy:prod": "ng build --prod && firebase deploy --project project"

@george43g
Copy link
Contributor Author

Would this already help you? firebase deploy --project project-dev

In my project I am having a npm command like "deploy:prod": "ng build --prod && firebase deploy --project project"

Of course, the above method would work, although this is more about consistency and working in teams.

If large teams are working on the same monorepo, they may want to use multiple different development server environments (think building a branch or unreleased version).

Currently, each team or member would have to make their own edits to package.json or angular.json to specify which development env they want to use. If this change was accidentally committed to git, wouldn't be great. Hence the preference for files (.env) that aren't typically checked into version control (so .gitignore'd).

In NRWL NX monorepo, for example, whenever you use run-commands builder, you are able to specify a .env file and use variables in your commands, for example:
firebase deploy -P $APP_DEV_PROJECT_ID --only functions and it will read the $VAR from .env.

You may be able to achieve something like this with NPM scripts as well, but some may prefer to use the ng deploy functionality and keep their deploy setups in angular.json or workspace.json which uses Angular CLI under the hood.

For these reasons, I think it would be beneficial to allow some kind of config to be read that isn't checked into version control, which is usually the .env file in the root dir.

@jamesdaniels
Copy link
Member

project is now an option in angular.json for the schematic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants