Skip to content

Commit

Permalink
Refactor open (login) window functionality (#304)
Browse files Browse the repository at this point in the history
- Replace src/auth.js authentication helper with src/utils/withAuth.js HOC
- Move open window functionality to src/utils/openWindow.js
- Move src/schema.graphql to the project's root folder
- Add PGSSLCERT, PGSSLKEY and PGROOTCERT environment variables to .env
- Add yarn db, yarn db --prod script (PostgreSQL shell)
- Update firebase.json to make it compatible with the latest (buggy) version of Firebase Tools
- Update project dependencies
- Add prestart script that compiles GraphQL queries before launching the app
- Remove CONTRIBUTING.md in favor of Contributing section in Wiki

Ref #290, #299
  • Loading branch information
koistya authored May 12, 2018
1 parent 1ab5b9a commit 7e478d3
Show file tree
Hide file tree
Showing 35 changed files with 668 additions and 827 deletions.
2 changes: 1 addition & 1 deletion .circleci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM circleci/node:10.0.0
FROM circleci/node:10.1.0

ENV WATCHMAN_VERSION 4.9.0
ENV PATH=$PATH:/home/circleci/.config/yarn/global/node_modules/.bin
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: 2
jobs:
build:
docker:
- image: kriasoft/node:9.6.1
- image: kriasoft/node:10.1.0
steps:
- checkout
- restore_cache:
Expand Down
6 changes: 5 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ FIREBASE_SERVICE_KEY={"type":"service_account","project_id":"react-firebase-grap
# Authentication

JWT_SECRET=xxxxx

GOOGLE_CLIENT_ID=xxxxx
GOOGLE_CLIENT_SECRET=xxxxx

FACEBOOK_APP_ID=xxxxx
FACEBOOK_APP_SECRET=xxxxx

Expand All @@ -25,4 +27,6 @@ PGDATABASE=app
PGPASSWORD=
PGPORT=5432
# PGSSLMODE=require

# PGSSLCERT=./ssl/client-cert.pem
# PGSSLKEY=./ssl/client-key.pem
# PGSSLROOTCERT=./ssl/server-ca.pem
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

# Dependencies
/node_modules
/functions/node_modules

# Testing
/coverage
Expand Down
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build
node_modules
package.json
__generated__
package.json
142 changes: 0 additions & 142 deletions CONTRIBUTING.md

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ Also, you need to be familiar with [HTML][html], [CSS][css], [JavaScript][js] ([
│ ├── auth.js # Client-side authentication manager
│ ├── createRelay.js # Relay factory method for browser envrironment
│ ├── router.js # Universal application router
│ ├── graphql.schema # GraphQL schema (auto-generated, used by Relay)
│ ├── serviceWorker.js # Service worker helper methods
│ └── theme.js # Overrides for Material UI default styles
├── .env # Environment variables
├── config-overrides.js # Configuration overrides for Babel and Webpack
├── graphql.schema # GraphQL schema (auto-generated, used by Relay)
└── package.json # The list of project dependencies + NPM scripts
```

Expand Down Expand Up @@ -113,6 +113,7 @@ $ yarn db-migrate # Migrate database to the latest version
$ yarn db-rollback # Rollback the latest migration
$ yarn db-save # Save data from database to JSON files
$ yarn db-seed # Seed database with previously saved data
$ yarn db # Opens PostgreSQL shell (for testing/debugging)
```

### How to Test
Expand Down
21 changes: 20 additions & 1 deletion firebase.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
{
"functions": {
"source": ".",
"ignore": ["**", "!build/**", "!ssl/**", "!package.json", "build/public/**"]
"ignore": [
".circleci",
".vscode",
"build/public/**",
"coverage",
"migrations",
"node_modules",
"public",
"scripts",
"seeds",
"src",
".*",
"config-overrides.js",
"knexfile.js",
"LICENSE.txt",
"README.md",
"schema.graphql",
"storage.rules",
"*.log"
]
},
"hosting": {
"public": "build/public",
Expand Down
10 changes: 4 additions & 6 deletions knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* Copyright (c) 2015-present Kriasoft | MIT License
*/

require('dotenv').config({ path: '.env.local' });
require('dotenv').config({ path: '.env' });

const fs = require('fs');
const path = require('path');
require('./scripts/env');

function read(file) {
const filename = path.resolve(__dirname, `ssl/${file}`);
Expand All @@ -27,9 +25,9 @@ module.exports = {
(process.env.PGSSLMODE || 'disable') !== 'disable'
? {
rejectUnauthorized: false,
ca: read('server-ca.pem'),
key: read('client-key.pem'),
cert: read('client-cert.pem'),
cert: read(process.env.PGSSLCERT),
key: read(process.env.PGSSLKEY),
ca: read(process.env.PGSSLROOTCERT),
}
: undefined,
},
Expand Down
45 changes: 25 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,70 @@
]
},
"dependencies": {
"@babel/polyfill": "^7.0.0-beta.44",
"@babel/runtime": "^7.0.0-beta.44",
"@firebase/app": "^0.2.0",
"@material-ui/icons": "^1.0.0-beta.42",
"@babel/polyfill": "^7.0.0-beta.46",
"@babel/runtime": "^7.0.0-beta.46",
"@firebase/app": "^0.3.1",
"@material-ui/icons": "^1.0.0-beta.43",
"babel-plugin-lodash": "^3.3.2",
"body-parser": "^1.18.2",
"cookie": "^0.3.1",
"cookie-parser": "^1.4.3",
"ejs": "^2.5.9",
"ejs": "^2.6.1",
"express": "^4.16.3",
"express-graphql": "^0.6.12",
"firebase-admin": "^5.12.0",
"firebase-functions": "^1.0.1",
"firebase-functions": "^1.0.2",
"graphql": "^0.13.2",
"graphql-relay": "^0.5.5",
"history": "^4.7.2",
"hoist-non-react-statics": "^2.5.0",
"idx": "^2.3.0",
"jsonwebtoken": "^8.2.1",
"jwt-passport": "^0.0.5",
"knex": "^0.14.6",
"lodash": "^4.17.10",
"material-ui": "^1.0.0-beta.42",
"material-ui": "^1.0.0-beta.47",
"moment": "^2.22.1",
"passport": "^0.4.0",
"passport-facebook": "^2.1.1",
"passport-google-oauth20": "^1.0.0",
"pg": "^7.4.1",
"pg": "^7.4.3",
"prop-types": "^15.6.1",
"query-string": "^6.0.0",
"query-string": "^6.1.0",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-relay": "^1.5.0",
"relay-runtime": "^1.5.0",
"react-relay": "^1.6.0",
"recompose": "^0.27.0",
"relay-runtime": "^1.6.0",
"request": "^2.85.0",
"request-promise-native": "^1.0.5",
"serialize-javascript": "^1.5.0",
"slug": "^0.9.1",
"styled-components": "^3.2.6",
"universal-router": "^6.0.0",
"uuid": "^3.2.1",
"validator": "^9.4.1"
"validator": "^10.2.0"
},
"devDependencies": {
"@babel/register": "^7.0.0-beta.44",
"babel-plugin-relay": "^1.5.0",
"@babel/core": "^7.0.0-beta.46",
"@babel/register": "^7.0.0-beta.46",
"babel-plugin-relay": "^1.6.0",
"babel-plugin-styled-components": "^1.5.1",
"chai": "^4.1.2",
"dotenv": "^5.0.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-flowtype": "^2.46.3",
"eslint-plugin-prettier": "^2.6.0",
"flow-bin": "^0.70.0",
"flow-bin": "^0.72.0",
"gh-pages": "^1.1.0",
"husky": "^0.15.0-rc.13",
"lint-staged": "^7.0.4",
"lint-staged": "^7.1.0",
"prettier": "^1.12.1",
"raw-loader": "^1.0.0-beta.0",
"react-app-tools": "^2.0.3",
"relay-compiler": "^1.5.0",
"relay-compiler": "^1.6.0",
"stylelint": "^9.2.0",
"stylelint-config-primer": "^2.2.5",
"stylelint-config-primer": "^2.2.6",
"stylelint-config-standard": "^18.2.0",
"stylelint-config-styled-components-processor": "^0.1.1",
"stylelint-order": "^0.8.1",
Expand All @@ -101,13 +104,15 @@
},
"scripts": {
"update-schema": "node ./scripts/update-schema",
"relay": "relay-compiler --src ./src --schema ./src/schema.graphql --include \"**/*.js\"",
"relay": "relay-compiler --src ./src --schema ./schema.graphql --include \"**/*.js\"",
"setup": "node ./scripts/setup",
"prestart": "yarn relay",
"start": "react-app start",
"build": "react-app build",
"test": "react-app test --env=jsdom",
"lint": "eslint --ignore-path .gitignore --ignore-pattern \"!**/.*\" . && stylelint \"src/**/*.js\"",
"lint-fix": "eslint --ignore-path .gitignore --ignore-pattern \"!**/.*\" --fix .",
"lint-fix": "eslint --ignore-path .gitignore --ignore-pattern \"!**/.*\" --fix . && yarn run prettier --write \"**/*.{js,json}\"",
"db": "node ./scripts/db",
"db-save": "node ./scripts/db-save",
"db-change": "knex migrate:make",
"db-migrate": "knex migrate:latest",
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions scripts/db-save.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* Copyright (c) 2015-present Kriasoft | MIT License
*/

'use script';

const fs = require('fs');
const path = require('path');
const knex = require('knex');
Expand Down
16 changes: 16 additions & 0 deletions scripts/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* React Starter Kit for Firebase
* https://github.com/kriasoft/react-firebase-starter
* Copyright (c) 2015-present Kriasoft | MIT License
*/

const { spawn } = require('child_process');
require('./env');

const opts = { stdio: 'inherit' };

if (process.env.PGSSLKEY) {
spawn('chmod', ['0600', process.env.PGSSLKEY], opts);
}

spawn('psql', opts);
Loading

0 comments on commit 7e478d3

Please sign in to comment.