-
Notifications
You must be signed in to change notification settings - Fork 32
/
Gruntfile.js
268 lines (263 loc) · 12.8 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/*
* Copyright (C) 2014 TopCoder Inc., All Rights Reserved.
*/
/**
* This module defines the grunt tasks used for packaging the application.
*
* Changes in version 1.1 (Module Assembly - Web Arena UI - Phase I Bug Fix):
* - Updated the logics for CSS bundles for different themes.
* app/css/app.css contains the layout styles.
* app/css/darkTheme.css and app/css/topcoder.css contain the dark theme colors.
* app/css/light/lightTheme.css and app/css/topcoder.css contain the light theme colors.
* bundle.css wraps app/css/app.css and dark theme related files.
* bundle-light.css wraps app/css/app.css and light theme related files.
* - Fixed JSLint issues.
*
* Changes in version 1.2 (Module Assembly - Web Arena UI - Contest Creation Wizard):
* - Added jwt token setting.
*
* Changes in version 1.3 (Module Assembly - Web Arena - Local Chat Persistence):
* - Added LOCAL_STORAGE_EXPIRE_TIME setting.
*
* Changes in version 1.4 (PoC Assembly - Share Member Status To Facebook and Twitter):
* - Added Facebook API Client ID to the configuration.
* - Added additional information to the configuration to handle social network messages.
*
* Changes in version 1.5 (PoC Assembly - Invite friends To Participate On A Match From Facebook and Twitter):
* - Added facebook / twitter related setting.
*
* Changes in version 1.6 (Module Assembly - Web Arena UI - Match Summary Widget):
* - Added SUMMARY_TOPCODER_COUNT setting to limit number of coders in match summary leaderboard table.
*
* Changes in version 1.7 (Module Assembly - Practice Problem Listing Page):
* - Added PRACTICE_PROBLEM_LIST_PAGE_SIZE setting.
*
* Changes in version 1.8 (Member Feedback Widget Assembly):
* - Added FEEDBACK_SPREADSHEET_URL setting.
* - Added FEEDBACK_MAXLENGTH for feedback text
*
* Changes in version 1.9 (PoC Assembly - Web Arena - Chat Widget Improvement):
* - Added CHAT_ICON_DISAPPEAR_TIME setting.
*
* Changes in version 1.10 (Module Assembly - Web Arena - Challenges Advertising Widget):
* - Added TC_HOSTNAME and CHALLENGE_ADVERTISING_UPDATE
* to handle showing and updating challenge advertising data.
*
* @author amethystlei, flytoj2ee, dexy, shubhendus
* @version 1.10
*/
'use strict';
/*global module, process*/
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
s3: {
options: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_ACCESS_KEY,
bucket: process.env.AWS_BUCKET,
access: 'public-read',
gzip: false
},
deploy: {
cwd: 'build/',
src: '**',
dest: process.env.AWS_FOLDER
}
},
clean : {
build: ['build/'],
release: ['release/']
},
replace : {
build: {
options: {
patterns: [
{ match : 'AUTH0_CLIENT_ID', replacement: process.env.AUTH0_CLIENT_ID },
{ match : 'AUTH0_DOMAIN', replacement: process.env.AUTH0_DOMAIN },
{ match : 'AUTH0_CONNECTION', replacement: process.env.AUTH0_CONNECTION },
{ match : 'CALLBACK_URL', replacement: process.env.CALLBACK_URL },
{ match : 'CHALLENGE_ADVERTISING_INTERVAL', replacement: process.env.CHALLENGE_ADVERTISING_INTERVAL },
{ match : 'CHALLENGE_ADVERTISING_UPDATE', replacement: process.env.CHALLENGE_ADVERTISING_UPDATE },
{ match : 'WEB_SOCKET_URL', replacement: process.env.WEB_SOCKET_URL },
{ match : 'API_DOMAIN', replacement: process.env.API_DOMAIN },
{ match : 'SSO_KEY', replacement: process.env.SSO_KEY },
{ match : 'STATIC_FILE_HOST', replacement: process.env.STATIC_FILE_HOST },
{ match : 'GOOGLE_ANALYTICS_TRACKING_ID', replacement: process.env.GOOGLE_ANALYTICS_TRACKING_ID },
{ match : 'CONNECTION_TIMEOUT', replacement: process.env.CONNECTION_TIMEOUT },
{ match : 'MEMBER_PHOTO_HOST', replacement: process.env.MEMBER_PHOTO_HOST },
{ match : 'JWT_TOKEN', replacement: process.env.JWT_TOKEN },
{ match : 'CHAT_LENGTH', replacement: process.env.CHAT_LENGTH },
{ match : 'LOCAL_STORAGE_EXPIRE_TIME', replacement: process.env.LOCAL_STORAGE_EXPIRE_TIME },
{ match : 'FACEBOOK_API_ID', replacement: process.env.FACEBOOK_API_ID },
{ match : 'SOCIAL_STATUS_TEMPLATE', replacement: process.env.SOCIAL_STATUS_TEMPLATE },
{ match : 'SOCIAL_ARENA_URL', replacement: process.env.SOCIAL_ARENA_URL },
{ match : 'SOCIAL_ARENA_DESCRIPTION', replacement: process.env.SOCIAL_ARENA_DESCRIPTION },
{ match : 'SOCIAL_ARENA_TITLE', replacement: process.env.SOCIAL_ARENA_TITLE },
{ match : 'TWEET_TEXT', replacement: process.env.TWEET_TEXT },
{ match : 'TWEET_URL', replacement: process.env.TWEET_URL },
{ match : 'FACEBOOK_LINK', replacement: process.env.FACEBOOK_LINK },
{ match : 'DIVISION_LEADERBOARD_LIMIT', replacement: process.env.DIVISION_LEADERBOARD_LIMIT },
{ match : 'SUMMARY_TOPCODER_COUNT', replacement: process.env.SUMMARY_TOPCODER_COUNT },
{ match : 'PRACTICE_PROBLEM_LIST_PAGE_SIZE', replacement: process.env.PRACTICE_PROBLEM_LIST_PAGE_SIZE },
{ match : 'REGISTRATION_URL', replacement: process.env.REGISTRATION_URL },
{ match : 'SPINNER_TIMEOUT', replacement: process.env.SPINNER_TIMEOUT },
{ match : 'FEEDBACK_SPREADSHEET_URL', replacement: process.env.FEEDBACK_SPREADSHEET_URL },
{ match : 'FEEDBACK_MAXLENGTH', replacement: process.env.FEEDBACK_MAXLENGTH },
{ match : 'KEYBOARD_SHORTCUT', replacement: process.env.KEYBOARD_SHORTCUT },
{ match : 'CHAT_ICON_DISAPPEAR_TIME', replacement: process.env.CHAT_ICON_DISAPPEAR_TIME },
{ match : 'TC_HOSTNAME', replacement: process.env.TC_HOSTNAME }
]
},
files : [
{ src: 'app/js/config.def.js', dest: 'app/js/config.js' }
]
},
cdn: {
options: {
patterns: [
{ match : 'STATIC_FILE_HOST', replacement: process.env.STATIC_FILE_HOST },
{ match : 'GOOGLE_ANALYTICS_TRACKING_ID', replacement: process.env.GOOGLE_ANALYTICS_TRACKING_ID }
]
},
files: [
{ expand: true, cwd: 'app/', src: '**/*.html', dest: 'build/' },
{ expand: true, cwd: 'app/data', src: '**/*.json', dest: 'build/data' }
]
}
},
browserify: {
build: {
// A single entry point for our app
src: 'app/js/app.js',
// Compile to a single file to add a script tag for in your HTML
dest: 'build/js/bundle.js'
}
},
cssmin: {
dark: {
src: [
'app/css/bootstrap.min.css',
'bower_components/codemirror/lib/codemirror.css',
'bower_components/codemirror/addon/fold/foldgutter.css',
'bower_components/fullcalendar/fullcalendar.css',
'thirdparty/jquery.qtip/jquery.qtip.min.css',
'thirdparty/ng-scrollbar/dist/ng-scrollbar.min.css',
'thirdparty/bootstrap-notify/css/bootstrap-notify.css',
'app/css/notifications.css',
'app/css/app.css',
'app/css/local.css',
'app/css/dark/topcoder.css',
'app/css/dark/darkTheme.css'
],
// Compile to a single file to add a script tag for in your HTML
dest: 'build/css/bundle.css'
},
light: {
files: {
'build/css/bundle-light.css': [
'app/css/bootstrap.min.css',
'bower_components/codemirror/lib/codemirror.css',
'bower_components/codemirror/addon/fold/foldgutter.css',
'bower_components/fullcalendar/fullcalendar.css',
'thirdparty/jquery.qtip/jquery.qtip.min.css',
'thirdparty/ng-scrollbar/dist/ng-scrollbar.min.css',
'thirdparty/bootstrap-notify/css/bootstrap-notify.css',
'app/css/notifications.css',
'app/css/app.css',
'app/css/local.css',
'app/css/light/topcoder.css',
'app/css/light/lightTheme.css'
]
}
},
orange: {
files: {
'build/css/bundle-orange.css': [
'app/css/bootstrap.min.css',
'bower_components/codemirror/lib/codemirror.css',
'bower_components/codemirror/addon/fold/foldgutter.css',
'bower_components/fullcalendar/fullcalendar.css',
'thirdparty/jquery.qtip/jquery.qtip.min.css',
'thirdparty/ng-scrollbar/dist/ng-scrollbar.min.css',
'thirdparty/bootstrap-notify/css/bootstrap-notify.css',
'app/css/notifications.css',
'app/css/app.css',
'app/css/local.css',
'app/css/orange/topcoder.css',
'app/css/orange/orangeTheme.css'
]
}
}
},
uglify: {
release: {
src: 'build/js/bundle.js',
dest: 'release/js/bundle.js'
}
},
copy: {
build: {
// This copies all the html and images into the build/ folder. css and js were done already.
expand: true,
cwd: 'app/',
src: ['**/*.html', 'img/**', 'fonts/**', 'data/**', 'robots.txt'],
dest: 'build/'
},
release: {
// This copies all the html, css and images into the release/ folder. js was done already.
expand: true,
cwd: 'build/',
src: ['**/*.html', 'img/**', 'css/**', 'fonts/**', 'data/**', 'robots.txt'],
dest: 'release/'
}
},
watch: {
dev: {
files: ['app/**', '!app/js/config.js'],
tasks: ['build']
}
},
compress: {
deploy: {
options: {
archive: './build.zip',
mode: 'zip'
},
files: [
{
expand: true,
cwd: './build',
src: '**'
}
]
}
},
jshint: {
all: ['Gruntfile.js', 'app/js/*.js'],
options: {
force: true
}
}
});
// Load the npm installed tasks
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-aws');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-jshint');
// The default tasks to run when you type: grunt
grunt.registerTask('default', ['clean:build', 'replace:build', 'browserify:build', 'cssmin:dark', 'cssmin:light', 'cssmin:orange', 'copy:build', 'replace:cdn']);
grunt.registerTask('build', ['clean:build', 'replace:build', 'browserify:build', 'cssmin:dark', 'cssmin:light', 'cssmin:orange', 'copy:build', 'replace:cdn']);
//release tasks work out of build directory - build must be run first!
grunt.registerTask('release', ['clean:release', 'uglify:release', 'copy:release']);
grunt.registerTask('heroku', ['build']);
grunt.registerTask('deploy-cdn', ['s3:deploy']);
grunt.registerTask('deploy-compress', ['compress:deploy']);
grunt.registerTask('jslint', ['jshint:all']);
};