Skip to content

Commit

Permalink
v7.3.0 (#283)
Browse files Browse the repository at this point in the history
* fix: prevent module not found error when opting into redux - #282
* fix: do not throw error for disabling notifications
* build(app): update firebase and notistack
* examples: update redux examples
* build(deps-dev): bump @babel/preset-env from 7.11.0 to 7.11.5 (#281)
* build(deps-dev): bump @babel/polyfill from 7.10.4 to 7.11.5 (#280)
* build(deps-dev): bump @babel/plugin-transform-runtime (#279)
* build(deps-dev): bump mocha from 8.1.1 to 8.1.3 (#278)
  • Loading branch information
prescottprue committed Sep 18, 2020
1 parent 8cb04a0 commit 30867bb
Show file tree
Hide file tree
Showing 136 changed files with 6,551 additions and 8,469 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -78,6 +78,12 @@ _When opting into redux_
- [react-redux-firebase](https://react-redux-firebase.com) - Easily Persist results of Firebase queries to redux state
- [redux-auth-wrapper](https://github.com/mjrussell/redux-auth-wrapper) - Easily create HOCs for route/component protection based on auth state

## Screenshots
![image](https://user-images.githubusercontent.com/2992224/93631046-f486e000-f9b8-11ea-9eed-9e150dd42bdb.png)

![image](https://user-images.githubusercontent.com/2992224/93629646-a07afc00-f9b6-11ea-873b-9ca777939546.png)


## Sub generators

Sub generators are included to help speed up the application building process. You can run a sub-generator by calling `yo react-firebase:<name of sub-generator> <param1>`.
Expand Down
17 changes: 17 additions & 0 deletions examples/react-firebase-redux/.github/dependabot.yml
@@ -0,0 +1,17 @@
# For for information on config options, visit docs:
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/functions"
open-pull-requests-limit: 3
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
8 changes: 4 additions & 4 deletions examples/react-firebase-redux/.github/workflows/deploy.yml
Expand Up @@ -12,25 +12,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.4.0
uses: styfle/cancel-workflow-action@0.4.1
with:
access_token: ${{ github.token }}

- name: Checkout Repo
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v1
uses: actions/setup-node@v2.1.1
with:
node-version: 10
node-version: 12

- name: Get Library Versions For Binary Caching
id: cache-settings
run: |
echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache App Dependencies
uses: actions/cache@v1
uses: actions/cache@v2.1.0
with:
path: ${{ steps.cache-settings.outputs.dir }}
key: ${{ runner.os }}-app-${{ hashFiles('yarn.lock') }}
Expand Down
20 changes: 10 additions & 10 deletions examples/react-firebase-redux/.github/workflows/verify.yml
Expand Up @@ -8,25 +8,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.4.0
uses: styfle/cancel-workflow-action@0.4.1
with:
access_token: ${{ github.token }}

- name: Checkout Repo
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v1
uses: actions/setup-node@v2.1.1
with:
node-version: 10
node-version: 12

- name: Get Library Versions For Binary Caching
id: cache-settings
run: |
echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache App Dependencies
uses: actions/cache@v1
uses: actions/cache@v2.1.0
with:
path: ${{ steps.cache-settings.outputs.dir }}
key: ${{ runner.os }}-app-${{ hashFiles('yarn.lock') }}
Expand Down Expand Up @@ -125,9 +125,9 @@ jobs:
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v1
uses: actions/setup-node@v2.1.1
with:
node-version: 10
node-version: 12

- name: Get Library Versions For Binary Caching
id: cache-settings
Expand All @@ -137,19 +137,19 @@ jobs:
echo "::set-output name=cypress::$(yarn list -s --depth=0 --pattern cypress | tail -n 1 | sed 's/.*@//g')"
- name: Cache Firebase Emulator Binaries
uses: actions/cache@v1
uses: actions/cache@v2.1.0
with:
path: ~/.cache/firebase/emulators
key: ${{ runner.os }}-firebase-${{ steps.cache-settings.outputs.firebase-tools }}

- name: Cache Cypress Binary
uses: actions/cache@v1
uses: actions/cache@v2.1.0
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ steps.cache-settings.outputs.cypress }}

- name: Cache App Dependencies
uses: actions/cache@v1
uses: actions/cache@v2.1.0
with:
path: ${{ steps.cache-settings.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
# This stage tests a version of the app which is running locally in the
# container on port 3000.
- name: Cypress Run
uses: cypress-io/github-action@v1
uses: cypress-io/github-action@v2
with:
record: true
start: yarn emulators:hosting --project ${{ env.GCLOUD_PROJECT }}
Expand Down
3 changes: 2 additions & 1 deletion examples/react-firebase-redux/.yo-rc.json
Expand Up @@ -17,7 +17,8 @@
"ciProvider": "githubActions",
"measurementId": "G-62D5FVVQWZ",
"appId": "1:823357791673:web:819546ad651f4513e06a68",
"functionsTestTool": "jest"
"functionsTestTool": "jest",
"typescriptCloudFunctions": true
}
}
}
25 changes: 14 additions & 11 deletions examples/react-firebase-redux/README.md
Expand Up @@ -19,7 +19,7 @@

## Requirements

- node `^10.15.0`
- node `^12.18.0`
- npm `^6.0.0`

## Getting Started
Expand Down Expand Up @@ -52,18 +52,18 @@

While developing, you will probably rely mostly on `yarn start`; however, there are additional scripts at your disposal:

| `yarn <script>` | Description |
| `yarn <script>` | Description |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `start` | Serves your app at `localhost:3000` with automatic refreshing and hot module replacement |
| `start:dist` | Builds the application to `./build` then serves at `localhost:3000` using firebase hosting emulator |
| `start:emulate` | Same as `start`, but pointed to database emulators (make sure to call `emulators` first to boot up emulators) |
| `build` | Builds the application to `./build` |
| `emulators:hosting` | Starts database and hosting emulators (used in verify workflow by Cypress) |
| `build` | Builds the application to `./build` |
| `emulators:hosting` | Starts database and hosting emulators (used in verify workflow by Cypress) |
| `test` | Runs unit tests with Jest. See [testing](#testing) |
| `test:watch` | Runs `test` in watch mode to re-run tests when changed |
| `test:watch` | Runs `test` in watch mode to re-run tests when changed |
| `test:ui:run` | Runs UI tests with Cypress. See [testing](#testing) |
| `test:ui` | Opens UI tests runner (Cypress Dashboard). See [testing](#testing) |
| `test:ui:emulate` | Same as `test:ui` but with tests pointed at emulators |
| `test:ui:emulate` | Same as `test:ui` but with tests pointed at emulators |
| `lint` | [Lints](http://stackoverflow.com/questions/8503559/what-is-linting) the project for potential errors |
| `lint:fix` | Lints the project and [fixes all correctable errors](http://eslint.org/docs/user-guide/command-line-interface.html#fix) |

Expand All @@ -74,8 +74,8 @@ While developing, you will probably rely mostly on `yarn start`; however, there
There are multiple configuration files:

- Firebase Project Configuration - `.firebaserc`
- Project Configuration - `.env.local`
- Cloud Functions Local Configuration - `functions/.runtimeconfig.json`
- Local Project Configuration - `.env.local`
- Local Cloud Functions Configuration - `functions/.runtimeconfig.json`

More details in the [Application Structure Section](#application-structure)

Expand All @@ -92,6 +92,7 @@ The application structure presented in this boilerplate is **fractal**, where fu
├── cypress # UI Integration Tests
├── functions # Cloud Functions
│ ├── src # Cloud Functions Source code (each folder represents a function)
│ ├── .runtimeconfig.json # Cloud Functions local configuration
│ └── index.js # Mount point of Cloud Functions (loads functions by name)
├── public # All build-related configuration
│ └── index.html # Main HTML page container for app
Expand All @@ -116,7 +117,7 @@ The application structure presented in this boilerplate is **fractal**, where fu
│ ├── components.js # Utilities for building/implementing React components
│ ├── form.js # Utilities for forms (validation)
│ └── router.js # Utilities for routing such as those that redirect back to home if not logged in
├── .env.local # Environment settings for when running locally
├── .env.local # Local Environment settings (automatically loaded up by react-scripts commands)
├── .eslintignore # ESLint ignore file
├── .eslintrc.js # ESLint configuration
├── .firebaserc # Firebase Project configuration settings (including ci settings)
Expand Down Expand Up @@ -178,6 +179,7 @@ More about how routing works is available in [the react-router-dom docs](https:/
Cypress is used to write and run UI tests which live in the `cypress` folder. [`cypress-firebase`](https://github.com/prescottprue/cypress-firebase) is used to generate a custom auth token for the test user and to communicate with Firebase databases with admin privileges.

#### Tests Setup

1. Visit the [Firebase Console](https://console.firebase.google.com/)
1. Select your project
1. Navigate to Project Settings (gear icon button at the top left of the page).
Expand All @@ -186,6 +188,7 @@ Cypress is used to write and run UI tests which live in the `cypress` folder. [`
1. Save the service account file to the root of the repo under `serviceAccount.json`

#### Running Tests

The following npm scripts can be used to run tests:

- Run using Cypress run: `yarn test:ui:run`
Expand Down Expand Up @@ -238,9 +241,9 @@ For more options on CI settings checkout the [firebase-ci docs](https://github.c

## FAQ

1. Why node `10` instead of a newer version?
1. Why node `12` instead of a newer version?

[Cloud Functions runtime runs on `10`](https://cloud.google.com/functions/docs/writing/#the_cloud_functions_runtime), which is why that is what is used for the CI build version.
[Cloud Functions runtime runs on `12`](https://cloud.google.com/functions/docs/concepts/nodejs-runtime), which is why that is what is used for the CI build version.

[build-status-image]: https://img.shields.io/github/workflow/status/prescottprue/react-firebase-redux/Deploy?style=flat-square
[build-status-url]: https://github.com/prescottprue/react-firebase-redux/actions
Expand Down
32 changes: 21 additions & 11 deletions examples/react-firebase-redux/functions/.eslintrc.js
@@ -1,15 +1,25 @@
module.exports = {
extends: ['../.eslintrc.js', 'plugin:jsdoc/recommended'],
plugins: ['jsdoc'],
settings: {
'import/resolver': {
node: {
moduleDirectory: ['node_modules', '/']
}
}
},
extends: [
'../.eslintrc.js',
'plugin:jsdoc/recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint'
],
parser: '@typescript-eslint/parser',
plugins: ['node', 'jsdoc', '@typescript-eslint'],
rules: {
'no-console': 0,
'jsdoc/newline-after-description': 0
}
'jsdoc/newline-after-description': 0,
'jsdoc/require-param-type': 0,
'jsdoc/require-returns-type': 0,
'@typescript-eslint/no-explicit-any': 0
},
overrides: [
{
files: ['./index.js'],
rules: {
'@typescript-eslint/no-var-requires': 0
}
}
]
}
26 changes: 9 additions & 17 deletions examples/react-firebase-redux/functions/index.js
@@ -1,42 +1,34 @@
const glob = require('glob')
const path = require('path')
const admin = require('firebase-admin')
const functions = require('firebase-functions')
require('source-map-support/register')

// Initialize Firebase so it is available within functions
// Initialize firebase-admin so it is available within functions
try {
admin.initializeApp(functions.config().firebase)
} catch (e) {
admin.initializeApp()
} catch (err) {
/* istanbul ignore next: not called in tests */
console.error(
'Caught error initializing app with functions.config():',
e.message || e
'Caught error initializing default firebase-admin app instance:',
err
)
}

// Set Firestore timestamp settings
// NOTE: Skipped when running tests tests so it does not have to be mocked
if (process.env.NODE_ENV !== 'test') {
admin.firestore().settings({ timestampsInSnapshots: true })
}

// Load all folders within dist directory (mirrors layout of src)
const files = glob.sync('./dist/**/index.js', {
cwd: __dirname,
ignore: ['./node_modules/**', './dist/utils/**', './dist/constants/**']
})

// Loop over all folders found within dist loading only the relevant function
// instead of all functions. Done to help improve function cold start times.
// Load only files associated with the current function if FUNCTION_NAME env
// variable exists - Done to help improve function cold start times.
files.forEach((functionFile) => {
// Get folder name from file name (removing any dashes)
const folderName = path
.basename(path.dirname(functionFile))
.replace(/[-]/g, '')

// Load single function from default
// Load single function from default export of function folder's index file
!process.env.FUNCTION_NAME || process.env.FUNCTION_NAME === folderName // eslint-disable-line no-unused-expressions
? (exports[folderName] = require(functionFile).default) // eslint-disable-line global-require
: () => {}
: () => {} // eslint-disable-line @typescript-eslint/no-empty-function
})
19 changes: 8 additions & 11 deletions examples/react-firebase-redux/functions/package.json
Expand Up @@ -5,32 +5,29 @@
"main": "index.js",
"private": true,
"engines": {
"node": "10"
"node": "12"
},
"scripts": {
"lint": "eslint -c .eslintrc.js .",
"lint:fix": "yarn lint --fix",
"clean": "rimraf dist etc",
"build": "yarn clean && babel src -d --out-dir dist",
"build": "yarn clean && tsc",
"watch": "yarn build --watch",
"shell": "yarn build && firebase functions:shell",
"start": "yarn shell",
"deploy": "firebase deploy --only functions"
},
"dependencies": {
"firebase-admin": "^9.0.0",
"firebase-functions": "^3.8.0",
"firebase-admin": "^9.1.0",
"firebase-functions": "^3.9.1",
"glob": "^7.1.6",
"source-map-support": "^0.5.19"
},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.10.5",
"@babel/preset-env": "^7.10.4",
"babel-plugin-module-resolver": "^4.0.0",
"babel-preset-minify": "^0.5.1",
"@types/node": "^14.0.13",
"cross-env": "^7.0.2",
"prettier": "^2.0.5",
"rimraf": "^3.0.2"
"rimraf": "^3.0.2",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
}
}

0 comments on commit 30867bb

Please sign in to comment.