React Starter Kit for Firebase a.k.a. Serverless Edition
React Starter Kitfor Firebase is a popular project template (aka, boilerplate) for building
modern, scalable web applications with React, Relay, and GraphQL using serverless infrastructure
provided by Google Cloud (Cloud SQL, Cloud Functions, CDN
hosting, and file storage). It allows you to save time and build upon a solid foundation and
design patterns.
PostgreSQL v9.6 or newer, only if you're planning to use a local db for development
Getting Started
Just clone the repo, update environment variables in .env and/or .env.local file, and start
hacking:
$ git clone https://github.com/kriasoft/react-firebase-starter.git MyApp
$ cd MyApp
$ yarn setup # Installs dependencies; creates PostgreSQL database
$ yarn start # Compile the app and opens it in a browser with "live reload"
In order to re-compile GraphQL fragments, run yarn relay or yarn relay --watch (in watch mode).
How to Migrate Database Schema
While the app is in development, you can use a simplified migration workflow by
creating a backup of your existing database, making changes to the existing
migration file (see migrations/20180101000000_initial.js), re-apply the
migration and restore data from the backup file (backup.sql):
Upon deployment to production, switch to normal migration workflow:
$ yarn db-change <name># Create a new database migration file
$ yarn db-migrate --env=dev # Migrate database to the latest version
HINT: Test your migration thoroughly with a local instance of the DB first
(by using --env=local or --env=dev (default) flag) then apply it to your
test or prod database instance using --env=test or --env=prod command
argument.
Other helpful database scripts:
$ yarn db-version --env=dev # Print the version number of the last migration
$ yarn db-rollback --env=dev # Rollback the latest migration
$ yarn db-restore --env=dev # Restore database from backup.sql
$ yarn db-seed --env=dev # Seed database with test data
$ yarn db --env=dev # Open Knex.js REPL shell (type ".exit" for exit)
$ yarn psql --env=dev # Open PostgreSQL shell (type "\q" for exit)
How to Test
$ yarn lint # Check JavaScript and CSS code for potential issues
$ yarn lint-fix # Attempt to automatically fix ESLint warnings
$ yarn test# Run unit tests. Or, `yarn test -- --watch`
How to Deploy
$ yarn build # Build the in production mode (NODE_ENV=production)
$ yarn deploy-test # Deploy the app to TEST environment
$ yarn deploy-prod # Deploy the app to PROD environment
For more information refer to the Deployment
guide in the project's Wiki.
How to Update
If you keep the original Git history after cloning this repo, you can always fetch and merge
the recent updates back into your project by running:
NOTE: Try to merge as soon as the new changes land on the master branch in the upstream
repository, otherwise your project may differ too much from the base/upstream repo.
Alternatively, you can use a folder diff tool like Beyond Compare for keeping your project
up to date with the base repository.
请发表评论