aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/Gruntfile.coffee
blob: 845cfb3669428a81ebd6dc69bde7c92c1111e2c1 (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
module.exports = (grunt) ->
  grunt.loadNpmTasks('grunt-karma')
  grunt.loadNpmTasks('grunt-express-server')
  grunt.loadNpmTasks('grunt-casper')

  pkg = grunt.file.readJSON('package.json')

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

    less:
      dev:
        files:
          '<%= pkg.assets %>css/sonar.css': [
            '<%= pkg.sources %>less/yui-reset-font.less'
            '<%= pkg.sources %>less/jquery-ui.less'
            '<%= pkg.sources %>less/select2.less'
            '<%= pkg.sources %>less/select2-sonar.less'
            '<%= pkg.sources %>less/layout.less'
            '<%= pkg.sources %>less/style.less'
            '<%= pkg.sources %>less/icons.less'
            '<%= pkg.sources %>less/ui.less'
            '<%= pkg.sources %>less/sonar-colorizer.less'
            '<%= pkg.sources %>less/dashboard.less'
            '<%= pkg.sources %>less/select-list.less'
            '<%= pkg.sources %>less/navigator.less'
            '<%= pkg.sources %>less/*.less'
          ]
      build:
        options:
          cleancss: true
        files:
          '<%= pkg.assets %>css/sonar.css': [
            '<%= pkg.sources %>less/yui-reset-font.less'
            '<%= pkg.sources %>less/jquery-ui.less'
            '<%= pkg.sources %>less/select2.less'
            '<%= pkg.sources %>less/select2-sonar.less'
            '<%= pkg.sources %>less/layout.less'
            '<%= pkg.sources %>less/style.less'
            '<%= pkg.sources %>less/icons.less'
            '<%= pkg.sources %>less/ui.less'
            '<%= pkg.sources %>less/sonar-colorizer.less'
            '<%= pkg.sources %>less/dashboard.less'
            '<%= pkg.sources %>less/select-list.less'
            '<%= pkg.sources %>less/navigator.less'
            '<%= pkg.sources %>less/*.less'
          ]


    cssUrlRewrite:
      build:
        src: '<%= pkg.assets %>css/sonar.css'
        dest: '<%= 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: '<%= pkg.assets %>js'
          ext: '.js'
        ]


    concat:
      dev:
        files:
          '<%= pkg.assets %>js/sonar.js': [
            '<%= pkg.assets %>js/translate.js'
            '<%= pkg.assets %>js/third-party/jquery.js'
            '<%= pkg.assets %>js/third-party/jquery-ui.js'
            '<%= pkg.assets %>js/third-party/d3.js'
            '<%= pkg.assets %>js/third-party/underscore.js'
            '<%= pkg.assets %>js/third-party/select2.js'
            '<%= pkg.assets %>js/third-party/keymaster.js'
            '<%= pkg.assets %>js/select2-jquery-ui-fix.js'
            '<%= pkg.assets %>js/widgets/base.js'
            '<%= pkg.assets %>js/widgets/widget.js'
            '<%= pkg.assets %>js/widgets/bubble-chart.js'
            '<%= pkg.assets %>js/widgets/timeline.js'
            '<%= pkg.assets %>js/widgets/stack-area.js'
            '<%= pkg.assets %>js/widgets/pie-chart.js'
            '<%= pkg.assets %>js/widgets/histogram.js'
            '<%= pkg.assets %>js/widgets/word-cloud.js'
            '<%= pkg.assets %>js/widgets/treemap.js'
            '<%= pkg.assets %>js/top-search.js'
            '<%= pkg.assets %>js/sortable.js'
            '<%= pkg.assets %>js/common/inputs.js'
            '<%= pkg.assets %>js/common/dialogs.js'
            '<%= pkg.assets %>js/application.js'
            '<%= pkg.assets %>js/dashboard.js'
            '<%= pkg.assets %>js/duplication.js'
            '<%= pkg.assets %>js/resource.js'
            '<%= pkg.assets %>js/issue.js'
            '<%= pkg.assets %>js/recent-history.js'
            '<%= pkg.assets %>js/latinize.js'
          ]
      build:
        files:
          '<%= pkg.assets %>build/js/sonar.js': [
            '<%= pkg.assets %>js/translate.js'
            '<%= pkg.assets %>js/third-party/jquery.js'
            '<%= pkg.assets %>js/third-party/jquery-ui.js'
            '<%= pkg.assets %>js/third-party/d3.js'
            '<%= pkg.assets %>js/third-party/underscore.js'
            '<%= pkg.assets %>js/third-party/select2.js'
            '<%= pkg.assets %>js/third-party/keymaster.js'
            '<%= pkg.assets %>js/select2-jquery-ui-fix.js'
            '<%= pkg.assets %>js/widgets/base.js'
            '<%= pkg.assets %>js/widgets/widget.js'
            '<%= pkg.assets %>js/widgets/bubble-chart.js'
            '<%= pkg.assets %>js/widgets/timeline.js'
            '<%= pkg.assets %>js/widgets/stack-area.js'
            '<%= pkg.assets %>js/widgets/pie-chart.js'
            '<%= pkg.assets %>js/widgets/histogram.js'
            '<%= pkg.assets %>js/widgets/word-cloud.js'
            '<%= pkg.assets %>js/widgets/treemap.js'
            '<%= pkg.assets %>js/top-search.js'
            '<%= pkg.assets %>js/sortable.js'
            '<%= pkg.assets %>js/common/inputs.js'
            '<%= pkg.assets %>js/common/dialogs.js'
            '<%= pkg.assets %>js/application.js'
            '<%= pkg.assets %>js/dashboard.js'
            '<%= pkg.assets %>js/duplication.js'
            '<%= pkg.assets %>js/resource.js'
            '<%= pkg.assets %>js/issue.js'
            '<%= pkg.assets %>js/recent-history.js'
            '<%= pkg.assets %>js/latinize.js'
          ]


    requirejs:
      options:
        baseUrl: '<%= 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: '<%= pkg.assets %>build/js/quality-gate/app.js'

      codingRules: options:
        name: 'coding-rules/app'
        out: '<%= pkg.assets %>build/js/coding-rules/app.js'

      issues: options:
        name: 'issues/app'
        out: '<%= pkg.assets %>build/js/issues/app.js'

      measures: options:
        name: 'measures/app'
        out: '<%= pkg.assets %>build/js/measures/app.js'

      selectList: options:
        name: 'common/select-list'
        out: '<%= pkg.assets %>build/js/common/select-list.js'

      apiDocumentation: options:
        name: 'api-documentation/app'
        out: '<%= pkg.assets %>build/js/api-documentation/app.js'

      drilldown: options:
        name: 'drilldown/app'
        out: '<%= pkg.assets %>build/js/drilldown/app.js'

      dashboardFile: options:
        name: 'dashboard/file-app'
        out: '<%= pkg.assets %>build/js/dashboard/file-app.js'

      componentViewer: options:
        name: 'component-viewer/app'
        out: '<%= pkg.assets %>build/js/component-viewer/app.js'


    handlebars:
      options:
        amd: true
        namespace: 'SS.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:
          '<%= pkg.assets %>js/templates/navigator.js': [
            '<%= pkg.sources %>hbs/navigator/**/*.hbs'
          ]
          '<%= pkg.assets %>js/templates/coding-rules.js': [
            '<%= pkg.sources %>hbs/common/**/*.hbs'
            '<%= pkg.sources %>hbs/coding-rules/**/*.hbs'
          ]
          '<%= pkg.assets %>js/templates/quality-gates.js': [
            '<%= pkg.sources %>hbs/quality-gates/**/*.hbs'
          ]
          '<%= pkg.assets %>js/templates/component-viewer.js': [
            '<%= pkg.sources %>hbs/component-viewer/**/*.hbs'
          ]
          '<%= pkg.assets %>js/templates/issue.js': [
            '<%= pkg.sources %>hbs/common/**/*.hbs'
            '<%= pkg.sources %>hbs/issue/**/*.hbs'
          ]
          '<%= pkg.assets %>js/templates/issues.js': [
            '<%= pkg.sources %>hbs/issues/**/*.hbs'
          ]
          '<%= pkg.assets %>js/templates/api-documentation.js': [
            '<%= pkg.sources %>hbs/api-documentation/**/*.hbs'
          ]


    clean:
      options: {
        force: true
      },
      css: ['<%= pkg.assets %>css/']
      js: ['<%= pkg.assets %>js/']
      build: ['<%= pkg.assets %>build/']


    copy:
      js:
        expand: true, cwd: '<%= pkg.sources %>js/', src: ['**'], dest: '<%= pkg.assets %>js/'
      build:
        expand: true, cwd: '<%= pkg.assets %>build/js/', src: ['**'], dest: '<%= pkg.assets %>js/'
      requirejs:
        src: '<%= pkg.sources %>js/require.js', dest: '<%= pkg.assets %>js/require.js'


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


    casper:
      test:
        options:
          test: true
          'no-colors': true
        src: ['<%= pkg.sources %>js/tests/e2e/tests/**/*.js']
      cw:
        options:
          test: true
          'no-colors': true
        src: ['<%= pkg.sources %>js/tests/e2e/tests/component-viewer-spec.js']


    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'


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


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

  grunt.registerTask 'test', ['clean:js', 'coffee:build', 'handlebars:build', 'copy:js', 'concat:dev',
                              'express:test', 'casper:test']

  grunt.registerTask 'cw', ['clean:js', 'coffee:build', 'handlebars:build', 'copy:js', 'concat:dev',
                            'express:test', 'casper:cw']