aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/Gruntfile.coffee
blob: fbb1f883bc3efa55175aee96c9303cd620f53193 (plain)
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
module.exports = (grunt) ->
  pkg = grunt.file.readJSON('package.json')
  expressPort = '<%= grunt.option("port") || 3000 %>'

  grunt.initConfig
    pkg: grunt.file.readJSON('package.json')

    less:
      dev:
        files:
          '<%= grunt.option("assetsDir") || pkg.assets %>css/sonar.css': [
            '<%= pkg.sources %>less/jquery-ui.less'
            '<%= pkg.sources %>less/select2.less'
            '<%= pkg.sources %>less/select2-sonar.less'

            '<%= pkg.sources %>less/init.less'
            '<%= pkg.sources %>less/components.less'
            '<%= pkg.sources %>less/pages.less'

            '<%= pkg.sources %>less/style.less'

            '<%= pkg.sources %>less/*.less'
          ]
      build:
        options:
          cleancss: true
        files:
          '<%= grunt.option("assetsDir") || pkg.assets %>css/sonar.css': [
            '<%= pkg.sources %>less/jquery-ui.less'
            '<%= pkg.sources %>less/select2.less'
            '<%= pkg.sources %>less/select2-sonar.less'

            '<%= pkg.sources %>less/init.less'
            '<%= pkg.sources %>less/components.less'
            '<%= pkg.sources %>less/pages.less'

            '<%= pkg.sources %>less/style.less'

            '<%= pkg.sources %>less/*.less'
          ]


    cssUrlRewrite:
      build:
        src: '<%= grunt.option("assetsDir") || pkg.assets %>css/sonar.css'
        dest: '<%= grunt.option("assetsDir") || pkg.assets %>css/sonar.css'
        options:
          skipExternal: true
          rewriteUrl: (url, options, dataURI) ->
            path = url.replace pkg.assets, ''
            if path.indexOf('data:') == 0
              "#{path}"
            else
              hash = require('crypto').createHash('md5').update(dataURI).digest('hex')
              "../#{path}?#{hash}"



    coffee:
      build:
        files: [
          expand: true
          cwd: '<%= pkg.sources %>coffee'
          src: ['**/*.coffee']
          dest: '<%= grunt.option("assetsDir") || pkg.assets %>js'
          ext: '.js'
        ]


    concat:
      dev:
        files:
          '<%= grunt.option("assetsDir") || pkg.assets %>js/sonar.js': [
            '<%= grunt.option("assetsDir") || pkg.assets %>js/translate.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/jquery.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/jquery-ui.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/d3.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/latinize.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/underscore.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/backbone.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/backbone.marionette.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/handlebars.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/underscore.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/select2.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/keymaster.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/moment.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/numeral.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/numeral-languages.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/bootstrap/tooltip.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/bootstrap/dropdown.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/select2-jquery-ui-fix.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/base.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/widget.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/bubble-chart.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/timeline.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/stack-area.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/pie-chart.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/histogram.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/word-cloud.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/tag-cloud.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/treemap.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/pie-chart.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/timeline.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/barchart.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/top-search.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/sortable.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/common/inputs.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/common/dialogs.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/common/processes.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/common/jquery-isolated-scroll.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/common/handlebars-extensions.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/application.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/csv.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/dashboard.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/recent-history.js'
          ]
      build:
        files:
          '<%= grunt.option("assetsDir") || pkg.assets %>build/js/sonar.js': [
            '<%= grunt.option("assetsDir") || pkg.assets %>js/translate.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/jquery.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/jquery-ui.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/d3.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/latinize.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/underscore.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/backbone.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/backbone.marionette.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/handlebars.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/underscore.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/select2.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/keymaster.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/moment.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/numeral.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/numeral-languages.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/bootstrap/tooltip.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/third-party/bootstrap/dropdown.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/select2-jquery-ui-fix.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/base.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/widget.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/bubble-chart.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/timeline.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/stack-area.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/pie-chart.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/histogram.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/word-cloud.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/tag-cloud.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/widgets/treemap.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/pie-chart.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/timeline.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/barchart.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/top-search.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/sortable.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/common/inputs.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/common/dialogs.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/common/processes.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/common/jquery-isolated-scroll.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/common/handlebars-extensions.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/application.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/csv.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/dashboard.js'
            '<%= grunt.option("assetsDir") || pkg.assets %>js/recent-history.js'
          ]


    requirejs:
      options:
        baseUrl: '<%= grunt.option("assetsDir") || pkg.assets %>js/'
        preserveLicenseComments: false
        optimize: 'none'

        paths:
          'backbone': 'third-party/backbone'
          'backbone.marionette': 'third-party/backbone.marionette'
          'handlebars': 'third-party/handlebars'
          'moment': 'third-party/moment'
          'select-list': 'common/select-list'
          'jquery.mockjax': 'third-party/jquery.mockjax'

        shim:
          'backbone.marionette':
            deps: ['backbone']
            exports: 'Marionette'
          'backbone': exports: 'Backbone'
          'handlebars': exports: 'Handlebars'
          'moment': exports: 'moment'
          'select-list': exports: 'SelectList'

      qualityGate: options:
        name: 'quality-gate/app'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/quality-gate/app.js'

      codingRules: options:
        name: 'coding-rules/app'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/coding-rules/app.js'

      issues: options:
        name: 'issues/app-new'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/issues/app-new.js'

      issuesContext: options:
        name: 'issues/app-context'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/issues/app-context.js'

      measures: options:
        name: 'measures/app'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/measures/app.js'

      selectList: options:
        name: 'common/select-list'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/common/select-list.js'

      apiDocumentation: options:
        name: 'api-documentation/app'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/api-documentation/app.js'

      drilldown: options:
        name: 'drilldown/app'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/drilldown/app.js'

      dashboard: options:
        name: 'dashboard/app'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/dashboard/app.js'

      sourceViewer: options:
        name: 'source-viewer/app'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/source-viewer/app.js'

      design: options:
        name: 'design/app'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/design/app.js'

      libraries: options:
        name: 'libraries/app'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/libraries/app.js'

      monitoring: options:
        name: 'analysis-reports/app'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/analysis-reports/app.js'

      nav: options:
        name: 'nav/app'
        out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/nav/app.js'


    handlebars:
      options:
        namespace: 'Templates'
        processName: (name) ->
          pieces = name.split '/'
          fileName = pieces[pieces.length - 1]
          fileName.split('.')[0]
        processPartialName: (name) ->
          pieces = name.split '/'
          fileName = pieces[pieces.length - 1]
          fileName.split('.')[0]

      build:
        files:
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/navigator.js': [
            '<%= pkg.sources %>hbs/navigator/**/*.hbs'
          ]
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/coding-rules.js': [
            '<%= pkg.sources %>hbs/common/**/*.hbs'
            '<%= pkg.sources %>hbs/coding-rules/**/*.hbs'
          ]
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/quality-gates.js': [
            '<%= pkg.sources %>hbs/quality-gates/**/*.hbs'
          ]
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/source-viewer.js': [
            '<%= pkg.sources %>hbs/source-viewer/**/*.hbs'
          ]
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/issue.js': [
            '<%= pkg.sources %>hbs/common/**/*.hbs'
            '<%= pkg.sources %>hbs/issue/**/*.hbs'
          ]
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/issues.js': [
            '<%= pkg.sources %>hbs/issues/**/*.hbs'
          ]
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/api-documentation.js': [
            '<%= pkg.sources %>hbs/api-documentation/**/*.hbs'
          ]
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/design.js': [
            '<%= pkg.sources %>hbs/design/**/*.hbs'
          ]
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/libraries.js': [
            '<%= pkg.sources %>hbs/libraries/**/*.hbs'
          ]
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/dashboard.js': [
            '<%= pkg.sources %>hbs/dashboard/**/*.hbs'
          ]
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/analysis-reports.js': [
            '<%= pkg.sources %>hbs/analysis-reports/**/*.hbs'
          ]
          '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/nav.js': [
            '<%= pkg.sources %>hbs/nav/**/*.hbs'
          ]


    clean:
      options:
        force: true
      css: ['<%= grunt.option("assetsDir") || pkg.assets %>css/']
      js: ['<%= grunt.option("assetsDir") || pkg.assets %>js/']
      build: ['<%= grunt.option("assetsDir") || pkg.assets %>build/']


    copy:
      js:
        expand: true, cwd: '<%= pkg.sources %>js/', src: ['**'], dest: '<%= grunt.option("assetsDir") || pkg.assets %>js/'
      build:
        expand: true, cwd: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/', src: ['**'], dest: '<%= grunt.option("assetsDir") || pkg.assets %>js/'
      requirejs:
        src: '<%= pkg.sources %>js/require.js', dest: '<%= grunt.option("assetsDir") || pkg.assets %>js/require.js'


    express:
      test:
        options:
          script: '<%= pkg.sources %>js/tests/e2e/server.js'
          port: expressPort
      dev:
        options:
          background: false
          script: '<%= pkg.sources %>js/tests/e2e/server.js'


    casper:
      test:
        options:
          test: true
          'no-colors': true
          'fail-fast': true
          concise: true
          parallel: true
          port: expressPort
        src: ['<%= pkg.sources %>js/tests/e2e/tests/**/*.js']
      single:
        options:
          test: true
          verbose: true
          'fail-fast': true
          port: expressPort
        src: ['<%= pkg.sources %>js/tests/e2e/tests/<%= grunt.option("spec") %>-spec.js']
      testfile:
        options:
          test: true
          verbose: true
          'fail-fast': true
          port: expressPort
        src: ['<%= grunt.option("file") %>']


    uglify:
      build:
        files: [
          expand: true
          cwd: '<%= grunt.option("assetsDir") || pkg.assets %>js'
          src: ['**/*.js']
          dest: '<%= grunt.option("assetsDir") || pkg.assets %>js'
          ext: '.js'
        ]


    jshint:
      dev:
        src: [
          '<%= pkg.sources %>js/**/*.js'
          '!<%= pkg.sources %>js/third-party/underscore.js'
          '!<%= pkg.sources %>js/third-party/**/*.js'
          '!<%= pkg.sources %>js/tests/**/*.js'
          '!<%= pkg.sources %>js/require.js'
        ]
        options:
          jshintrc: true


    watch:
      options:
        spawn: false

      less:
        files: '<%= pkg.sources %>less/**/*.less'
        tasks: ['less:dev']

      coffee:
        files: '<%= pkg.sources %>coffee/**/*.coffee'
        tasks: ['coffee:build', 'copy:js', 'concat:dev']

      js:
        files: '<%= pkg.sources %>js/**/*.js'
        tasks: ['copy:js', 'concat:dev']

      handlebars:
        files: '<%= pkg.sources %>hbs/**/*.hbs'
        tasks: ['handlebars:build']



  # Load grunt-contrib-* plugins
  grunt.loadNpmTasks 'grunt-contrib-less'
  grunt.loadNpmTasks 'grunt-css-url-rewrite'
  grunt.loadNpmTasks 'grunt-contrib-coffee'
  grunt.loadNpmTasks 'grunt-contrib-uglify'
  grunt.loadNpmTasks 'grunt-contrib-requirejs'
  grunt.loadNpmTasks 'grunt-contrib-handlebars'
  grunt.loadNpmTasks 'grunt-contrib-watch'
  grunt.loadNpmTasks 'grunt-contrib-clean'
  grunt.loadNpmTasks 'grunt-contrib-copy'
  grunt.loadNpmTasks 'grunt-contrib-concat'
  grunt.loadNpmTasks 'grunt-contrib-jshint'
  grunt.loadNpmTasks 'grunt-express-server'
  grunt.loadNpmTasks 'grunt-casper'


  # Define tasks
  grunt.registerTask 'dev',
      ['clean:css', 'clean:js', 'less:dev', 'coffee:build', 'handlebars:build', 'copy:js', 'concat:dev']

  grunt.registerTask 'build',
      ['clean:css', 'clean:js', 'less:build', 'cssUrlRewrite:build', 'coffee:build', 'handlebars:build', 'copy:js',
       'concat:build', 'requirejs', 'clean:js', 'copy:build', 'copy:requirejs', 'uglify:build', 'clean:build']

  grunt.registerTask 'default',
      ['build']

  grunt.registerTask 'test',
      ['dev', 'express:test', 'casper:test']

  grunt.registerTask 'single',
      ['dev', 'express:test', 'casper:single']

  grunt.registerTask 'testfile',
      ['dev', 'express:test', 'casper:testfile']

  # tasks used by Maven build (see pom.xml)
  grunt.registerTask 'maven-build-skip-tests-true',
      ['build']

  grunt.registerTask 'maven-build-skip-tests-false',
      ['test', 'build']