Package Exports
- functions-differ
- functions-differ/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (functions-differ) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
functions-differ
A tool to selectively deploy only the Firebase Functions that changed.
functions-differ takes a list of Firebase Functions from your repository and returns a list of functions that changed since its last invocation. This helps you selectively deploy only the functions that changed, thus saving time during re-deployments.
It detects any changes to a function by bundling it into a single minified file, and calculating a hash for it. This works for changes in the function's code, change in its installed dependencies, or any other local imports.
Usage
- Create a
.differspec.jsonfile in the directory containing your Firebase Functions:
my-firebase-project
├── firebase.json
├── functions
├── src
└── .differspec.json - Specify your function names and their paths in
.differspec.json:
{
"functions": {
"login": "src/auth/login/function.ts",
"register": "src/auth/login/function.ts"
}
}- Run
functions-differin the directory containing.differspec.json
cd my-firebase-project/functions
functions-differfunctions-differwill then output a list of functions that need to be (re)deployed. This includes any functions that were changed or added since its last invocation.
> functions-differ
functions:login,functions:registerThe default output is suitable for passing to firebase deploy --only command.
Options
functions-differ supports the following options:
| Name | Alias | Description | Default |
|---|---|---|---|
| dir | d | The directory containing .differspec.json file |
(current working directory) |
| write | w | Write output to .differspec.json file or not |
true |
| verbose | v | Output verbose logs | false |
| prefix | Prefix for each function name output | functions: |
|
| sep | Separator for each output function | , |
.differspec.json
.differspec.json serves as persistent storage for functions-differ. It contains the following properties:
| Name | Description |
|---|---|
functions |
JSON object containing names of functions in the repository along with their paths |
hashes |
(AUTOGENERATED, DO NOT MODIFY) JSON object containing hashes of all functions in the functions property |
lastDiff |
(AUTOGENERATED, DO NOT MODIFY) JSON object containing the results of the last successful invocation of functions-differ |
- The
functionsproperty serves as an index of all functions present in your repository.functions-differdoes not support automatic discovery of functions in the project (yet), and therefore this property is required. - The
hashesandlastDiffproperties are autogenerated byfunctions-differ, and should not be created/edited manually.
Contributions
Please discuss bugs, feature requests, and help in Github Issues. Pull requests are welcome, but please make sure to open an issue for your changes first.
Installation
Install the package with npm:
npm install -g functions-differ