Skip to content
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

Fix firebase init remoteconfig #3139

Merged
merged 5 commits into from
Mar 5, 2021
Merged

Conversation

inlined
Copy link
Member

@inlined inlined commented Feb 15, 2021

Description

Fix firebase init for remote config. Previously:

  • There was a meaningless print of the file the user just chose to use as their template
  • We overwrote any existing template even if the user chose not to
  • The default template was an empty file which caused firebase deploy to crash

Scenarios Tested

  1. Initializing without a template file creates a template that can be safely deployed
  2. Initializing with a template file prompts for an overwrite which the user can reject
  3. Initializing with a template file prompts for an overwrite which the user can accept

transcript

$ rm remoteconfig.template.json
$ firebase init remoteconfig

     ######## #### ########  ######## ########     ###     ######  ########
     ##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
     ######    ##  ########  ######   ########  #########  ######  ######
     ##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
     ##       #### ##     ## ######## ########  ##     ##  ######  ########

You're about to initialize a Firebase project in this directory:

  /Users/inlined/git/junkdrawer

Before we get started, keep in mind:

  * You are initializing in an existing Firebase project directory


=== Project Setup

First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.

i  .firebaserc already has a default project, using inlined-junkdrawer.

=== Remoteconfig Setup
? What file should be used for your Remote Config template? remoteconfig.template.json

i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...

✔  Firebase initialization complete!
$ cat remoteconfig.template.json
{}$ firebase deploy --only remoteconfig

=== Deploying to 'inlined-junkdrawer'...

i  deploying remoteconfig

✔  Deploy complete!

Project Console: https://console.firebase.google.com/project/inlined-junkdrawer/overview
$ echo '{"key":"value"}' > remoteconfig.template.json
$ firebase init remoteconfig

     ######## #### ########  ######## ########     ###     ######  ########
     ##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
     ######    ##  ########  ######   ########  #########  ######  ######
     ##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
     ##       #### ##     ## ######## ########  ##     ##  ######  ########

You're about to initialize a Firebase project in this directory:

  /Users/inlined/git/junkdrawer

Before we get started, keep in mind:

  * You are initializing in an existing Firebase project directory


=== Project Setup

First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.

i  .firebaserc already has a default project, using inlined-junkdrawer.

=== Remoteconfig Setup
? What file should be used for your Remote Config template? remoteconfig.template.json
? File remoteconfig.template.json already exists. Do you want to overwrite the existing Remote Config template? No

i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...

✔  Firebase initialization complete!
$ cat remoteconfig.template.json
{"key":"value"}
$ firebase init remoteconfig

     ######## #### ########  ######## ########     ###     ######  ########
     ##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
     ######    ##  ########  ######   ########  #########  ######  ######
     ##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
     ##       #### ##     ## ######## ########  ##     ##  ######  ########

You're about to initialize a Firebase project in this directory:

  /Users/inlined/git/junkdrawer

Before we get started, keep in mind:

  * You are initializing in an existing Firebase project directory


=== Project Setup

First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.

i  .firebaserc already has a default project, using inlined-junkdrawer.

=== Remoteconfig Setup
? What file should be used for your Remote Config template? remoteconfig.template.json
? File remoteconfig.template.json already exists. Do you want to overwrite the existing Remote Config template? Yes

i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...

✔  Firebase initialization complete!
$ cat remoteconfig.template.json
{}

Sample Commands

firebase init
firebase init remoteconfig

@google-cla google-cla bot added the cla: yes Manual indication that this has passed CLA. label Feb 15, 2021
@inlined inlined requested a review from joehan February 15, 2021 23:50
Copy link
Contributor

@joehan joehan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - sorry for the delay on this, I need to pay better attention to my Github notifications

@inlined inlined merged commit 14b2214 into master Mar 5, 2021
@bkendall bkendall deleted the inlined.remoteconfig-inlitialization branch August 4, 2021 19:26
devpeerapong pushed a commit to devpeerapong/firebase-tools that referenced this pull request Dec 14, 2021
Fix firebase init remoteconfig. The CLI no longer overwrites the existing remote config templates when the user selects "no". The default template is now a valid (empty) JSON object instead of an empty string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Manual indication that this has passed CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

firebase init remoteconfig will always overwrite existing template files
2 participants