Skip to content

Commit 5a56360

Browse files
authored
Merge pull request #39 from topcoder-platform/develop
Promoting to prod for initial release
2 parents 9c68b9d + eb388b2 commit 5a56360

File tree

678 files changed

+72554
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

678 files changed

+72554
-3
lines changed

.babelrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Babel config for NodeJS (server-side). Frontend Babel configuration is embed
2+
// inside Webpack config.
3+
{
4+
"presets": ["env", "react", "stage-2"],
5+
"plugins": [
6+
["css-modules-transform", {
7+
"extensions": [".css", ".scss"],
8+
"generateScopedName": "[path]___[name]__[local]___[hash:base64:5]"
9+
}],
10+
"inline-react-svg",
11+
["module-resolver", {
12+
"extensions": [".js", ".jsx"],
13+
"root": [
14+
"./src/shared",
15+
"./src"
16+
]
17+
}],
18+
["react-css-modules", {
19+
"filetypes": {
20+
".scss": "postcss-scss"
21+
}
22+
}]
23+
]
24+
}

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__coverage__/
2+
node_modules/
3+
.git/

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__coverage__
2+
build
3+
node_modules

.eslintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "airbnb",
3+
"settings": {
4+
"import/resolver": {
5+
"babel-module": {}
6+
}
7+
}
8+
}

.gitignore

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pids
1212
lib-cov
1313

1414
# Coverage directory used by tools like istanbul
15+
__coverage__
1516
coverage
1617

1718
# nyc test coverage
@@ -24,7 +25,7 @@ coverage
2425
.lock-wscript
2526

2627
# Compiled binary addons (http://nodejs.org/api/addons.html)
27-
build/Release
28+
build
2829

2930
# Dependency directories
3031
node_modules
@@ -35,3 +36,14 @@ jspm_packages
3536

3637
# Optional REPL history
3738
.node_repl_history
39+
40+
# Elastic Beanstalk Files
41+
.elasticbeanstalk/*
42+
!.elasticbeanstalk/*.cfg.yml
43+
!.elasticbeanstalk/*.global.yml
44+
45+
# macOS system files
46+
*.DS_Store
47+
48+
# Misc files
49+
.vscode

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v6.10.2

.stylelintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "stylelint-config-standard",
3+
"rules": {
4+
"selector-pseudo-class-no-unknown": [true, {
5+
"ignorePseudoClasses": ["global"]
6+
}]
7+
}
8+
}

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:6.10.2
2+
LABEL version="1.0"
3+
LABEL description="Community App"
4+
5+
# Create app directory
6+
RUN mkdir -p /opt/app
7+
ADD package.json /opt/app/package.json
8+
WORKDIR /opt/app
9+
RUN npm install
10+
11+
ADD . /opt/app
12+
13+
ARG BUILD_ENV=prod
14+
ENV NODE_ENV=$BUILD_ENV
15+
RUN npm run build
16+
17+
EXPOSE 3000
18+
19+
CMD ["npm", "start"]

README.md

Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,103 @@
1-
# community-app
2-
React webapp for serving Topcoder Community
1+
![Dev Build Status](https://img.shields.io/circleci/project/github/topcoder-platform/community-app/develop.svg?label=develop)
2+
3+
# Topcoder Community App
4+
New version of Topcoder Community website.
5+
6+
### Deployment and Execution
7+
8+
*Disclaimer:* Current instructions are biased towards Ubuntu 16.04. Hovewer, similar recipies should work for other OS. Should you encounter and overcome any tricky issues on other OS, you are welcome to add notes/hints into this file.
9+
10+
1. You should have NodeJS 6.10.0 (other recent versions should also work fine);
11+
12+
2. Install dependencies with one of the following commands:
13+
- `$ npm install` Installs all dependencies. Recommended for local development;
14+
- `$ npm install --production` Installs only production dependencies. These include all you need to run linters & unit tests, to build & run production version of the App. Does not include additional development tools.
15+
16+
3. Run linters and unit tests with following commands:
17+
- `$ npm run lint:js` Runs ESLint (AirBnB style);
18+
- `$ npm run lint:scss` Runs Stylelint (standard Stylelint style);
19+
- `$ npm run lint` Runs both ESLint and Stylelint;
20+
- `$ npm run jest` Runs unit tests;
21+
- `$ npm run jest -- -u` Runs unit test with update of component snapshots;
22+
- `$ npm test` Runs ESLint, Stylelint and unit tests.
23+
24+
4. Set environment variables:
25+
- `PORT` Specifies the port to run the App at. Defaults to 3000;
26+
- `NODE_ENV` Specifies Topcoder backend to use. Should be either `development` either `production`. Defaults to `production`.
27+
28+
5. To rebuild the App's frontend (initially, it is automatically build as a part of the install step) run one of (the result of build will be output into `/build` folder in both cases):
29+
- `$ npm run build` To rebuild production frontend;
30+
- `$ npm run build:dev` This command should only be used to test whether development build of the front end works. You don't have to execute this command to run development version of the App (the server will automatically build frontend in memory anyway). You can't successfully execute this command without installing dev dependencies.
31+
32+
6. To run the App use:
33+
- `$ npm start` To run the App in normal mode. The frontend will be served from `/build` folder. The Topcoder backend to use will be chosen depending on `NODE_ENV` value;
34+
- `$ npm run dev` To run the App with development tools. In this case the frontend is build in memory by server and uses dev tools like redux-devtools. The Topcoder backend to use will be chosen depending on `NODE_ENV` value. This demands dev dependencies installed at the firts step.
35+
36+
If you run the App locally against development Topcoder backend you should access the App as `local.topcoder-dev.com:3000`. Prior doing this you should add into your `/etc/hosts` the line `127.0.0.1 local.topcoder-dev.com:3000`. To login into development Topcoder backend use `accounts.topcoder-dev.com/members` to login. Log out at `www.topcoder-dev.com`, or just wipe out auth cookies.
37+
38+
If you run the App locally against production Topcoder backend you should run it at the port 80 and access the App as `local.topcoder.com`. Prior doing this you should add into your `/etc/hosts` the line `127.0.0.1 local.topcoder.com`. The easiest way to allow the App to listen at the port 80 on Ubuntu 16.04 is (no guarantees, how safe is it):
39+
- `$ sudo apt install libcap2-bin`;
40+
- `$ which node` to figure out your `path/to/node`;
41+
- `$ sudo setcap cap_net_bind_service=+ep /path/to/node`;
42+
- Now you can run the App.
43+
To login into production Topcoder backend use `accounts.topcoder.com/members` with your regular account, and to logout you can just wipe out cookies, or just log out at `www.topcoder.com`.
44+
45+
Development dependencies include StyleFMT. You can execute `$ npm run fix:styles` to automatically correct you stylesheets to comply with Stylelint rules (but it can fail for some rules).
46+
To automatically correct js files, you can use `npm run fix:js`.
47+
48+
### Development Notes
49+
- [Challenge Listing - Notes from winning submission](docs/challenge-listing-notes.md)
50+
- [Leaderboard - Notes from the winning submission](docs/leaderboard-notes.md)
51+
- [Wipro Community - Notes from the preliminary winning submission](docs/wipro-community.md)
52+
- [Why Reducer Factories and How to Use Them?](docs/why-reducer-factories-and-how-to-use-them.md)
53+
- [~~WYSIWYG Page Editor - Notes from the winning submission~~](docs/editor-notes.pdf)
54+
55+
### Current Status
56+
57+
*Note:* Server-side rendering is supported. It means, if you go to `/src/server/App.jsx` and remove the line `<_script type="application/javascript" src="/bundle.js"></script>`, which loads JS bundle in the page, when you start the App and load any page, you'll still see a properly rendered page (without any interactivity). It means that loading of JS bundle and initialization of ReactJS do not block the proper rendering of the page.
58+
59+
*Setup of this App is not finished yet. Here is a brief summary of current configuration and problems found on the way.*
60+
61+
This App already contains:
62+
- A high-level draft of isomorphic App structure;
63+
- A dummy client App;
64+
- A set of general Topcoder stylesheets in `/src/styles`;
65+
- Autoprefixer;
66+
- Babel with latest JS support both client- and server-side;
67+
- ESLint (AirBnB style);
68+
- Express server;
69+
- Font loading (Roboto fonts are included into the repo);
70+
- Hot Module Replacement for JS code and SCSS styles in dev environment;
71+
- Isomorphic fetch and Topcoder API Auth;
72+
- Loading of .svg assets as ReactJS components with babel-plugin-inline-react-svg
73+
- Node-Config;
74+
- React;
75+
- React CSS Modules (via Babel plugin);
76+
- [react-css-themr](https://github.com/javivelasco/react-css-themr);
77+
- React Router;
78+
- Redux with Flux Standard Actions, redux-promise middleware, support of server-side rendering, and DevTools for dev environment;
79+
- SCSS support;
80+
- CSS support for third party modules;
81+
- StyleFMT;
82+
- Stylelint for scss (standard Stylelint style);
83+
- Unit testing with Jest;
84+
- Various examples;
85+
- Webpack;
86+
87+
Pending low-priority stuff (these are important, but can be added along the way):
88+
- Webpack Dashboard (https://github.com/FormidableLabs/webpack-dashboard);
89+
90+
### CI / CD
91+
Deploy scripts are setup to use AWS ECS + CircleCI. Make sure the following environment variables are setup in CircleCI:
92+
* AWS_ECS_SERVICE
93+
* AWS_REPOSITORY
94+
* DEV_AWS_ACCESS_KEY_ID
95+
* DEV_AWS_ACCOUNT_ID
96+
* DEV_AWS_ECS_CLUSTER
97+
* DEV_AWS_REGION
98+
* DEV_AWS_SECRET_ACCESS_KEY
99+
* PROD_AWS_ACCESS_KEY_ID
100+
* PROD_AWS_ACCOUNT_ID
101+
* PROD_AWS_ECS_CLUSTER
102+
* PROD_AWS_REGION
103+
* PROD_AWS_SECRET_ACCESS_KEY
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Mock redux-devtools-dock-monitor module.
3+
* Allows to test development-only code depending on that module even
4+
* in production environment, where that module is not installed.
5+
*/
6+
7+
export default function ReduxDevtoolsDockMonitor() {
8+
return null;
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function ReduxDevtoolsLogMonitor() {
2+
return null;
3+
}

__mocks__/redux-devtools.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import _ from 'lodash';
2+
3+
export function createDevTools(obj) {
4+
const res = () => obj;
5+
res.instrument = _.noop;
6+
return res;
7+
}
8+
9+
export default undefined;

__mocks__/webpack-dev-middleware.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function webpackDevMiddleware(req, res, next) {
2+
if (next) next();
3+
}
4+
5+
module.exports = () => webpackDevMiddleware;

__mocks__/webpack-hot-middleware.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function webpackHotMiddleware(req, res, next) {
2+
if (next) next();
3+
}
4+
5+
module.exports = () => webpackHotMiddleware;

__mocks__/webpack.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import _ from 'lodash';
2+
3+
module.exports = _.noop;

__tests__/.eslintrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"env": {
3+
"jest/globals": true
4+
},
5+
"plugins": [
6+
"jest"
7+
],
8+
"rules": {
9+
"global-require": 0,
10+
"import/no-dynamic-require": 0
11+
}
12+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Properly starts with process.env.FRONT_ENV evaluating true Renders proper code (matching snapshot) 1`] = `
4+
<div>
5+
<h1>
6+
Mock react-redux Provider
7+
</h1>
8+
<div>
9+
<h1>
10+
Mock react-router-dom BrowserRouter
11+
</h1>
12+
Mock Browser History
13+
<div>
14+
Application
15+
</div>
16+
</div>
17+
</div>
18+
`;

0 commit comments

Comments
 (0)