forked from overleaf/web
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.coffee
202 lines (179 loc) · 5.68 KB
/
Gruntfile.coffee
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
fs = require "fs"
module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-less'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-mocha-test'
grunt.loadNpmTasks 'grunt-available-tasks'
grunt.loadNpmTasks 'grunt-contrib-requirejs'
grunt.loadNpmTasks 'grunt-execute'
grunt.loadNpmTasks 'grunt-bunyan'
grunt.initConfig
execute:
app:
src: "app.js"
coffee:
app_dir:
expand: true,
flatten: false,
cwd: 'app/coffee',
src: ['**/*.coffee'],
dest: 'app/js/',
ext: '.js'
app:
src: 'app.coffee'
dest: 'app.js'
BackgroundJobsWorker:
src: 'BackgroundJobsWorker.coffee'
dest: 'BackgroundJobsWorker.js'
sharejs:
options:
join: true
files:
"public/js/libs/sharejs.js": [
"public/coffee/editor/ShareJSHeader.coffee"
"public/coffee/editor/sharejs/types/helpers.coffee"
"public/coffee/editor/sharejs/types/text.coffee"
"public/coffee/editor/sharejs/types/text-api.coffee"
"public/coffee/editor/sharejs/types/json.coffee"
"public/coffee/editor/sharejs/types/json-api.coffee"
"public/coffee/editor/sharejs/client/microevent.coffee"
"public/coffee/editor/sharejs/client/doc.coffee"
"public/coffee/editor/sharejs/client/ace.coffee"
]
client:
expand: true,
flatten: false,
cwd: 'public/coffee',
src: ['**/*.coffee'],
dest: 'public/js/',
ext: '.js'
smoke_tests:
expand: true,
flatten: false,
cwd: 'test/smoke/coffee',
src: ['**/*.coffee'],
dest: 'test/smoke/js/',
ext: '.js'
unit_tests:
expand: true,
flatten: false,
cwd: 'test/UnitTests/coffee',
src: ['**/*.coffee'],
dest: 'test/UnitTests/js/',
ext: '.js'
less:
app:
files:
"public/stylesheets/mainStyle.css": "public/stylesheets/mainStyle.less"
requirejs:
compile:
options:
optimize:"uglify2"
uglify2:
mangle: false
appDir: "public/js"
baseUrl: "./"
dir: "public/minjs"
inlineText: false
preserveLicenseComments: false
paths:
"underscore": "libs/underscore"
"jquery": "libs/jquery"
"moment": "libs/moment"
shim:
"libs/backbone":
deps: ["libs/underscore"]
"libs/pdfListView/PdfListView":
deps: ["libs/pdf"]
"libs/pdf":
deps: ["libs/compatibility"]
skipDirOptimize: true
modules: [
{
name: "main",
exclude: ["jquery"]
}, {
name: "ide",
exclude: ["jquery"]
}, {
name: "home",
exclude: ["jquery"]
}, {
name: "list",
exclude: ["jquery"]
}
]
clean:
app: ["app/js"]
unit_tests: ["test/UnitTests/js"]
mochaTest:
unit:
src: ["test/UnitTests/js/#{grunt.option('feature') or '**'}/*.js"]
options:
reporter: grunt.option('reporter') or 'spec'
grep: grunt.option("grep")
smoke:
src: ['test/smoke/js/**/*.js']
options:
reporter: grunt.option('reporter') or 'spec'
grep: grunt.option("grep")
availabletasks:
tasks:
options:
filter: 'exclude',
tasks: [
'coffee'
'less'
'clean'
'mochaTest'
'availabletasks'
'wrap_sharejs'
'requirejs'
'execute'
'bunyan'
]
groups:
"Compile tasks": [
"compile:server"
"compile:client"
"compile:tests"
"compile"
"compile:unit_tests"
"compile:smoke_tests"
"compile:css"
"compile:minify"
"install"
]
"Test tasks": [
"test:unit"
]
"Run tasks": [
"run"
"default"
]
"Misc": [
"help"
]
grunt.registerTask 'wrap_sharejs', 'Wrap the compiled ShareJS code for AMD module loading', () ->
content = fs.readFileSync "public/js/libs/sharejs.js"
fs.writeFileSync "public/js/libs/sharejs.js", """
define(["ace/range"], function() {
#{content}
return window.sharejs;
});
"""
grunt.registerTask 'help', 'Display this help list', 'availabletasks'
grunt.registerTask 'compile:server', 'Compile the server side coffee script', ['clean:app', 'coffee:app', 'coffee:app_dir']
grunt.registerTask 'compile:client', 'Compile the client side coffee script', ['coffee:client', 'coffee:sharejs', 'wrap_sharejs']
grunt.registerTask 'compile:css', 'Compile the less files to css', ['less']
grunt.registerTask 'compile:minify', 'Concat and minify the client side js', ['requirejs']
grunt.registerTask 'compile:unit_tests', 'Compile the unit tests', ['clean:unit_tests', 'coffee:unit_tests']
grunt.registerTask 'compile:smoke_tests', 'Compile the smoke tests', ['coffee:smoke_tests']
grunt.registerTask 'compile:tests', 'Compile all the tests', ['compile:smoke_tests', 'compile:unit_tests']
grunt.registerTask 'compile', 'Compiles everything need to run web-sharelatex', ['compile:server', 'compile:client', 'compile:css']
grunt.registerTask 'install', "Compile everything when installing as an npm module", ['compile']
grunt.registerTask 'test:unit', 'Run the unit tests (use --grep=<regex> or --feature=<feature> for individual tests)', ['compile:server', 'compile:unit_tests', 'mochaTest:unit']
grunt.registerTask 'test:smoke', 'Run the smoke tests', ['compile:smoke_tests', 'mochaTest:smoke']
grunt.registerTask 'run', "Compile and run the web-sharelatex server", ['compile', 'bunyan', 'execute']
grunt.registerTask 'default', 'run'