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

fireseeder

v0.1.10

Published

Commandline tool for seeding Firestore

Downloads

23

Readme

fireseeder

Commandline tool for seeding data to Firestore

Features

  • Supports all firestore data types including GeoPoint, Ref, etc.
  • Supports firestore subcollections and nested subcollections
  • Easily create complex seed data with random values
  • Change seed data language
  • Clear collections/subcollections before seeding
  • Seed data merging

Getting Started

Install fireseeder using npm:

$ npm install fireseeder --save-dev

or yarn:

$ yarn add fireseeder -D

Then, download the Firebase Admin SDK json secret from the Firebase console, and place it somewhere in your project directory.

Create seeds directory in your project root (where your package.json is created), and add your config inside package.json:

"fireseeder": {
  "seedDir": "./seeds",
  "databaseUrl": "https://xxxxxx.firebaseio.com",
  "credential": "./path/to/credential.json"
},

Finally, create seed files inside ./seeds and run:

$ fireseeder seed

Configuration

Setting up project options

There are 3 ways to configure your project:

  1. Use the CLI options
  2. Use the fireseeder key in your package.json
  3. Use environment variables

CLI usage

$ fireseeder seed [options]

Configuration using package.json

{
  "name": "fireseeder-example",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "seed": "fireseeder seed --fresh"
  },
  "fireseeder": {
    "databaseUrl": "https://xxxxxx.firebaseio.com",
    "credential": "./secret/credential.json",
    "lang": "en"
  }
}

NOTE:
The options in package.json should be in camelCase.
Also note that the CLI options takes precedence over the package.json config.

Using the environment variables

Environment variables should be prefixed with FSSEEDER_.

The options below are currently supported:

  • FSSEEDER_SEED_DIR
  • FSSEEDER_DATABASE_URL
  • FSSEEDER_CREDENTIAL
  • FSSEEDER_EMULATOR
  • FSSEEDER_ID_KEY
  • FSSEEDER_LANG

NOTE:
Environment variables takes precedence over the package.json config.

Configuration priority

  1. CLI Options (Highest priority)
  2. Environment variables
  3. package.json config (Lowest priority)

Creating seed files

Example seed file

import { mapCollection, mapSubCollection, ref, geoPoint, name } from 'fireseeder'

export default mapCollection(10, (index) => ({
  _id: index + 1,
  firstName: name.firstName(),
  lastName: name.lastName(),
  ref: ref('/mod/1'),
  geopoint: geoPoint({ lat: 1, lng: 1 }),
  arr: ['a', 'b', 'c'],
  map: { a: 'b', c: 'd' },
  subCollection: mapSubCollection(4, () => ({ key: 'value' }))
}))

API Reference

TODO

Options Reference

seedDir [string]

Default: './seeds'

Path to directory containing the seed files

databaseUrl [string]

Default: ''

Firestore database URL

credential [string]

Default: './serviceAccountCredentials.json'

Path to firebase admin credentials json

emulator [string]

Default: ''

Firestore emulator host

fresh [boolean]

Default: false

Remove all documents in collection before seeding.

If the fresh option is set to false, fireseeder will:

  1. Automatically create new data if the id is specified,
  2. Otherwise it will merge the seed data by id

lang [string]

Default: 'en'

Seed data language.

fireseeder uses faker.js under the hood, check here for locales available.

include [string[]]

Default: []

Collection name to seed (All collections are seeded if not specified)

exclude [string[]]

Default: []

Collection name to exclude from seed

idKey [string]

Default: '_id'

ID key of the seed data.

The idKey option can be specified in various places:

  1. (Highest priority) Seed file's idKey option specified in each of these API: mapCollection, mapSubCollection, collection, document, subCollection
  2. CLI Option
  3. Environment variable FSSEEDER_ID_KEY
  4. (Lowest priority) package.json config

NOTE: If the id is not specified in the seed data, a random ID will be created by firestore.