Skip to content

Commit a9f8586

Browse files
initial commit
0 parents  commit a9f8586

File tree

151 files changed

+24135
-0
lines changed

Some content is hidden

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

151 files changed

+24135
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.circleci/config.yml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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:
33+
command: |
34+
./awsconfiguration.sh $DEPLOY_ENV
35+
source awsenvconf
36+
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-buildvar
37+
- run:
38+
command: |
39+
source buildenvvar
40+
./build.sh ${APPNAME}
41+
#- save_cache: *save_cache_settings
42+
- deploy:
43+
name: Running MasterScript.
44+
command: |
45+
./awsconfiguration.sh $DEPLOY_ENV
46+
source awsenvconf
47+
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar
48+
source buildenvvar
49+
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}
50+
jobs:
51+
# Build & Deploy against development backend
52+
"build-dev":
53+
<<: *defaults
54+
environment:
55+
DEPLOY_ENV: "DEV"
56+
LOGICAL_ENV: "dev"
57+
APPNAME: "micro-frontends-self-service-app"
58+
steps: *builddeploy_steps
59+
60+
"build-prod":
61+
<<: *defaults
62+
environment:
63+
DEPLOY_ENV: "PROD"
64+
LOGICAL_ENV: "prod"
65+
APPNAME: "micro-frontends-self-service-app"
66+
steps: *builddeploy_steps
67+
68+
workflows:
69+
version: 2
70+
build:
71+
jobs:
72+
# Development builds are executed on "develop" branch only.
73+
- "build-dev":
74+
context: org-global
75+
filters:
76+
branches:
77+
only:
78+
- develop
79+
80+
# Production builds are exectuted only on tagged commits to the
81+
# master branch.
82+
- "build-prod":
83+
context: org-global
84+
filters:
85+
branches:
86+
only:
87+
- master

.eslintrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": ["react-important-stuff", "plugin:prettier/recommended"],
3+
"parser": "babel-eslint",
4+
"env": {
5+
"node": true
6+
}
7+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.prettierignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.gitignore
2+
.prettierignore
3+
yarn.lock
4+
yarn-error.log
5+
package-lock.json
6+
dist
7+
coverage
8+
*.svg
9+
*.sh
10+
*.env
11+
Dockerfile
12+
*.png

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": false
3+
}

babel.config.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
module.exports = function (api) {
2+
const isProd = process.env.APPMODE === "production";
3+
api.cache(!isProd);
4+
5+
const generateScopedName = isProd
6+
? "[hash:base64:6]"
7+
: "self_service_[path][name]___[local]___[hash:base64:6]";
8+
return {
9+
presets: ["@babel/preset-env", "@babel/preset-react"],
10+
plugins: [
11+
[
12+
"@babel/plugin-transform-runtime",
13+
{
14+
useESModules: true,
15+
regenerator: false,
16+
},
17+
],
18+
[
19+
"react-css-modules",
20+
{
21+
filetypes: {
22+
".scss": {
23+
syntax: "postcss-scss",
24+
},
25+
},
26+
generateScopedName,
27+
},
28+
],
29+
"inline-react-svg",
30+
],
31+
env: {
32+
test: {
33+
presets: [
34+
[
35+
"@babel/preset-env",
36+
{
37+
targets: "current node",
38+
},
39+
],
40+
],
41+
plugins: [
42+
[
43+
"module-resolver",
44+
{
45+
alias: {
46+
styles: "./src/styles",
47+
components: "./src/components",
48+
hooks: "./src/hooks",
49+
utils: "./src/utils",
50+
constants: "./src/constants",
51+
services: "./src/services",
52+
},
53+
},
54+
],
55+
],
56+
},
57+
},
58+
};
59+
};

build.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
APP_NAME=$1
4+
UPDATE_CACHE=""
5+
6+
docker build -f docker/Dockerfile -t $APP_NAME:latest \
7+
--build-arg APPMODE=$APPMODE \
8+
--build-arg APPENV=$APPENV \
9+
--build-arg HEAP_ANALYTICS_KEY=$HEAP_ANALYTICS_KEY .
10+
11+
docker create --name app $APP_NAME:latest
12+
13+
if [ -d node_modules ]
14+
then
15+
mv package-lock.json old-package-lock.json
16+
docker cp app:/$APP_NAME/package-lock.json package-lock.json
17+
set +eo pipefail
18+
UPDATE_CACHE=$(cmp package-lock.json old-package-lock.json)
19+
set -eo pipefail
20+
else
21+
UPDATE_CACHE=1
22+
fi
23+
24+
if [ "$UPDATE_CACHE" == 1 ]
25+
then
26+
docker cp app:/$APP_NAME/node_modules .
27+
fi

config/dev.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
/**
3+
* URL of Topcoder Community Website
4+
*/
5+
TOPCODER_COMMUNITY_WEBSITE_URL: "https://topcoder-dev.com",
6+
7+
/**
8+
* URL of Topcoder Connect Website
9+
*/
10+
CONNECT_WEBSITE_URL: "https://connect.topcoder-dev.com",
11+
12+
API: {
13+
V5: "https://api.topcoder-dev.com/v5",
14+
V3: "https://api.topcoder-dev.com/v3",
15+
},
16+
};

config/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* global process */
2+
3+
module.exports = (() => {
4+
const env = process.env.APPENV || "dev";
5+
6+
console.info(`APPENV: "${env}"`);
7+
8+
// for security reason don't let to require any arbitrary file defined in process.env
9+
if (["prod", "dev"].indexOf(env) < 0) {
10+
return require("./dev");
11+
}
12+
13+
return require("./" + env);
14+
})();

config/local.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
COMMUNITY_ADMIN_URL: "",
3+
};

config/prod.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
/**
3+
* URL of Topcoder Community Website
4+
*/
5+
TOPCODER_COMMUNITY_WEBSITE_URL: "https://topcoder.com",
6+
7+
/**
8+
* URL of Topcoder Connect Website
9+
*/
10+
CONNECT_WEBSITE_URL: "https://connect.topcoder.com",
11+
12+
API: {
13+
V5: "https://api.topcoder.com/v5",
14+
V3: "https://api.topcoder.com/v3",
15+
},
16+
};

docker/Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Use the base image with Node.js
2+
FROM node:10.22.1
3+
4+
ARG APPMODE
5+
ARG APPENV
6+
7+
ENV APPMODE=$APPMODE
8+
ENV APPENV=$APPENV
9+
10+
# Copy the current directory into the Docker image
11+
COPY . /micro-frontends-self-service-app
12+
13+
# Set working directory for future use
14+
WORKDIR /micro-frontends-self-service-app
15+
16+
# Install the dependencies from package.json
17+
RUN npm install
18+
19+
RUN npm run build
20+
21+
CMD npm start

docker/docker-compose.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3"
2+
services:
3+
micro-frontends-self-service-app:
4+
image: micro-frontends-self-service-app:latest
5+
build:
6+
context: ../
7+
dockerfile: docker/Dockerfile
8+
env_file:
9+
- api.env
10+
network_mode: "host"

docker/sample.api.env

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
AWS_ACCESS_KEY_ID=<AWS Access Key ID>
2+
AWS_SECRET_ACCESS_KEY=<AWS Secret Access Key>

jest.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
rootDir: "src",
3+
transform: {
4+
"^.+\\.(j|t)sx?$": "babel-jest",
5+
},
6+
transformIgnorePatterns: ["node_modules/?!(react-avatar)"],
7+
moduleNameMapper: {
8+
"\\.(s?css)$": "identity-obj-proxy",
9+
"\\.svg$": "<rootDir>/__mocks__/fileMock.js",
10+
},
11+
setupFilesAfterEnv: [
12+
"../node_modules/@testing-library/jest-dom/dist/index.js",
13+
],
14+
};

jsconfig.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2017",
4+
"baseUrl": ".",
5+
"moduleResolution": "node",
6+
"paths": {
7+
"styles/*": ["./src/styles/*"],
8+
"components/*": ["./src/components/*"],
9+
"hooks/*": ["./src/hooks/*"],
10+
"utils/*": ["./src/utils/*"],
11+
"constants/*": ["./src/constants/*"],
12+
"services/*": ["./src/services/*"]
13+
}
14+
},
15+
"exclude": ["node_modules", "dist"]
16+
}

0 commit comments

Comments
 (0)