@@ -105,7 +105,7 @@ module.exports = function(grunt) {
105
105
'src/js/directives/*.js' ,
106
106
'src/js/filters/*.js' ,
107
107
'src/js/routes.js' ,
108
- 'src/js/services/*.js' ,
108
+ 'src/js/services/**/* .js' ,
109
109
'src/js/models/*.js' ,
110
110
'src/js/controllers/**/*.js'
111
111
] ,
@@ -188,8 +188,8 @@ module.exports = function(grunt) {
188
188
'src/js/models/*.js' ,
189
189
'!src/js/models/*.spec.js' ,
190
190
191
- 'src/js/services/*.js' ,
192
- '!src/js/services/*.spec.js' ,
191
+ 'src/js/services/**/* .js' ,
192
+ '!src/js/services/**/* .spec.js' ,
193
193
194
194
'src/js/controllers/**/*.js' ,
195
195
'!src/js/controllers/**/*.spec.js' ,
@@ -201,7 +201,8 @@ module.exports = function(grunt) {
201
201
'src/js/trezor-url.js' ,
202
202
'bower_components/trezor-connect/connect.js' ,
203
203
'node_modules/bezier-easing/dist/bezier-easing.min.js' ,
204
- 'node_modules/cordova-plugin-qrscanner/dist/cordova-plugin-qrscanner-lib.min.js'
204
+ 'node_modules/cordova-plugin-qrscanner/dist/cordova-plugin-qrscanner-lib.min.js' ,
205
+ 'node_modules/cordova-plugin-camera-preview/www/CameraPreview.js'
205
206
] ,
206
207
dest : 'www/js/app.js'
207
208
}
@@ -261,6 +262,24 @@ module.exports = function(grunt) {
261
262
} ,
262
263
} ,
263
264
} ,
265
+ gen_constant_moonpay_dev : {
266
+ src : 'src/js/templates/constants/moonpay-config.constant.js' ,
267
+ dest : 'src/js/generated/constants/moonpay-config.constant.js' ,
268
+ options : {
269
+ process : function ( content , srcpath ) {
270
+ return processMoonPayConfig ( content , 'dev' ) ;
271
+ } ,
272
+ } ,
273
+ } ,
274
+ gen_constant_moonpay_prod : {
275
+ src : 'src/js/templates/constants/moonpay-config.constant.js' ,
276
+ dest : 'src/js/generated/constants/moonpay-config.constant.js' ,
277
+ options : {
278
+ process : function ( content , srcpath ) {
279
+ return processMoonPayConfig ( content , 'prod' ) ;
280
+ } ,
281
+ } ,
282
+ } ,
264
283
ionic_fonts : {
265
284
expand : true ,
266
285
flatten : true ,
@@ -369,8 +388,8 @@ module.exports = function(grunt) {
369
388
370
389
grunt . registerTask ( 'default' , [ 'pre-dev' , 'main' ] ) ;
371
390
grunt . registerTask ( 'main' , [ 'nggettext_compile' , 'exec:appConfig' , 'exec:externalServices' , 'browserify' , 'sass' , 'concat' , 'copy:ionic_fonts' , 'copy:ionic_js' ] ) ;
372
- grunt . registerTask ( 'pre-dev' , [ 'copy:gen_constant_leanplum_dev' ] ) ;
373
- grunt . registerTask ( 'prod' , [ 'copy:gen_constant_leanplum_prod' , 'main' , 'uglify' ] ) ;
391
+ grunt . registerTask ( 'pre-dev' , [ 'copy:gen_constant_leanplum_dev' , 'copy:gen_constant_moonpay_dev' ] ) ;
392
+ grunt . registerTask ( 'prod' , [ 'copy:gen_constant_leanplum_prod' , 'copy:gen_constant_moonpay_prod' , ' main', 'uglify' ] ) ;
374
393
grunt . registerTask ( 'translate' , [ 'nggettext_extract' ] ) ;
375
394
grunt . registerTask ( 'chrome' , [ 'default' , 'exec:chrome' ] ) ;
376
395
grunt . registerTask ( 'cordovaclean' , [ 'exec:cordovaclean' ] ) ;
@@ -423,7 +442,7 @@ module.exports = function(grunt) {
423
442
function processLeanplumConfig ( content , env ) {
424
443
var leanplumConfig = { } ;
425
444
try {
426
- leanplumConfig = grunt . file . readJSON ( '../leanplum-config.json' ) ;
445
+ leanplumConfig = grunt . file . readJSON ( '../wallet-configs/app-v1/ leanplum-config.json' ) ;
427
446
} catch ( e ) {
428
447
// Without this, there is no clue on the console about what happened.
429
448
if ( env === 'prod' ) {
@@ -446,4 +465,36 @@ module.exports = function(grunt) {
446
465
. replace ( "key: ''" , "key: '" + key + "'" ) ;
447
466
return newContent ;
448
467
}
468
+
469
+ function processMoonPayConfig ( content , env ) {
470
+ var moonPayConfig = { } ;
471
+ try {
472
+ moonPayConfig = grunt . file . readJSON ( '../wallet-configs/app-v1/moonpay-config.json' ) ;
473
+ } catch ( e ) {
474
+ // Without this, there is no clue on the console about what happened.
475
+ if ( env === 'prod' ) {
476
+ console . error ( 'Error reading JSON' , e ) ;
477
+ throw e ;
478
+ } else { // Allow people to build if they don't care about MoonPay
479
+ console . warn ( 'Failed to read MoonPay config JSON' , e ) ;
480
+ return content ;
481
+ }
482
+ }
483
+
484
+ var moonPayForEnv = env === 'prod' ? moonPayConfig . prod : moonPayConfig . dev ;
485
+ var baseUrl = moonPayForEnv . baseUrl ;
486
+ var pubKey = moonPayForEnv . pubKey ;
487
+ var secretKey = moonPayForEnv . secretKey ;
488
+ console . log ( 'MoonPay baseUrl: "' + baseUrl + '"' ) ;
489
+ console . log ( 'MoonPay pubKey: "' + pubKey + '"' ) ;
490
+ console . log ( 'MoonPay secretKey: "' + secretKey + '"' ) ;
491
+ console . log ( 'MoonPay env: "' + env + '"' ) ;
492
+
493
+ var newContent = '// Generated\n' + content
494
+ . replace ( "baseUrl: ''" , "baseUrl: '" + baseUrl + "'" )
495
+ . replace ( "pubKey: ''" , "pubKey: '" + pubKey + "'" )
496
+ . replace ( "secretKey: ''" , "secretKey: '" + secretKey + "'" )
497
+ . replace ( "env: ''" , "env: '" + env + "'" ) ;
498
+ return newContent ;
499
+ }
449
500
} ;
0 commit comments