From c771f8ff7da86a34b7b84acf6f8be662d88f374f Mon Sep 17 00:00:00 2001 From: Simon M Date: Fri, 5 Apr 2024 22:34:07 +0100 Subject: [PATCH 1/8] Readme updated --- README.md | 140 ++++++++++++++++++++++----------- docs/quick-start.md | 64 --------------- docs/user-guide.md | 40 ++++++++++ packages/nx-firebase/README.md | 127 +++++++++++++++++++++++++----- 4 files changed, 239 insertions(+), 132 deletions(-) delete mode 100644 docs/quick-start.md create mode 100644 docs/user-guide.md diff --git a/README.md b/README.md index 19dd839..e459081 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,116 @@ -# @simondotm/nx-firebase +# @simondotm/nx-firebase ![Status](https://github.com/simondotm/nx-firebase/actions/workflows/ci.yml/badge.svg) ![Status](https://img.shields.io/badge/Nx-v16.8.1-blue) ![Status](https://img.shields.io/npm/v/@simondotm/nx-firebase) ![npm](https://img.shields.io/npm/dw/@simondotm/nx-firebase.svg) -![npm](https://img.shields.io/npm/dw/@simondotm/nx-firebase.svg) +A plugin for [Nx](https://nx.dev) v16.8.1+ that integrates Firebase workflows in an Nx monorepo workspace. -A plugin for [Nx](https://nx.dev) v16.8.1+ that provides support for Firebase projects in an Nx monorepo workspace. +* Easily generate Firebase applications and functions +* Uses `esbuild` for fast Firebase function builds so you can easily create & import shared Nx libraries with the benefits of tree-shaking +* Supports function environment variables and secrets +* Supports single or multiple firebase projects/apps within an Nx workspace +* Full support for the Firebase Emulator suite for local development, with watch mode for functions +* Keeps your `firebase.json` configurations in sync when renaming or deleting Firebase apps & functions +* Only very lightly opinionated about your Firebase configurations and workspace layouts; you can use Nx or the Firebase CLI See [CHANGELOG](https://github.com/simondotm/nx-firebase/blob/main/CHANGELOG.md) for release notes. -## Overview +## Install Plugin -Nx provides a great way to manage monorepo workflows and this plugin helps make it easy to integrate Firebase projects with Nx. +**`npm install @simondotm/nx-firebase --save-dev`** -### Features +- Installs this plugin into your Nx workspace +- This will also install `@nx/node` and firebase SDK's to your root workspace `package.json` if they are not already installed -- **Firebase Apps** - - Generates Firebase application projects, with default `firebase.json` configurations, rules and indexes for each Firebase app -- **Firebase Functions** - - Generates Firebase function apps based on Typescript Nx node applications - - Bundling of Firebase functions using `esbuild` for extremely fast compilation & tree-shaking for optimal function cold starts - - Easily import Typescript Nx libraries from your Nx workspace into your Firebase functions for code sharing across projects - - Supports function environment variables and secrets -- **Firebase Features** - - Use the Firebase Emulator suite whilst developing locally - all functions are watched and updated live while you work - - Use Firebase hosting with Nx to easily build & deploy web apps -- **Workspace Management** - - Nx's automatic dependency checking for no-fuss builds, and per-project or per-function deployments - - Supports single or multiple firebase projects/apps within an Nx workspace - - Nx workspace management with the `sync` generator keeps your project & `firebase.json` configs automatically updated when renaming or deleting Firebase apps & functions - - Only very lightly opinionated about your Firebase configurations and workspace layouts; you can use Nx or the Firebase CLI +## Generate Firebase Application -# User Guide +**`nx g @simondotm/nx-firebase:app my-new-firebase-app [--directory=dir] [--project=proj]`** -- **[Quick Start](docs/quick-start.md)** -- [Migrating to new plugin versions](docs/nx-firebase-migrations.md) +- Generates a new Nx Firebase application project in the workspace +- The app generator will also create a Firebase configuration file in the root of your workspace (along with a default `.firebaserc` and `firebase.json` if they don't already exist) +- For the first firebase application you create, the project firebase configuration will be `firebase.json` +- If you create additional firebase applications, the project firebase configuration will be `firebase..json` +- Use `--project` to link your Firebase App to a Firebase project name in your `.firebaserc` file -**Nx Firebase Generators** +## Generate Firebase Function -- [Firebase Applications](docs/nx-firebase-applications.md) -- [Firebase Functions](docs/nx-firebase-functions.md) -- [Firebase Functions - Environment Variables](docs/nx-firebase-functions-environment.md) +**`nx g @simondotm/nx-firebase:function my-new-firebase-function --app=my-new-firebase-app [--directory=dir]`** -**Nx Firebase** +- Generates a new Nx Firebase function application project in the workspace +- Firebase Function projects must be linked to a Firebase application project with the `--app` option +- Firebase Function projects can contain one or more firebase functions +- You can generate as many Firebase Function projects as you need for your application -- [Firebase Hosting](docs/nx-firebase-hosting.md) -- [Firebase Emulators](docs/nx-firebase-emulators.md) -- [Firebase Databases](docs/nx-firebase-databases.md) -- [Firebase Projects](docs/nx-firebase-projects.md) +## Build -**Nx Firebase Workspace Management** +**`nx build my-new-firebase-app`** -- [Nx-Firebase Sync](docs/nx-firebase-sync.md) -- [Nx-Firebase Project Schemas](docs/nx-firebase-project-structure.md) +- Compiles & builds all Firebase function applications linked to the Nx Firebase application or an individual function -**Nx Workspace** +**`nx build my-new-firebase-function`** -- [Nx Workspace Layout Ideas](docs/nx-workspace-layout.md) -- [Using Nx Libraries with Firebase Functions](docs/nx-libraries.md) -- [Migrating an existing Firebase project to Nx](docs/nx-migration.md) +- Compiles & builds an individual function -**Version information** -- [Firebase Versions](docs/firebase-versions.md) -- [Nx Versions](docs/nx-versions.md) +## Serve -_Note: Some of these may not always be upto date - it's hard work keeping track of external releases and compatibilities!_ +**`nx serve my-new-firebase-app`** -**Notes** +- Builds & Watches all Firebase functions apps linked to the Firebase application +- Starts the Firebase emulators -- [Plugin Development Notes](docs/nx-plugin-commands.md) -- [Nx Development Setup for Mac](docs/nx-setup-mac.md) +## Deploy + +### Firebase Application + +**`nx deploy my-new-firebase-app [--only ...]`** + +- By default, deploys ALL of your cloud resources associated with your Firebase application (eg. sites, functions, database rules etc.) +- Use the `--only` option to selectively deploy (same as Firebase CLI) + +For initial deployment: + +- **`firebase login`** if not already authenticated +- **`firebase use --add`** to add your Firebase Project(s) to the `.firebaserc` file in your workspace. This step must be completed before you can deploy anything to Firebase. + +Note that you can also use the firebase CLI directly if you prefer: + +- **`firebase deploy --config=firebase..json --only functions`** + +### Firebase Function + +**`nx deploy my-new-firebase-function`** + +- Deploys only a specific Firebase function + + + +## Test + +**`nx test my-new-firebase-app`** + +- Runs unit tests for all Firebase functions apps linked to the Firebase application + +**`nx test my-new-firebase-function`** + +- Runs unit tests for an individual function + + +## Lint + +**`nx lint my-new-firebase-app`** + +- Runs linter for all Firebase functions apps linked to the Firebase application or an individual function + +**`nx lint my-new-firebase-function`** + +- Runs linter for an individual function + +## Sync Workspace + +**`nx g @simondotm/nx-firebase:sync`** + +- Ensures that your `firebase.json` configurations are kept up to date with your workspace + - If you rename or move firebase application or firebase function projects + - If you delete firebase function projects + +## Further Information + +See the full plugin [User Guide](https://github.com/simondotm/nx-firebase/blob/main/docs/user-guide.md) for more details. \ No newline at end of file diff --git a/docs/quick-start.md b/docs/quick-start.md deleted file mode 100644 index 308305c..0000000 --- a/docs/quick-start.md +++ /dev/null @@ -1,64 +0,0 @@ -# Quick Start - -- [Quick Start](#quick-start) - - [Install Plugin](#install-plugin) - - [Generate Firebase Application Project](#generate-firebase-application-project) - - [Generate Firebase Function Application Project](#generate-firebase-function-application-project) - - [Build Firebase Application](#build-firebase-application) - - [Deploy Firebase Application](#deploy-firebase-application) - - [Serve Firebase Project](#serve-firebase-project) - -## Install Plugin - -**`npm install @simondotm/nx-firebase --save-dev`** - -- Installs this plugin into your Nx workspace. -- This will also install some Nx and firebase dependencies (both for backend and frontend) to your root workspace `package.json` if they are not already installed. -- The plugin is compatible with Nx versions 16.1.1 or above - -## Generate Firebase Application Project - -**`nx g @simondotm/nx-firebase:app [--directory=dir] [--project=proj]`** - -- Generates a new Nx Firebase application project in the workspace -- The app generator will also create a Firebase configuration file in the root of your workspace (along with a default `.firebaserc` and `firebase.json` if they don't already exist). -- For the first firebase application you create, the project firebase configuration will be `firebase.json`. -- If you create additional firebase applications, the project firebase configuration will be `firebase..json`. - -## Generate Firebase Function Application Project - -**`nx g @simondotm/nx-firebase:function --app= [--directory=dir]`** - -- Generates a new Nx Firebase function application project in the workspace -- Firebase Function projects must be linked to a Firebase application project with the `--app` option -- Firebase Function projects can contain one or more firebase functions -- You can generate as many Firebase Function projects as you need for your application - -## Build Firebase Application - -**`nx build `** - -- Compiles & builds all Firebase function applications linked to the Nx Firebase - -## Deploy Firebase Application - -**`nx deploy [--only ...]`** - -- By default, deploys ALL of your cloud resources associated with your Firebase application (eg. sites, functions, database rules etc.) -- Use the `--only` option to selectively deploy (same as Firebase CLI) - -For inital deployment: - -- **`firebase login`** if not already authenticated -- **`firebase use --add`** to add your Firebase Project(s) to the `.firebaserc` file in your workspace. This step must be completed before you can deploy anything to Firebase. - -Note that you can also use the firebase CLI directly if you prefer: - -- **`firebase deploy --config=firebase..json --only functions`** - -## Serve Firebase Project - -**`nx serve `** - -- Builds & Watches all Firebase functions apps linked to the Firebase application -- Starts the Firebase emulators diff --git a/docs/user-guide.md b/docs/user-guide.md new file mode 100644 index 0000000..0b0ab2a --- /dev/null +++ b/docs/user-guide.md @@ -0,0 +1,40 @@ +# User Guide + + +- [Migrating to new plugin versions](./nx-firebase-migrations.md) + +**Nx Firebase Generators** + +- [Firebase Applications](./nx-firebase-applications.md) +- [Firebase Functions](./nx-firebase-functions.md) +- [Firebase Functions - Environment Variables](./nx-firebase-functions-environment.md) + +**Nx Firebase** + +- [Firebase Hosting](./nx-firebase-hosting.md) +- [Firebase Emulators](./nx-firebase-emulators.md) +- [Firebase Databases](./nx-firebase-databases.md) +- [Firebase Projects](./nx-firebase-projects.md) + +**Nx Firebase Workspace Management** + +- [Nx-Firebase Sync](./nx-firebase-sync.md) +- [Nx-Firebase Project Schemas](./nx-firebase-project-structure.md) + +**Nx Workspace** + +- [Nx Workspace Layout Ideas](./nx-workspace-layout.md) +- [Using Nx Libraries with Firebase Functions](./nx-libraries.md) +- [Migrating an existing Firebase project to Nx](./nx-migration.md) + +**Version information** + +- [Firebase Versions](./firebase-versions.md) +- [Nx Versions](./nx-versions.md) + +_Note: Some of these may not always be upto date - it's hard work keeping track of external releases and compatibilities!_ + +**Notes** + +- [Plugin Development Notes](./nx-plugin-commands.md) +- [Nx Development Setup for Mac](./nx-setup-mac.md) \ No newline at end of file diff --git a/packages/nx-firebase/README.md b/packages/nx-firebase/README.md index d98c893..e459081 100644 --- a/packages/nx-firebase/README.md +++ b/packages/nx-firebase/README.md @@ -1,31 +1,116 @@ -# @simondotm/nx-firebase +# @simondotm/nx-firebase ![Status](https://github.com/simondotm/nx-firebase/actions/workflows/ci.yml/badge.svg) ![Status](https://img.shields.io/badge/Nx-v16.8.1-blue) ![Status](https://img.shields.io/npm/v/@simondotm/nx-firebase) ![npm](https://img.shields.io/npm/dw/@simondotm/nx-firebase.svg) -A plugin for [Nx](https://nx.dev) v16.8.1+ that provides support for Firebase projects in an Nx monorepo workspace. +A plugin for [Nx](https://nx.dev) v16.8.1+ that integrates Firebase workflows in an Nx monorepo workspace. + +* Easily generate Firebase applications and functions +* Uses `esbuild` for fast Firebase function builds so you can easily create & import shared Nx libraries with the benefits of tree-shaking +* Supports function environment variables and secrets +* Supports single or multiple firebase projects/apps within an Nx workspace +* Full support for the Firebase Emulator suite for local development, with watch mode for functions +* Keeps your `firebase.json` configurations in sync when renaming or deleting Firebase apps & functions +* Only very lightly opinionated about your Firebase configurations and workspace layouts; you can use Nx or the Firebase CLI See [CHANGELOG](https://github.com/simondotm/nx-firebase/blob/main/CHANGELOG.md) for release notes. -## Overview +## Install Plugin + +**`npm install @simondotm/nx-firebase --save-dev`** + +- Installs this plugin into your Nx workspace +- This will also install `@nx/node` and firebase SDK's to your root workspace `package.json` if they are not already installed + +## Generate Firebase Application + +**`nx g @simondotm/nx-firebase:app my-new-firebase-app [--directory=dir] [--project=proj]`** + +- Generates a new Nx Firebase application project in the workspace +- The app generator will also create a Firebase configuration file in the root of your workspace (along with a default `.firebaserc` and `firebase.json` if they don't already exist) +- For the first firebase application you create, the project firebase configuration will be `firebase.json` +- If you create additional firebase applications, the project firebase configuration will be `firebase..json` +- Use `--project` to link your Firebase App to a Firebase project name in your `.firebaserc` file + +## Generate Firebase Function + +**`nx g @simondotm/nx-firebase:function my-new-firebase-function --app=my-new-firebase-app [--directory=dir]`** + +- Generates a new Nx Firebase function application project in the workspace +- Firebase Function projects must be linked to a Firebase application project with the `--app` option +- Firebase Function projects can contain one or more firebase functions +- You can generate as many Firebase Function projects as you need for your application + +## Build + +**`nx build my-new-firebase-app`** + +- Compiles & builds all Firebase function applications linked to the Nx Firebase application or an individual function + +**`nx build my-new-firebase-function`** + +- Compiles & builds an individual function + + +## Serve + +**`nx serve my-new-firebase-app`** + +- Builds & Watches all Firebase functions apps linked to the Firebase application +- Starts the Firebase emulators + +## Deploy + +### Firebase Application + +**`nx deploy my-new-firebase-app [--only ...]`** + +- By default, deploys ALL of your cloud resources associated with your Firebase application (eg. sites, functions, database rules etc.) +- Use the `--only` option to selectively deploy (same as Firebase CLI) + +For initial deployment: + +- **`firebase login`** if not already authenticated +- **`firebase use --add`** to add your Firebase Project(s) to the `.firebaserc` file in your workspace. This step must be completed before you can deploy anything to Firebase. + +Note that you can also use the firebase CLI directly if you prefer: + +- **`firebase deploy --config=firebase..json --only functions`** + +### Firebase Function + +**`nx deploy my-new-firebase-function`** + +- Deploys only a specific Firebase function + + + +## Test + +**`nx test my-new-firebase-app`** + +- Runs unit tests for all Firebase functions apps linked to the Firebase application + +**`nx test my-new-firebase-function`** + +- Runs unit tests for an individual function + + +## Lint + +**`nx lint my-new-firebase-app`** + +- Runs linter for all Firebase functions apps linked to the Firebase application or an individual function + +**`nx lint my-new-firebase-function`** + +- Runs linter for an individual function -Nx provides a great way to manage monorepo workflows and this plugin helps make it easy to integrate Firebase projects with Nx. +## Sync Workspace -### Features +**`nx g @simondotm/nx-firebase:sync`** -- **Firebase Apps** - - Generates Firebase application projects, with default `firebase.json` configurations, rules and indexes for each Firebase app -- **Firebase Functions** - - Generates Firebase function apps based on Typescript Nx node applications - - Bundling of Firebase functions using `esbuild` for extremely fast compilation & tree-shaking for optimal function cold starts - - Easily import Typescript Nx libraries from your Nx workspace into your Firebase functions for code sharing across projects - - Supports function environment variables and secrets -- **Firebase Features** - - Use the Firebase Emulator suite whilst developing locally - all functions are watched and updated live while you work - - Use Firebase hosting with Nx to easily build & deploy web apps -- **Workspace Management** - - Nx's automatic dependency checking for no-fuss builds, and per-project or per-function deployments - - Supports single or multiple firebase projects/apps within an Nx workspace - - Nx workspace management with the `sync` generator keeps your project & `firebase.json` configs automatically updated when renaming or deleting Firebase apps & functions - - Only very lightly opinionated about your Firebase configurations and workspace layouts; you can use Nx or the Firebase CLI +- Ensures that your `firebase.json` configurations are kept up to date with your workspace + - If you rename or move firebase application or firebase function projects + - If you delete firebase function projects ## Further Information -See the full plugin [README](https://github.com/simondotm/nx-firebase/blob/main/README.md) for more details. +See the full plugin [User Guide](https://github.com/simondotm/nx-firebase/blob/main/docs/user-guide.md) for more details. \ No newline at end of file From e4cd4138167f98a31f70e57a28332b3717a187ce Mon Sep 17 00:00:00 2001 From: Simon M Date: Fri, 5 Apr 2024 23:14:00 +0100 Subject: [PATCH 2/8] Change readme badge names --- README.md | 2 +- packages/nx-firebase/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e459081..f0be34b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# @simondotm/nx-firebase ![Status](https://github.com/simondotm/nx-firebase/actions/workflows/ci.yml/badge.svg) ![Status](https://img.shields.io/badge/Nx-v16.8.1-blue) ![Status](https://img.shields.io/npm/v/@simondotm/nx-firebase) ![npm](https://img.shields.io/npm/dw/@simondotm/nx-firebase.svg) +# @simondotm/nx-firebase ![actions](https://github.com/simondotm/nx-firebase/actions/workflows/ci.yml/badge.svg) ![nx](https://img.shields.io/badge/Nx-v16.8.1-blue) ![npm](https://img.shields.io/npm/v/@simondotm/nx-firebase) ![downloads](https://img.shields.io/npm/dw/@simondotm/nx-firebase.svg) A plugin for [Nx](https://nx.dev) v16.8.1+ that integrates Firebase workflows in an Nx monorepo workspace. diff --git a/packages/nx-firebase/README.md b/packages/nx-firebase/README.md index e459081..f0be34b 100644 --- a/packages/nx-firebase/README.md +++ b/packages/nx-firebase/README.md @@ -1,4 +1,4 @@ -# @simondotm/nx-firebase ![Status](https://github.com/simondotm/nx-firebase/actions/workflows/ci.yml/badge.svg) ![Status](https://img.shields.io/badge/Nx-v16.8.1-blue) ![Status](https://img.shields.io/npm/v/@simondotm/nx-firebase) ![npm](https://img.shields.io/npm/dw/@simondotm/nx-firebase.svg) +# @simondotm/nx-firebase ![actions](https://github.com/simondotm/nx-firebase/actions/workflows/ci.yml/badge.svg) ![nx](https://img.shields.io/badge/Nx-v16.8.1-blue) ![npm](https://img.shields.io/npm/v/@simondotm/nx-firebase) ![downloads](https://img.shields.io/npm/dw/@simondotm/nx-firebase.svg) A plugin for [Nx](https://nx.dev) v16.8.1+ that integrates Firebase workflows in an Nx monorepo workspace. From 1d7268f7111bec4abd8df610aa2796311da341b7 Mon Sep 17 00:00:00 2001 From: Simon M Date: Fri, 5 Apr 2024 23:14:15 +0100 Subject: [PATCH 3/8] Add Nx badges to each changelog release --- CHANGELOG.md | 73 +++++++++++++++++++++------------------------------- 1 file changed, 30 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b290c..4352465 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,46 +1,24 @@ # @simondotm/nx-firebase Changelog -All notable changes to this project will be documented in this file. -This plugin was completely rewritten since V2.x to use esbuild for bundling cloud functions. For documentation of the legacy v1.x plugin version see [here](https://github.com/simondotm/nx-firebase/tree/release/v1.1.0). -- [@simondotm/nx-firebase Changelog](#simondotmnx-firebase-changelog) - - [v2.2.0](#v220) - - [v2.1.2](#v212) - - [v2.1.1](#v211) - - [v2.1.0](#v210) - - [v2.0.0](#v200) - - [v2.0.0-beta.1](#v200-beta1) - - [v2.0.0-beta.0](#v200-beta0) - - [v1.1.0](#v110) - - [v1.1.0-beta.0](#v110-beta0) - - [v1.0.0](#v100) - - [v0.13.0-beta.1](#v0130-beta1) - - [v0.13.0-beta.0](#v0130-beta0) - - [v0.3.4](#v034) - - [v0.3.3](#v033) - - [v0.3.2](#v032) - - [v0.3.1](#v031) - - [v0.3.0](#v030) - - [v0.2.3](#v023) - - [v0.2.2 - Initial Release](#v022---initial-release) - -## v2.2.0 + +## v2.2.0 ![nx](https://img.shields.io/badge/Nx-v16.8.1-blue) - Fix package dependencies for `@nx/node`, plugin init generator now adds this if/when needed - This prevents scenarios where incorrect Nx plugin versions could be added to the user workspace - It may also fix an issue with `@nx/esbuild` plugin version being out of sync and bundling external dependencies incorrectly -## v2.1.2 +## v2.1.2 ![nx](https://img.shields.io/badge/Nx-v16.6.0-blue) - Include `@nx/devkit` as a peer dependency for the package - Listing in the [Nx plugin registry](https://nx.dev/plugin-registry) -## v2.1.1 +## v2.1.1 ![nx](https://img.shields.io/badge/Nx-v16.6.0-blue) - Fix issues in the v2.1.0 release -## v2.1.0 +## v2.1.0 ![nx](https://img.shields.io/badge/Nx-v16.6.0-blue) - Added support for [environment variables](docs/nx-firebase-functions-environment.md) - Added support for [secrets](docs/nx-firebase-functions-environment.md#environment-file-types) @@ -49,19 +27,19 @@ This plugin was completely rewritten since V2.x to use esbuild for bundling clou - Added a custom `migrate` generator to ensure workspace configurations match the latest plugin version schemas - Updated plugin to be built against Nx 16.6.0 -## v2.0.0 +## v2.0.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) Official v2 release - Updated default function template to match firebase CLI -## v2.0.0-beta.1 +## v2.0.0-beta.1 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) - Fixed issue with dependencies - Sort codebases - Updated documents -## v2.0.0-beta.0 +## v2.0.0-beta.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) Initial beta of plugin version 2.0. @@ -80,23 +58,27 @@ Users of earlier plugin versions must read [here for plugin v1 -> v2 migration i - Minimum Nx version is now 16.1.1 - Watch mode build of function code & libraries is now fully supported when running Firebase emulator -## v1.1.0 +# Version 2 + +This plugin was completely rewritten since V2.x to use esbuild for bundling cloud functions. For documentation of the legacy v1.x plugin version see [here](https://github.com/simondotm/nx-firebase/tree/release/v1.1.0). + +## v1.1.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) No changes from beta. -## v1.1.0-beta.0 +## v1.1.0-beta.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) Updated for Nx 16.1.1+ - You will need to migrate your workspace to Nx 16.1.1 before updating the plugin -## v1.0.0 +## v1.0.0 ![nx](https://img.shields.io/badge/Nx-v13.10.6-blue) First Major release. No change since `0.13.0-beta.1`. Compatible with Nx 13.10.6+ -## v0.13.0-beta.1 +## v0.13.0-beta.1 ![nx](https://img.shields.io/badge/Nx-v13.10.6-blue) **Changes** @@ -110,7 +92,7 @@ Compatible with Nx 13.10.6+ - Check the [targets documentation](docs/nx-firebase-targets.md) if you already have a workspace that is using nx-firebase - Remove `main` from `package.json` files in any nx-firebase apps in your workspace -## v0.13.0-beta.0 +## v0.13.0-beta.0 ![nx](https://img.shields.io/badge/Nx-v13.10.6-blue) Due to the large number of API changes in Nx from version 12 to version 13.10, this plugin has been rewritten from scratch: @@ -133,7 +115,11 @@ Due to the large number of API changes in Nx from version 12 to version 13.10, t Recommended minimum version of Nx is now 13.10.6. See [Nx Migration](docs/nx-migration.md) documentation for more information. -## v0.3.4 +## v0.3.13 ![nx](https://img.shields.io/badge/Nx-v13.2.3-blue) + + + +## v0.3.4 ![nx](https://img.shields.io/badge/Nx-v13.2.3-blue) Interim release fixes for issues introduced in nx version 13.0.2+ where `createProjectGraph` was deprecated. @@ -170,7 +156,7 @@ Nx version migrations below may handle this transition for you, but if not, you See [Nx Migration](docs/nx-migration.md) documentation for more information. -## v0.3.3 +## v0.3.3 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) **General changes** @@ -283,7 +269,8 @@ And in your `firebase..json` config settings for `"emulators"` add `"au } ``` -## v0.3.2 +## v0.3.2 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) + - Plugin now detects incompatible Nx library dependencies and aborts compilation when found @@ -295,14 +282,14 @@ Incompatible dependencies are as follows: If either of these two types of libraries are imported by Firebase functions, the compilation will be halted, since a functional app cannot be created with these types of dependencies. See the [README](README.md#using-nx-libraries-within-nested-sub-directories) for more information. - -## v0.3.1 + +## v0.3.1 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) - Removed undocumented/unusued `firebase` target in app generator. No longer needed. - `serve` target now builds `--with-deps` before watching to ensure all dependent local libraries are built. Note that `serve` only detects incremental changes to the main application, and not dependent libraries as well at this time. -## v0.3.0 +## v0.3.0 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) Project has been renamed from `@simondotm/nxfirebase` to `@simondotm/nx-firebase` to better match Nx plugin naming conventions. Took a deep breath and did it early before many installs occurred. Apologies to any users who this may have inconvenienced - I didn't realise I could deprecate packages until after I'd deleted & renamed the pnm project. Rest assured, I won't be making any further major modifications like this! @@ -312,7 +299,7 @@ If you have already generated NxFirebase applications using `@simondotm/nxfireba 2. `npm install @simondotm/nx-firebase --save-dev` 3. Update the `builder` targets in any NxFirebase applications you already have in your `workspace.json` or `angular.json` config from `@simondotm/nxfirebase:build` to `@simondotm/nx-firebase:build` -## v0.2.3 +## v0.2.3 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) Built against Nx 12.3.4 @@ -367,6 +354,6 @@ v0.2.3 adds these targets to your `workspace.json` or `angular.json`, so for use }, ``` -## v0.2.2 - Initial Release +## v0.2.2 - Initial Release ![nx](https://img.shields.io/badge/Nx-v12.1.1-blue) Built against Nx 12.1.1 From cdd00cb222dda0ef954258562021b141a940e7b9 Mon Sep 17 00:00:00 2001 From: Simon M Date: Sat, 6 Apr 2024 00:01:14 +0100 Subject: [PATCH 4/8] Update CHANGELOG.md --- CHANGELOG.md | 55 +++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4352465..fda0bfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,24 +1,29 @@ # @simondotm/nx-firebase Changelog +* **Nx badges** for each release indicate the Nx version the plugin was built against, and the minimum required version of Nx to use the plugin. Each plugin release may be with earlier or future versions of Nx, but this is not always guaranteed. +* **Node badges** for each release indicate the Node version the plugin was built against, and the default engine set for Firebase functions generated by the plugin, not the node version required to use the plugin. +## v2.3.0 ![nx](https://img.shields.io/badge/Nx-v16.8.1-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) -## v2.2.0 ![nx](https://img.shields.io/badge/Nx-v16.8.1-blue) +- TODO + +## v2.2.0 ![nx](https://img.shields.io/badge/Nx-v16.6.0-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) - Fix package dependencies for `@nx/node`, plugin init generator now adds this if/when needed - This prevents scenarios where incorrect Nx plugin versions could be added to the user workspace - It may also fix an issue with `@nx/esbuild` plugin version being out of sync and bundling external dependencies incorrectly -## v2.1.2 ![nx](https://img.shields.io/badge/Nx-v16.6.0-blue) +## v2.1.2 ![nx](https://img.shields.io/badge/Nx-v16.6.0-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) - Include `@nx/devkit` as a peer dependency for the package - Listing in the [Nx plugin registry](https://nx.dev/plugin-registry) -## v2.1.1 ![nx](https://img.shields.io/badge/Nx-v16.6.0-blue) +## v2.1.1 ![nx](https://img.shields.io/badge/Nx-v16.6.0-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) - Fix issues in the v2.1.0 release -## v2.1.0 ![nx](https://img.shields.io/badge/Nx-v16.6.0-blue) +## v2.1.0 ![nx](https://img.shields.io/badge/Nx-v16.6.0-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) - Added support for [environment variables](docs/nx-firebase-functions-environment.md) - Added support for [secrets](docs/nx-firebase-functions-environment.md#environment-file-types) @@ -27,26 +32,22 @@ - Added a custom `migrate` generator to ensure workspace configurations match the latest plugin version schemas - Updated plugin to be built against Nx 16.6.0 -## v2.0.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) +## v2.0.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) Official v2 release - Updated default function template to match firebase CLI -## v2.0.0-beta.1 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) +## v2.0.0-beta.1 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) - Fixed issue with dependencies - Sort codebases - Updated documents -## v2.0.0-beta.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) +## v2.0.0-beta.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) Initial beta of plugin version 2.0. -Users of earlier plugin versions must read [here for plugin v1 -> v2 migration instructions](docs/nx-firebase-migrations.md) - -> **Please note that legacy v1 versions of the plugin are no longer supported from this point on, so only take this update if you are prepared to migrate your workspace and Firebase projects** - **Changes** - Plugin is completely rewritten @@ -62,23 +63,29 @@ Users of earlier plugin versions must read [here for plugin v1 -> v2 migration i This plugin was completely rewritten since V2.x to use esbuild for bundling cloud functions. For documentation of the legacy v1.x plugin version see [here](https://github.com/simondotm/nx-firebase/tree/release/v1.1.0). -## v1.1.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) +Users of earlier plugin versions must read [here for plugin v1 -> v2 migration instructions](docs/nx-firebase-migrations.md) + +> **Please note that legacy v1 versions of the plugin are no longer supported from this point on, so only take this update if you are prepared to migrate your workspace and Firebase projects** + +# Version 1 + +## v1.1.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) No changes from beta. -## v1.1.0-beta.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) +## v1.1.0-beta.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) Updated for Nx 16.1.1+ - You will need to migrate your workspace to Nx 16.1.1 before updating the plugin -## v1.0.0 ![nx](https://img.shields.io/badge/Nx-v13.10.6-blue) +## v1.0.0 ![nx](https://img.shields.io/badge/Nx-v13.10.6-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) First Major release. No change since `0.13.0-beta.1`. Compatible with Nx 13.10.6+ -## v0.13.0-beta.1 ![nx](https://img.shields.io/badge/Nx-v13.10.6-blue) +## v0.13.0-beta.1 ![nx](https://img.shields.io/badge/Nx-v13.10.6-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) **Changes** @@ -92,7 +99,7 @@ Compatible with Nx 13.10.6+ - Check the [targets documentation](docs/nx-firebase-targets.md) if you already have a workspace that is using nx-firebase - Remove `main` from `package.json` files in any nx-firebase apps in your workspace -## v0.13.0-beta.0 ![nx](https://img.shields.io/badge/Nx-v13.10.6-blue) +## v0.13.0-beta.0 ![nx](https://img.shields.io/badge/Nx-v13.10.6-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) Due to the large number of API changes in Nx from version 12 to version 13.10, this plugin has been rewritten from scratch: @@ -115,11 +122,11 @@ Due to the large number of API changes in Nx from version 12 to version 13.10, t Recommended minimum version of Nx is now 13.10.6. See [Nx Migration](docs/nx-migration.md) documentation for more information. -## v0.3.13 ![nx](https://img.shields.io/badge/Nx-v13.2.3-blue) +## v0.3.13 ![nx](https://img.shields.io/badge/Nx-v13.2.3-blue) ![nx](https://img.shields.io/badge/Node-v12-orange) -## v0.3.4 ![nx](https://img.shields.io/badge/Nx-v13.2.3-blue) +## v0.3.4 ![nx](https://img.shields.io/badge/Nx-v13.2.3-blue) ![nx](https://img.shields.io/badge/Node-v12-orange) Interim release fixes for issues introduced in nx version 13.0.2+ where `createProjectGraph` was deprecated. @@ -156,7 +163,7 @@ Nx version migrations below may handle this transition for you, but if not, you See [Nx Migration](docs/nx-migration.md) documentation for more information. -## v0.3.3 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) +## v0.3.3 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) ![nx](https://img.shields.io/badge/Node-v12-orange) **General changes** @@ -269,7 +276,7 @@ And in your `firebase..json` config settings for `"emulators"` add `"au } ``` -## v0.3.2 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) +## v0.3.2 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) ![nx](https://img.shields.io/badge/Node-v12-orange) - Plugin now detects incompatible Nx library dependencies and aborts compilation when found @@ -283,13 +290,13 @@ If either of these two types of libraries are imported by Firebase functions, th See the [README](README.md#using-nx-libraries-within-nested-sub-directories) for more information. -## v0.3.1 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) +## v0.3.1 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) ![nx](https://img.shields.io/badge/Node-v12-orange) - Removed undocumented/unusued `firebase` target in app generator. No longer needed. - `serve` target now builds `--with-deps` before watching to ensure all dependent local libraries are built. Note that `serve` only detects incremental changes to the main application, and not dependent libraries as well at this time. -## v0.3.0 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) +## v0.3.0 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) ![nx](https://img.shields.io/badge/Node-v12-orange) Project has been renamed from `@simondotm/nxfirebase` to `@simondotm/nx-firebase` to better match Nx plugin naming conventions. Took a deep breath and did it early before many installs occurred. Apologies to any users who this may have inconvenienced - I didn't realise I could deprecate packages until after I'd deleted & renamed the pnm project. Rest assured, I won't be making any further major modifications like this! @@ -299,7 +306,7 @@ If you have already generated NxFirebase applications using `@simondotm/nxfireba 2. `npm install @simondotm/nx-firebase --save-dev` 3. Update the `builder` targets in any NxFirebase applications you already have in your `workspace.json` or `angular.json` config from `@simondotm/nxfirebase:build` to `@simondotm/nx-firebase:build` -## v0.2.3 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) +## v0.2.3 ![nx](https://img.shields.io/badge/Nx-v12.3.4-blue) ![nx](https://img.shields.io/badge/Node-v12-orange) Built against Nx 12.3.4 @@ -354,6 +361,6 @@ v0.2.3 adds these targets to your `workspace.json` or `angular.json`, so for use }, ``` -## v0.2.2 - Initial Release ![nx](https://img.shields.io/badge/Nx-v12.1.1-blue) +## v0.2.2 - Initial Release ![nx](https://img.shields.io/badge/Nx-v12.1.1-blue) ![nx](https://img.shields.io/badge/Node-v12-orange) Built against Nx 12.1.1 From 7a1c025a6acdd788cb6a8627c52cbf1438751ec6 Mon Sep 17 00:00:00 2001 From: Simon M Date: Sat, 6 Apr 2024 00:06:31 +0100 Subject: [PATCH 5/8] Remove outdated docs --- docs/nx-versions.md | 74 ----------------------------------------- docs/plugin-versions.md | 38 --------------------- docs/user-guide.md | 1 - 3 files changed, 113 deletions(-) delete mode 100644 docs/nx-versions.md delete mode 100644 docs/plugin-versions.md diff --git a/docs/nx-versions.md b/docs/nx-versions.md deleted file mode 100644 index df6dd26..0000000 --- a/docs/nx-versions.md +++ /dev/null @@ -1,74 +0,0 @@ -# Nx Versions - -Nx versions change rapidly, and are often linked to Angular releases. - -The `nx-firebase` plugin does not currently have a migration script, so recommended changes for updating from older Nx versions are as follows: - -- Nx versions prior to 13.10.0 used `@nrwl/tao` dependency which doesn't seem to get migrated automatically, so... -- If you are using Nx version < 13.10.x, we would recommend that Nx updates are applied sequentially to ensure safe migrations using this sequence of commands for each update: - - `npx nx @nx/workspace@` - - `npm install` - - `npm install @nrwl/tao@` - - `npx nx migrate --run-migrations` - - `npx nx run-many --target=build --all` - to check your build continues to work ok with this updated version - -Then, run this sequence for each minor release upto Nx 13.10.x, where the list of each minor Nx Update release `version` is: - -| Nx Version | `@nrwl/tao` Version | Notes | -| ---------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | -| `12.2.0` | Same | (use same `@nrwl/tao` version unless specified otherwise) | -| `12.3.6` | Same | | -| `12.4.0` | Same | | -| `12.5.9` | Same | recommend running `nx g @nx/workspace:convert-to-nx-project --all` for this version | -| | | Upgrade node to at least 14.2.0 from this version | -| `12.6.6` | Same | | -| `12.7.2` | Same | | -| `12.8.0` | Same | | -| `12.9.0` | Same | and `12.10.0` seem to be problematic, so can skip to: | -| `13.0.0` | Same | | -| `13.0.2` | Same | at this point you will need to `npm install @simondotm/nx-firebase@0.3.4` | -| `13.1.6` | `@13.1.4` | | -| `13.2.3` | `@13.2.4` | | -| `13.3.12` | Same | | -| `13.4.6` | Same | | -| `13.5.3` | Same | | -| `13.6.1` | Same | | -| `13.7.3` | Same | | -| `13.8.8` | Same | In this release `@nx/node:package` is replaced with `@nx/js:tsc` | -| `13.9.7` | n/a | In this release `@nrwl/tao` is replaced with the `nx` cli, so manual updates of `@nrwl/tao` package version are no longer necessary from hereon | -| `13.10.6` | n/a | The last minor release of Nx 13. | - -## Nx 14 - -| Nx Version | Notes | -| ---------- | --------------------------------------------------------------------------------------------------------------------------- | -| `14.0.0` | Minor changes to workspace, js configs to ts configs for jest. Angular stays at 13. | -| `14.0.4` | `root` removed from `project.json`, still at Angular 13 | -| `14.0.5` | Broken - forget it. _TypeError: Cannot read properties of undefined (reading 'endsWith')_ | -| `14.1.0` | Fixed again. Repeat of `root` removal migration. Still Angular 13. | -| `14.1.5` | Jest config changes | -| `14.1.8` | DO NOT TAKE THIS VERSION. MESSED UP NX VERSIONS | -| `14.1.11` | | -| `14.2.0` | Updates Angular 14.0.7. Had to use `--legacy-peer-deps` on npm install. es2020 for angular apps. | -| | Some angular migrations for forms. Also some rootdir issues in this version. | -| `14.2.4` | Rootdir issues resolved. Had to update ngx-cookie-service and @angular/flex-layout, webapps issue with mediaObserver.media$ | -| `14.3.4` | Adds `targetDefaults` to `nx.json` | -| `14.4.3` | `@types/node` updated to `18.0.0`, no other migrations | -| `14.5.2` | Angular updates | -| `14.5.5` | Jest config & tsconfig.spec updates | -| `14.5.10` | Updates `rxjs`, manally updated eslint to fix peerdeps issue, some legacy Angular libs may need updating to be compatible | -| `14.6.0` | Updates some angular packages, eslint, jest, installs an rc version of Nx which breaks the nx-firebase plugin on peer deps | -| `14.7.6` | @nx/node:webpack => @nrwl/webpack migration | -| `14.8.0` | Migrates from `@nx/workspace:run-command` to `nx:run-command` | - -## Nx 14.8.0 - -- Node 16 recommended -- Latest Firebase SDK's work well -- ES Modules / es2020 are available, and latest Firebase SDK's support this - -## Nx 15 - -The plugin is not yet tested with Nx version 15+ - -See also [Firebase Versions](firebase-versions.md). diff --git a/docs/plugin-versions.md b/docs/plugin-versions.md deleted file mode 100644 index a11f1b2..0000000 --- a/docs/plugin-versions.md +++ /dev/null @@ -1,38 +0,0 @@ -# Plugin Versions - -- Plugin versions will be matched to Nx versions - eg. 13.10.6 -- There will be a release/v13.10.6 branch for each release that will allow patching if necessary - -- `release/v13.10.6` -> Compatible with Nx 13.10.6 - -Unit testing - -Can we create a bunch of skeleton workspaces that we run tests on? - -eg. - -- `/compat` - - `/13.10.6` - - `/14.0.0` - -Each of these is a blank workspace. We can gitignore everything. - -Maybe we just create the workspaces in a script. What do we need? - -1. `npm ci` the workspace -2. Build the plugin -3. `npx create-nx-workspace@13.10.6 --preset=apps` -4. Add a local ref to the plugin -5. Generate a firebase app - check it builds -6. Generate a lib - check it builds -7. Add the lib as an import - check it builds -8. Modify the firebaserc with our secret firebase project -9. Check it deploys - -Do this for each node version we want - 14, 16, 18 -Do this for each Nx version we want - 13 -We can check that old plugin versions work with newer Nx: - -- Plugin v13 check against Nx 13,14,15, for Node 14,16,18 -- Plugin v14 check against Nx 14,15, for Node 14,16,18 -- Plugin v15 check against Nx 15, for Node 14,16,18 diff --git a/docs/user-guide.md b/docs/user-guide.md index 0b0ab2a..1fb21de 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -30,7 +30,6 @@ **Version information** - [Firebase Versions](./firebase-versions.md) -- [Nx Versions](./nx-versions.md) _Note: Some of these may not always be upto date - it's hard work keeping track of external releases and compatibilities!_ From 673c80bfe2a7a5fdb0d1033d973461299eda99e3 Mon Sep 17 00:00:00 2001 From: Simon M Date: Sat, 6 Apr 2024 01:02:28 +0100 Subject: [PATCH 6/8] Update migration links --- CHANGELOG.md | 4 +++- docs/nx-firebase-migrations.md | 4 ++-- docs/user-guide.md | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fda0bfe..97a3245 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ - Added a custom `migrate` generator to ensure workspace configurations match the latest plugin version schemas - Updated plugin to be built against Nx 16.6.0 +Read [here for plugin v2.0.0 -> v2.1.0+ migration instructions](docs/nx-firebase-migrations.md#migrating-from-plugin-v200-to-v210) + ## v2.0.0 ![nx](https://img.shields.io/badge/Nx-v16.1.1-blue) ![nx](https://img.shields.io/badge/Node-v16-orange) Official v2 release @@ -63,7 +65,7 @@ Initial beta of plugin version 2.0. This plugin was completely rewritten since V2.x to use esbuild for bundling cloud functions. For documentation of the legacy v1.x plugin version see [here](https://github.com/simondotm/nx-firebase/tree/release/v1.1.0). -Users of earlier plugin versions must read [here for plugin v1 -> v2 migration instructions](docs/nx-firebase-migrations.md) +Users of earlier plugin versions must read [here for plugin v1 -> v2 migration instructions](docs/nx-firebase-migrations.md#migration-from-plugin-v1x-to-v200) > **Please note that legacy v1 versions of the plugin are no longer supported from this point on, so only take this update if you are prepared to migrate your workspace and Firebase projects** diff --git a/docs/nx-firebase-migrations.md b/docs/nx-firebase-migrations.md index d367c4e..6e24b2f 100644 --- a/docs/nx-firebase-migrations.md +++ b/docs/nx-firebase-migrations.md @@ -14,7 +14,7 @@ Please note that these migrations are provided on a 'best effort' basis, due to - [5. Library updates](#5-library-updates) - [6. Check Migration](#6-check-migration) -## Migrating to plugin v2.1 from v2.0 +## Migrating from plugin v2.0.0 to v2.1.0 Plugin version 2.1 [added some new features](../CHANGELOG.md#v210) that required changes to the project configurations. @@ -27,7 +27,7 @@ This tool will run checks on your workspace firebase apps, functions and configu > Please note, this generator is not the same as Nx's own migration tool, so always review the changes it makes to ensure they are appropriate for your workspace. -## Migration to plugin v2.x from v1.x +## Migration from plugin v1.x to v2.0.0 Version 2.x of this plugin has been completely rewritten, and uses a completely new approach to building & deploying, so migrating an existing Nx workspace using V1 of the plugin to use V2 requires some manual migration procedures. diff --git a/docs/user-guide.md b/docs/user-guide.md index 1fb21de..718d03f 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -1,7 +1,7 @@ # User Guide -- [Migrating to new plugin versions](./nx-firebase-migrations.md) + **Nx Firebase Generators** @@ -20,7 +20,8 @@ - [Nx-Firebase Sync](./nx-firebase-sync.md) - [Nx-Firebase Project Schemas](./nx-firebase-project-structure.md) - +- [Migrating to new plugin versions](./nx-firebase-migrations.md) + **Nx Workspace** - [Nx Workspace Layout Ideas](./nx-workspace-layout.md) From 0c36989cc7481adae05690427697bfd5687257b0 Mon Sep 17 00:00:00 2001 From: Simon M Date: Sat, 6 Apr 2024 01:56:28 +0100 Subject: [PATCH 7/8] Functions & apps docs updated --- docs/nx-firebase-applications.md | 2 + docs/nx-firebase-functions.md | 102 ++++++++++++++++++++++--------- docs/nx-libraries.md | 7 +-- 3 files changed, 79 insertions(+), 32 deletions(-) diff --git a/docs/nx-firebase-applications.md b/docs/nx-firebase-applications.md index 5b202e7..319a9ae 100644 --- a/docs/nx-firebase-applications.md +++ b/docs/nx-firebase-applications.md @@ -17,6 +17,7 @@ OR | `name` | required | the project name for your firebase app | | `--directory=dir` | optional | the directory this app will be located in | | `--project=proj` | optional | the `--project` option that will be used for firebase CLI commands | +| `--projectNameAndRootFormat` | optional | `derived` or `as-provided` see [projectNameAndRootFormat](https://nx.dev/nx-api/node/generators/application#projectnameandrootformat) | ## About Firebase Apps @@ -31,6 +32,7 @@ When a new Nx Firebase application project is generated in the workspace it will - Default `database.rules.json` for Firebase realtime database - Default `storage.rules` for Firebase storage rules - Default `public/index.html` for Firebase hosting - _you can delete this if your firebase configuration for hosting points elsewhere_. +- Default `public/404.html` for Firebase hosting - _you can delete this if your firebase configuration for hosting points elsewhere_. - Default [environment variables](./nx-firebase-functions-environment.md) for your firebase functions **And in the workspace root:** diff --git a/docs/nx-firebase-functions.md b/docs/nx-firebase-functions.md index a529ec2..1fea17a 100644 --- a/docs/nx-firebase-functions.md +++ b/docs/nx-firebase-functions.md @@ -2,15 +2,15 @@ - [Firebase Functions](#firebase-functions) - [Nx-Firebase Functions](#nx-firebase-functions) - - [Generating a new function](#generating-a-new-function) - - [Firebase Function Projects](#firebase-function-projects) - - [Building a firebase function](#building-a-firebase-function) - - [Deploying a firebase function](#deploying-a-firebase-function) - - [Testing \& Linting your firebase function](#testing--linting-your-firebase-function) - - [Bulk operations for functions](#bulk-operations-for-functions) + - [Generating a new function](#generating-a-new-function) + - [Building a Firebase function](#building-a-firebase-function) + - [Firebase Function Dependencies \& Package Managers](#firebase-function-dependencies--package-managers) + - [Deploying a Firebase function](#deploying-a-firebase-function) + - [Testing \& Linting your firebase function](#testing--linting-your-firebase-function) + - [Managing Functions in your Workspace](#managing-functions-in-your-workspace) - [Functions \& Nx-Firebase Applications](#functions--nx-firebase-applications) - [How Nx-Firebase function apps are linked to Nx-Firebase apps](#how-nx-firebase-function-apps-are-linked-to-nx-firebase-apps) - - [Functions \& Firebase Config](#functions--firebase-config) + - [Functions \& Firebase Config Codebases](#functions--firebase-config-codebases) - [Functions \& ESBuild](#functions--esbuild) - [Using ES Modules output](#using-es-modules-output) - [Using CommonJS output](#using-commonjs-output) @@ -20,9 +20,30 @@ ## Nx-Firebase Functions -Since v2.x of the plugin, Nx-Firebase functions are now generated as individual applications, separately to the Nx-Firebase application. +Nx-Firebase functions are generated as individual Nx application projects, separately to the Nx-Firebase application. -### Generating a new function +* This allows for multiple functions to be generated in a single workspace, each with their own `src/main.ts` entry point and `package.json` file. + +* The default `src/main.ts` template is the same one generated by the Firebase CLI and defaults to using 2nd gen cloud functions. This file is of course just a starting point and can be modified as needed. + +* Each function project is a buildable Typescript node-based application, which is compiled and bundled using [esbuild](#functions--esbuild). + +* Each function project can export one or more firebase cloud functions. + +* Each function project must be linked to a single [Firebase application project](./nx-firebase-applications.md) in the workspace, which ensures all functions can be managed by the nx-firebase plugin. + +* Functions can import code from [Nx shared libraries](./nx-libraries.md) and `esbuild` will tree-shake and bundle the code into a single output file. + +* You rename or move Firebase function projects in your Nx workspace, and use the plugin [sync](./nx-firebase-sync.md) command to keep your `firebase.json` configuration file in sync. + +* Functions can be [tested](#testing--linting-your-firebase-function), [linted](#testing--linting-your-firebase-function), [built](#building-a-firebase-function) and [deployed](#deploying-a-firebase-function) using the Nx CLI + +[package dependencies](#firebase-function-dependencies-package-managers) + +* Functions support deployment with `npm`, `pnpm` or `yarn` package managers. + + +## Generating a new function Generate a new Firebase function using: @@ -38,50 +59,72 @@ OR | `--app=` | required | the firebase app this function will be a dependency of | | `--directory=dir` | optional | the directory this function will be located in | | `--format=<'cjs' or 'esm'>` | default 'esm' | specify if esbuild should generated commonJs or ES6 output | +| `--runTime=` | optional | the nodejs runtime you wish to use for this function - 14, 16, 18, 20 | +| `--tags` | optional | tags to set on the new project | +| `--setParserOptionsProject` | optional | set the parserOptions.project in the tsconfig.json file | +| `--projectNameAndRootFormat` | optional | `derived` or `as-provided` (see Nx docs for [projectNameAndRootFormat](https://nx.dev/nx-api/node/generators/application#projectnameandrootformat)) | -### Firebase Function Projects -Firebase function application projects are buildable node Typescript applications, which are compiled and bundled using `esbuild`. +## Building a Firebase function -The entry point module for function projects is `src/main.ts`. +To build your firebase function use this command: -The default `main.ts` template is the same one generated by the Firebase CLI and defaults to using 2nd gen cloud functions. This file is of course just a starting point and can be modified as needed. +- **`nx build your-firebase-function-project-name`** -> Newly generated function projects may not deploy out-of-the-box. For some reason the default Firebase CLI template for `main.ts` does not include code to call `initalizeApp()` so this has been added as a comment to the nx-firebase plugin version of the template. **This call must be enabled in order to successfully deploy a function.** +This will use `esbuild` to compile & bundle the input function Typescript source code to: -### Building a firebase function +- `dist/apps/your-firebase-function-project-name/main.js` - The bundled function code, in a single ESM format output file +- `dist/apps/your-firebase-function-project-name/package.json` - The ESM format package file for firebase CLI to process and deploy -To build your firebase function use this command: +## Firebase Function Dependencies & Package Managers -- **`nx build your-firebase-function-project-name`** +When building a function, Nx will automatically generate a `package.json` file in the output `dist` directory, which contains all package dependencies used by the function. -This will use `esbuild` to compile & bundle the input function Typescript source code to: +Nx will also generate a pruned `package-lock.json`, `yarn.lock` or `pnpm-lock.yaml` file in the function project root, depending on the package manager used in the workspace, which ensures your deployed function has exactly the same dependencies in the cloud as it does locally. + +## Deploying a Firebase function -- `dist/apps//main.js` - The bundled function code, in a single ESM format output file -- `dist/apps//package.json` - The ESM format package file for firebase CLI to process and deploy +To deploy all of your firebase function projects use: -### Deploying a firebase function +- **`nx deploy your-firebase-app-name --only:functions`** -To deploy your firebase function use this command: +To deploy one of your firebase function projects use this command: - **`nx deploy your-firebase-function-name`** -Your function will be deployed by the Firebase CLI. +To deploy a single function from within a firebase function project that exports multiple functions, use this command: -### Testing & Linting your firebase function +- **`nx deploy --only functions::function-name`** + +Where `` is whatever name you gave your nx-firebase:function project. + +> **IMPORTANT NOTE: Newly generated function projects do not deploy out-of-the-box. This is because the default Firebase CLI template for `main.ts` does not include code to call `initalizeApp()` so you will need to add this yourself:** + +``` + import { initializeApp } from "firebase-admin/app"; + initializeApp() +``` + +## Testing & Linting your firebase function - **`nx test your-firebase-function-name`** - **`nx lint your-firebase-function-name`** -### Bulk operations for functions +## Managing Functions in your Workspace -You can use the parent Firebase app to test, lint, build, watch and deploy all of your functions at once. +You can use the parent Firebase app to build, test, lint, watch and deploy all of your functions at once. + +- **`nx build your-firebase-app-name`** +- **`nx test your-firebase-app-name`** +- **`nx lint your-firebase-app-name`** +- **`nx watch your-firebase-app-name`** +- **`nx deploy your-firebase-app-name`** Note that there is no `serve` target for individual function projects, since serving only makes sense at a firebase app level with the Firebase Emulator suite, so use the following command instead: - **`nx serve your-firebase-app-name`** -See [here](./nx-firebase-applications.md#nx-firebase-application-project-targets) for more details. +See [Firebase Application Targets](./nx-firebase-applications.md#nx-firebase-application-project-targets) for more details. ## Functions & Nx-Firebase Applications @@ -98,7 +141,7 @@ The Nx-firebase plugin requires that Firebase function projects must always be a - Firebase function apps can export either just one or multiple firebase cloud functions - When running the Firebase emulator using `serve`, **all** firebase function applications are built using `watch` mode, so local development is much more convenient -### Functions & Firebase Config +### Functions & Firebase Config Codebases When new Firebase function applications are generated in the workspace: @@ -133,6 +176,7 @@ If you still use Node `require()` in your Typescript function code, the default Note that using `cjs` output may prevent tree-shaking optimizations. + ### Why ESBuild? While Webpack and Rollup are viable options for bundling node applications: @@ -144,6 +188,8 @@ While Webpack and Rollup are viable options for bundling node applications: If you want to try Webpack or Rollup, just change your `build` target in the function's `project.json` accordingly. +> The Nx Webpack bundler may be required for projects that require Typescript decorators such as NextJS. + ### Why not minify? This plugin does not set or recommend the minify option for esbuild. diff --git a/docs/nx-libraries.md b/docs/nx-libraries.md index a9f7116..d05f537 100644 --- a/docs/nx-libraries.md +++ b/docs/nx-libraries.md @@ -6,11 +6,10 @@ Nx-Firebase supports use of Nx Libraries within functions code. To use a shared library with an Nx Firebase Function Application, simply create a Typescript Nx node library in your workspace: -**`nx g @nx/js:lib mylib --importPath="@myorg/mylib`** +**`nx g @nx/js:lib mylib --importPath="@myorg/mylib [--bundler=]`** > _Note: The `--importPath` option is highly recommended to ensure the correct typescript aliases and npm package configurations for your library._ -Since v2.x of the plugin, functions are bundled with esbuild, so ## Importing a library @@ -32,10 +31,10 @@ OR ## Nx Library Notes -Since v2 of the plugin now uses `esbuild` to bundle function code, we gain a few benefits: +[Firebase functions](./nx-firebase-functions.md) use `esbuild` to bundle function code, we gain a few benefits: - Nx takes care of ensuring all necessary dependencies will be also built. -- It no longer matters if libraries are buildable or non-buildable +- It does not matter if libraries are buildable or non-buildable, as `esbuild` builds from Typescript sources, however buildable libraries may be preferred since `esbuild` does not do type checking of imported libraries. - We do not have to worry about how we structure libraries anymore for optimal function runtime. - For instance, we can use barrel imports freely, since `esbuild` will treeshake unused code and inline imports into the bundled output `main.js` - We can create as many libraries as we wish for our functions to use, and organise them in whatever makes most sense for the workspace From fe697f128f0e2df542c9b70964ba9ca66641981d Mon Sep 17 00:00:00 2001 From: Simon M Date: Sat, 6 Apr 2024 02:01:50 +0100 Subject: [PATCH 8/8] Minor few tweaks --- docs/nx-firebase-projects.md | 2 +- docs/user-guide.md | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/nx-firebase-projects.md b/docs/nx-firebase-projects.md index caccee8..7a903cc 100644 --- a/docs/nx-firebase-projects.md +++ b/docs/nx-firebase-projects.md @@ -12,7 +12,7 @@ [Firebase projects](https://firebase.google.com/docs/projects/learn-more) are created in the firebase web console, and then specified in your local workspace configurations as deployment targets in your `.firebaserc` file. -`nx-firebase` assumes a mapping of one `@simondotm/nx-firebase:app` to one firebase project and configuration file. +`nx-firebase` assumes a mapping of one `@simondotm/nx-firebase:app` to one firebase CLI project and one [Firebase configuration file](./nx-firebase-project-structure.md#firebase-function-configs). ## Nx Workspaces With Single Firebase Projects diff --git a/docs/user-guide.md b/docs/user-guide.md index 718d03f..55200e7 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -1,8 +1,5 @@ # User Guide - - - **Nx Firebase Generators** - [Firebase Applications](./nx-firebase-applications.md)