Skip to content

Commit 6c69610

Browse files
committed
For topcoder-archive#469: Create private fork when users register
1 parent e294c62 commit 6c69610

26 files changed

+16669
-14275
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ root = true
22

33
[*]
44
indent_style = space
5-
indent_size = 4
5+
indent_size = 2
66
charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ Thumbs.db
4343

4444
src/public/
4545
.tmp
46+
47+
.env
48+
.envrc

gulp/browserify.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
var gulp = require('gulp');
1+
const gulp = require('gulp');
2+
const browserify = require('browserify');
3+
const uglify = require('gulp-uglify');
4+
const buffer = require('vinyl-buffer');
5+
const source = require('vinyl-source-stream');
6+
const gutil = require('gulp-util');
7+
const fs = require('fs');
8+
const { styles } = require('./styles');
29

3-
var paths = gulp.paths;
10+
const browserifyFn = () => {
11+
const cssFilePath = gulp.paths.tmp + '/serve/app/bundle.css';
412

5-
var browserify = require('browserify');
6-
var uglify = require('gulp-uglify');
7-
var buffer = require('vinyl-buffer');
8-
var source = require('vinyl-source-stream');
9-
var gutil = require('gulp-util');
10-
var fs = require('fs');
11-
12-
gulp.task('browserify', ['styles'], function () {
13-
14-
var cssFilePath = paths.tmp + '/serve/app/bundle.css';
15-
16-
//delete file if exist
13+
// Delete file if exists
1714
if (fs.existsSync(cssFilePath)) {
1815
fs.unlinkSync(cssFilePath);
1916
}
2017

21-
return browserify('./src/front/src/index.js')
18+
return browserify('./src/front/src/index.js')
2219
.transform(require('browserify-css'), {
2320
rootDir: 'src',
2421
debug: true,
@@ -30,12 +27,16 @@ gulp.task('browserify', ['styles'], function () {
3027
}
3128
})
3229
.bundle()
33-
.on('error', function (e) {
34-
gutil.log("Browserify Error", gutil.colors.red(e.message))
35-
})
36-
//Pass desired output filename to vinyl-source-stream
3730
.pipe(source('bundle.js'))
3831
.pipe(buffer())
3932
.pipe(uglify())
40-
.pipe(gulp.dest(paths.tmp + '/serve/app'))
41-
});
33+
.on('error', function (e) {
34+
gutil.log("Browserify Error", gutil.colors.red(e.message));
35+
})
36+
.pipe(gulp.dest(gulp.paths.tmp + '/serve/app'));
37+
};
38+
39+
const _browserify = gulp.series(styles, browserifyFn);
40+
gulp.task('browserify', _browserify);
41+
42+
module.exports = { browserify: _browserify }

gulp/build.js

Lines changed: 65 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
'use strict';
1+
const gulp = require('gulp');
2+
const eslint = require('gulp-eslint');
3+
const gulpIf = require('gulp-if');
4+
const { inject } = require('./inject')
25

3-
var gulp = require('gulp');
4-
var eslint = require('gulp-eslint');
6+
const paths = gulp.paths;
57

6-
var paths = gulp.paths;
7-
8-
var $ = require('gulp-load-plugins')({
8+
const $ = require('gulp-load-plugins')({
99
pattern: ['gulp-*', 'uglify-save-license', 'del']
1010
});
1111

12-
gulp.task('partials', function () {
12+
const partialsFn = () => {
1313
return gulp.src([
1414
paths.src + '/{app,components}/**/*.html',
1515
paths.tmp + '/{app,components}/**/*.html'
@@ -23,53 +23,49 @@ gulp.task('partials', function () {
2323
module: 'topcoderX'
2424
}))
2525
.pipe(gulp.dest(paths.tmp + '/partials/'));
26-
});
26+
}
27+
gulp.task('partials', partialsFn);
2728

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-
};
29+
const html = () => {
30+
return new Promise(async (resolve, reject) => {
31+
const partialsInjectFile = gulp.src(paths.tmp + '/partials/templateCacheHtml.js', { read: false });
32+
const partialsInjectOptions = {
33+
starttag: '<!-- inject:partials -->',
34+
ignorePath: paths.tmp + '/partials',
35+
addRootSlash: false
36+
};
37+
const rev = (await import('gulp-rev')).default;
3538

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-
});
39+
return gulp.src(paths.tmp + '/serve/*.html')
40+
.pipe($.inject(partialsInjectFile, partialsInjectOptions))
41+
.pipe($.useref())
42+
.pipe(rev())
43+
.pipe(gulpIf('**/*.js', $.ngAnnotate()))
44+
.pipe(gulpIf('**/*.js', $.uglify()))
45+
.pipe(gulpIf('**/*.css', $.replace(/\.?\.?\/node_modules\/\w+-?\/?\w+\/fonts\/?/g, '../fonts/')))
46+
.pipe(gulpIf('**/*.css', $.csso()))
47+
.pipe($.revReplace())
48+
.pipe(gulpIf('**/*.html', $.minifyHtml({
49+
empty: true,
50+
spare: true,
51+
quotes: true,
52+
conditionals: true
53+
})))
54+
.pipe(gulp.dest(paths.dist + '/'))
55+
.pipe($.size({ title: paths.dist + '/', showFiles: true }))
56+
.on('finish', resolve)
57+
.on('error', reject);
58+
});
59+
}
60+
gulp.task('html', gulp.series(inject, partialsFn, html));
6661

67-
gulp.task('images', function () {
62+
const images = () => {
6863
return gulp.src(paths.src + '/assets/images/**/*')
6964
.pipe(gulp.dest(paths.dist + '/assets/images/'));
70-
});
65+
}
66+
gulp.task('images', images);
7167

72-
gulp.task('fonts', function () {
68+
const fonts = () => {
7369
return gulp.src([
7470
"node_modules/bootstrap/dist/fonts/*.{eot,svg,ttf,woff,woff2}",
7571
"node_modules/footable/css/fonts/*.{eot,svg,ttf,woff,woff2}"
@@ -78,28 +74,34 @@ gulp.task('fonts', function () {
7874
.pipe($.flatten())
7975
.pipe(gulp.dest(paths.dist + '/fonts/'))
8076
.pipe(gulp.dest(paths.dist + '/styles/fonts/'));
81-
});
77+
}
78+
gulp.task('fonts', fonts);
8279

83-
gulp.task('fontawesome', function () {
80+
const fontAwesome = () => {
8481
return gulp.src('node_modules/font-awesome/fonts/*.{eot,svg,ttf,woff,woff2}')
8582
.pipe(gulp.dest(paths.dist + '/fonts/'));
86-
});
83+
}
84+
gulp.task('fontawesome', fontAwesome);
8785

88-
gulp.task('misc', function () {
86+
const misc = () => {
8987
return gulp.src(paths.src + '/**/*.ico')
9088
.pipe(gulp.dest(paths.dist + '/'));
91-
});
89+
}
90+
gulp.task('misc', misc);
9291

93-
gulp.task('clean', function (done) {
92+
const cleanFn = (done) => {
9493
$.del([paths.dist + '/', paths.tmp + '/', paths.src + '/app/config.js'], done);
95-
});
94+
}
95+
const clean = gulp.series(cleanFn);
96+
gulp.task('clean', cleanFn);
9697

97-
gulp.task('lint', () => {
98+
const lint = () => {
9899
// ESLint ignores files with "node_modules" paths.
99100
// So, it's best to have gulp ignore the directory as well.
100101
// Also, Be sure to return the stream from the task;
101102
// 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+
return gulp
104+
.src(['src/**/*.js', '!src/front/e2e/**/*.js', '!src/public/**', '!gulp/**', '!node_modules/**'])
103105
// eslint() attaches the lint output to the "eslint" property
104106
// of the file object so it can be used by other modules.
105107
.pipe(eslint({
@@ -111,7 +113,10 @@ gulp.task('lint', () => {
111113
// To have the process exit with an error code (1) on
112114
// lint error, return the stream and pipe to failAfterError last.
113115
.pipe(eslint.failAfterError());
114-
});
116+
}
117+
gulp.task('lint', lint);
118+
119+
const build = gulp.series(lint, html, images, fonts, fontAwesome, misc);
120+
gulp.task('build', build);
115121

116-
gulp.task('build', ['lint', 'html', 'images', 'fonts', 'fontawesome', 'misc']);
117-
gulp.task('build:watch', ['watch:build']);
122+
module.exports = { clean, build };

gulp/e2e-tests.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
'use strict';
1+
const gulp = require('gulp');
22

3-
var gulp = require('gulp');
3+
const $ = require('gulp-load-plugins')();
44

5-
var $ = require('gulp-load-plugins')();
5+
const browserSync = require('browser-sync').create();
66

7-
var browserSync = require('browser-sync');
8-
9-
var paths = gulp.paths;
7+
const paths = gulp.paths;
108

119
// Downloads the selenium webdriver
1210
gulp.task('webdriver-update', $.protractor.webdriver_update);
1311

1412
gulp.task('webdriver-standalone', $.protractor.webdriver_standalone);
1513

1614
function runProtractor (done) {
17-
1815
gulp.src(paths.e2e + '/**/*.js')
1916
.pipe($.protractor.protractor({
2017
configFile: 'src/front/protractor.conf.js',
@@ -30,6 +27,6 @@ function runProtractor (done) {
3027
});
3128
}
3229

33-
gulp.task('protractor', ['protractor:src']);
34-
gulp.task('protractor:src', ['serve:e2e', 'webdriver-update'], runProtractor);
35-
gulp.task('protractor:dist', ['serve:e2e-dist', 'webdriver-update'], runProtractor);
30+
gulp.task('protractor', gulp.series('protractor:src'));
31+
gulp.task('protractor:src', gulp.series('serve:e2e', 'webdriver-update', runProtractor));
32+
gulp.task('protractor:dist', gulp.series('serve:e2e-dist', 'webdriver-update', runProtractor));

gulp/inject.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1-
'use strict';
1+
const gulp = require('gulp');
2+
const { browserify } = require('./browserify');
23

3-
var gulp = require('gulp');
4+
const paths = gulp.paths;
45

5-
var paths = gulp.paths;
6+
const $ = require('gulp-load-plugins')();
67

7-
var $ = require('gulp-load-plugins')();
8-
9-
10-
gulp.task('inject', ['browserify'], function () {
11-
12-
var injectStyles = gulp.src([
8+
const injectFn = () => {
9+
const injectStyles = gulp.src([
1310
paths.tmp + '/serve/{app,components}/**/*.css',
1411
'!' + paths.tmp + '/serve/app/vendor.css'
1512
], { read: false });
1613

17-
var injectScripts = gulp.src([
14+
const injectScripts = gulp.src([
1815
paths.src + '/{app,components}/**/*.js',
1916
'!' + paths.src + '/{app,components}/**/*.spec.js',
2017
'!' + paths.src + '/{app,components}/**/*.mock.js'
2118
]).pipe($.angularFilesort());
2219

23-
var injectOptions = {
20+
const injectOptions = {
2421
ignorePath: [paths.src, paths.tmp + '/serve'],
2522
addRootSlash: false
2623
};
27-
24+
2825
return gulp.src(paths.src + '/*.html')
2926
.pipe($.inject(injectStyles, injectOptions))
3027
.pipe($.inject(injectScripts, injectOptions))
3128
.pipe(gulp.dest(paths.tmp + '/serve'));
29+
}
30+
31+
const inject = gulp.series(browserify, injectFn);
32+
gulp.task('inject', inject);
3233

33-
});
34+
module.exports = { inject }

gulp/proxy.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/*jshint unused:false */
2-
31
/***************
42
53
This file allow to configure a proxy system plugged into BrowserSync
@@ -13,21 +11,19 @@
1311
1412
***************/
1513

16-
'use strict';
17-
18-
var httpProxy = require('http-proxy');
19-
var chalk = require('chalk');
14+
const httpProxy = require('http-proxy');
15+
const chalk = require('chalk');
2016

2117
/*
2218
* Location of your backend server
2319
*/
24-
var proxyTarget = 'http://server/context/';
20+
const proxyTarget = 'http://server/context/';
2521

26-
var proxy = httpProxy.createProxyServer({
22+
const proxy = httpProxy.createProxyServer({
2723
target: proxyTarget
2824
});
2925

30-
proxy.on('error', function(error, req, res) {
26+
proxy.on('error', function (error, req, res) {
3127
res.writeHead(500, {
3228
'Content-Type': 'text/plain'
3329
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy