source: Dev/trunk/Gruntfile.js @ 487

Last change on this file since 487 was 487, checked in by hendrikvanantwerpen, 11 years ago

Completed migration to API, without CouchDB proxy.

Move to API is now completed. The full API is password protected, a very
limited API is exposed for respondents, which works with secrets that
are passed in URLs.

Serverside the HTTPResult class was introduced, which is similar to
Promises, but specifically for HTTP. It carries a status code and
response and makes it easier to extract parts of async handling in
separate functions.

Fixed a bug in our schema (it seems optional attributes don't exist but
a required list does). Verification of our schema by grunt-tv4 didn't
work yet. Our schema is organized the wrong way (this is fixable),
but the json-schema schema has problems with simple types and $refs.

File size: 5.6 KB
Line 
1/** Gruntfile - control build and deploy tasks
2 */
3
4var _ = require('underscore');
5
6module.exports = function(grunt) {
7
8    // TASKS
9
10    grunt.registerTask('default', ['compile']);
11    grunt.registerTask('compile', ['svn-ignore:compile'
12                                  ,'jshint:lint-sources'
13                                  ,'htmlhint:lint'
14                                  ,'coffeelint:lint'
15                                  //,'tv4:lint'
16                                  ,'less:compile'
17                                  ,'usebanner:generated-css'
18                                  ,'coffee:compile'
19                                  ,'usebanner:generated-js'
20                                  ,'jshint:lint-generated'
21                                //,'amd-check' // too smart about plugins, r.js can't find them
22                                  ]);
23    grunt.registerTask('build', ['compile'
24                                ,'clean:build'
25                                ,'copy:build'
26                                ,'dojo:build'
27                                ]);
28
29    // FILES AND FOLDERS
30   
31    var srcDir   = 'src/';
32    var buildDir = 'build/';
33    var coffeeMap = grunt.file.expandMapping(
34        [ 'client/qed-client/**/*.coffee', 'server/**/*.coffee' ],
35        srcDir,
36        { cwd: srcDir, ext: '.js' });
37    var lessMap = grunt.file.expandMapping(
38        [ 'client/qed-client/css/qed.less' ],
39        srcDir,
40        { cwd: srcDir, ext: '.css' });
41
42    // TASK CONFIG
43   
44    grunt.initConfig({
45        'amd-check': {
46            files: [ srcDir+'client/qed-client/**/*.js' ]
47        },
48        clean: {
49            build: { src: [buildDir] }
50        },
51        coffee: {
52            options: { bare: true },
53            compile: { files: coffeeMap }
54        },
55        coffeelint: {
56            lint: { options: require('./'+srcDir+'.coffeelint.json'),
57                    files: coffeeMap }
58        },
59        copy: {
60            build: { files: [{ expand: true,
61                               cwd: srcDir,
62                               src: ['**', '!client/*/**' ],
63                               dest: buildDir }]}
64        },
65        dojo: {
66            build: { options: { dojo: srcDir+'client/dojo/dojo.js',
67                                profile: srcDir+'client/client.profile.js',
68                                releaseDir: '../../'+buildDir }}
69        },
70        htmlhint: {
71            options: { htmlhintrc: srcDir+".htmlhintrc" },
72            lint: { files: [{ expand: true,
73                              cwd: srcDir,
74                              src: ['client/*.html', 'client/qed-client/**/*.html'] }]}
75        },
76        jshint: {
77            'lint-sources': { options: { jshintrc: srcDir+".jshintrc" },
78                              files: { src: [ srcDir+'client/qed-client/**/*.js', srcDir+'server/**/*.js' ].concat(exclude(dest(coffeeMap))) }},
79            'lint-generated': { options: { jshintrc: srcDir+".jshintrc-generated" },
80                                files: { src: dest(coffeeMap) }}
81        },
82        less: {
83            options: { strictImports: false,
84                       dumpLineNumbers: "all" },
85            compile: { files: lessMap }
86        },
87        requirejs: {
88            basePath: srcDir+'client/',
89            packages: [
90                { name: "dojo", location: "dojo" },
91                { name: "dijit", location: "dijit" },
92                { name: "dojox", location: "dojox" },
93                { name: "qed-client", location: "qed-client" }
94            ]
95        },
96        'svn-ignore': {
97            compile: {
98                files: { src: dest(coffeeMap).concat(dest(lessMap)) }
99            }
100        },
101        'svn-ignore-clean': {
102            clean: {
103                files: [{
104                    expand: true,
105                    cwd: srcDir,
106                    src: ['**', '!node_modules/**', '!client/dojo/**', '!client/dijit/**', '!client/dojox/**', '!client/util/**'],
107                    filter: 'isDirectory'
108                }]
109            }
110        },
111        tv4: {
112            lint: {
113                options: {
114                    root: grunt.file.readJSON('json-schema-draft-04.json'),
115                    multi: true
116                },
117                src: [srcDir+'server/config/couchdb-schema.json']
118            }
119        },
120        usebanner: {
121            'generated-css': { options: { position: 'top',
122                                          banner: '/* This CSS file is generated. All edits will be lost on recompile. */'},
123                               files: { src: dest(lessMap) }},
124            'generated-js': { options: { position: 'top',
125                                         banner: '/* This JS file is generated, All edits will be lost on recompile. */'},
126                               files: { src: dest(coffeeMap) }}
127        }
128    });
129
130    // LOAD TASKS
131
132    grunt.loadNpmTasks('grunt-amd-check');
133    grunt.loadNpmTasks('grunt-banner');
134    grunt.loadNpmTasks('grunt-coffeelint');
135    grunt.loadNpmTasks('grunt-contrib-clean');
136    grunt.loadNpmTasks('grunt-contrib-coffee');
137    grunt.loadNpmTasks('grunt-contrib-copy');
138    grunt.loadNpmTasks('grunt-contrib-jshint');
139    grunt.loadNpmTasks('grunt-contrib-less');
140    grunt.loadNpmTasks('grunt-dojo');
141    grunt.loadNpmTasks('grunt-htmlhint');
142    grunt.loadNpmTasks('grunt-tv4');
143    grunt.loadTasks('./grunt-tasks');
144
145    // UTIL FUNCTIONS
146
147    function dest(files) {
148        return _.chain(files)
149            .map(function(item){ return item.dest; })
150            .flatten()
151            .value();
152    }
153
154    function exclude(dest) {
155        return _.map(dest, function(dest){ return '!'+dest; });
156    }
157   
158};
Note: See TracBrowser for help on using the repository browser.