Skip to content

Commit

Permalink
Merge pull request #12 from andela/fix-ch-deploy-frontend-to-Heroku-1…
Browse files Browse the repository at this point in the history
…67664242

#167664242 Add heroku:build command
  • Loading branch information
tolumide-ng committed Aug 2, 2019
2 parents d685cf1 + d0ddf58 commit 13f7564
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 7 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: npm run start
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
28 changes: 28 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
coverageDirectory: 'coverage',
testPathIgnorePatterns: ['/node_modules/'],
transformIgnorePatterns: ['<rootDir>/node_modules/'],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/__mocks__/fileMock.js',
'\\.(css|less)$': '<rootDir>/__mocks__/styleMock.js'
},
collectCoverageFrom: [
'**/*.{js,jsx}',
'!**/node_modules/**',
'!jest.config.js',
'!**/dist/**',
'!**/webpack-build-utils/**',
'!README.md',
'Procfile',
'Postcss.config.js',
'!package.json',
'!package-lock.json',
'!cypress.json',
'!<rootDir>/server.js',
'!webpack.common.js',
'!webpack.config.js',
'!**/coverage/**',
'!**/tests/**'
]
};
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
"description": "errorSwag frontend",
"main": "index.js",
"scripts": {
"test": "jest --coverage",
"lint": "eslint '**/*.js'",
"lint:fix": "prettier-eslint \"**/*.{js,json}\" --write",
"prettier": "prettier **/*.{js,json} --write",
"format": "pretty-quick",
"develop": "webpack --env.mode development --watch",
"heroku-postbuild": "webpack --env.mode production",
"heroku-postbuild": "npm run build",
"start": "node server.js",
"build": "webpack --env.mode production",
"start": "webpack-dev-server --hot --env.mode development --open",
"start:dev": "webpack-dev-server --hot --env.mode development --open",
"cypress": "cypress open",
"test:watch": "npm run test -- --watch",
"test": "jest --coverage",
"test:watch": "jest --watch --coverage",
"coverage": "cat ./coverage/lcov.info | coveralls"
},
"husky": {
Expand Down Expand Up @@ -79,6 +80,7 @@
"autoprefixer": "^9.6.1",
"clean-webpack-plugin": "^3.0.0",
"css-loader": "^3.1.0",
"express": "^4.17.1",
"glob": "^7.1.4",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.8.0",
Expand Down
15 changes: 15 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const express = require('express');
const path = require('path');

const port = process.env.PORT || 9000;
const app = express();

app.use(express.static(`${__dirname}/dist`));

app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, './dist/index.html'));
});

app.listen(process.env.PORT || 3000, () => {
process.stdout.write(`Listening on port ${port}`);
});
File renamed without changes
5 changes: 3 additions & 2 deletions src/pages/hompage.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React, { Component } from 'react';
import React from 'react';
import { Link } from 'react-router-dom';
import logo from '../assets/images/logo.png';

const Homepage = () => {
return (
<div className="m-20 text-center">
<h1 className="text-green-700">
Welcome to ErrorSwag, what on your mind?
</h1>
<img src="../../public/images/logo.png" alt="errorswag logo" />
<img src={logo} alt="errorswag logo" />
<Link to="/login">
<button
type="button"
Expand Down
128 changes: 128 additions & 0 deletions tests/__snapshots__/App.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Application test should work fine Home Page 1`] = `
<div
className="m-20 text-center"
>
<h1
className="text-green-700"
>
Welcome to ErrorSwag, what on your mind?
</h1>
<img
alt="errorswag logo"
src={Object {}}
/>
<Link
to="/login"
>
<button
className="bg-green-300 text-white p-2 hover:bg-green-700 border hover:border-red-300"
type="button"
>
Login
</button>
</Link>
</div>
`;

exports[`Application test should work fine on App 1`] = `
<BrowserRouter>
<Routes />
</BrowserRouter>
`;

exports[`Application test should work fine on Login Page 1`] = `
<Fragment>
<Link
to="/"
>
<button
style={
Object {
"backgroundColor": "sky-blue",
"border": "none",
"color": "black",
"marginLeft": "80%",
"padding": "7px 9px",
}
}
type="button"
>
Home
</button>
</Link>
<form>
<label
style={
Object {
"height": "2em",
"width": "50%",
}
}
>
Email
</label>
<input
placeholder="example@email.com"
style={
Object {
"border": "1px solid #333",
"height": "2em",
"width": "100%",
}
}
type="email"
/>
<label
style={
Object {
"height": "2em",
"width": "50%",
}
}
>
Password
</label>
<input
placeholder="......."
style={
Object {
"border": "1px solid #333",
"height": "2em",
"width": "100%",
}
}
type="password"
/>
<input
style={
Object {
"backgroundColor": "sky-blue",
"border": "none",
"color": "black",
"marginLeft": "80%",
"padding": "7px 9px",
}
}
type="submit"
value="login"
/>
</form>
</Fragment>
`;

exports[`Application test should work fine on Routes 1`] = `
<Switch>
<Route
component={[Function]}
exact={true}
path="/"
/>
<Route
component={[Function]}
exact={true}
path="/login"
/>
</Switch>
`;
2 changes: 1 addition & 1 deletion webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
}
},
{
test: /\.(svg|png|gif|jpeg|jpg)$/,
test: /\.(svg|png|jpeg|jpg)$/,
use: {
loader: 'file-loader',
options: {
Expand Down

0 comments on commit 13f7564

Please sign in to comment.