firetree
v0.1.5
Published
AST parser and generator for Firebase Firestore and Storage security rules
Downloads
15
Maintainers
Readme
firetree 🔥🌲
AST parser and generator for Firebase Firestore and Storage security rules
Project Status
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
- [x] Parses firestore rules into an AST
- [x] Generates rules from an AST
TODO
- [ ] Support stdin and stdout for the binary commands
Install
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
npm install --save firetree
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
npm install -g firemin
To parse a rules file, use the parse
command
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.
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
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.
firetree generate -f ./path/to/my-firestore.ast.rules.json -o ./output/file/my-firestore.rules