https://github.com/brianneisler/firetree
AST parser and generator for Firebase Firestore and Storage security rules
https://github.com/brianneisler/firetree
ast-parser firebase firebase-storage firestore security-rules
Last synced: about 1 month ago
JSON representation
AST parser and generator for Firebase Firestore and Storage security rules
- Host: GitHub
- URL: https://github.com/brianneisler/firetree
- Owner: brianneisler
- License: apache-2.0
- Created: 2020-11-02T00:41:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-07T05:03:52.000Z (over 2 years ago)
- Last Synced: 2025-04-19T07:20:27.561Z (about 2 months ago)
- Topics: ast-parser, firebase, firebase-storage, firestore, security-rules
- Language: JavaScript
- Homepage: https://firetree.io
- Size: 1.09 MB
- Stars: 8
- Watchers: 1
- Forks: 3
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# firetree 🔥🌲
AST parser and generator for Firebase Firestore and Storage security rules
## Project Status
[](https://github.com/brianneisler/moltres/blob/master/LICENSE)
[](https://badge.fury.io/js/firetree)
[](https://travis-ci.com/brianneisler/firetree)
[](https://codecov.io/gh/brianneisler/firetree/branch/main/)
[](https://nodei.co/npm/firetree/)## Documentation
[Full API documentation](docs/API.md) - 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](https://github.com/brianneisler/firemin)## Features
- [x] Parses firestore rules into an AST
- [x] Generates rules from an AST## TODO
- [ ] Support stdin and stdout for the binary commands
## Install
```sh
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```sh
npm install --save firetree
``````js
import { generate, parse, setupContext } from 'firetree'const context = setupContext()
const ast = await parse(context, {
filePath: './path/to/firestore.rules')
})
const rulesString = await generate(context, { ast })
```## Using the Binary
You can using the binary directly by installing globally
```sh
npm install -g firemin
```To parse a rules file, use the `parse` command
```sh
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.```sh
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
```sh
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.```sh
firetree generate -f ./path/to/my-firestore.ast.rules.json -o ./output/file/my-firestore.rules
```