项目作者: brianneisler

项目描述 :
AST parser and generator for Firebase Firestore and Storage security rules
高级语言: JavaScript
项目地址: git://github.com/brianneisler/firetree.git
创建时间: 2020-11-02T00:41:31Z
项目社区:https://github.com/brianneisler/firetree

开源协议:Other

下载


firetree 🔥🌲

AST parser and generator for Firebase Firestore and Storage security rules

Project Status

license
npm version

Build Status

Code coverage

NPM

Documentation

Full API documentation - Learn about each method

Why?

Firestore security rules lacks an available AST parser…. so I made one.

This can come in handy for making additional tools, like IDE plugins, security
rules analyzers or even a minifier

Features

  • Parses firestore rules into an AST
  • Generates rules from an AST

TODO

  • Support stdin and stdout for the binary commands

Install

  1. npm install --save-dev firetree

Usage

The firetree parser can be used as an imported library or as a binary.

Using Programmatically

To do so, simply
install firetree as a project dependency and then
import the necessary methods from the firetree package

  1. npm install --save firetree
  1. import { generate, parse, setupContext } from 'firetree'
  2. const context = setupContext()
  3. const ast = await parse(context, {
  4. filePath: './path/to/firestore.rules')
  5. })
  6. const rulesString = await generate(context, { ast })

Using the Binary

You can using the binary directly by installing globally

  1. npm install -g firemin

To parse a rules file, use the parse command

  1. firetree parse -f ./path/to/my-firestore.rules

By default the output file is ./firestore.ast.rules.json. To specify a different
path you can use the -o option.

  1. firetree parse -f ./path/to/my-firestore.rules -o ./output/file/my-firestore.ast.rules.json

To generate a rules file from an AST, use the generate command

  1. firetree generate -f ./path/to/my-firestore.ast.rules.json

By default the output file is ./firestore.rules. To specify a different
path you can use the -o option.

  1. firetree generate -f ./path/to/my-firestore.ast.rules.json -o ./output/file/my-firestore.rules