• Stars
    star
    240
  • Rank 168,229 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Application for Managing Firebase Applications. Includes support for multiple environments and data migrations

fireadmin

Build Status Cypress Dashboard License Code Style

Application for Managing Firebase Applications. Includes support for multiple environments and data migrations

Table of Contents

  1. Features
  2. Getting Started
  3. NPM Scripts
  4. Application Structure
  5. Run Your Own
  6. Requirements
  7. Before Starting
  8. Testing
  9. Cloud Functions Unit
  10. App E2E
  11. Deployment
  12. FAQ

Features

  • Manage multiple environments as a single project
  • Project Sharing (invite by email coming soon)
  • "Action Runner" for common project actions such as data migrations, and generating reports
  • Action Features include support for:
    • Multiple steps allowing many actions in one run
    • Backup phase (for easy backing up data before running your actions)
  • Project level tracking of actions which have been run through Action Runner
  • Get/Set CORS Config of Storage Buckets
  • Testing for React App (Cypress) and Cloud Functions (Mocha)

coming soon

  • Support for copying Single Firestore Document in Copy Action
  • Map action - for mapping each item in a collection both on RTDB and Firestore
  • Authorized Google API Request Panel
  • Invite new users by email
  • User manager (including role assignment)
  • Data Viewer

Interested in adding a feature or contributing? Please open an issue!

Getting Started

Since this is source code, a great place to start is checking the hosted version of Fireadmin available at fireadmin.io.

NPM Scripts

While developing, you will probably rely mostly on npm start; however, there are additional scripts at your disposal:

yarn <script> Description
start Serves your app at localhost:3000
start:dist Builds the application to ./dist and Serves it at localhost:3000 using firebase serve
functions:start Runs Functions REPL locally (uses firebase functions:shell
functions:build Builds Cloud Functions to ./functions/dist
functions:test Runs Functions Unit Tests with Mocha
build Builds the application to ./dist
test Runs E2E Tests with Cypress. See testing
lint Lints the project for potential errors
lint:fix Lints the project and fixes all correctable errors

Husky is used to enable prepush hook capability. The prepush script currently runs eslint, which will keep you from pushing if there is any lint within your code. If you would like to disable this, remove the prepush script from the package.json.

Application Structure

├── .github                      # Github Settings + Github Actions Workflows
│   ├── deploy.yml               # Deploy workflow (called on merges to "master" and "production" branches)
│   └── verify.yml               # Verify workflow (run when PR is created)
├── cypress                      # UI Integration Tests
├── docs                         # Docs application (built with Gatsby)
│   ├── content                  # Content of docs (written in markdown)
│   ├── components               # React components used in docs app
│   ├── gatsby-config.js         # Gatsby plugin settings
│   └── gatsby-node.js           # Gatsby node definitions (how templates are combined with content)
│   └── package.json             # Docs package file (docs specific dependencies)
├── functions                    # Cloud Functions (uses Cloud Functions for Firebase)
│   ├── src                      # Cloud Functions Source code (each folder represents a function)
│   └── index.js                 # Functions entry point
├── public                       # Public assets
│   ├── favicon.ico              # Favicon
│   ├── firebase-messaging.sw.js # Messaging Service worker (loaded by Firebase SDK)
│   └── index.html               # Main HTML page container for app
├── src                          # Application source code
│   ├── components               # Global Reusable Presentational Components
│   ├── containers               # Global Reusable Container Components
│   ├── layouts                  # Components that dictate major page structure
│   │   └── CoreLayout           # Global application layout in which to render routes
│   ├── routes                   # Main route definitions and async split points
│   │   ├── index.js             # Bootstrap main application routes with store
│   │   └── Home                 # Fractal route
│   │       ├── index.js         # Route definitions and async split points
│   │       ├── assets           # Assets required to render components
│   │       ├── components       # Presentational React Components
│   │       ├── modules          # Collections of reducers/constants/actions
│   │       └── routes **        # Fractal sub-routes (** optional)
│   ├── static                   # Static assets
│   └── utils                    # Application-wide utils (form validation etc)
├── .firebaserc                  # Firebase project settings (including settings for CI deployment)
├── cypress.json                 # Cypress Integration Test settings
├── database.rules.json          # Firebase Real Time Database Rules
├── firebase.json                # Firebase resource settings (including which folders are deployed)
├── firestore.indexes.json       # Firestore Indexes
├── firestore.rules              # Firestore Database Rules
└── storage.rules                # Cloud Storage Rules

Run Your Own

Requirements

Before Starting

  1. Make sure you have enabled billing on your Firebase account - external API communication requires setting up a payment method (you are only charged based on usage)
  2. Create an account on Algolia - Create a new app, you will need the API keys later
  3. Install Firebase Command Line Tools: npm i -g firebase-tools

Local Environment Setup

  1. Install dependencies: yarn install

  2. Create a Web app within the Firebase Console of your project (config will be used in next step)

  3. Create a .env.local that has the following format (with your values filled from previous step):

    REACT_APP_FIREBASE_apiKey=<- api key ->
    REACT_APP_FIREBASE_authDomain=<- auth domain ->
    REACT_APP_FIREBASE_databaseURL=<- database URL ->
    REACT_APP_FIREBASE_projectId=<- project ID ->
    REACT_APP_FIREBASE_storageBucket=<- storageBucket ->
    REACT_APP_FIREBASE_messagingSenderId=<- message sender ID ->
    REACT_APP_FIREBASE_appId=<- project app id ->
    REACT_APP_FIREBASE_PUBLIC_VAPID_KEY=<- project app id ->
    REACT_APP_ALGOLIA_APP_ID=<- ->
    REACT_APP_ALGOLIA_API_KEY=<- ->
  4. Create functions/.runtimeconfig.json file that looks like so:

    {
      "algolia": {
        "api_key": "<- your API KEY ->",
        "app_id": "<- your Algolia APP ID ->"
      },
      "gmail": {
        "email": "<- gmail account for sending invite emails ->",
        "password": "<- password for ^ email ->"
      },
      "encryption": {
        "password": "<- your own made up encryption password for service accounts -> "
      }
    }
  5. Set Functions config variables to match the file you just made (for the deployed version of your functions):

    firebase functions:config:set $(jq -r 'to_entries[] | [.key, (.value | tojson)] | join("=")' < functions/.runtimeconfig.json)
  6. Build Project: yarn build

  7. Deploy to Firebase: firebase deploy (deploys, Cloud Functions, Rules, and Hosting)

  8. Start Development server: npm start NOTE: You can also use yarn start:dist to test how your application will work when deployed to Firebase

  9. View the deployed version of the site by running firebase open hosting:site

Deployment

CI Deploy (recommended)

Note: Config for this is located within .github/workflows/app-deploy.yml. firebase-ci has been added to simplify the CI deployment process by getting settings from the .firebaserc. All that is required is providing authentication with Firebase:

  1. Have at least two Firebase projects to ready to use, one for each environment (staging and production)

  2. Replace info within .firebaserc under both the projects, ci, and targets sections

  3. Login: firebase login:ci to generate an authentication token. This token will be used to give the CI provider rights to deploy on your behalf. Settings are provided for Gitlab, but any CI provider can be used.

  4. Set FIREBASE_TOKEN environment variable within Github Actions secrets

  5. Add the following environment variables to Github Actions's variables (within /settings/ci_cd):

    FIREBASE_TOKEN; // Used to deploy to Firebase (token generated in last step)
    CYPRESS_RECORD_KEY; // Record key for Cypress Dashboard
    SERVICE_ACCOUNT; // Used to authenticate with database to run hosted tests
  6. Run a build on Github Actions by pushing code to your Git remote (most likely Github)

For more options on CI settings checkout the firebase-ci docs.

Manual deploy

  1. Build Project: yarn build
  2. Deploy to firebase: firebase deploy NOTE: You can use firebase serve to test how your application will work when deployed to Firebase, but make sure you run yarn build first.

Docs

Documentation is available at fireadmin.io/docs

All source code and content for docs is located within the docs folder. Docs are generated from markdown into static files using Gatsby based on settings in gatsby-config.js.

Visit the docs README for more info.

Testing

NOTE: If you have setup CI deployment, E2E tests and Unit Tests can automatically run against your staging environment before running the production build.

Cloud Functions Unit Tests

Cloud Functions Unit tests are written in Mocha with code coverage generated by Istanbul. These tests cover "backend functionality" handled by Cloud Functions by stubbing the functions environment (including dependencies).

Run Locally
  1. Go into the functions folder: cd functions
  2. Confirm you have dependencies installed: npm i
  3. Run unit tests: npm test
  4. To also generate coverage while testing, run yarn test:cov

App UI Tests

End to End tests are done using Cypress and they live within the cypress folder. These tests cover UI functionality and are run directly on the hosted environment of Fireadmin. Application end to end tests are run automatically in Github Actions the after deploying to the staging environment before deploying to production.

Run Locally
  1. Create a service account within the Firebase console

  2. Save the service account as serviceAccount.json within the root of the project

  3. Get the UID of the user that you want to use while testing from the Authentication tab of the Firebase console to

  4. Create cypress.env.json with the following format:

    {
      "TEST_UID": "<- user account's UID ->"
    }
  5. Run yarn emulators. This will bootup the emulators (pointed to during testing)

  6. In a different terminal yun yarn start:emulate. This will bootup the application pointed to the emulators

  7. In a different terminal tab, run yarn test:emulate:run. This will run Cypress integration tests pointed at emulators (for seeding and verifing)

To Open Cypress's local test runner UI where you can run single tests or all tests use yarn test:emulate.

FAQ

  1. Why node 12 instead of a newer version? Cloud Functions runtime supports up to 12, which is why that is what is used for the CI build version. This will be switched when the functions runtime is updated
  2. Uploading service accounts? Where do they go and how are my service accounts stored? When uploading a service account, it first goes to a Google Cloud Storage Bucket which has security rules and does not have CORS access. The copyServiceAccountToFirestore Cloud Function converts it into an encrypted string, stores it within Firestore, then removes the original file from Cloud Storage. Firestore rules keep anyone that is not a collaborator on your project using or reading the service account. Since it is associated with a specific environment, you can then limit access to what can be done with it right in the Users/Permissions tab of Fireadmin.

More Repositories

1

react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
JavaScript
2,545
star
2

redux-firestore

Redux bindings for Firestore
JavaScript
574
star
3

generator-react-firebase

React Firebase (Redux optional) yeoman generator
JavaScript
296
star
4

cypress-firebase

Cypress plugin and custom commands for testing Firebase projects
TypeScript
255
star
5

react-google-button

Simple google button for React that follows Google's style guidelines (https://developers.google.com/identity/sign-in/web/build-button)
JavaScript
74
star
6

firebase-ci

Simplified Firebase interaction for continuous integration
JavaScript
72
star
7

redux-firebasev3

Actions/Reducer with HOC for using redux with Firebase v3
JavaScript
36
star
8

gitbook-plugin-versions-select

A gitbook plugin that provides a version dropdown. Works with multiple versions on one domain.
JavaScript
12
star
9

redux-firebase

Redux bindings for Firebase
JavaScript
7
star
10

tsheets-sdk

Javascript SDK for TSheets API
JavaScript
6
star
11

ng-reveal

Angular Directive wrapper for RevealJS presentation library.
JavaScript
6
star
12

cra-template-rrf

JavaScript
4
star
13

authrocket

Javascript library to interact with Auth Rocket service
JavaScript
3
star
14

generator-firebase-functions

Yeoman generator for creating Cloud Functions For Firebase within a Firebase project
JavaScript
3
star
15

renovate-config

My personal renovate config presets
3
star
16

functions-queue

Task Queuing for use with Cloud Functions for Firebase. Similar to firebase-queue but handles Functions events.
JavaScript
3
star
17

fireadmin-site

App for managing Firebase instances (including data migrations and analytics)
JavaScript
2
star
18

parsePush

DEPRECATED. Parse no longer exists
Go
2
star
19

devshare

JS library on which devshare.io is built and extended
JavaScript
2
star
20

redux-devshare

Redux connector for devshare library
JavaScript
2
star
21

generator-next-firebase

NextJS and Firebase project generator
JavaScript
2
star
22

tessellate

Application building/sharing API
JavaScript
2
star
23

machinepack-spotify

A machinepack to interact with the Spotify API
JavaScript
2
star
24

spanner-graphql-example

Example of React App which interacts with a Cloud Spanner instance using GraphQL (hosted on Cloud Functions)
TypeScript
2
star
25

firebase-tools-extra

Extra methods for firebase-tools which support using a service account.
TypeScript
1
star
26

AngularFireAdmin

Angular integration for FireAdmin library.
CSS
1
star
27

firething

JavaScript
1
star
28

deploy-changed-functions

TypeScript
1
star
29

portfolio

Personal website
JavaScript
1
star
30

PiOpenLighting

Open Lighting Library modified to be used on a pi that is placed in the amplifier rack that I build for my fraternity. Originally from open-lighting-24ba77cc10d1.
C++
1
star
31

Dyml

CSS
1
star
32

revealPortfolio

Portfolio sample built with RevealJS and AngularJS.
JavaScript
1
star
33

s3Upload

Go package to simplify file uploads to s3
Go
1
star
34

machinepack-jwtauth

Handle JSON Web Tokens from request headers.
JavaScript
1
star
35

devshare-cli

Command line interface for devshare
JavaScript
1
star
36

blues-mui-stack

Remix blues stack with material-ui
TypeScript
1
star
37

fireuser

User/Session management for Firebase
JavaScript
1
star
38

react-es6-basic

Basic React hello world app with ES6 and Babel.
HTML
1
star
39

new-project-tutorial

HTML
1
star
40

hypercube-server

CSS
1
star