Skip to content

Commit

Permalink
v3.0.0-alpha.13 (#726)
Browse files Browse the repository at this point in the history
* feat(types): add types for hooks including `useFirestore`, `useFirebase`, `useFirestoreConnect`, `useFirebaseConnect` - #653
* fix(types): make scopes optional in `credentials` - #671
* fix(docs): remove v2 auth ready docs from v3 docs - #676
* fix(providers): prevent unwanted re-initialization when parent component updates - #725 - @illuminist
* fix(profile): pass `updateProfile` options to action - #701 - @cruzdanilo 
* fix(firebaseConnect): remove `dispatch` from reserved props list - #675, #700
* feat(types): improve types for `withFirestore` and `withFirebase`
* feat(types): added `ExtendedFirebaseInstance` and `ExtendedFirestoreInstance` types
* feat(examples): update typescript example to use hooks
* fix(firestoreConnect): add error for passing of reserved props `firebase` and `firestore` when using `firestoreConnect`
* feat(types): add typing for firebase queries used in `firebaseConnect` and `useFirebaseConnect`
* fix(types): fix spelling of initialize in types
* feat(docs): add api docs pages for context providers and new hooks api 
* feat(docs): automatically find files for doc generation instead of having a constant that needs updating
* feat(core): add uglify and lodash plugins to webpack build to shrink bundle build size
  • Loading branch information
prescottprue committed Jul 13, 2019
2 parents e4100c9 + 5b9a244 commit 068ad3f
Show file tree
Hide file tree
Showing 41 changed files with 2,826 additions and 2,608 deletions.
9 changes: 8 additions & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
* [React Chrome Redux](/docs/integrations/react-chrome-redux.md)
* [API Reference](/docs/api/README.md)
* [constants](/docs/api/constants.md)
* [firebaseConnect](/docs/api/connect.md)
* [firebaseConnect](/docs/api/firebaseConnect.md)
* [withFirebase](/docs/api/withFirebase.md)
* [firestoreConnect](/docs/api/firestoreConnect.md)
* [withFirestore](/docs/api/withFirestore.md)
* [useFirebase](/docs/api/useFirebase.md)
* [useFirebaseConnect](/docs/api/useFirebaseConnect.md)
* [useFirestore](/docs/api/useFirestore.md)
* [firebaseReducer](/docs/api/reducer.md)
* [isInitializingReducer](/docs/api/reducers.md#isinitializingreducer)
* [requestingReducer](/docs/api/reducers.md#requestingreducer)
Expand All @@ -44,6 +47,10 @@
* [orderedReducer](/docs/api/reducers.md#orderedreducer)
* [props.firebase](/docs/api/props-firebase.md)
* [firebaseInstance](/docs/api/firebaseInstance.md)
* [ReactReduxFirebaseContext](/docs/api/ReactReduxFirebaseContext.md)
* [ReactReduxFirebaseProvider](/docs/api/ReactReduxFirebaseProvider.md)
* [ReduxFirestoreContext](/docs/api/ReduxFirestoreContext.md)
* [ReduxFirestoreProvider](/docs/api/ReduxFirestoreProvider.md)
* [helpers](/docs/api/helpers.md)
* Migration Guides
* [v3 Migration Guide](/docs/v3-migration-guide.md)
Expand Down
71 changes: 30 additions & 41 deletions bin/api-docs-generate.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,18 @@
/* eslint-disable no-console */
const exec = require('child-process-promise').exec
const fs = require('fs')

const files = [
{
src: 'firebaseConnect.js',
dest: 'connect.md'
},
{
src: 'firestoreConnect.js',
dest: 'firestoreConnect.md'
},
{
src: 'withFirebase.js',
dest: 'withFirebase.md'
},
{
src: 'withFirestore.js',
dest: 'withFirestore.md'
},
{
src: 'createFirebaseInstance.js',
dest: 'firebaseInstance.md'
},
{
src: 'helpers.js',
dest: 'helpers.md'
},
{
src: 'reducers.js',
dest: 'reducers.md'
},
{
src: 'reducer.js',
dest: 'reducer.md'
},
{
src: 'constants.js',
dest: 'constants.md'
}
]
const SRC_FOLDER = 'src'
const pathsToSkip = ['index.js', 'utils', '.DS_Store', 'actions']
const fileRenames = {
'createFirebaseInstance.js': 'firebaseInstance'
}

function generateDocForFile(file) {
return exec(
`$(npm bin)/documentation build src/${file.src} -f md -o docs/api/${
file.dest
} --shallow`
`$(npm bin)/documentation build ${SRC_FOLDER}/${
file.src
} -f md -o docs/api/${file.dest} --shallow`
)
.then(res => {
console.log('Successfully generated', file.dest || file)
Expand All @@ -56,10 +24,31 @@ function generateDocForFile(file) {
})
}

function getFileNames() {
return new Promise((resolve, reject) => {
fs.readdir(SRC_FOLDER, (err, files) => {
console.log('files:', files)
if (err) {
return reject(err)
}
const cleanedFileNames = files.filter(
fileName => !pathsToSkip.includes(fileName)
)
const mappedFileNames = cleanedFileNames.map(fileName => {
const newName = fileRenames[fileName] || fileName
return { src: newName, dest: `${newName.replace('.js', '')}.md` }
})
console.log('mapped file names', mappedFileNames)
resolve(mappedFileNames)
})
})
}

;(async function() {
console.log(
'Generating API documentation (docs/api) from JSDoc comments within src...\n'
)
const files = await getFileNames()
try {
await Promise.all(files.map(generateDocForFile))
console.log('\nAPI documentation generated successfully!')
Expand Down
10 changes: 9 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@
* [React Chrome Redux](/docs/integrations/react-chrome-redux.md)
* [API Reference](/docs/api/README.md)
* [constants](/docs/api/constants.md)
* [firebaseConnect](/docs/api/connect.md)
* [firebaseConnect](/docs/api/firebaseConnect.md)
* [withFirebase](/docs/api/withFirebase.md)
* [firestoreConnect](/docs/api/firestoreConnect.md)
* [withFirestore](/docs/api/withFirestore.md)
* [useFirebase](/docs/api/useFirebase.md)
* [useFirebaseConnect](/docs/api/useFirebaseConnect.md)
* [useFirestore](/docs/api/useFirestore.md)
* [useFirestoreConnect](/docs/api/useFirestoreConnect.md)
* [firebaseReducer](/docs/api/reducer.md)
* [isInitializingReducer](/docs/api/reducers.md#isinitializingreducer)
* [requestingReducer](/docs/api/reducers.md#requestingreducer)
Expand All @@ -45,6 +49,10 @@
* [orderedReducer](/docs/api/reducers.md#orderedreducer)
* [props.firebase](/docs/api/props-firebase.md)
* [firebaseInstance](/docs/api/firebaseInstance.md)
* [ReactReduxFirebaseContext](/docs/api/ReactReduxFirebaseContext.md)
* [ReactReduxFirebaseProvider](/docs/api/ReactReduxFirebaseProvider.md)
* [ReduxFirestoreContext](/docs/api/ReduxFirestoreContext.md)
* [ReduxFirestoreProvider](/docs/api/ReduxFirestoreProvider.md)
* [helpers](/docs/api/helpers.md)
* [FAQ](/docs/FAQ.md)
* [Roadmap](/docs/roadmap.md)
Expand Down
4 changes: 2 additions & 2 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Just like [redux](http://redux.js.org/docs/api/index.html), the react-redux-firebase API surface is intentionally as small as possible.

## Top-Level Exports
* [firebaseConnect](/docs/api/connect.md#firebaseconnect)
* [createFirebaseConnect](/docs/api/connect.md#createfirebaseconnect)
* [firebaseConnect](/docs/api/firebaseConnect.md#firebaseconnect)
* [createFirebaseConnect](/docs/api/firebaseConnect.md#createfirebaseconnect)
* [withFirebase](/docs/api/withFirebase.md)
* [firestoreConnect](/docs/api/firestoreConnect.md#firebaseconnect)
* [createFirestoreConnect](/docs/api/firestoreConnect.md#createfirestoreconnect)
Expand Down
10 changes: 10 additions & 0 deletions docs/api/ReactReduxFirebaseContext.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

- [ReactReduxFirebaseContext](#reactreduxfirebasecontext)

## ReactReduxFirebaseContext

Context for extended firebase instance created
by react-redux-firebase
20 changes: 20 additions & 0 deletions docs/api/ReactReduxFirebaseProvider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

- [ReactReduxFirebaseProvider](#reactreduxfirebaseprovider)

## ReactReduxFirebaseProvider

Provider for context containing extended firebase instance created
by react-redux-firebase

**Parameters**

- `props` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `{}`)
- `props.config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** react-redux-firebase config
- `props.dispatch` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Redux's dispatch function
- `props.firebase` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Firebase library
- `props.initializeAuth` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to initialize auth
- `props.createFirestoreInstance` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Function for creating
extended firestore instance
10 changes: 10 additions & 0 deletions docs/api/ReduxFirestoreContext.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

- [ReduxFirestoreContext](#reduxfirestorecontext)

## ReduxFirestoreContext

Context for extended firebase instance created
by react-redux-firebase
20 changes: 20 additions & 0 deletions docs/api/ReduxFirestoreProvider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

- [ReduxFirestoreProvider](#reduxfirestoreprovider)

## ReduxFirestoreProvider

Provider for context containing extended firestore instance created
by react-redux-firebase

**Parameters**

- `props` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `{}`)
- `props.config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** react-redux-firebase config
- `props.dispatch` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Redux's dispatch function
- `props.firebase` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Firebase library
- `props.initializeAuth` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to initialize auth
- `props.createFirestoreInstance` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Function for creating
extended firestore instance
20 changes: 11 additions & 9 deletions docs/api/connect.md → docs/api/firebaseConnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## createFirebaseConnect

Function that creates a Higher Order Component that
Function that creates a Higher Order Component which
automatically listens/unListens to provided firebase paths using
React's Lifecycle hooks.
**WARNING!!** This is an advanced feature, and should only be used when
Expand Down Expand Up @@ -69,7 +69,7 @@ const enhance = compose(
]),
connect((state) => ({
todos: state.firebase.ordered.todos
})
}))
)

// use enhnace to pass todos list as props.todos
Expand All @@ -92,17 +92,19 @@ import { firebaseConnect, getVal } from 'react-redux-firebase'
const enhance = compose(
firebaseConnect((props) => ([
`posts/${props.postId}` // sync /posts/postId from firebase into redux
]),
])),
connect((state, props) => ({
post: getVal(state.firebase.data, `posts/${props.postId}`),
})
}))
)

const Post = ({ post }) => (
<div>
{JSON.stringify(post, null, 2)}
</div>
)
function Post({ post }) {
return (
<div>
{JSON.stringify(post, null, 2)}
</div>
)
}

export default enhance(Post)
```
Expand Down

0 comments on commit 068ad3f

Please sign in to comment.