Skip to content

Commit

Permalink
Merge pull request #18 from simondotm/rename-project
Browse files Browse the repository at this point in the history
Rename project
  • Loading branch information
simondotm authored May 22, 2021
2 parents cd45bfd + 6be44ed commit ee8aaf1
Show file tree
Hide file tree
Showing 61 changed files with 110 additions and 103 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
- run: npm install

- name: Build plugin
run: npx nx build nxfirebase
run: npx nx build nx-firebase

- name: Create package
run: npm pack
working-directory: ./dist/packages/nxfirebase
working-directory: ./dist/packages/nx-firebase

- name: Publish to GitHub Packages
run: npm publish
working-directory: ./dist/packages/nxfirebase
working-directory: ./dist/packages/nx-firebase
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -46,11 +46,11 @@ jobs:
- run: npm install

- name: Build plugin
run: npx nx build nxfirebase
run: npx nx build nx-firebase

- name: Publish to NPM
run: npm publish --access=public
working-directory: ./dist/packages/nxfirebase
working-directory: ./dist/packages/nx-firebase
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
12 changes: 6 additions & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
"tasks": [
{
"type": "npm",
"script": "build -- nxfirebase",
"script": "build -- nx-firebase",
"group": "build",
"problemMatcher": [],
"label": "Build Nx firebase plugin",
"detail": "nx build nxfirebase"
"detail": "nx build nx-firebase"
},
{
"type": "npm",
"script": "test -- nxfirebase",
"script": "test -- nx-firebase",
"group": "test",
"problemMatcher": [],
"label": "Test Nx firebase plugin",
"detail": "nx test nxfirebase"
"detail": "nx test nx-firebase"
},
{
"type": "npm",
"script": "e2e -- nxfirebase-e2e",
"script": "e2e -- nx-firebase-e2e",
"group": "test",
"problemMatcher": [],
"label": "Test e2e Nx firebase plugin",
"detail": "nx e2e nxfirebase-e2e"
"detail": "nx e2e nx-firebase-e2e"
}
]
}
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# NxFirebase Changelog
# @simondotm/nx-firebase Changelog
All notable changes to this project will be documented in this file.


## v0.3.0

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. Live & learn!


## v0.2.3

Built against Nx 12.3.4
Expand All @@ -20,7 +26,7 @@ Built against Nx 12.3.4

- Default `firebase.appname.json` now has a valid default hosting configuration and apps ship with a template `public/index.html` (as generated by Firebase CLI) inside the application folder

- NxFirebase App generator sets `target` in `tsconfig.app.ts` to `es2018` to ensure Node 10 compatibility for Firebase Functions (for scenarios where root workspace `tsconfig.base.json` may be set to a later ES target)
- Nx-Firebase App generator sets `target` in `tsconfig.app.ts` to `es2018` to ensure Node 10 compatibility for Firebase Functions (for scenarios where root workspace `tsconfig.base.json` may be set to a later ES target)

- Fixed `predeploy` scripts in `firebase.appname.json` to use `npx nx` so that they work correctly in CI environments

Expand Down
2 changes: 1 addition & 1 deletion README-Nx.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @simondotm/nxfirebase
# @simondotm/nx-firebase

This project was generated using [Nx](https://nx.dev).

Expand Down
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @simondotm/nxfirebase
# @simondotm/nx-firebase

A plugin for [Nx](https://nx.dev) that provides support for Firebase projects in an Nx monorepo workspace.

Expand All @@ -22,18 +22,18 @@ This plugin aims to help with this by:
# Quick Start

## Installation
**`npm install @simondotm/nxfirebase`**
**`npm install @simondotm/nx-firebase`**

Installs this plugin into your Nx workspace.


**`nx g @simondotm/nxfirebase:init`**
**`nx g @simondotm/nx-firebase:init`**

Installs firebase dependencies (both for backend and frontend) to your root workspace `package.json` (or you can just `npm install` firebase dependencies manually)

## Create Firebase Application

**`nx g @simondotm/nxfirebase:app <appname> [--directory dir]`**
**`nx g @simondotm/nx-firebase:app <appname> [--directory dir]`**

Generates a new Nx Firebase application in the workspace - `/apps/[dir]/appname`

Expand Down Expand Up @@ -85,7 +85,7 @@ Or

An Nx Firebase application is primarily a container for _firebase functions_, but it also contains the various configurations for other Firebase features you might use such as _storage, firestore, and real time database_.

You don't have to use all of these features, but the NxFirebase plugin ensures they are all there if/when you do.
You don't have to use all of these features, but the Nx-Firebase plugin ensures they are all there if/when you do.

When a new Nx Firebase application project is added to the workspace it will generate:

Expand All @@ -108,7 +108,7 @@ When a new Nx Firebase application project is added to the workspace it will gen
>
> _**Important:** The default `firebase.json` is intentionally empty, because the idea is to use `firebase.appname.json` instead. (Although I'm reviewing this atm as it seems slightly unintuitive for [single firebase project workspaces](#nx-workspaces-with-single-firebase-projects)!)_
## NxFirebase Application Targets (Executors)
## Nx-Firebase Application Targets (Executors)

* `build` - Build the functions applicaion
* `serve` - Build the functions application in `--watch` mode and start the Firebase Emulators
Expand Down Expand Up @@ -140,11 +140,11 @@ If you only use a single Firebase project in your Nx workspace, feel free to del

The Firebase CLI will then just use this default configuration file instead, and in this scenario there's no need to pass the additional `--config` CLI option.

> **Important:** _If you do rename your firebase configuration files, remember to update (or remove) any `--config` settings in your NxFirebase application's `serve` and `deploy` targets in your `workspace.json` or `angular.json` configuration file._
> **Important:** _If you do rename your firebase configuration files, remember to update (or remove) any `--config` settings in your Nx-Firebase application's `serve` and `deploy` targets in your `workspace.json` or `angular.json` configuration file._
## Firebase Functions

An NxFirebase app is essentially a Firebase _functions_ directory (along with the few other configuration files as mentioned above). The main difference is that there isn't a directory called `functions` which you may be used to from projects setup by the Firebase CLI; with NxFirebase your app directory IS your functions folder.
An Nx-Firebase app is essentially a Firebase _functions_ directory (along with the few other configuration files as mentioned above). The main difference is that there isn't a directory called `functions` which you may be used to from projects setup by the Firebase CLI; with Nx-Firebase your app directory IS your functions folder.

Inside the new `apps/appname` directory you will find the following functions-specific files:
* `package.json` - The stub package file used when deploying firebase functions
Expand All @@ -153,17 +153,17 @@ Inside the new `apps/appname` directory you will find the following functions-sp

> **Note:** _Firebase functions `tsconfig.app.json` is by default set to target `es2018` which is the maximum ES version for Node 10 engine. This override exists in case the root `tsconfig.base.json` sets an ES target that is incompatible with Firebase Functions Node environment. If you are using Node 12 engine, you can change this target to `es2019`._
## NxFirebase Application Naming
## Nx-Firebase Application Naming

You may find it convenient/familiar to create your NxFirebase application simply with `functions` as it's app name eg. `nx g @simondotm/nxfirebase:app functions`.
You may find it convenient/familiar to create your Nx-Firebase application simply with `functions` as it's app name eg. `nx g @simondotm/nx-firebase:app functions`.

If you have multiple Firebase projects in your workspace, the NxFirebase application generator supports the `--directory` option, so you may also find it convenient to organise your workspace as follows:
If you have multiple Firebase projects in your workspace, the Nx-Firebase application generator supports the `--directory` option, so you may also find it convenient to organise your workspace as follows:

`apps/<projectname>/...<projectapps>`

And generate your app as follows:

`nx g @simondotm/nxfirebase:app functions --directory projectname`
`nx g @simondotm/nx-firebase:app functions --directory projectname`

So your workspace layout might look like this:

Expand Down Expand Up @@ -202,11 +202,11 @@ If you deploy static websites to Firebase Hosting (that do not need to get built

The firebase CLI hosting deploy command above will just upload the static content as required.

An application generated by NxFirebase is by default configured to host content in the `apps/appname/public` directory.
An application generated by Nx-Firebase is by default configured to host content in the `apps/appname/public` directory.

## Rules & Indexes

To keep the root of your Nx workspace tidy, the NxFirebase plugin puts default Firebase rules and index files inside the app folder, and the `firebase.appname.json` configuration file simply points to them there.
To keep the root of your Nx workspace tidy, the Nx-Firebase plugin puts default Firebase rules and index files inside the app folder, and the `firebase.appname.json` configuration file simply points to them there.

Again, this works just fine with the usual Firebase CLI command, eg:

Expand All @@ -218,15 +218,15 @@ Or

This is also useful for cleaner separation if you have multiple Firebase projects in your Nx workspace.

Again, you are free to modify these locations if you wish by simply changing the Firebase configuration files; the NxFirebase plugin does not use these configuration files in any way.
Again, you are free to modify these locations if you wish by simply changing the Firebase configuration files; the Nx-Firebase plugin does not use these configuration files in any way.

## Migrating an existing Firebase project to Nx

To bring an existing Firebase project into an Nx workspace, simply generate the Nx Firebase application(s) first, and then just overwrite the generated Firebase configuration & rules/indexes with your existing `firebase.json`, rules & index files.

## Using Nx Libraries with Firebase Functions

NxFirebase supports use of Nx Libraries within functions code.
Nx-Firebase supports use of Nx Libraries within functions code.

To use a shared library with an Nx Firebase Application (Functions), first create a buildable (and it must be buildable) Typescript Nx node library in your workspace:

Expand Down Expand Up @@ -282,9 +282,9 @@ Other considerations:
2. The Firebase CLI is great and familar, so we don't really want to have to add any extra complexity or wrappers around it if we can help it.

## Supporting Libraries in Functions
Supporting Nx libraries as external packages with Firebase functions is slightly tricky. The solution the NxFirebase plugin uses is to use [local package references](https://firebase.google.com/docs/functions/handle-dependencies#including_local_nodejs_modules).
Supporting Nx libraries as external packages with Firebase functions is slightly tricky. The solution the Nx-Firebase plugin uses is to use [local package references](https://firebase.google.com/docs/functions/handle-dependencies#including_local_nodejs_modules).

NxFirebase has a custom build executor which is based on the `@nrwl/node:package` executor, with a few additional build steps.
Nx-Firebase has a custom build executor which is based on the `@nrwl/node:package` executor, with a few additional build steps.

1. It compiles any node libraries that are dependents of our Firebase application
2. It compiles the Firebase application functions code as a pure buildable Typescript library package
Expand Down Expand Up @@ -329,15 +329,15 @@ Notes mainly for my own benefit/reminder here.

## To create the plugin workspace

`npx create-nx-plugin simondotm --pluginName nxfirebase`
`npx create-nx-plugin simondotm --pluginName nx-firebase`

## To build the plugin

`nx run nxfirebase:build`
`nx run nx-firebase:build`

## To test the plugin

`nx run nxfirebase-e2e:e2e`
`nx run nx-firebase-e2e:e2e`

Creates a temporary workspace in `/tmp/nx-e2e/`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
displayName: 'nxfirebase-e2e',
displayName: 'nx-firebase-e2e',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
Expand All @@ -10,5 +10,5 @@ module.exports = {
'^.+\\.[tj]s$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/e2e\nxfirebase-e2e',
coverageDirectory: '../../coverage/e2e/nx-firebase-e2e',
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('nxfirebase e2e', () => {

describe('nxfirebase plugin', () => {
it('should install correctly', async (done) => {
ensureNxProject('@simondotm/nxfirebase', 'dist/packages/nxfirebase');
ensureNxProject('@simondotm/nx-firebase', 'dist/packages/nx-firebase');
done();
});

Expand All @@ -49,7 +49,7 @@ describe('nxfirebase e2e', () => {
describe('nxfirebase init generator', () => {
it('should init nxfirebase plugin', async (done) => {
await runNxCommandAsync(
`generate @simondotm/nxfirebase:init`
`generate @simondotm/nx-firebase:init`
);

done();
Expand All @@ -64,9 +64,9 @@ describe('nxfirebase e2e', () => {


it('should create nxfirebase:application', async (done) => {
//ensureNxProject('@simondotm/nxfirebase', 'dist/packages/nxfirebase');
//ensureNxProject('@simondotm/nx-firebase', 'dist/packages/nx-firebase');
await runNxCommandAsync(
`generate @simondotm/nxfirebase:application ${appProject}`
`generate @simondotm/nx-firebase:application ${appProject}`
);
done();
});
Expand Down Expand Up @@ -109,9 +109,9 @@ describe('nxfirebase e2e', () => {
describe('--directory', () => {
it('should create files in the specified application directory', async (done) => {
const plugin = 'nxfirebase-subdir-app' //uniq('nxfirebase-subdir-app');
//ensureNxProject('@simondotm/nxfirebase', 'dist/packages/nxfirebase');
//ensureNxProject('@simondotm/nx-firebase', 'dist/packages/nx-firebase');
const result = await runNxCommandAsync(
`generate @simondotm/nxfirebase:application ${plugin} --directory subdir`
`generate @simondotm/nx-firebase:application ${plugin} --directory subdir`
);
expect(() =>
checkFilesExist(...expectedProjectFiles(`apps/subdir/${plugin}`)),
Expand All @@ -132,9 +132,9 @@ describe('nxfirebase e2e', () => {
describe('--tags', () => {
it('should add tags to nx.json', async (done) => {
const plugin = 'nxfirebase-root-app-tags' //uniq('nxfirebase-root-app-tags');
//ensureNxProject('@simondotm/nxfirebase', 'dist/packages/nxfirebase');
//ensureNxProject('-', 'dist/packages/nx-firebase');
const result = await runNxCommandAsync(
`generate @simondotm/nxfirebase:application ${plugin} --tags e2etag,e2ePackage`
`generate @simondotm/nx-firebase:application ${plugin} --tags e2etag,e2ePackage`
);
const nxJson = readJson('nx.json');
expect(nxJson.projects[plugin].tags).toEqual(['e2etag', 'e2ePackage']);
Expand Down Expand Up @@ -202,9 +202,9 @@ describe('nxfirebase e2e', () => {
const plugin = uniq('nxfirebase-functions-app');
it('should create nxfirebase:functions', async (done) => {
//ensureNxProject('@simondotm/nxfirebase', 'dist/packages/nxfirebase');
//ensureNxProject('@simondotm/nx-firebase', 'dist/packages/nx-firebase');
await runNxCommandAsync(
`generate @simondotm/nxfirebase:functions ${plugin}`
`generate @simondotm/nx-firebase:functions ${plugin}`
);
done();
Expand All @@ -222,9 +222,9 @@ describe('nxfirebase e2e', () => {
describe('--directory', () => {
it('should create src/index.ts & package.json in the specified functions directory', async (done) => {
const plugin = uniq('nxfirebase-functions-app');
//ensureNxProject('@simondotm/nxfirebase', 'dist/packages/nxfirebase');
//ensureNxProject('@simondotm/nx-firebase', 'dist/packages/nx-firebase');
await runNxCommandAsync(
`generate @simondotm/nxfirebase:functions ${plugin} --directory subdir`
`generate @simondotm/nx-firebase:functions ${plugin} --directory subdir`
);
expect(() =>
checkFilesExist(`apps/subdir/${plugin}/src/index.ts`, `apps/subdir/${plugin}/package.json`),
Expand All @@ -236,9 +236,9 @@ describe('nxfirebase e2e', () => {
describe('--tags', () => {
it('should add tags to nx.json', async (done) => {
const plugin = uniq('nxfirebase');
//ensureNxProject('@simondotm/nxfirebase', 'dist/packages/nxfirebase');
//ensureNxProject('@simondotm/nx-firebase', 'dist/packages/nx-firebase');
await runNxCommandAsync(
`generate @simondotm/nxfirebase:functions ${plugin} --tags e2etag,e2ePackage`
`generate @simondotm/nx-firebase:functions ${plugin} --tags e2etag,e2ePackage`
);
const nxJson = readJson('nx.json');
expect(nxJson.projects[plugin].tags).toEqual(['e2etag', 'e2ePackage']);
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
projects: ['<rootDir>/packages/nxfirebase', '<rootDir>/e2e\\nxfirebase-e2e'],
projects: ['<rootDir>/packages/nx-firebase', '<rootDir>/e2e\\nx-firebase-e2e'],
};
4 changes: 2 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
}
},
"projects": {
"nxfirebase": { "tags": [] },
"nxfirebase-e2e": { "tags": [], "implicitDependencies": ["nxfirebase"] }
"nx-firebase": { "tags": [] },
"nx-firebase-e2e": { "tags": [], "implicitDependencies": ["nx-firebase"] }
},
"workspaceLayout": { "appsDir": "e2e", "libsDir": "packages" }
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "nx build",
"test": "nx test",
"lint": "nx workspace-lint && nx lint",
"e2e": "nx run nxfirebase-e2e:e2e",
"e2e": "nx run nx-firebase-e2e:e2e",
"affected:apps": "nx affected:apps",
"affected:libs": "nx affected:libs",
"affected:build": "nx affected:build",
Expand All @@ -24,7 +24,7 @@
"workspace-generator": "nx workspace-generator",
"dep-graph": "nx dep-graph",
"help": "nx help",
"release": "npm version patch --prefix packages/nxfirebase --no-git-tag-version",
"release": "npm version patch --prefix packages/nx-firebase --no-git-tag-version",
"release:help": "echo Bump patch version & commit. Using Github Desktop doesn't push tags it didn't make, so they have to be manually added & pushed to create the release on Github"
},
"private": true,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": ["packages/nxfirebase/tsconfig.*?.json"]
"project": ["packages/nx-firebase/tsconfig.*?.json"]
},
"rules": {}
},
Expand Down
Loading

0 comments on commit ee8aaf1

Please sign in to comment.