forked from bitpay/wallet
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Gruntfile.js
312 lines (307 loc) · 11 KB
/
Gruntfile.js
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
'use strict';
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-asset-hash');
// Project Configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
exec: {
appConfig: {
command: 'node ./util/buildAppConfig.js'
},
externalServices: {
command: 'node ./util/buildExternalServices.js'
},
addManifest: {
command: 'node ./util/addManifest.js'
},
clean: {
command: 'rm -Rf bower_components node_modules'
},
removeDist: {
command: 'rm -Rf dist'
},
cordovaclean: {
command: 'make -C cordova clean'
},
macos: {
command: 'sh desktop-build-configs/build-macos.sh sign'
},
coveralls: {
command: 'cat coverage/report-lcov/lcov.info |./node_modules/coveralls/bin/coveralls.js'
},
chrome: {
command: 'make -C chrome-app '
},
wpinit: {
command: 'make -C cordova wp-init',
},
wpcopy: {
command: 'make -C cordova wp-copy',
},
iosdebug: {
command: 'npm run build:ios',
},
ios: {
command: 'npm run build:ios-release',
},
xcode: {
command: 'npm run open:ios',
},
androiddebug: {
command: 'npm run build:android',
},
android: {
command: 'npm run build:android-release',
},
androidrun: {
command: 'npm run run:android && npm run log:android',
},
androidbuild: {
command: 'cd cordova/project && cordova build android --release',
},
androidsign: {
command: 'rm -f cordova/project/platforms/android/build/outputs/apk/android-release-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../cordova-keys/navpay.keystore -signedjar cordova/project/platforms/android/build/outputs/apk/android-release-signed.apk cordova/project/platforms/android/build/outputs/apk/android-release-unsigned.apk copay_play && ~/Library/Android/sdk/build-tools/27.0.2/zipalign -v 4 cordova/project/platforms/android/build/outputs/apk/android-release-signed.apk cordova/project/platforms/android/build/outputs/apk/android-release-signed-aligned.apk',
stdin: true,
},
desktopsign: {
cmd: 'gpg -u B2477504775F724B --output webkitbuilds/<%= pkg.title %>-linux.zip.sig --detach-sig webkitbuilds/<%= pkg.title %>-linux.zip ; gpg -u B2477504775F724B --output webkitbuilds/<%= pkg.title %>.exe.sig --detach-sig webkitbuilds/<%= pkg.title %>.exe'
},
desktopverify: {
cmd: 'gpg --verify webkitbuilds/<%= pkg.title %>-linux.zip.sig webkitbuilds/<%= pkg.title %>-linux.zip; gpg --verify webkitbuilds/<%= pkg.title %>.exe.sig webkitbuilds/<%= pkg.title %>.exe'
},
osxsign: {
cmd: 'gpg -u B2477504775F724B --output webkitbuilds/<%= pkg.title %>.dmg.sig --detach-sig webkitbuilds/<%= pkg.title %>.dmg'
},
},
watch: {
options: {
dateFormat: function(time) {
grunt.log.writeln('The watch finished in ' + time + 'ms at ' + (new Date()).toString());
grunt.log.writeln('Waiting for more changes...');
},
},
sass: {
files: ['src/sass/**/**/*.scss'],
tasks: ['sass']
},
main: {
files: [
'src/js/init.js',
'src/js/app.js',
'src/js/directives/*.js',
'src/js/filters/*.js',
'src/js/routes.js',
'src/js/services/*.js',
'src/js/models/*.js',
'src/js/controllers/**/*.js'
],
tasks: ['concat:js']
},
gettext: {
files: [
'i18n/po/*.po',
'i18n/po/*.pot'
],
tasks: ['nggettext_compile','concat']
},
},
sass: {
dist: {
options: {
style: 'compact',
sourcemap: 'none'
},
files: [{
expand: true,
flatten: true,
src: ['src/sass/main.scss'],
dest: 'www/css/',
ext: '.css'
}]
}
},
concat: {
options: {
sourceMap: false,
sourceMapStyle: 'link' // embed, link, inline
},
angular: {
src: [
'bower_components/qrcode-generator/js/qrcode.js',
'bower_components/qrcode-generator/js/qrcode_UTF8.js',
'bower_components/moment/min/moment-with-locales.js',
'bower_components/angular-moment/angular-moment.js',
'bower_components/ng-lodash/build/ng-lodash.js',
'bower_components/angular-qrcode/angular-qrcode.js',
'bower_components/angular-gettext/dist/angular-gettext.js',
'bower_components/ng-csv/build/ng-csv.js',
'bower_components/ionic-toast/dist/ionic-toast.bundle.min.js',
'bower_components/angular-clipboard/angular-clipboard.js',
'bower_components/angular-md5/angular-md5.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/ngtouch/src/ngTouch.js',
'bower_components/jsencrypt/bin/jsencrypt.js',
'angular-bitauth/angular-bitauth.js',
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js'
],
dest: 'www/lib/angular-components.js'
},
js: {
src: [
'src/js/app.js',
'src/js/routes.js',
'src/js/directives/*.js',
'src/js/filters/*.js',
'src/js/models/*.js',
'src/js/services/*.js',
'src/js/controllers/**/*.js',
'src/js/translations.js',
'src/js/appConfig.js',
'src/js/externalServices.js',
'src/js/init.js',
'src/js/trezor-url.js',
'bower_components/trezor-connect/connect.js',
'node_modules/bezier-easing/dist/bezier-easing.min.js',
'node_modules/cordova-plugin-qrscanner/dist/cordova-plugin-qrscanner-lib.min.js'
],
dest: 'www/js/app.js'
}
},
uglify: {
options: {
mangle: false
},
prod: {
files: {
'dist/www/js/app.js': ['dist/www/js/app.js'],
'dist/www/lib/angular-components.js': ['dist/www/lib/angular-components.js'],
}
}
},
nggettext_extract: {
pot: {
files: {
'i18n/po/template.pot': [
'www/index.html',
'www/views/**/*.html',
'src/js/routes.js',
'src/js/services/*.js',
'src/js/controllers/**/*.js'
]
}
},
},
nggettext_compile: {
all: {
options: {
module: 'copayApp'
},
files: {
'src/js/translations.js': ['i18n/po/*.po']
}
},
},
copy: {
ionic_fonts: {
expand: true,
flatten: true,
src: 'bower_components/ionic/release/fonts/ionicons.*',
dest: 'www/fonts/'
},
ionic_js: {
expand: true,
flatten: true,
src: 'bower_components/ionic/release/js/ionic.bundle.min.js',
dest: 'www/lib/'
},
linux: {
files: [{
expand: true,
cwd: 'webkitbuilds/',
src: ['.desktop', '../www/img/app/favicon.ico', '../resources/<%= pkg.name %>/linux/512x512.png'],
dest: 'webkitbuilds/<%= pkg.title %>/linux64/',
flatten: true,
filter: 'isFile'
}],
},
dist: {expand: true, src: ['www/**'], dest: 'dist/'},
},
nwjs: {
options: {
appName: '<%= pkg.title %>',
platforms: ['win64', 'osx64', 'linux64'],
buildDir: './webkitbuilds',
version: '0.19.5',
macIcns: './resources/<%= pkg.name %>/mac/app.icns',
exeIco: './www/img/app/logo.ico',
macPlist: {
'CFBundleURLTypes': [
{
'CFBundleURLName': 'URI Handler',
'CFBundleURLSchemes': ['bitcoin', '<%= pkg.name %>']
}
]
}
},
src: ['./package.json', './www/**/*']
},
compress: {
linux: {
options: {
archive: './webkitbuilds/<%= pkg.title %>-linux.zip'
},
expand: true,
cwd: './webkitbuilds/<%= pkg.title %>/linux64/',
src: ['**/*'],
dest: '<%= pkg.title %>-linux/'
}
},
browserify: {
dist: {
files: {
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js': ['angular-bitcore-wallet-client/index.js'],
'angular-bitauth/angular-bitauth.js': ['angular-bitauth/index.js']
},
}
},
asset_hash: {
options: {
preserveSourceMaps: false, // Set to true when assets should share the same location as their source map.
assetMap: false,
hashLength: 8, // Number of hex characters in the hash folder. (0 means no hashing is done).
algorithm: 'md5', // Crypto algorithm used to hash the contents.
srcBasePath: 'dist/www/', // The directory prefix to be stripped from the asset map src paths.
destBasePath: 'dist/www/', // The directory prefix to be stripped from the asset map dest paths.
hashType: 'file', // Defaults to `/$HASH/filename.ext`, but `'file'` will output `filename.$HASH.ext`.
references: ['dist/www/index.html', 'dist/www/cache.manifest'] // Files to replace references in (eg. a CSS file where `image.png` should become `image.$HASH.png`)
},
your_target: {
files: [
{ src: ['dist/www/**/*.js', 'dist/www/**/*.css'], // A collection of assets to be hashed.
dest: 'dist/www/' // A folder to contained the hashed assets. Cannot be a file.
}
]
},
},
});
grunt.registerTask('default', ['nggettext_compile', 'exec:appConfig', 'exec:externalServices', 'browserify', 'sass', 'concat', 'copy:ionic_fonts', 'copy:ionic_js']);
grunt.registerTask('prod', ['default', 'exec:removeDist', 'copy:dist', 'uglify', 'exec:addManifest', 'asset_hash']);
grunt.registerTask('beta', ['default', 'exec:removeDist', 'copy:dist', 'exec:addManifest', 'asset_hash']);
grunt.registerTask('translate', ['nggettext_extract']);
grunt.registerTask('desktop', ['prod', 'nwjs', 'copy:linux', 'compress:linux']);
grunt.registerTask('osx', ['prod', 'nwjs', 'exec:macos', 'exec:osxsign']);
grunt.registerTask('osx-debug', ['default', 'nwjs']);
grunt.registerTask('chrome', ['exec:chrome']);
grunt.registerTask('wp', ['prod', 'exec:wp']);
grunt.registerTask('wp-copy', ['default', 'exec:wpcopy']);
grunt.registerTask('wp-init', ['default', 'exec:wpinit']);
grunt.registerTask('ios', ['exec:ios']);
grunt.registerTask('ios-debug', ['exec:iosdebug']);
grunt.registerTask('ios-run', ['exec:xcode']);
grunt.registerTask('cordovaclean', ['exec:cordovaclean']);
grunt.registerTask('android-debug', ['exec:androiddebug', 'exec:androidrun']);
grunt.registerTask('android', ['exec:android']);
grunt.registerTask('android-release', ['prod', 'exec:android', 'exec:androidsign']);
grunt.registerTask('desktopsign', ['exec:desktopsign', 'exec:desktopverify']);
};