npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

firebase-config-sync

v1.1.2

Published

Synchronize Firebase Functions config variables with ease

Downloads

481

Readme

firebase-config-sync

Synchronize Firebase Functions config variables with ease from local config (.env) files.

npm install --dev firebase-config-sync

The Firebase CLI is a peer dependency of this, so if you don't already have it installed, do it:

npm install --dev firebase-tools

So what's this?

This is a CLI for uploading a whole JSON file full of Firebase Function config variables to a Firebase project. The normal way of updating your config is setting variables one by one. See the docs here: https://firebase.google.com/docs/functions/config-env

But with firebase-config-sync you can upload all your config at once, with the following command:

firebase-config-sync set

All you need is to configure which files go to which Firebase projects. Do this by adding a field configFiles in your .firebaserc:

// .firebaserc
{
  "projects": {
    "prod": "awesomeproject-prod",
    "staging": "awesomeproject-staging",
    "dev": "awesomeproject-dev"
  },
+  "configFiles": {
+    "prod": ".env.prod.json",
+    "staging": ".env.staging.json",
+    "dev": ".env.dev.json"
+  }
}

The keys in configFiles should equal those in projects. firebase-config-sync will upload config for all projects found in configFiles, overwriting existing config.

What do these config files look like?

Normally when setting a config variable, you do it like this:

firebase functions:config:set some_service.key="THE API KEY" someservice.id="THE CLIENT ID"

You can retrieve the config with this command:

firebase functions:config:get

It should return something that looks like this:

{
  "some_service": {
    "key":"THE API KEY",
    "id":"THE CLIENT ID"
  }
}

And that's what you'd want your config files to look like. But wait, there's more! firebase-config-sync will stringify the values (if they're not already strings), and parse them when downloaded. This allows you to use more complex types like booleans, arrays and objects in your config files:

{
  "some_service": {
    "some_list_of_cheeses": [
      "camembert",
      "brie",
      "jarlsberg"
    ]
  }
}

API

Set

Upload config from config files to their Firebase projects

firebase-config-sync set

Options

-c, --config <path>     Config file to find config files map in. Default: .firebaserc
-P, --project <names>   Comma-separated list of project names to deploy to. Default is all projects.
-q, --quiet             Disable all logging
-f, --file <path>       Custom file to use instead of those in the config file. Must be used together with --project with a single argument.

Get

Download config from Firebase projects to their config files

firebase-config-sync get

Options

-c, --config <path>     Config file to find config files map in. Default: .firebaserc
-P, --project <names>   Comma-separated list of project names to fetch for. Default is all projects.
-q, --quiet             Disable all logging
-i, --ignore            Don't save properties that don't already exist in local file
-s, --sort              Sort config alphabetically before saving to config file
-n, --no-parsing        Do not parse config values before saving to file
-f, --file <path>       Custom file to save to, if you don't want to use the one specified in configFiles

Purge

Purge config entries not found in config files from Firebase projects.

firebase-config-sync purge

Options

-c, --config <path>     Config file to find config files map in. Default: .firebaserc
-P, --project <names>   Comma-separated list of project names to fetch for. Default is all projects.
-q, --quiet             Disable all logging