Skip to content

Commit b661fab

Browse files
prescottpruelucasharadamacinjoke
authored
* feat(auth): add support for microsoft auth provider - @lucasharada (prescottprue#880) * fix(types): switch order of schema type arguments - @macinjoke (prescottprue#875) * feat(docs): update docs include microsoft.com provider - @lucasharada (prescottprue#880) * feat(tests): add test for microsoft.com auth provider - @lucasharada (prescottprue#880) * chore(ci): switch to Github Actions for CI in place of TravisCI * chore(build): add lint-staged for quicker lint checking on pre-commit * chore(deps): update dev dependencies including babel deps Co-authored-by: Lucas Harada <lucasharada5@gmail.com> Co-authored-by: macinjoke <shunji.makino@gmail.com>
1 parent d0f0990 commit b661fab

File tree

12 files changed

+27674
-23985
lines changed

12 files changed

+27674
-23985
lines changed

.github/workflows/publish.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: NPM Package Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- next
8+
- alpha
9+
10+
jobs:
11+
publish-npm:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
17+
- name: Check package version
18+
uses: technote-space/package-version-check-action@v1
19+
with:
20+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
21+
22+
- name: Setup Node 10
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: 10
26+
registry-url: https://registry.npmjs.org/
27+
28+
# Setup dependency caching
29+
- uses: actions/cache@v1
30+
with:
31+
path: ~/.npm
32+
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
33+
34+
- name: Install Dependencies
35+
env:
36+
CI: true
37+
run: npm ci
38+
39+
- name: Check For Lint
40+
env:
41+
CI: true
42+
run: npm run lint
43+
44+
- name: Run Unit Tests + Coverage
45+
env:
46+
CI: true
47+
CODE_CLIMATE: ${{ secrets.CODE_CLIMATE }}
48+
run: npm run test:cov
49+
50+
- name: Publish
51+
env:
52+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
53+
GITHUB_REF: ${{ github.ref }}
54+
run: |
55+
export GIT_BRANCH=${GITHUB_REF##*/}
56+
export PUBLISH_FLAG=$(if [ "$GITHUB_REF" != 'refs/heads/master' ]; then eval echo '--tag $GIT_BRANCH'; else echo ''; fi;)
57+
npm publish $PUBLISH_FLAG
58+
59+
- name: Archive Build Artifact
60+
uses: actions/upload-artifact@master
61+
if: success()
62+
with:
63+
name: build
64+
path: lib
65+
66+
- name: Upload Coverage
67+
if: success()
68+
env:
69+
CI: true
70+
CODE_COV: ${{ secrets.CODE_COV }}
71+
# Upload to Code Cover. Curl used in place of codecov/codecov-action
72+
# due to long build time. See https://github.com/codecov/codecov-action/issues/21
73+
run: curl -s https://codecov.io/bash | bash -s -- -t $CODE_COV
74+

.github/workflows/verify.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Verify
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
name: Build
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
node-version: [10.x, 12.x]
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Use Node.js ${{ matrix.node-version }}
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: ${{ matrix.node-version }}
20+
21+
# Setup dependency caching
22+
- uses: actions/cache@v1
23+
with:
24+
path: ~/.npm
25+
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
26+
27+
- name: Install Dependencies
28+
env:
29+
CI: true
30+
run: npm ci
31+
32+
- name: Check For Lint
33+
env:
34+
CI: true
35+
run: npm run lint
36+
37+
- name: Run Unit Tests + Coverage
38+
if: success()
39+
run: npm run test:cov
40+
41+
- name: Run Build
42+
run: npm run build
43+
44+
- name: Upload Coverage
45+
if: matrix.node-version == '10.x' && success()
46+
env:
47+
CI: true
48+
CODE_COV: ${{ secrets.CODE_COV }}
49+
# Upload to codecov.io. Curl used in place of codecov/codecov-action
50+
# due to long build time. See https://github.com/codecov/codecov-action/issues/21
51+
run: curl -s https://codecov.io/bash | bash -s -- -t $CODE_COV

.istanbul.yml

-2
This file was deleted.

.travis.yml

-57
This file was deleted.

README.md

+22-28
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
[![Code Coverage][coverage-image]][coverage-url]
77
[![Code Style][code-style-image]][code-style-url]
88
[![License][license-image]][license-url]
9-
[![Build Status][travis-image]][travis-url]
10-
[![Dependency Status][daviddm-image]][daviddm-url]
9+
[![Build Status][build-status-image]][build-status-url]
1110

1211
[![Gitter][gitter-image]][gitter-url]
1312

@@ -21,7 +20,7 @@ The [Material Example](https://github.com/prescottprue/react-redux-firebase/tree
2120

2221
## Features
2322

24-
* Out of the box support for authentication (with auto load user profile)
23+
* Out of the box support for authentication (with auto loading user profile from database/firestore)
2524
* Full Firebase Platform Support Including Real Time Database, Firestore, and Storage
2625
* Automatic binding/unbinding of listeners through React Hooks (`useFirebaseConnect`, `useFirestoreConnect`) or Higher Order Components (`firebaseConnect` and `firestoreConnect`)
2726
* [Population capability](http://react-redux-firebase.com/docs/populate) (similar to mongoose's `populate` or SQL's `JOIN`)
@@ -58,7 +57,10 @@ import 'firebase/auth'
5857
// import 'firebase/firestore' // <- needed if using firestore
5958
// import 'firebase/functions' // <- needed if using httpsCallable
6059
import { createStore, combineReducers, compose } from 'redux'
61-
import { ReactReduxFirebaseProvider, firebaseReducer } from 'react-redux-firebase'
60+
import {
61+
ReactReduxFirebaseProvider,
62+
firebaseReducer
63+
} from 'react-redux-firebase'
6264
// import { createFirestoreInstance, firestoreReducer } from 'redux-firestore' // <- needed if using firestore
6365

6466
const fbConfig = {}
@@ -89,7 +91,7 @@ const store = createStore(rootReducer, initialState)
8991
const rrfProps = {
9092
firebase,
9193
config: rrfConfig,
92-
dispatch: store.dispatch,
94+
dispatch: store.dispatch
9395
// createFirestoreInstance // <- needed if using firestore
9496
}
9597

@@ -101,7 +103,7 @@ function App() {
101103
<Todos />
102104
</ReactReduxFirebaseProvider>
103105
</Provider>
104-
);
106+
)
105107
}
106108

107109
render(<App />, document.getElementById('root'))
@@ -126,9 +128,7 @@ export default function Todos() {
126128
return (
127129
<div>
128130
<h1>New Sample Todo</h1>
129-
<button onClick={addSampleTodo}>
130-
Add
131-
</button>
131+
<button onClick={addSampleTodo}>Add</button>
132132
</div>
133133
)
134134
}
@@ -146,7 +146,7 @@ export default function Todos() {
146146
useFirebaseConnect([
147147
'todos' // { path: '/todos' } // object notation
148148
])
149-
149+
150150
const todos = useSelector(state => state.firebase.ordered.todos)
151151

152152
if (!isLoaded(todos)) {
@@ -160,13 +160,9 @@ export default function Todos() {
160160
return (
161161
<div>
162162
<ul>
163-
{
164-
Object.keys(todos).map(
165-
(key, id) => (
166-
<TodoItem key={key} id={id} todo={todos[key]}/>
167-
)
168-
)
169-
}
163+
{Object.keys(todos).map((key, id) => (
164+
<TodoItem key={key} id={id} todo={todos[key]} />
165+
))}
170166
</ul>
171167
</div>
172168
)
@@ -192,8 +188,10 @@ export default function Todo() {
192188
{ path: `todos/${todoId}` } // create todo listener
193189
// `todos/${props.params.todoId}` // equivalent string notation
194190
])
195-
196-
const todo = useSelector(({ firebase: { data } }) => data.todos && data.todos[todoId])
191+
192+
const todo = useSelector(
193+
({ firebase: { data } }) => data.todos && data.todos[todoId]
194+
)
197195

198196
function updateTodo() {
199197
return firebase.update(`todos/${params.todoId}`, { done: !todo.isDone })
@@ -233,11 +231,9 @@ function TodosList() {
233231

234232
return (
235233
<ul>
236-
{
237-
Object.keys(todos).map((key, id) =>
238-
<TodoItem key={key} id={id} todo={todos[key]}/>
239-
)
240-
}
234+
{Object.keys(todos).map((key, id) => (
235+
<TodoItem key={key} id={id} todo={todos[key]} />
236+
))}
241237
</ul>
242238
)
243239
}
@@ -381,10 +377,8 @@ Thank you to all our backers! 🙏
381377
[quality-url]: https://packagequality.com/#?package=react-redux-firebase
382378
[backers]: https://opencollective.com/react-redux-firebase/backers/badge.svg?style=flat-square&color=blue
383379
[become-a-backer]: https://opencollective.com/react-redux-firebase#backer
384-
[travis-image]: https://img.shields.io/travis/prescottprue/react-redux-firebase/master.svg?style=flat-square
385-
[travis-url]: https://travis-ci.org/prescottprue/react-redux-firebase
386-
[daviddm-image]: https://img.shields.io/david/prescottprue/react-redux-firebase.svg?style=flat-square
387-
[daviddm-url]: https://david-dm.org/prescottprue/react-redux-firebase
380+
[build-status-image]: https://img.shields.io/github/workflow/status/prescottprue/react-redux-firebase/NPM%20Package%20Publish?style=flat-square
381+
[build-status-url]: https://github.com/prescottprue/react-redux-firebase/actions
388382
[climate-image]: https://img.shields.io/codeclimate/github/prescottprue/react-redux-firebase.svg?style=flat-square
389383
[climate-url]: https://codeclimate.com/github/prescottprue/react-redux-firebase
390384
[coverage-image]: https://img.shields.io/codecov/c/github/prescottprue/react-redux-firebase.svg?style=flat-square

docs/auth.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ For examples of how to use this API, checkout the [auth recipes section](/docs/r
4444
* provider (runs `ref.authWithOAuthPopup(provider)` or `ref.authWithOAuthRedirect(provider)`) :
4545
```js
4646
{
47-
provider: "facebook | google | twitter",
47+
provider: "facebook | google | twitter | microsoft.com",
4848
type: "popup | redirect", // popup is default
4949
scopes: Array // email is default
5050
}
@@ -59,7 +59,7 @@ For examples of how to use this API, checkout the [auth recipes section](/docs/r
5959
* provider and token (runs `ref.authWithOAuthToken(provider, token)`) **NOTE**: *Deprecated as of v1.5.0* :
6060
```js
6161
{
62-
provider: "facebook | google | twitter",
62+
provider: "facebook | google | twitter | microsoft.com",
6363
token : String
6464
}
6565
```
@@ -85,7 +85,7 @@ For examples of how to use this API, checkout the [auth recipes section](/docs/r
8585
* provider (runs `ref.reauthenticateWithPopup(provider)` or `ref.reauthenticateWithRedirect(provider)`) :
8686
```js
8787
{
88-
provider: "facebook | google | twitter",
88+
provider: "facebook | google | twitter | microsoft.com",
8989
type: "popup | redirect", // popup is default
9090
scopes: Array // email is default
9191
}

index.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -809,12 +809,12 @@ export function firebaseConnect<ProfileType, TInner = {}>(
809809
export function firebaseReducer<
810810
UserType,
811811
Schema extends Record<string, Record<string | number, string | number>>
812-
>(state: any, action: any): FirebaseReducer.Reducer<UserType, Schema>
812+
>(state: any, action: any): FirebaseReducer.Reducer<Schema, UserType>
813813

814814
export function makeFirebaseReducer<
815815
Schema extends Record<string, Record<string | number, string | number>>,
816816
UserType = {}
817-
>(): (state: any, action: any) => FirebaseReducer.Reducer<UserType, Schema>
817+
>(): (state: any, action: any) => FirebaseReducer.Reducer<Schema, UserType>
818818

819819
/**
820820
* React HOC that attaches/detaches Cloud Firestore listeners on mount/unmount
@@ -1128,8 +1128,8 @@ export interface Data<T extends FirestoreTypes.DocumentData> {
11281128

11291129
export namespace FirebaseReducer {
11301130
export interface Reducer<
1131-
ProfileType = {},
1132-
Schema extends Record<string, Record<string | number, string | number>>
1131+
Schema extends Record<string, Record<string | number, string | number>>,
1132+
ProfileType = {}
11331133
> {
11341134
auth: AuthState
11351135
profile: Profile<ProfileType>

0 commit comments

Comments
 (0)