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 🙏

© 2026 – Pkg Stats / Ryan Hefner

grunt-firebase

v0.1.5

Published

Update your firebase data from a Grunt task!

Readme

grunt-firebase

Update your firebase data from a Grunt task!

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-firebase --save-dev

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-firebase');

The "firebase" task

Overview

In your project's Gruntfile, add a section named firebase to the data object passed into grunt.initConfig().

grunt.initConfig({
  firebase: {
      options: {
        //
        // reference to start with (full firebase url)
        //
        reference: 'https://grunt-firebase.firebaseio.com/demo',

        //
        // token is the secret key used for connecting to firebase from the server
        // this is redacted from the public repo... add a file called ./config/auth.json
        // with your token in it... { "token": "my token here" }
        //
        token: '<%= authConfig.token %>'
      },
      load: {
        options: {
          data: {
            one: {
              foo: 'bar'
            },
            two: [
              { a: 'A' },
              { b: 'B' },
              { c: 'C' }
            ],
            three: [ 'first', 'second', 'third' ]
          }
        }
      }
  }
});

Options

options.reference

Type: string Require: true

reference to start with (full firebase url)

options.token

Type: String Require: true

token is the secret key used for connecting to firebase from the server this is redacted from the public repo... add a file called ./config/auth.json with your token in it... { "token": "my token here" }

options.data

Type: String | Object | Array

This is the data that will be loaded into firebase at the specified reference point.

options.mode

Type: String Required: false Default: upload

Specify if you want to upload or download your data from firebase.

Modes
  • upload: files in the files property will be uploaded to the reference location
  • download: add a dest to your options to determine where the data file will go.
  • live: files in the files property will be watched and uploaded to firebase when changed or downloaded from firebase when changed remotely.

options.dest

Type: String Required: false Default: ./

Used when mode: download is set in the options. This is the base path for which the downloaded file will go.

Usage Examples

var authConfig = grunt.file.readJSON('./config/auth.json');

grunt.initConfig({
  
  authConfig: authConfig,

  firebase: {
    options: {
      //
      // reference to start with (full firebase url)
      //
      reference: 'https://grunt-firebase.firebaseio.com/demo',

      //
      // token is the secret key used for connecting to firebase from the server
      // this is redacted from the public repo... add a file called ./config/auth.json
      // with your token in it... { "token": "my token here" }
      //
      token: '<%= authConfig.token %>'
    },
    load: {
      options: {
        data: {
          one: {
            foo: 'bar'
          },
          two: [
            { a: 'A' },
            { b: 'B' },
            { c: 'C' }
          ],
          three: [ 'first', 'second', 'third' ]
        }
      }
    }
  }
});

You don't want to put your data in the Gruntfile?!?! Why not?

Okay... just put it in some .json files and tell the task where to find them. We'll handle importing the data and uploading it to firebase for you:

var authConfig = grunt.file.readJSON('./config/auth.json');

grunt.initConfig({
  
  authConfig: authConfig,

  firebase: {
    options: {
      //
      // reference to start with (full firebase url)
      //
      reference: 'https://grunt-firebase.firebaseio.com/demo',

      //
      // token is the secret key used for connecting to firebase from the server
      // this is redacted from the public repo... add a file called ./config/auth.json
      // with your token in it... { "token": "my token here" }
      //
      token: '<%= authConfig.token %>'
    },
    load: {
      files: [
        { src: './path/to/my/data/**/*.json' }
      ]
    }
  }
});

Now that your file is uploaded, make some changes to it through the Firebase Forge and download the updates to your file:

var authConfig = grunt.file.readJSON('./config/auth.json');

grunt.initConfig({
  
  authConfig: authConfig,

  firebase: {
    options: {
      //
      // reference to start with (full firebase url)
      // when downloading, the final segment in the path
      // will determine the filename where your data goes
      //
      reference: 'https://grunt-firebase.firebaseio.com/demo',

      //
      // token is the secret key used for connecting to firebase from the server
      // this is redacted from the public repo... add a file called ./config/auth.json
      // with your token in it... { "token": "my token here" }
      //
      token: '<%= authConfig.token %>'
    },
    getMyFiles: {
      options: {
        mode: 'download',
        dest: 'path/to/downloaded/files/'
      }
    }
  }
});

This will result in all of your data located at https://grunt-firebase.firebaseio.com/demo to be downloaded and stored in a file located at path/to/downloaded/files/demo.json

By now you might be thinking... "This is all great, but I want to really use Firebase features and collaborate in realtime."

You can!!! Almost... it all depends on your text editor, but there's now a live mode! Just set the option mode: live and tell grunt-firebase which files to watch. Each file in the glob pattern will be uploaded to the reference path when changed locally, and the local file will be updated when changed remotely.

var authConfig = grunt.file.readJSON('./config/auth.json');

grunt.initConfig({
  
  authConfig: authConfig,

  firebase: {
    options: {
      //
      // reference to start with (full firebase url)
      // this is the root path that will be watched for changes
      // and each "key" will be it's own file
      //
      reference: 'https://grunt-firebase.firebaseio.com/demo',

      //
      // token is the secret key used for connecting to firebase from the server
      // this is redacted from the public repo... add a file called ./config/auth.json
      // with your token in it... { "token": "my token here" }
      //
      token: '<%= authConfig.token %>'
    },
    getMyFiles: {
      options: {
        mode: 'live'
      },
      files: [
        { src: './path/to/my/data/**/*.json' }
      ]
    }
  }
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)