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

prod release #7

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["react-important-stuff", "plugin:prettier/recommended"],
"parser": "babel-eslint"
}
105 changes: 105 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.sh

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.16.0
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.gitignore
.prettierignore
yarn.lock
yarn-error.log
package-lock.json
dist
coverage
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": false
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"javascript.preferences.quoteStyle": "double",
"typescript.preferences.quoteStyle": "double",
"prettier.jsxSingleQuote": false
}
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "";
59 changes: 59 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module.exports = function (api) {
const isProd = process.env.APPMODE === "production";
api.cache(!isProd);

const generateScopedName = isProd
? "[hash:base64:6]"
: "community_admin_[path][name]___[local]___[hash:base64:6]";
return {
presets: ["@babel/preset-env", "@babel/preset-react"],
plugins: [
[
"@babel/plugin-transform-runtime",
{
useESModules: true,
regenerator: false,
},
],
[
"react-css-modules",
{
filetypes: {
".scss": {
syntax: "postcss-scss",
},
},
generateScopedName,
},
],
"inline-react-svg",
],
env: {
test: {
presets: [
[
"@babel/preset-env",
{
targets: "current node",
},
],
],
plugins: [
[
"module-resolver",
{
alias: {
styles: "./src/styles",
components: "./src/components",
hooks: "./src/hooks",
utils: "./src/utils",
constants: "./src/constants",
services: "./src/services",
},
},
],
],
},
},
};
};
28 changes: 28 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -eo pipefail
APP_NAME=$1
UPDATE_CACHE=""

docker build -f docker/Dockerfile -t $APP_NAME:latest \
--build-arg APPMODE=$APPMODE \
--build-arg APPENV=$APPENV .

docker build -f docker/mockDockerfile -t mock-$APP_NAME:latest .

#docker create --name app $APP_NAME:latest

#if [ -d node_modules ]
#then
# mv package-lock.json old-package-lock.json
# docker cp app:/$APP_NAME/package-lock.json package-lock.json
# set +eo pipefail
# UPDATE_CACHE=$(cmp package-lock.json old-package-lock.json)
# set -eo pipefail
#else
# UPDATE_CACHE=1
#fi

#if [ "$UPDATE_CACHE" == 1 ]
#then
# docker cp app:/$APP_NAME/node_modules .
#fi
18 changes: 18 additions & 0 deletions config/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
/**
* URL of Topcoder Community Website
*/
TOPCODER_COMMUNITY_WEBSITE_URL: "https://topcoder-dev.com",

/**
* URL of Topcoder Connect Website
*/
CONNECT_WEBSITE_URL: "https://connect.topcoder-dev.com",

API: {
V5: "https://api.topcoder-dev.com/v5",
V3: "https://api.topcoder-dev.com/v3",
},

COMMUNITY_ADMIN_URL: "https://tc-micro-community-admin.herokuapp.com",
};
14 changes: 14 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* global process */

module.exports = (() => {
const env = process.env.APPENV || "dev";

console.info(`APPENV: "${env}"`);

// for security reason don't let to require any arbitrary file defined in process.env
if (["prod", "dev"].indexOf(env) < 0) {
return require("./dev");
}

return require("./" + env);
})();
3 changes: 3 additions & 0 deletions config/local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
COMMUNITY_ADMIN_URL: "",
};
16 changes: 16 additions & 0 deletions config/prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
/**
* URL of Topcoder Community Website
*/
TOPCODER_COMMUNITY_WEBSITE_URL: "https://topcoder.com",

/**
* URL of Topcoder Connect Website
*/
CONNECT_WEBSITE_URL: "https://connect.topcoder.com",

API: {
V5: "https://api.topcoder.com/v5",
V3: "https://api.topcoder.com/v3",
},
};
14 changes: 14 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
rootDir: "src",
transform: {
"^.+\\.(j|t)sx?$": "babel-jest",
},
transformIgnorePatterns: ["node_modules/?!(react-avatar)"],
moduleNameMapper: {
"\\.(s?css)$": "identity-obj-proxy",
"\\.svg$": "<rootDir>/__mocks__/fileMock.js",
},
setupFilesAfterEnv: [
"../node_modules/@testing-library/jest-dom/dist/index.js",
],
};
16 changes: 16 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "es2017",
"baseUrl": ".",
"moduleResolution": "node",
"paths": {
"styles/*": ["./src/styles/*"],
"components/*": ["./src/components/*"],
"hooks/*": ["./src/hooks/*"],
"utils/*": ["./src/utils/*"],
"constants/*": ["./src/constants/*"],
"services/*": ["./src/services/*"]
}
},
"exclude": ["node_modules", "dist"]
}
Loading