summaryrefslogtreecommitdiffstats
path: root/js/Gruntfile.js
blob: 79c11908787fb8c7b7aae095c35c35cdc2a2bf87 (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
/**
 * ownCloud - News
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Bernhard Posselt <dev@bernhard-posselt.com>
 * @copyright Bernhard Posselt 2012, 2014
 */
module.exports = function (grunt) {
    'use strict';

    // load needed modules
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-phpunit');
    grunt.loadNpmTasks('grunt-wrap');
    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-ng-annotate');
    grunt.loadNpmTasks('grunt-protractor-runner');
    grunt.loadNpmTasks('grunt-protractor-webdriver');

    grunt.initConfig({
        meta: {
            pkg: grunt.file.readJSON('package.json'),
            version: '<%= meta.pkg.version %>',
            production: 'build/'
        },
        concat: {
            options: {
                // remove license headers
                stripBanners: true
            },
            dist: {
                src: [
                    'app/App.js',
                    'app/Config.js',
                    'app/Run.js',
                    'controller/**/*.js',
                    'filter/**/*.js',
                    'service/**/*.js',
                    'gui/**/*.js',
                    'utility/**/*.js',
                    'directive/**/*.js'
                ],
                dest: '<%= meta.production %>app.js'
            }
        },
        ngAnnotate: {
            app: {
                src: ['<%= meta.production %>app.js'],
                dest: '<%= meta.production %>app.js'
            }
        },
        uglify: {
            app: {
                files: {
                    '<%= meta.production %>app.min.js':
                        ['<%= meta.production %>app.js']
                }
            }
        },
        wrap: {
            basic: {
                src: ['<%= meta.production %>app.js'],
                dest: '<%= meta.production %>app.js',
                options: {
                    wrapper: [
                        '(function(window, document, angular, $, OC, ' +
                            'csrfToken, undefined){\n\n\'use strict\';\n\n',

                        '\n})(window, document, angular, jQuery, OC, ' +
                            'oc_requesttoken);'
                    ]
                }
            }
        },
        jshint: {
            app: {
                src: [
                    'app/Config.js',
                    'app/Run.js',
                    'filter/**/*.js',
                    'service/**/*.js',
                    'controller/**/*.js',
                    'directive/**/*.js',
                    'tests/**/*.js',
                    'gui/**/*.js'
                ]
            },
            options: {
                jshintrc: true
            }
        },
        watch: {
            concat: {
                files: [
                    'tests/**/*.js',
                    'app/**/*.js',
                    'controller/**/*.js',
                    'utility/**/*.js',
                    'directive/**/*.js',
                    'filter/**/*.js',
                    'service/**/*.js',
                    'gui/**/*.js',
                    '../templates/**/*.php'
                ],
                tasks: ['default'],
                options: {
                    livereload: true
                }
            },
            phpunit: {
                files: [
                    '../**/*.php'
                ],
                tasks: ['phpunit']
            }
        },
        karma: {
            unit: {
                configFile: 'karma.conf.js',
                autoWatch: true
            },
            continuous: {
                configFile: 'karma.conf.js',
                browsers: ['Firefox'],
                singleRun: true,
            }
        },
        phpunit: {
            classes: {
                dir: '../tests'
            },
            options: {
                colors: true,
                configuration: '../phpunit.xml'
            }
        },
        protractor_webdriver: {
            app: {

            }
        },
        protractor: {
            firefox: {
                options: {
                    configFile: 'protractor.conf.js'
                }
            },
        },
        connect: {
            server: {
                options: {
                    base: 'tests/static/'
                }
            }
        }
    });

    // make tasks available under simpler commands
    grunt.registerTask('default', ['jshint', 'concat',  'wrap', 'ngAnnotate',
                                   'uglify']);
    grunt.registerTask('dev', ['watch:concat']);
    grunt.registerTask('test', ['karma:unit']);
    grunt.registerTask('php', ['watch:phpunit']);
    grunt.registerTask('e2e', ['protractor_webdriver', 'connect',
                               'protractor']);
    grunt.registerTask('ci-unit', ['default', 'karma:continuous']);
    grunt.registerTask('ci-e2e', ['protractor_webdriver', 'connect',
                                  'protractor']);
};