{"id":16525770,"url":"https://github.com/haroldadmin/functions-differ","last_synced_at":"2025-06-10T13:06:22.167Z","repository":{"id":41882907,"uuid":"359065604","full_name":"haroldadmin/functions-differ","owner":"haroldadmin","description":"Tool to find Firebase Functions that changed for selective redeployments","archived":false,"fork":false,"pushed_at":"2023-10-02T10:23:01.000Z","size":128,"stargazers_count":40,"open_issues_count":7,"forks_count":13,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-18T20:29:18.783Z","etag":null,"topics":["ci","esbuild","firebase","serverless"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/functions-differ","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haroldadmin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-18T06:39:48.000Z","updated_at":"2024-09-09T08:43:21.000Z","dependencies_parsed_at":"2022-09-17T00:21:15.689Z","dependency_job_id":null,"html_url":"https://github.com/haroldadmin/functions-differ","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2Ffunctions-differ","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2Ffunctions-differ/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2Ffunctions-differ/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2Ffunctions-differ/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haroldadmin","download_url":"https://codeload.github.com/haroldadmin/functions-differ/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221667210,"owners_count":16860570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","esbuild","firebase","serverless"],"created_at":"2024-10-11T17:06:41.824Z","updated_at":"2024-10-27T11:09:12.074Z","avatar_url":"https://github.com/haroldadmin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# functions-differ\n\n[![Build and test](https://github.com/haroldadmin/functions-differ/actions/workflows/build-test.yml/badge.svg)](https://github.com/haroldadmin/functions-differ/actions/workflows/build-test.yml)\n[![npm](https://img.shields.io/npm/dm/functions-differ)](https://www.npmjs.com/package/functions-differ)\n[![npm](https://img.shields.io/npm/v/functions-differ)](https://www.npmjs.com/package/functions-differ)\n\nA tool to selectively deploy only the Firebase Functions that changed.\n\n[functions-differ](https://www.npmjs.com/package/functions-differ) takes a list of Firebase Functions from your repository and returns a list of functions that changed since its last invocation.\nThis helps you selectively deploy only the functions that changed, thus saving time during re-deployments.\n\nIt 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, changes in its installed dependencies, or any other local imports.\n\n## Usage\n\n-   Create a `.differspec.json` file in the directory containing your Firebase Functions:\n\n```shell\nmy-firebase-project\n    ├── firebase.json\n    ├── functions\n        ├── src\n        └── .differspec.json\n```\n\n-   Specify your function names and their paths in `.differspec.json`:\n\n\u003e This step is optional if you use the experimental `--discover` flag, which lets functions-differ discover the exported Cloud Functions from your project automatically.\n\n```json\n{\n    \"functions\": {\n        \"login\": \"src/auth/login/function.ts\",\n        \"register\": \"src/auth/login/function.ts\"\n    }\n}\n```\n\n-   Run `functions-differ` in the directory containing `.differspec.json`\n\n```shell\ncd my-firebase-project/functions\nfunctions-differ\n```\n\n-   `functions-differ` will 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.\n\n```shell\n\u003e functions-differ\nfunctions:login,functions:register\n```\n\nThe default output is suitable for passing to `firebase deploy --only` command.\n\n## Options\n\n`functions-differ` supports the following options:\n\n| Name          | Alias | Description                                                                                                                     | Default                                 |\n| ------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |\n| dir           | d     | The directory containing `.differspec.json` file                                                                                | (current working directory)             |\n| write         | w     | Write output to `.differspec.json` file or not                                                                                  | true                                    |\n| verbose       | v     | Output verbose logs                                                                                                             | false                                   |\n| prefix        |       | Prefix for each function name output                                                                                            | `functions:`                            |\n| sep           |       | Separator for each output function                                                                                              | `,`                                     |\n| bundlerConfig |       | Path to the bundler config file which would be passed to esbuild                                                                |                                         |\n| concurrency   |       | Number to control the concurrency of the bundling process. Useful in CI/CD flows with limited memory                            | Number of functions in .differspec.json |\n| discover      |       | (**Experimental**) Flag indicating whether to use automatic function path discovery                                             | true                                    |\n| no-discover   |       | (**Experimental**) Negates the `--discover` flag                                                                                |                                         |\n| indexFilePath |       | (**Experimental**) Location of the index.ts file which exports all the functions. Optional. Only used if used with `--discover` | `src/index.ts`                          |\n\n## .differspec.json\n\n`.differspec.json` serves as persistent storage for `functions-differ`. It contains the following properties:\n\n| Name        | Description                                                                                                                   |\n| ----------- | ----------------------------------------------------------------------------------------------------------------------------- |\n| `functions` | JSON object containing names of functions in the repository along with their paths                                            |\n| `hashes`    | (**AUTOGENERATED, DO NOT MODIFY**) JSON object containing hashes of all functions in the `functions` property                 |\n| `lastDiff`  | (**AUTOGENERATED, DO NOT MODIFY**) JSON object containing the results of the last successful invocation of `functions-differ` |\n\n-   The `hashes` and `lastDiff` properties are autogenerated by `functions-differ`, and should not be created/edited manually.\n\n## Contributions\n\nPlease 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.\n\n## Installation\n\nInstall the package with `npm`:\n\n`npm install -g functions-differ`\n\n## Notes\n\n### Automatic Functions Discovery (Experimental)\n\n`functions-differ` has experimental support for discovering Cloud Functions exported from your project automatically. This lets you skip defining function paths in your `.differspec.json` file manually.\n\nIt does this by using the TypeScript AST on exports from your project's root `index.ts` file. It makes the following assumptions about your codebase:\n\n1. The `src/index.ts` file must contain all exported Cloud Functions from your project, and no other exports.\n2. Every Cloud Function is defined in a separate file. E.g.: `src/auth/login/index.ts`, `src/auth/register/index.ts`, etc.\n\nIf you use automatic functions discovery in your project, make sure the above assumptions hold true.\n\n### Integration with CI/CD\n\nI built `functions-differ` to help reduce the average deployment time of Cloud Functions in a project, but does not offer native support for CI builds.\n\nFiles generated during CI builds are usually ephemeral. They are lost once the CI build completes. If you plan to run `functions-differ` in your CI workflow, you need to backup the `.differspec.json` generated by the previous build, and restore it for the next built.\n\nHere are some ways to do that for GitHub Actions:\n\n1. Use [caching](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows) between CI runs for the `.differspec.json` file.\n2. Read/store the contents of the `.differspec.json` file in GitHub secrets in each CI run using the `gh` CLI available to every job.\n\nThis tool uses ESBuild internally to bundle Cloud Functions in parallel. Bundling is a resource intensive process.\nIf your CI builds appear to crash or run very slowly after integrating functions-differ, it could be due to high memory usage by ESBuild. Consider using the `--concurrency` option to control how many Cloud Functions to bundle in parallel.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharoldadmin%2Ffunctions-differ","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharoldadmin%2Ffunctions-differ","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharoldadmin%2Ffunctions-differ/lists"}