Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit eb0e4b3

Browse files
committed
earn-app based on react-app
1 parent 3eae98b commit eb0e4b3

34 files changed

+16341
-1
lines changed

.circleci/config.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
version: 2
2+
defaults: &defaults
3+
docker:
4+
- image: circleci/python:2.7-stretch-browsers
5+
install_dependency: &install_dependency
6+
name: Installation of build and deployment dependencies.
7+
command: |
8+
sudo apt install jq
9+
sudo pip install awscli --upgrade
10+
sudo pip install docker-compose
11+
install_deploysuite: &install_deploysuite
12+
name: Installation of install_deploysuite.
13+
command: |
14+
git clone --branch v1.4.2 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
15+
cp ./../buildscript/master_deploy.sh .
16+
cp ./../buildscript/buildenv.sh .
17+
cp ./../buildscript/awsconfiguration.sh .
18+
restore_cache_settings_for_build: &restore_cache_settings_for_build
19+
key: docker-node-modules-{{ checksum "package-lock.json" }}
20+
21+
save_cache_settings: &save_cache_settings
22+
key: docker-node-modules-{{ checksum "package-lock.json" }}
23+
paths:
24+
- node_modules
25+
26+
builddeploy_steps: &builddeploy_steps
27+
- checkout
28+
- setup_remote_docker
29+
- run: *install_dependency
30+
- run: *install_deploysuite
31+
- restore_cache: *restore_cache_settings_for_build
32+
- run: ./build.sh ${APPNAME}
33+
- save_cache: *save_cache_settings
34+
- deploy:
35+
name: Running MasterScript.
36+
command: |
37+
./awsconfiguration.sh $DEPLOY_ENV
38+
source awsenvconf
39+
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar
40+
source buildenvvar
41+
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}
42+
43+
jobs:
44+
# Build & Deploy against development backend
45+
"build-dev":
46+
<<: *defaults
47+
environment:
48+
DEPLOY_ENV: "DEV"
49+
LOGICAL_ENV: "dev"
50+
APPNAME: "micro-frontends-earn-app"
51+
steps: *builddeploy_steps
52+
53+
"build-prod":
54+
<<: *defaults
55+
environment:
56+
DEPLOY_ENV: "PROD"
57+
LOGICAL_ENV: "prod"
58+
APPNAME: "micro-frontends-earn-app"
59+
steps: *builddeploy_steps
60+
61+
workflows:
62+
version: 2
63+
build:
64+
jobs:
65+
# Development builds are executed on "develop" branch only.
66+
- "build-dev":
67+
context: org-global
68+
filters:
69+
branches:
70+
only:
71+
- dev
72+
73+
# Production builds are exectuted only on tagged commits to the
74+
# master branch.
75+
- "build-prod":
76+
context: org-global
77+
filters:
78+
branches:
79+
only: master

.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": ["react-important-stuff", "plugin:prettier/recommended"],
3+
"parser": "babel-eslint"
4+
}

.gitattributes

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
## GITATTRIBUTES FOR WEB PROJECTS
2+
#
3+
# These settings are for any web project.
4+
#
5+
# Details per file setting:
6+
# text These files should be normalized (i.e. convert CRLF to LF).
7+
# binary These files are binary and should be left untouched.
8+
#
9+
# Note that binary is a macro for -text -diff.
10+
######################################################################
11+
12+
*.css merge=ours
13+
*.css.map merge=ours
14+
15+
## AUTO-DETECT
16+
## Handle line endings automatically for files detected as
17+
## text and leave all files detected as binary untouched.
18+
## This will handle all files NOT defined below.
19+
* text=auto eol=lf
20+
21+
## SOURCE CODE
22+
*.bat text eol=crlf
23+
*.coffee text eol=lf
24+
*.css text eol=lf
25+
*.htm text eol=lf
26+
*.html text eol=lf
27+
*.inc text
28+
*.ini text
29+
*.js text eol=lf
30+
*.json text
31+
*.jsx text
32+
*.less text
33+
*.od text
34+
*.onlydata text
35+
*.php text
36+
*.pl text
37+
*.py text
38+
*.rb text
39+
*.sass text eol=lf
40+
*.scm text
41+
*.scss text eol=lf
42+
*.sh text eol=lf
43+
*.sql text
44+
*.styl text
45+
*.tag text
46+
*.ts text
47+
*.tsx text
48+
*.xml text
49+
*.xhtml text
50+
51+
## DOCKER
52+
*.dockerignore text
53+
Dockerfile text
54+
55+
## DOCUMENTATION
56+
*.markdown text
57+
*.md text
58+
*.mdwn text
59+
*.mdown text
60+
*.mkd text
61+
*.mkdn text
62+
*.mdtxt text
63+
*.mdtext text
64+
*.txt text
65+
AUTHORS text
66+
CHANGELOG text
67+
CHANGES text
68+
CONTRIBUTING text
69+
COPYING text
70+
copyright text
71+
*COPYRIGHT* text
72+
INSTALL text
73+
license text
74+
LICENSE text
75+
NEWS text
76+
readme text
77+
*README* text
78+
TODO text
79+
80+
## TEMPLATES
81+
*.dot text
82+
*.ejs text
83+
*.haml text
84+
*.handlebars text
85+
*.hbs text
86+
*.hbt text
87+
*.jade text
88+
*.latte text
89+
*.mustache text
90+
*.njk text
91+
*.phtml text
92+
*.tmpl text
93+
*.tpl text
94+
*.twig text
95+
96+
## LINTERS
97+
.babelrc text
98+
.csslintrc text
99+
.eslintrc text
100+
.htmlhintrc text
101+
.jscsrc text
102+
.jshintrc text
103+
.jshintignore text
104+
.prettierrc text
105+
.stylelintrc text
106+
107+
## CONFIGS
108+
*.bowerrc text
109+
*.cnf text
110+
*.conf text
111+
*.config text
112+
.browserslistrc text
113+
.editorconfig text
114+
.gitattributes text
115+
.gitconfig text
116+
.gitignore text
117+
.htaccess text
118+
*.npmignore text
119+
*.yaml text
120+
*.yml text
121+
browserslist text
122+
Makefile text
123+
makefile text
124+
125+
## HEROKU
126+
Procfile text
127+
.slugignore text
128+
129+
## GRAPHICS
130+
*.ai binary
131+
*.bmp binary
132+
*.eps binary
133+
*.gif binary
134+
*.ico binary
135+
*.jng binary
136+
*.jp2 binary
137+
*.jpg binary
138+
*.jpeg binary
139+
*.jpx binary
140+
*.jxr binary
141+
*.pdf binary
142+
*.png binary
143+
*.psb binary
144+
*.psd binary
145+
*.svg text
146+
*.svgz binary
147+
*.tif binary
148+
*.tiff binary
149+
*.wbmp binary
150+
*.webp binary
151+
152+
## AUDIO
153+
*.kar binary
154+
*.m4a binary
155+
*.mid binary
156+
*.midi binary
157+
*.mp3 binary
158+
*.ogg binary
159+
*.ra binary
160+
161+
## VIDEO
162+
*.3gpp binary
163+
*.3gp binary
164+
*.as binary
165+
*.asf binary
166+
*.asx binary
167+
*.fla binary
168+
*.flv binary
169+
*.m4v binary
170+
*.mng binary
171+
*.mov binary
172+
*.mp4 binary
173+
*.mpeg binary
174+
*.mpg binary
175+
*.ogv binary
176+
*.swc binary
177+
*.swf binary
178+
*.webm binary
179+
180+
## ARCHIVES
181+
*.7z binary
182+
*.gz binary
183+
*.jar binary
184+
*.rar binary
185+
*.tar binary
186+
*.zip binary
187+
188+
## FONTS
189+
*.ttf binary
190+
*.eot binary
191+
*.otf binary
192+
*.woff binary
193+
*.woff2 binary
194+
195+
## EXECUTABLES
196+
*.exe binary
197+
*.pyc binary

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ build/Release
4141
node_modules/
4242
jspm_packages/
4343

44+
# Mac files
45+
.DS_Store
46+
**/.DS_Store
47+
4448
# TypeScript v1 declaration files
4549
typings/
4650

.nvmrc

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

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.gitignore
2+
.prettierignore
3+
yarn.lock
4+
yarn-error.log
5+
package-lock.json
6+
dist
7+
coverage

README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,59 @@
1-
# micro-frontends-earn-app
1+
# micro-frontends-earn-app
2+
3+
# Topcoder Earn App
4+
5+
This is a [single-spa](https://single-spa.js.org/) example React microapp.
6+
7+
> NOTE. This application have been configured to be run as child app of a single-spa application. So while this app can be deployed and run independently, we would need some frame [single-spa](https://single-spa.js.org/) which would load it. While technically we can achieve running this app as standalone app it's strongly not recommended by the author of the `single-spa` approch, see this [GitHub Issue](https://github.com/single-spa/single-spa/issues/640) for details.
8+
9+
## Requirements
10+
11+
- node - v10.22.1
12+
- npm - v6.14.6
13+
14+
## NPM Commands
15+
16+
Command | Description
17+
--------------------- | -----------------------------------------------------------------
18+
`npm start` | Run server which serves production ready build from `dist` folder
19+
`npm run dev` | Run app in the development mode
20+
`npm run dev-https` | Run app in the development mode using HTTPS protocol
21+
`npm run build` | Build app for production and puts files to the `dist` folder
22+
`npm run analyze` | Analyze dependencies sizes and opens report in the browser
23+
`npm run lint` | Check code for lint errors
24+
`npm run format` | Format code using prettier
25+
`npm run test` | Run unit tests
26+
`npm run watch-tests` | Watch for file changes and run unit tests on changes
27+
`npm run coverage` | Generate test code coverage report
28+
29+
## Local Deployment
30+
31+
Inside the project folder run:
32+
33+
- `export APPMODE="development"; export APPENV="local";` - to load APPMODE & APPENV
34+
- `nvm use 10.22.1;` - to use npm version: 10.22.1
35+
- `npm i` - install dependencies
36+
- `npm run dev` - run app in development mode
37+
- As this app can be loaded only inside a frame single-spa, you have to run a `micro-frontends-frame` frame app and configure it to use the URL `http://localhost:8008/topcoder-micro-frontends-earn-app.js`.
38+
39+
## Deployment to Production
40+
41+
- `npm i` - install dependencies
42+
- `npm build` - build code to `dist/` folder
43+
- Now you can host `dist/` folder using any static server. For example, you may run a simple `Express` server by running `npm start`.
44+
45+
### Deploying to Heroku
46+
47+
Make sure you have [Heroky CLI](https://devcenter.heroku.com/articles/heroku-cli) installed and you have a Heroku account. And then inside the project folder run the next commands:
48+
49+
- If there is not Git repository inited yet, create a repo and commit all the files:
50+
51+
- `git init`
52+
- `git add .`
53+
- `git commit -m'inital commit'`
54+
55+
- `heroku apps:create` - create Heroku app
56+
57+
- `git push heroku master` - push changes to Heroku and trigger deploying
58+
59+
- Now you have to configure frame app to use the URL provided by Heroku like `https://<APP-NAME>.herokuapp.com/topcoder-micro-frontends-earn-app.js` to load this microapp.

babel.config.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"presets": ["@babel/preset-env", "@babel/preset-react"],
3+
"plugins": [
4+
[
5+
"@babel/plugin-transform-runtime",
6+
{
7+
"useESModules": true,
8+
"regenerator": false
9+
}
10+
]
11+
],
12+
"env": {
13+
"test": {
14+
"presets": [
15+
[
16+
"@babel/preset-env",
17+
{
18+
"targets": "current node"
19+
}
20+
]
21+
]
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)