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

Commit 7a1d0ba

Browse files
committed
January 2019 release challenge
#125 #118 #107 #119 #109 #115
1 parent e607354 commit 7a1d0ba

29 files changed

+354
-253
lines changed

TopcoderXDeploy.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Sample from our local development environment:
3838
AWS_ACCESS_KEY_ID: 'FAKE_ACCESS_KEY_ID'
3939
AWS_SECRET_ACCESS_KEY: 'FAKE_SECRET_ACCESS_KEY'
4040
AWS_REGION: 'FAKE_REGION'
41-
IS_LOCAL: 'true'
41+
IS_LOCAL: true
4242
```
4343
## Kafka
4444

@@ -88,12 +88,12 @@ To this:
8888

8989
## Local DNS setup
9090

91-
For login to work, your local Topcoder-X-UI deployment needs to have a `*.topcoder-dev.com` DNS name. Our development environment uses `x.topcoder-dev.com`. But for local setup it's better to use another one to not interfere with the one deployed on DEV Topcoder environment. So better to use `topcoderx.topcoder-dev.com` which is already configured in `config.js`.
91+
For login to work, your local Topcoder-X-UI deployment needs to have a `*.topcoder-dev.com` DNS name. Our development environment uses `x.topcoder-dev.com`
9292

9393
You can make this change in your local `/etc/hosts` file.
9494

9595
```
96-
127.0.0.1 topcoderx.topcoder-dev.com
96+
127.0.0.1 x.topcoder-dev.com
9797
```
9898

9999
You can login with one of these sample accounts:
@@ -185,7 +185,7 @@ TOPIC: topcoder-x
185185
AWS_ACCESS_KEY_ID: FAKE_ACCESS_KEY_ID
186186
AWS_SECRET_ACCESS_KEY: FAKE_SECRET_ACCESS_KEY
187187
AWS_REGION: FAKE_REGION
188-
IS_LOCAL: 'true'
188+
IS_LOCAL: true
189189
```
190190

191191
#### Topcoder-X receiver
@@ -203,7 +203,7 @@ TOPIC: topcoder-x
203203
AWS_ACCESS_KEY_ID: FAKE_ACCESS_KEY_ID
204204
AWS_SECRET_ACCESS_KEY: FAKE_SECRET_ACCESS_KEY
205205
AWS_REGION: FAKE_REGION
206-
IS_LOCAL: 'true'
206+
IS_LOCAL: true
207207
```
208208

209209
#### Topcoder-X UI
@@ -229,5 +229,7 @@ WEBSITE: https://x.topcoder-dev.com
229229
AWS_ACCESS_KEY_ID: FAKE_ACCESS_KEY_ID
230230
AWS_SECRET_ACCESS_KEY: FAKE_SECRET_ACCESS_KEY
231231
AWS_REGION: FAKE_REGION
232-
IS_LOCAL: 'true'
232+
IS_LOCAL: true
233+
TC_LOGIN_URL: https://accounts.topcoder-dev.com/member
234+
TC_USER_PROFILE_URL: https://api.topcoder-dev.com/v2/user/profile
233235
```

configuration.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
1+
12
# Topcoder X Configuration
23

34
The following config parameters are supported, they are defined in `src/config.js` and can be configured as env variables:
45

56

6-
| Name | Description | Default |
7+
| Name | Description | Default |
78
| :------------------------------------- | :----------------------------------------: | :------------------------------: |
8-
| PORT | the port the application will listen on | 80 |
9-
| API_VERSION | the API version | v1 |
10-
| LOG_LEVEL | the log level | info |
11-
| SESSION_SECRET | the session secret | kjsdfkj34857 |
12-
| GITHUB_CLIENT_ID | the GitHub client id | No default - needs to be set up using the instructions below |
13-
| GITHUB_CLIENT_SECRET | the GitHub client secret | No default - needs to be set up using the instructions below |
14-
| GITLAB_CLIENT_ID | the GitLab client id | No default - needs to be set up using the instructions below |
15-
| GITLAB_CLIENT_SECRET | the GitLab client secret | No default - needs to be set up using the instructions below |
16-
| WEBSITE | used as base to construct various URLs | http://topcoderx.topcoder-dev.com/ |
17-
| GITLAB_API_BASE_URL | The Gitlab API base URL | https://gitlab.com|
9+
| PORT | the port the application will listen on | 80 |
10+
| API_VERSION | the API version | v1 |
11+
| LOG_LEVEL | the log level | info |
12+
| SESSION_SECRET | the session secret | kjsdfkj34857 |
13+
| GITHUB_CLIENT_ID | the GitHub client id | No default - needs to be set up using the instructions below |
14+
| GITHUB_CLIENT_SECRET | the GitHub client secret | No default - needs to be set up using the instructions below |
15+
| GITLAB_CLIENT_ID | the GitLab client id | No default - needs to be set up using the instructions below |
16+
| GITLAB_CLIENT_SECRET | the GitLab client secret | No default - needs to be set up using the instructions below |
17+
| WEBSITE | used as base to construct various URLs | http://topcoderx.topcoder-dev.com/ |
18+
| GITLAB_API_BASE_URL | The Gitlab API base URL | https://gitlab.com|
1819
|TOPIC | The Kafka topic where events are published. This must be the same as the configured value for topcoder-x-processor| |
19-
|KAFKA_OPTIONS | Kafka connection options| |
20+
|KAFKA_OPTIONS | Kafka connection options| |
2021
|KAFKA_HOST | The Kafka host to connect to| localhost:9092 |
2122
|KAFKA_CLIENT_CERT | The Kafka SSL certificate to use when connecting| Read from kafka_client.cer file, but this can be set as a string like it is on Heroku |
2223
|KAFKA_CLIENT_CERT_KEY | The Kafka SSL certificate key to use when connecting| Read from kafka_client.key file, but this can be set as a string like it is on Heroku|
23-
| HOOK_BASE_URL | The base URL of the topcoder-x-receiver, used when adding webhooks automatically to repositories | |
24+
| HOOK_BASE_URL | The base URL of the topcoder-x-receiver, used when adding webhooks automatically to repositories | |
2425
| TOPCODER_ENV | The topcoder environment to use, can support 'dev' or 'prod' | 'dev' |
2526
|LABELS| Labels we are going to add to the repository in the form of array of object with `name` and `color` property. Color should be hex code without hash||
2627
|ALLOWED_TOPCODER_ROLES| The allowed Topcoder role to use Topcoder X app| see configuration |
2728
|COPILOT_ROLE| The role to identify copilot|'copilot'|
2829
|HELP_LINK| The link for help| 'https://github.com/topcoder-platform/topcoder-x-ui/wiki'|
29-
|ADMINISTRATOR_ROLES| The array of roles to be considered as admin| `['administrator', 'admin']`|
30+
|ADMINISTRATOR_ROLES| The array of roles to be considered as admin| `['administrator', 'admin']`|
3031
|AWS_ACCESS_KEY_ID | The Amazon certificate key to use when connecting. Use local dynamodb you can set fake value|FAKE_ACCESS_KEY_ID |
3132
|AWS_SECRET_ACCESS_KEY | The Amazon certificate access key to use when connecting. Use local dynamodb you can set fake value|FAKE_SECRET_ACCESS_KEY |
3233
|AWS_REGION | The Amazon certificate region to use when connecting. Use local dynamodb you can set fake value|FAKE_REGION |
33-
|IS_LOCAL | Use Amazon DynamoDB Local or server. |'false' |
34+
|IS_LOCAL | Use Amazon DynamoDB Local or server. |true |
35+
|TC_LOGIN_URL | TC login url | |
36+
|TC_USER_PROFILE_URL | TC user profile url | |
3437

3538
## GitHub OAuth App Setup
3639

@@ -56,7 +59,7 @@ These instructions should be used to generate the GITLAB_CLIENT_ID and GITLAB_CL
5659
- Enter an application name, e.g. `Topcoder-X`
5760
- For Redirect URI, enter two callback URLs, one callback URL per line, so there are two lines:
5861
http://topcoderx.topcoder-dev.com/api/v1/gitlab/owneruser/callback
59-
http://topcoderx.topcoder-dev.com/api/v1/gitlab/normaluser/callback
62+
http://topcoderx.topcoder-dev.com/api/v1/gitlab/normaluser/callback
6063
- For Scopes, check the `api` and `read_user`, the `api` is for owner user, the `read_user` is for normal user
6164
- Finally, click `Save application` to save the OAuth app, then you will see its generated Application Id and Secret,
6265
these should be set to GITLAB_CLIENT_ID and GITLAB_CLIENT_SECRET environment variables

gulp/build.js

Lines changed: 117 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,117 @@
1-
'use strict';
2-
3-
var gulp = require('gulp');
4-
var eslint = require('gulp-eslint');
5-
6-
var paths = gulp.paths;
7-
8-
var $ = require('gulp-load-plugins')({
9-
pattern: ['gulp-*', 'uglify-save-license', 'del']
10-
});
11-
12-
gulp.task('partials', function () {
13-
return gulp.src([
14-
paths.src + '/{app,components}/**/*.html',
15-
paths.tmp + '/{app,components}/**/*.html'
16-
])
17-
.pipe($.minifyHtml({
18-
empty: true,
19-
spare: true,
20-
quotes: true
21-
}))
22-
.pipe($.angularTemplatecache('templateCacheHtml.js', {
23-
module: 'topcoderX'
24-
}))
25-
.pipe(gulp.dest(paths.tmp + '/partials/'));
26-
});
27-
28-
gulp.task('html', ['inject', 'partials'], function () {
29-
var partialsInjectFile = gulp.src(paths.tmp + '/partials/templateCacheHtml.js', { read: false });
30-
var partialsInjectOptions = {
31-
starttag: '<!-- inject:partials -->',
32-
ignorePath: paths.tmp + '/partials',
33-
addRootSlash: false
34-
};
35-
36-
var htmlFilter = $.filter('*.html');
37-
var jsFilter = $.filter('**/*.js');
38-
var cssFilter = $.filter('**/*.css');
39-
var assets;
40-
41-
return gulp.src(paths.tmp + '/serve/*.html')
42-
.pipe($.inject(partialsInjectFile, partialsInjectOptions))
43-
.pipe(assets = $.useref.assets())
44-
.pipe($.rev())
45-
.pipe(jsFilter)
46-
.pipe($.ngAnnotate())
47-
.pipe($.uglify({ preserveComments: $.uglifySaveLicense }))
48-
.pipe(jsFilter.restore())
49-
.pipe(cssFilter)
50-
.pipe($.replace(/\.?\.?\/node_modules\/\w+-?\/?\w+\/fonts\/?/g, '../fonts/'))
51-
.pipe($.csso())
52-
.pipe(cssFilter.restore())
53-
.pipe(assets.restore())
54-
.pipe($.useref())
55-
.pipe($.revReplace())
56-
.pipe(htmlFilter)
57-
.pipe($.minifyHtml({
58-
empty: true,
59-
spare: true,
60-
quotes: true
61-
}))
62-
.pipe(htmlFilter.restore())
63-
.pipe(gulp.dest(paths.dist + '/'))
64-
.pipe($.size({ title: paths.dist + '/', showFiles: true }));
65-
});
66-
67-
gulp.task('images', function () {
68-
return gulp.src(paths.src + '/assets/images/**/*')
69-
.pipe(gulp.dest(paths.dist + '/assets/images/'));
70-
});
71-
72-
gulp.task('fonts', function () {
73-
return gulp.src([
74-
"node_modules/bootstrap/dist/fonts/*.{eot,svg,ttf,woff,woff2}",
75-
"node_modules/footable/css/fonts/*.{eot,svg,ttf,woff,woff2}"
76-
])
77-
.pipe($.filter('**/*.{eot,svg,ttf,woff,woff2}'))
78-
.pipe($.flatten())
79-
.pipe(gulp.dest(paths.dist + '/fonts/'))
80-
.pipe(gulp.dest(paths.dist + '/styles/fonts/'));
81-
});
82-
83-
gulp.task('fontawesome', function () {
84-
return gulp.src('node_modules/font-awesome/fonts/*.{eot,svg,ttf,woff,woff2}')
85-
.pipe(gulp.dest(paths.dist + '/fonts/'));
86-
});
87-
88-
gulp.task('misc', function () {
89-
return gulp.src(paths.src + '/**/*.ico')
90-
.pipe(gulp.dest(paths.dist + '/'));
91-
});
92-
93-
gulp.task('clean', function (done) {
94-
$.del([paths.dist + '/', paths.tmp + '/', paths.src + '/app/config.js'], done);
95-
});
96-
97-
gulp.task('lint', () => {
98-
// ESLint ignores files with "node_modules" paths.
99-
// So, it's best to have gulp ignore the directory as well.
100-
// Also, Be sure to return the stream from the task;
101-
// Otherwise, the task may end before the stream has finished.
102-
return gulp.src(['src/**/*.js', '!src/front/e2e/**/*.js', '!src/public/**', '!gulp/**', '!node_modules/**'])
103-
// eslint() attaches the lint output to the "eslint" property
104-
// of the file object so it can be used by other modules.
105-
.pipe(eslint({
106-
fix: true
107-
}))
108-
// eslint.format() outputs the lint results to the console.
109-
// Alternatively use eslint.formatEach() (see Docs).
110-
.pipe(eslint.format())
111-
// To have the process exit with an error code (1) on
112-
// lint error, return the stream and pipe to failAfterError last.
113-
.pipe(eslint.failAfterError());
114-
});
115-
116-
gulp.task('build', ['lint', 'html', 'images', 'fonts', 'fontawesome', 'misc']);
117-
gulp.task('build:watch', ['watch:build']);
1+
'use strict';
2+
3+
var gulp = require('gulp');
4+
var eslint = require('gulp-eslint');
5+
6+
var paths = gulp.paths;
7+
8+
var $ = require('gulp-load-plugins')({
9+
pattern: ['gulp-*', 'uglify-save-license', 'del']
10+
});
11+
12+
gulp.task('partials', function () {
13+
return gulp.src([
14+
paths.src + '/{app,components}/**/*.html',
15+
paths.tmp + '/{app,components}/**/*.html'
16+
])
17+
.pipe($.minifyHtml({
18+
empty: true,
19+
spare: true,
20+
quotes: true
21+
}))
22+
.pipe($.angularTemplatecache('templateCacheHtml.js', {
23+
module: 'topcoderX'
24+
}))
25+
.pipe(gulp.dest(paths.tmp + '/partials/'));
26+
});
27+
28+
gulp.task('html', ['inject', 'partials'], function () {
29+
var partialsInjectFile = gulp.src(paths.tmp + '/partials/templateCacheHtml.js', { read: false });
30+
var partialsInjectOptions = {
31+
starttag: '<!-- inject:partials -->',
32+
ignorePath: paths.tmp + '/partials',
33+
addRootSlash: false
34+
};
35+
36+
var htmlFilter = $.filter('*.html');
37+
var jsFilter = $.filter('**/*.js');
38+
var cssFilter = $.filter('**/*.css');
39+
var assets;
40+
41+
return gulp.src(paths.tmp + '/serve/*.html')
42+
.pipe($.inject(partialsInjectFile, partialsInjectOptions))
43+
.pipe(assets = $.useref.assets())
44+
.pipe($.rev())
45+
.pipe(jsFilter)
46+
.pipe($.ngAnnotate())
47+
.pipe($.uglify({ preserveComments: $.uglifySaveLicense }))
48+
.pipe(jsFilter.restore())
49+
.pipe(cssFilter)
50+
.pipe($.replace(/\.?\.?\/node_modules\/\w+-?\/?\w+\/fonts\/?/g, '../fonts/'))
51+
.pipe($.csso())
52+
.pipe(cssFilter.restore())
53+
.pipe(assets.restore())
54+
.pipe($.useref())
55+
.pipe($.revReplace())
56+
.pipe(htmlFilter)
57+
.pipe($.minifyHtml({
58+
empty: true,
59+
spare: true,
60+
quotes: true
61+
}))
62+
.pipe(htmlFilter.restore())
63+
.pipe(gulp.dest(paths.dist + '/'))
64+
.pipe($.size({ title: paths.dist + '/', showFiles: true }));
65+
});
66+
67+
gulp.task('images', function () {
68+
return gulp.src(paths.src + '/assets/images/**/*')
69+
.pipe(gulp.dest(paths.dist + '/assets/images/'));
70+
});
71+
72+
gulp.task('fonts', function () {
73+
return gulp.src([
74+
"node_modules/bootstrap/dist/fonts/*.{eot,svg,ttf,woff,woff2}",
75+
"node_modules/footable/css/fonts/*.{eot,svg,ttf,woff,woff2}"
76+
])
77+
.pipe($.filter('**/*.{eot,svg,ttf,woff,woff2}'))
78+
.pipe($.flatten())
79+
.pipe(gulp.dest(paths.dist + '/fonts/'))
80+
.pipe(gulp.dest(paths.dist + '/styles/fonts/'));
81+
});
82+
83+
gulp.task('fontawesome', function () {
84+
return gulp.src('node_modules/font-awesome/fonts/*.{eot,svg,ttf,woff,woff2}')
85+
.pipe(gulp.dest(paths.dist + '/fonts/'));
86+
});
87+
88+
gulp.task('misc', function () {
89+
return gulp.src(paths.src + '/**/*.ico')
90+
.pipe(gulp.dest(paths.dist + '/'));
91+
});
92+
93+
gulp.task('clean', function (done) {
94+
$.del([paths.dist + '/', paths.tmp + '/', paths.src + '/app/config.js'], done);
95+
});
96+
97+
gulp.task('lint', () => {
98+
// ESLint ignores files with "node_modules" paths.
99+
// So, it's best to have gulp ignore the directory as well.
100+
// Also, Be sure to return the stream from the task;
101+
// Otherwise, the task may end before the stream has finished.
102+
return gulp.src(['src/**/*.js', '!src/front/e2e/**/*.js', '!src/public/**', '!gulp/**', '!node_modules/**'])
103+
// eslint() attaches the lint output to the "eslint" property
104+
// of the file object so it can be used by other modules.
105+
.pipe(eslint({
106+
fix: true
107+
}))
108+
// eslint.format() outputs the lint results to the console.
109+
// Alternatively use eslint.formatEach() (see Docs).
110+
.pipe(eslint.format())
111+
// To have the process exit with an error code (1) on
112+
// lint error, return the stream and pipe to failAfterError last.
113+
.pipe(eslint.failAfterError());
114+
});
115+
116+
gulp.task('build', ['ng-config', 'lint', 'html', 'images', 'fonts', 'fontawesome', 'misc']);
117+
gulp.task('build:watch', ['watch:build']);

gulp/ng-config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
var gulp = require('gulp');
4+
5+
var gulpNgConfig = require('gulp-ng-config');
6+
7+
var paths = gulp.paths;
8+
9+
gulp.task('ng-config', function () {
10+
gulp.src('src/front/config.json')
11+
.pipe(
12+
gulpNgConfig('app.constants', {
13+
environment: process.env.BUILD_ENV || 'dev',
14+
}))
15+
.pipe(gulp.dest(paths.src + '/app/'))
16+
});

src/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ _.forEach(routes, (verbs, path) => {
6161
}
6262
req.session.tcLoginReturnUrl = req.originalUrl;
6363
const callbackUri = `${config.WEBSITE}${constants.TC_LOGIN_CALLBACK_URL}`;
64-
return res.redirect(`${constants.TOPCODER_VALUES[config.TOPCODER_ENV].TC_LOGIN_URL}?retUrl=${encodeURIComponent(callbackUri)}`);
64+
return res.redirect(`${config.TOPCODER_VALUES[config.TOPCODER_ENV].TC_LOGIN_URL}?retUrl=${encodeURIComponent(callbackUri)}`);
6565
});
6666
}
6767
if (!def.allowNormalUser) {

0 commit comments

Comments
 (0)