I'm trying to clean up my build system and I'd like to use the firebase-tools (Firebase-hosted docs) module in doing so. Documentation for using the package in the CLI is fine enough, but the documentation for using it as a node module is sparse (and diving through the source code of the package hasn't been straightforward, either).
At the time of this writing, here is the relevant documentation (it only appears in the GH repository):
Using as a Module
The Firebase CLI can also be used programmatically as a standard Node module. This can only be done on your machine, and cannot be done within Cloud Functions. Each command is exposed as a function that takes an options object and returns a Promise. For example:
var client = require('firebase-tools');
client.list().then(function(data) {
console.log(data);
}).catch(function(err) {
// handle error
});
client.deploy({
project: 'myfirebase',
token: process.env.FIREBASE_TOKEN,
cwd: '/path/to/project/folder'
}).then(function() {
console.log('Rules have been deployed!')
}).catch(function(err) {
// handle error
});
As you can see, only two very basic examples are included, and there is no description of the various options that can be provided to each command.
For example, the CLI uses the --only
tag (such as --only database
if one only wants to push new rules). If I want to only deploy rules, do I include only: "database"
in the options?
The output in the example does boast the "Rules have been deployed!" success message, but nothing about the options provided to deploy
seem to indicate that this would only be pushing rules (rather than a full deploy without the --only
option)!
Bonus question: what if I have different paths for my rules file vs. files that I would want hosted? I see only one cwd
option provided in the example.
Some clearer documentation here would go a long way :)