Skip to content

Commit 13ee2dc

Browse files
committed
split constants in separate files by branch
1 parent 7fec01b commit 13ee2dc

File tree

6 files changed

+142
-155
lines changed

6 files changed

+142
-155
lines changed

config/constants.js

Lines changed: 0 additions & 144 deletions
This file was deleted.

config/constants/dev.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module.exports = {
2+
API_URL : 'https://api.topcoder-dev.com/v3',
3+
API_URL_V2 : 'https://api.topcoder-dev.com/v2',
4+
WORK_API_URL : 'https://api-work.topcoder-dev.com/v3',
5+
INTERNAL_API_URL : 'https://internal-api.topcoder-dev.com/v3',
6+
ASSET_PREFIX : 'https://s3.amazonaws.com/app.topcoder-dev.com/',
7+
AUTH_API_URL : 'https://api.topcoder-dev.com/v3',
8+
auth0Callback : 'https://api.topcoder-dev.com/pub/callback.html',
9+
auth0Domain : 'topcoder-dev.auth0.com',
10+
clientId : process.env.AUTH0_CLIENT_ID_DEV,
11+
AUTH0_DOMAIN : 'topcoder-dev.auth0.com',
12+
AUTH0_CLIENT_ID : process.env.AUTH0_CLIENT_ID_DEV,
13+
domain : 'topcoder-dev.com',
14+
DOMAIN : 'topcoder-dev.com',
15+
ENV : 'DEV',
16+
17+
NEW_RELIC_APPLICATION_ID: process.env.TRAVIS_BRANCH ? '8957921' : '',
18+
19+
ARENA_URL : '//arena.topcoder-dev.com',
20+
BLOG_LOCATION : 'https://www.topcoder-dev.com/feed/',
21+
COMMUNITY_URL : '//community.topcoder-dev.com',
22+
FORUMS_APP_URL : '//apps.topcoder-dev.com/forums',
23+
HELP_APP_URL : 'help.topcoder-dev.com',
24+
MAIN_URL : 'https://www.topcoder-dev.com',
25+
PHOTO_LINK_LOCATION: 'https://community.topcoder-dev.com',
26+
SWIFT_PROGRAM_URL : 'apple.topcoder-dev.com',
27+
TCO16_URL : 'http://tco16.topcoder-dev.com',
28+
TCO17_URL : 'http://tco17.topcoder-dev.com',
29+
TCO_HOME_URL : 'https://www.topcoder-dev.com/tco',
30+
31+
ACCOUNTS_APP_URL : 'https://accounts.topcoder-dev.com/#!/member',
32+
ACCOUNTS_APP_CONNECTOR_URL : 'https://accounts.topcoder-dev.com/connector.html',
33+
34+
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY_DEV,
35+
FILE_PICKER_SUBMISSION_CONTAINER_NAME: 'submission-staging-dev',
36+
37+
SALESFORCE_PROJECT_LEAD_LINK: 'https://c.cs18.visual.force.com/apex/ConnectLead?connectProjectId=',
38+
39+
CONNECT_SEGMENT_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n',
40+
PREDIX_PROGRAM_ID : 3448,
41+
IBM_COGNITIVE_PROGRAM_ID : 3449,
42+
HEAP_ANALYTICS_APP_ID : '4153837120'
43+
}

config/constants/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = (() => {
2+
const branch = process.env.CIRCLE_BRANCH || 'dev'
3+
4+
// for security reason don't let to require any arbitrary file defined in process.env
5+
if (['dev', 'master', 'qa'].indexOf(branch) < 0) {
6+
throw Error('Unsupported CIRCLE_BRANCH value.')
7+
}
8+
9+
return require('./' + branch)
10+
})()

config/constants/master.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module.exports = {
2+
API_URL : 'https://api.topcoder.com/v3',
3+
API_URL_V2 : 'https://api.topcoder.com/v2',
4+
WORK_API_URL : 'https://api-work.topcoder.com/v3',
5+
INTERNAL_API_URL : 'https://internal-api.topcoder.com/v3',
6+
ASSET_PREFIX : 'https://s3.amazonaws.com/app.topcoder.com/',
7+
AUTH_API_URL : 'https://api.topcoder.com/v3',
8+
auth0Callback : 'https://api.topcoder.com/pub/callback.html',
9+
auth0Domain : 'topcoder.auth0.com',
10+
clientId : process.env.AUTH0_CLIENT_ID_PROD,
11+
AUTH0_DOMAIN : 'topcoder.auth0.com',
12+
AUTH0_CLIENT_ID : process.env.AUTH0_CLIENT_ID_PROD,
13+
domain : 'topcoder.com',
14+
DOMAIN : 'topcoder.com',
15+
ENV : 'PROD',
16+
NODE_ENV : 'production',
17+
18+
NEW_RELIC_APPLICATION_ID: process.env.TRAVIS_BRANCH ? '11352758' : '',
19+
20+
ARENA_URL : '//arena.topcoder.com',
21+
BLOG_LOCATION : 'https://www.topcoder.com/feed/',
22+
COMMUNITY_URL : '//community.topcoder.com',
23+
FORUMS_APP_URL : '//apps.topcoder.com/forums',
24+
HELP_APP_URL : 'help.topcoder.com',
25+
MAIN_URL : 'https://www.topcoder.com',
26+
PHOTO_LINK_LOCATION: 'https://community.topcoder.com',
27+
SWIFT_PROGRAM_URL : 'apple.topcoder.com',
28+
TCO16_URL : 'http://tco16.topcoder.com',
29+
TCO17_URL : 'http://tco17.topcoder.com',
30+
TCO_HOME_URL : 'https://www.topcoder.com/tco',
31+
32+
ACCOUNTS_APP_URL : 'https://accounts.topcoder.com/#!/member',
33+
ACCOUNTS_APP_CONNECTOR_URL : 'https://accounts.topcoder.com/connector.html',
34+
35+
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY_PROD,
36+
FILE_PICKER_SUBMISSION_CONTAINER_NAME: 'submission-staging-prod',
37+
38+
SALESFORCE_PROJECT_LEAD_LINK: 'https://topcoder.my.salesforce.com/apex/ConnectLead?connectProjectId=',
39+
CONNECT_SEGMENT_KEY: 'ajP6cQ5SN2EMUWoWTOLROVnAHsOlsDCn',
40+
PREDIX_PROGRAM_ID : 3448,
41+
IBM_COGNITIVE_PROGRAM_ID : 3449,
42+
HEAP_ANALYTICS_APP_ID : '638908330'
43+
}

config/constants/qa.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module.exports = {
2+
API_URL : 'https://api.topcoder-qa.com/v3',
3+
API_URL_V2 : 'https://api.topcoder-qa.com/v2',
4+
WORK_API_URL : 'https://api-work.topcoder-qa.com/v3',
5+
INTERNAL_API_URL : 'https://internal-api.topcoder-qa.com/v3',
6+
ASSET_PREFIX : 'https://s3.amazonaws.com/app.topcoder-qa.com/',
7+
AUTH_API_URL : 'https://api.topcoder-qa.com/v3',
8+
auth0Callback : 'https://api.topcoder-qa.com/pub/callback.html',
9+
auth0Domain : 'topcoder-qa.auth0.com',
10+
clientId : process.env.AUTH0_CLIENT_ID_QA,
11+
AUTH0_DOMAIN : 'topcoder-qa.auth0.com',
12+
AUTH0_CLIENT_ID : process.env.AUTH0_CLIENT_ID_QA,
13+
domain : 'topcoder-qa.com',
14+
DOMAIN : 'topcoder-qa.com',
15+
ENV : 'QA',
16+
17+
NEW_RELIC_APPLICATION_ID: process.env.TRAVIS_BRANCH ? '11199233' : '',
18+
19+
ARENA_URL : '//arena.topcoder-qa.com',
20+
BLOG_LOCATION : 'https://www.topcoder-qa.com/feed/',
21+
COMMUNITY_URL : '//community.topcoder-qa.com',
22+
FORUMS_APP_URL : '//apps.topcoder-qa.com/forums',
23+
HELP_APP_URL : 'help.topcoder-qa.com',
24+
MAIN_URL : 'https://www.topcoder-qa.com',
25+
PHOTO_LINK_LOCATION: 'https://community.topcoder-qa.com',
26+
SWIFT_PROGRAM_URL : 'apple.topcoder-qa.com',
27+
TCO16_URL : 'http://tco16.topcoder-qa.com',
28+
TCO17_URL : 'http://tco17.topcoder-qa.com',
29+
TCO_HOME_URL : 'https://www.topcoder-dev.com/tco',
30+
31+
ACCOUNTS_APP_URL : 'https://accounts.topcoder-qa.com/#!/member',
32+
ACCOUNTS_APP_CONNECTOR_URL : 'https://accounts.topcoder-qa.com/connector.html',
33+
34+
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY_QA,
35+
FILE_PICKER_SUBMISSION_CONTAINER_NAME: 'submission-staging-qa',
36+
37+
SALESFORCE_PROJECT_LEAD_LINK: 'https://c.cs18.visual.force.com/apex/ConnectLead?connectProjectId=',
38+
CONNECT_SEGMENT_KEY: '',
39+
PREDIX_PROGRAM_ID : 3448,
40+
IBM_COGNITIVE_PROGRAM_ID : 3449,
41+
HEAP_ANALYTICS_APP_ID : '4153837120'
42+
}

config/webpack/default.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
'use strict'
22

33
const _ = require('lodash')
4-
const path = require('path')
5-
const webpack = require('webpack')
4+
const path = require('path')
5+
const webpack = require('webpack')
66
const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
77
const ExtractCssChunks = require('extract-css-chunks-webpack-plugin')
88
const HtmlWebpackPlugin = require('html-webpack-plugin')
99

10-
const constants = require('../constants.js')
11-
12-
const branch = process.env.CIRCLE_BRANCH
13-
let env = 'DEV' // Default to DEV
14-
if (branch === 'master') env = 'PROD'
15-
if (branch === 'dev') env = 'DEV'
16-
if (branch === 'qa') env = 'QA'
17-
const envConstants = constants(env)
10+
const constants = require('../constants')
1811

1912
const dirname = path.resolve(__dirname, '../..')
2013

@@ -102,7 +95,7 @@ module.exports = {
10295

10396
plugins: [
10497
new webpack.DefinePlugin({
105-
'process.env': _.mapValues(envConstants, (value) => JSON.stringify(value))
98+
'process.env': _.mapValues(constants, (value) => JSON.stringify(value))
10699
}),
107100
new FaviconsWebpackPlugin({
108101
logo: './src/favicon.png',

0 commit comments

Comments
 (0)