|
| 1 | +module.exports = function(grunt) { |
| 2 | + require('load-grunt-tasks')(grunt); |
| 3 | + var path = require('path'); |
| 4 | + var buildDir = 'build'; |
| 5 | + var installDir = 'install'; |
| 6 | + |
| 7 | + grunt.initConfig({ |
| 8 | + pkg: grunt.file.readJSON('package.json'), |
| 9 | + watch: { |
| 10 | + concat_debug: { |
| 11 | + files: ['<%= concat.debug.src %>'], |
| 12 | + tasks: ['concat:debug'] |
| 13 | + }, |
| 14 | + ts_listcontrol_debug: { |
| 15 | + files: ['<%= ts.listcontrol_debug.src %>'], |
| 16 | + tasks: ['ts:listcontrol_debug'] |
| 17 | + }, |
| 18 | + ts_debug: { |
| 19 | + files: ['<%= ts.debug.src %>'], |
| 20 | + tasks: ['ts:debug'] |
| 21 | + }, |
| 22 | + ts_test: { |
| 23 | + files: ['<%= ts.test.src %>'], |
| 24 | + tasks: ['ts:test'] |
| 25 | + }, |
| 26 | + less: { |
| 27 | + files: ['src/assets/less/listcontrol.less'], |
| 28 | + tasks: ['less:debug'] |
| 29 | + }, |
| 30 | + copy: { |
| 31 | + files: [ |
| 32 | + 'src/htmls/**/*', |
| 33 | + 'lib/**/*', |
| 34 | + 'build/js/**/*.js', |
| 35 | + 'build/assets/css/**/*.css', |
| 36 | + ], |
| 37 | + tasks: ['copy:install', 'jasmine_node'] |
| 38 | + }, |
| 39 | + configFiles: { |
| 40 | + files: ['Gruntfile.js'], |
| 41 | + options: { |
| 42 | + reload: true, |
| 43 | + }, |
| 44 | + }, |
| 45 | + }, |
| 46 | + copy: { |
| 47 | + install: { |
| 48 | + files: [ |
| 49 | + { |
| 50 | + expand: true, |
| 51 | + cwd: 'src/htmls', |
| 52 | + src: ['**/*'], |
| 53 | + dest: path.join(installDir), |
| 54 | + filter: 'isFile' |
| 55 | + }, |
| 56 | + { |
| 57 | + expand: true, |
| 58 | + cwd: 'lib', |
| 59 | + src: ['*'], |
| 60 | + dest: path.join(installDir, 'lib'), |
| 61 | + filter: 'isFile' |
| 62 | + }, |
| 63 | + { |
| 64 | + expand: true, |
| 65 | + cwd: 'lib/bower', |
| 66 | + src: ['**/*'], |
| 67 | + dest: path.join(installDir, 'lib'), |
| 68 | + filter: 'isFile' |
| 69 | + }, |
| 70 | + { |
| 71 | + expand: true, |
| 72 | + src: ['test/**/*.js'], |
| 73 | + dest: path.join(installDir, 'js'), |
| 74 | + filter: 'isFile' |
| 75 | + }, |
| 76 | + { |
| 77 | + expand: true, |
| 78 | + cwd: 'build', |
| 79 | + src: ['js/**/*.js', 'assets/css/**/*.css'], |
| 80 | + dest: path.join(installDir), |
| 81 | + filter: 'isFile' |
| 82 | + }, |
| 83 | + ] |
| 84 | + } |
| 85 | + }, |
| 86 | + bower: { |
| 87 | + install: { |
| 88 | + options: { |
| 89 | + targetDir: './lib/bower', |
| 90 | + cleanup: true, |
| 91 | + }, |
| 92 | + }, |
| 93 | + }, |
| 94 | + clean: ['build', 'install'], |
| 95 | + karma: { |
| 96 | + unit: { |
| 97 | + configFile: 'karma.config.js', |
| 98 | + singleRun: true, |
| 99 | + browsers: ['Chrome', 'IE', 'FireFox'] |
| 100 | + } |
| 101 | + }, |
| 102 | + jasmine_node: { |
| 103 | + options: { |
| 104 | + forceExit: true, |
| 105 | + match: '.', |
| 106 | + matchall: false, |
| 107 | + extensions: 'js', |
| 108 | + specNameMatcher: 'jasmine.spec', |
| 109 | + jUnit: { |
| 110 | + report: true, |
| 111 | + savePath : "reports/jasmine/", |
| 112 | + useDotNotation: true, |
| 113 | + consolidate: true |
| 114 | + } |
| 115 | + }, |
| 116 | + all: ['install/js/test/'] |
| 117 | + }, |
| 118 | + less: { |
| 119 | + debug: { |
| 120 | + options: { |
| 121 | + paths: ['src/assets/css'], |
| 122 | + }, |
| 123 | + files: { |
| 124 | + 'build/assets/css/listcontrol.css' : 'src/assets/less/listcontrol.less', |
| 125 | + } |
| 126 | + }, |
| 127 | + }, |
| 128 | + concat: { |
| 129 | + debug: { |
| 130 | + src: [ |
| 131 | + 'src/scripts/head.p.ts', |
| 132 | + 'src/scripts/support.p.ts', |
| 133 | + 'src/scripts/definitions.p.ts', |
| 134 | + 'src/scripts/TableViewEditOperation.p.ts', |
| 135 | + 'src/scripts/TableViewKeySelectOperation.p.ts', |
| 136 | + 'src/scripts/TableViewMouseSelectOperation.p.ts', |
| 137 | + 'src/scripts/TableViewEditOperation.p.ts', |
| 138 | + 'src/scripts/TableViewReorderColumnOperation.p.ts', |
| 139 | + 'src/scripts/TableViewResizeColumnOperation.p.ts', |
| 140 | + 'src/scripts/TableView.p.ts', |
| 141 | + 'src/scripts/StackView.p.ts', |
| 142 | + 'src/scripts/Operator.p.ts', |
| 143 | + 'src/scripts/Theme.p.ts', |
| 144 | + 'src/scripts/RenderAndEditor.p.ts', |
| 145 | + 'src/scripts/Range.p.ts', |
| 146 | + 'src/scripts/Position.p.ts', |
| 147 | + 'src/scripts/Selection.p.ts', |
| 148 | + 'src/scripts/listcontrol.p.ts', |
| 149 | + 'src/scripts/tail.p.ts', |
| 150 | + ], |
| 151 | + dest: 'build/ts/listcontrol.ts' |
| 152 | + }, |
| 153 | + }, |
| 154 | + ts: { |
| 155 | + debug: { |
| 156 | + src: ['inc/*.d.ts'], |
| 157 | + outDir: ['build/js'], |
| 158 | + options: { |
| 159 | + target: 'es5', |
| 160 | + // module: 'amd', |
| 161 | + declaration: false, |
| 162 | + removeComments: false, |
| 163 | + }, |
| 164 | + }, |
| 165 | + listcontrol_debug: { |
| 166 | + src: ['build/ts/listcontrol.ts', 'inc/*.d.ts'], |
| 167 | + outDir: ['build/js'], |
| 168 | + options: { |
| 169 | + target: 'es5', |
| 170 | + // module: 'amd', |
| 171 | + declaration: false, |
| 172 | + removeComments: false, |
| 173 | + }, |
| 174 | + }, |
| 175 | + test: { |
| 176 | + src: ['test/*.ts', 'inc/*.d.ts'], |
| 177 | + outDir: ['build/js/test'], |
| 178 | + options: { |
| 179 | + target: 'es5', |
| 180 | + // module: 'amd', |
| 181 | + declaration: false, |
| 182 | + removeComments: false, |
| 183 | + }, |
| 184 | + }, |
| 185 | + }, |
| 186 | + }); |
| 187 | + |
| 188 | + grunt.registerTask('prepare', ['bower:install']); |
| 189 | + grunt.registerTask('install', ['copy:install']); |
| 190 | + grunt.registerTask('build', ['less:debug', 'concat:debug', 'ts:listcontrol_debug', 'ts:debug', 'install']); |
| 191 | + grunt.registerTask('test:karma', ['ts:test', 'install', 'karma']); |
| 192 | + grunt.registerTask('test:jasmine', ['ts:test', 'install', 'jasmine_node']); |
| 193 | + grunt.registerTask('test', ['ts:test', 'install', 'jasmine_node', 'karma']); |
| 194 | + grunt.registerTask('all', ['clean', 'prepare', 'less:debug', 'concat:debug', 'ts:listcontrol_debug', 'ts:debug', 'ts:test', 'install', 'jasmine_node', 'karma']); |
| 195 | + grunt.registerTask('default', function () { |
| 196 | + console.log('Use grunt build to build'); |
| 197 | + }); |
| 198 | +}; |
| 199 | + |
0 commit comments