|
| 1 | +module.exports = function(grunt) { |
| 2 | + |
| 3 | + function getPlatform(){ |
| 4 | + switch(process.platform){ |
| 5 | + case 'win32': return 'win64'; // change to 'win' for both 32 and 64 |
| 6 | + case 'linux': return 'linux64'; |
| 7 | + case 'darwin': return 'osx64'; |
| 8 | + default: throw Error("unknown platform "+process.platform); |
| 9 | + } |
| 10 | + } |
| 11 | + |
| 12 | + // Project Configuration |
| 13 | + grunt.initConfig({ |
| 14 | + pkg: grunt.file.readJSON('package.json'), |
| 15 | + exec: { |
| 16 | + version: { |
| 17 | + command: 'node ./util/version.js' |
| 18 | + }, |
| 19 | + clear: { |
| 20 | + command: 'rm -Rf bower_components node_modules' |
| 21 | + }, |
| 22 | + osx64: { |
| 23 | + command: '../byteballbuilds/build-osx.sh osx64' |
| 24 | + }, |
| 25 | + osx32: { |
| 26 | + command: '../byteballbuilds/build-osx.sh osx32' |
| 27 | + } |
| 28 | + }, |
| 29 | + watch: { |
| 30 | + options: { |
| 31 | + dateFormat: function(time) { |
| 32 | + grunt.log.writeln('The watch finished in ' + time + 'ms at ' + (new Date()).toString()); |
| 33 | + grunt.log.writeln('Waiting for more changes...'); |
| 34 | + }, |
| 35 | + }, |
| 36 | + css: { |
| 37 | + files: ['src/css/*.css'], |
| 38 | + tasks: ['concat:css'] |
| 39 | + }, |
| 40 | + main: { |
| 41 | + files: [ |
| 42 | + 'src/js/init.js', |
| 43 | + 'src/js/app.js', |
| 44 | + 'src/js/directives/*.js', |
| 45 | + 'src/js/filters/*.js', |
| 46 | + 'src/js/routes.js', |
| 47 | + 'src/js/services/*.js', |
| 48 | + 'src/js/models/*.js', |
| 49 | + 'src/js/controllers/*.js' |
| 50 | + ], |
| 51 | + tasks: ['concat:js'] |
| 52 | + } |
| 53 | + }, |
| 54 | + concat: { |
| 55 | + options: { |
| 56 | + sourceMap: false, |
| 57 | + sourceMapStyle: 'link' // embed, link, inline |
| 58 | + }, |
| 59 | + angular: { |
| 60 | + src: [ |
| 61 | + 'bower_components/fastclick/lib/fastclick.js', |
| 62 | + 'bower_components/qrcode-generator/js/qrcode.js', |
| 63 | + 'bower_components/qrcode-decoder-js/lib/qrcode-decoder.js', |
| 64 | + 'bower_components/moment/min/moment-with-locales.js', |
| 65 | + 'bower_components/angular/angular.js', |
| 66 | + 'bower_components/angular-ui-router/release/angular-ui-router.js', |
| 67 | + 'bower_components/angular-foundation/mm-foundation-tpls.js', |
| 68 | + 'bower_components/angular-moment/angular-moment.js', |
| 69 | + 'bower_components/ng-lodash/build/ng-lodash.js', |
| 70 | + 'bower_components/angular-qrcode/angular-qrcode.js', |
| 71 | + 'bower_components/angular-gettext/dist/angular-gettext.js', |
| 72 | + 'bower_components/angular-touch/angular-touch.js', |
| 73 | + 'bower_components/angular-carousel/dist/angular-carousel.js', |
| 74 | + 'bower_components/angular-ui-switch/angular-ui-switch.js' |
| 75 | + ], |
| 76 | + dest: 'public/angular.js' |
| 77 | + }, |
| 78 | + js: { |
| 79 | + src: [ |
| 80 | + 'angular-bitcore-wallet-client/index.js', |
| 81 | + 'src/js/app.js', |
| 82 | + 'src/js/routes.js', |
| 83 | + 'src/js/directives/*.js', |
| 84 | + 'src/js/filters/*.js', |
| 85 | + 'src/js/models/*.js', |
| 86 | + 'src/js/services/*.js', |
| 87 | + 'src/js/controllers/*.js', |
| 88 | + 'src/js/translations.js', |
| 89 | + 'src/js/version.js', |
| 90 | + 'src/js/init.js' |
| 91 | + ], |
| 92 | + dest: 'public/byteball.js' |
| 93 | + }, |
| 94 | + css: { |
| 95 | + src: ['src/css/*.css'], |
| 96 | + dest: 'public/css/byteball.css' |
| 97 | + }, |
| 98 | + foundation: { |
| 99 | + src: [ |
| 100 | + 'bower_components/angular/angular-csp.css', |
| 101 | + 'bower_components/foundation/css/foundation.css', |
| 102 | + 'bower_components/animate.css/animate.css', |
| 103 | + 'bower_components/angular-ui-switch/angular-ui-switch.css', |
| 104 | + 'bower_components/angular-carousel/dist/angular-carousel.css' |
| 105 | + ], |
| 106 | + dest: 'public/css/foundation.css', |
| 107 | + } |
| 108 | + }, |
| 109 | + uglify: { |
| 110 | + options: { |
| 111 | + mangle: false |
| 112 | + }, |
| 113 | + prod: { |
| 114 | + files: { |
| 115 | + 'public/byteball.js': ['public/byteball.js'], |
| 116 | + 'public/angular.js': ['public/angular.js'] |
| 117 | + } |
| 118 | + } |
| 119 | + }, |
| 120 | + nggettext_extract: { |
| 121 | + pot: { |
| 122 | + files: { |
| 123 | + 'i18n/po/template.pot': [ |
| 124 | + 'public/index.html', |
| 125 | + 'public/views/*.html', |
| 126 | + 'public/views/**/*.html', |
| 127 | + 'src/js/routes.js', |
| 128 | + 'src/js/services/*.js', |
| 129 | + 'src/js/controllers/*.js' |
| 130 | + ] |
| 131 | + } |
| 132 | + }, |
| 133 | + }, |
| 134 | + nggettext_compile: { |
| 135 | + all: { |
| 136 | + options: { |
| 137 | + module: 'copayApp' |
| 138 | + }, |
| 139 | + files: { |
| 140 | + 'src/js/translations.js': ['i18n/po/*.po'] |
| 141 | + } |
| 142 | + }, |
| 143 | + }, |
| 144 | + copy: { |
| 145 | + icons: { |
| 146 | + expand: true, |
| 147 | + flatten: true, |
| 148 | + src: 'bower_components/foundation-icon-fonts/foundation-icons.*', |
| 149 | + dest: 'public/icons/' |
| 150 | + }, |
| 151 | + osx: { |
| 152 | + expand: true, |
| 153 | + flatten: true, |
| 154 | + options: {timestamp: true, mode: true}, |
| 155 | + src: ['webkitbuilds/build-osx.sh', 'webkitbuilds/Background.png'], |
| 156 | + dest: '../byteballbuilds/' |
| 157 | + }, |
| 158 | + linux: { |
| 159 | + options: {timestamp: true, mode: true}, |
| 160 | + files: [ |
| 161 | + {expand: true, cwd: './webkitbuilds/', src: ['byteball.desktop', '../public/img/icons/icon-white-outline.ico', '../public/img/icons/icon-white-256.png'], dest: '../byteballbuilds/Byteball test/linux32/', flatten: true, filter: 'isFile', options: {timestamp: true, mode: true} }, |
| 162 | + {expand: true, cwd: './webkitbuilds/', src: ['byteball.desktop', '../public/img/icons/icon-white-outline.ico', '../public/img/icons/icon-white-256.png'], dest: '../byteballbuilds/Byteball test/linux64/', flatten: true, filter: 'isFile', options: {timestamp: true, mode: true} }, |
| 163 | + ], |
| 164 | + } |
| 165 | + }, |
| 166 | + karma: { |
| 167 | + unit: { |
| 168 | + configFile: 'test/karma.conf.js' |
| 169 | + }, |
| 170 | + prod: { |
| 171 | + configFile: 'test/karma.conf.js', |
| 172 | + singleRun: true |
| 173 | + } |
| 174 | + }, |
| 175 | + coveralls: { |
| 176 | + options: { |
| 177 | + debug: false, |
| 178 | + coverageDir: 'coverage/report-lcov', |
| 179 | + dryRun: true, |
| 180 | + force: true, |
| 181 | + recursive: false |
| 182 | + } |
| 183 | + }, |
| 184 | + nwjs: { |
| 185 | + options: { |
| 186 | + //platforms: ['win','osx64','linux'], |
| 187 | + //platforms: ['osx64'], |
| 188 | + platforms: [getPlatform()], |
| 189 | + appName: 'Byteball test', |
| 190 | + buildDir: '../byteballbuilds', |
| 191 | + version: '0.14.7', |
| 192 | + zip: false, |
| 193 | + macIcns: './public/img/icons/icon-white-outline.icns', |
| 194 | + winIco: './public/img/icons/icon-white-outline.ico', |
| 195 | + exeIco: './public/img/icons/icon-white-outline.ico', |
| 196 | + macPlist: {CFBundleURLTypes: [{CFBundleURLName: 'Byteball action', CFBundleURLSchemes: ['byteball']}], /*CFBundleIconFile: 'nw.icns',*/ LSHasLocalizedDisplayName: 0} |
| 197 | + }, |
| 198 | + src: ['./package.json', './public/**/*', './angular-bitcore-wallet-client/**/*'] |
| 199 | + }, |
| 200 | + compress: { |
| 201 | + linux32: { |
| 202 | + options: { |
| 203 | + archive: '../byteballbuilds/byteball-linux32.zip' |
| 204 | + }, |
| 205 | + expand: true, |
| 206 | + cwd: '../byteballbuilds/Byteball test/linux32/', |
| 207 | + src: ['**/*'], |
| 208 | + dest: 'byteball-linux32/' |
| 209 | + }, |
| 210 | + linux64: { |
| 211 | + options: { |
| 212 | + archive: '../byteballbuilds/byteball-linux64.zip' |
| 213 | + }, |
| 214 | + expand: true, |
| 215 | + cwd: '../byteballbuilds/Byteball test/linux64/', |
| 216 | + src: ['**/*'], |
| 217 | + dest: 'byteball-linux64/' |
| 218 | + } |
| 219 | + }, |
| 220 | + browserify: { |
| 221 | + dist:{ |
| 222 | + options:{ |
| 223 | + exclude: ['sqlite3', 'nw.gui', 'mysql', 'ws', 'regedit'] |
| 224 | + }, |
| 225 | + src: 'public/byteball.js', |
| 226 | + dest: 'public/byteball.js' |
| 227 | + } |
| 228 | + }, |
| 229 | + // .deb proved to be very slow to produce and install: lintian spends a lot of time verifying a .bin file |
| 230 | + debian_package: { |
| 231 | + linux64: { |
| 232 | + files: [ |
| 233 | + {expand: true, cwd: '../byteballbuilds/byteball-test/linux64/', src: ['**/*'], dest: '/opt/byteball-test/'}, |
| 234 | + //{expand: true, cwd: '../byteballbuilds/byteball-test/linux64', src: ['byteball.desktop'], dest: '/usr/share/applications/byteball-test.desktop'} |
| 235 | + ], |
| 236 | + options: { |
| 237 | + maintainer: { |
| 238 | + name: 'Byteball', |
| 239 | + |
| 240 | + }, |
| 241 | + long_description: 'A wallet for decentralized value', |
| 242 | + target_architecture: 'amd64' |
| 243 | + } |
| 244 | + } |
| 245 | + }, |
| 246 | + innosetup_compiler: { |
| 247 | + win64: { |
| 248 | + options: { |
| 249 | + gui: false, |
| 250 | + verbose: false |
| 251 | + }, |
| 252 | + script: 'webkitbuilds/setup-win64.iss' |
| 253 | + }, |
| 254 | + win32: { |
| 255 | + options: { |
| 256 | + gui: false, |
| 257 | + verbose: false |
| 258 | + }, |
| 259 | + script: 'webkitbuilds/setup-win32.iss' |
| 260 | + } |
| 261 | + } |
| 262 | + }); |
| 263 | + |
| 264 | + grunt.loadNpmTasks('grunt-contrib-concat'); |
| 265 | + grunt.loadNpmTasks('grunt-contrib-copy'); |
| 266 | + grunt.loadNpmTasks('grunt-contrib-watch'); |
| 267 | + grunt.loadNpmTasks('grunt-contrib-uglify'); |
| 268 | + grunt.loadNpmTasks('grunt-angular-gettext'); |
| 269 | + grunt.loadNpmTasks('grunt-browserify'); |
| 270 | + grunt.loadNpmTasks('grunt-exec'); |
| 271 | + grunt.loadNpmTasks('grunt-karma'); |
| 272 | + grunt.loadNpmTasks('grunt-karma-coveralls'); |
| 273 | + grunt.loadNpmTasks('grunt-nw-builder'); |
| 274 | + grunt.loadNpmTasks('grunt-contrib-compress'); |
| 275 | + //grunt.loadNpmTasks('grunt-debian-package'); |
| 276 | + grunt.loadNpmTasks('innosetup-compiler'); |
| 277 | + |
| 278 | + grunt.registerTask('default', ['nggettext_compile', 'exec:version', 'concat', 'copy:icons']); |
| 279 | + grunt.registerTask('cordova', ['default', 'browserify']); |
| 280 | + grunt.registerTask('cordova-prod', ['cordova', 'uglify']); |
| 281 | + //grunt.registerTask('prod', ['default', 'uglify']); |
| 282 | + grunt.registerTask('translate', ['nggettext_extract']); |
| 283 | + grunt.registerTask('test', ['karma:unit']); |
| 284 | + grunt.registerTask('test-coveralls', ['karma:prod', 'coveralls']); |
| 285 | + //grunt.registerTask('desktop', ['prod', 'nwjs', 'copy:linux', 'compress:linux32', 'compress:linux64', 'copy:osx', 'exec:osx32', 'exec:osx64']); |
| 286 | + grunt.registerTask('desktop', ['default', 'nwjs']); |
| 287 | + grunt.registerTask('dmg', ['copy:osx', 'exec:osx64']); |
| 288 | + grunt.registerTask('linux', ['copy:linux', 'compress:linux64']); |
| 289 | + grunt.registerTask('deb', ['debian_package:linux64']); |
| 290 | + grunt.registerTask('inno', ['innosetup_compiler:win64']); |
| 291 | +}; |
0 commit comments