@@ -105,7 +105,7 @@ module.exports = function(grunt) {
105105 'src/js/directives/*.js' ,
106106 'src/js/filters/*.js' ,
107107 'src/js/routes.js' ,
108- 'src/js/services/*.js' ,
108+ 'src/js/services/**/* .js' ,
109109 'src/js/models/*.js' ,
110110 'src/js/controllers/**/*.js'
111111 ] ,
@@ -188,8 +188,8 @@ module.exports = function(grunt) {
188188 'src/js/models/*.js' ,
189189 '!src/js/models/*.spec.js' ,
190190
191- 'src/js/services/*.js' ,
192- '!src/js/services/*.spec.js' ,
191+ 'src/js/services/**/* .js' ,
192+ '!src/js/services/**/* .spec.js' ,
193193
194194 'src/js/controllers/**/*.js' ,
195195 '!src/js/controllers/**/*.spec.js' ,
@@ -201,7 +201,8 @@ module.exports = function(grunt) {
201201 'src/js/trezor-url.js' ,
202202 'bower_components/trezor-connect/connect.js' ,
203203 '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'
205206 ] ,
206207 dest : 'www/js/app.js'
207208 }
@@ -261,6 +262,24 @@ module.exports = function(grunt) {
261262 } ,
262263 } ,
263264 } ,
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+ } ,
264283 ionic_fonts : {
265284 expand : true ,
266285 flatten : true ,
@@ -369,8 +388,8 @@ module.exports = function(grunt) {
369388
370389 grunt . registerTask ( 'default' , [ 'pre-dev' , 'main' ] ) ;
371390 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' ] ) ;
374393 grunt . registerTask ( 'translate' , [ 'nggettext_extract' ] ) ;
375394 grunt . registerTask ( 'chrome' , [ 'default' , 'exec:chrome' ] ) ;
376395 grunt . registerTask ( 'cordovaclean' , [ 'exec:cordovaclean' ] ) ;
@@ -423,7 +442,7 @@ module.exports = function(grunt) {
423442 function processLeanplumConfig ( content , env ) {
424443 var leanplumConfig = { } ;
425444 try {
426- leanplumConfig = grunt . file . readJSON ( '../leanplum-config.json' ) ;
445+ leanplumConfig = grunt . file . readJSON ( '../wallet-configs/app-v1/ leanplum-config.json' ) ;
427446 } catch ( e ) {
428447 // Without this, there is no clue on the console about what happened.
429448 if ( env === 'prod' ) {
@@ -446,4 +465,36 @@ module.exports = function(grunt) {
446465 . replace ( "key: ''" , "key: '" + key + "'" ) ;
447466 return newContent ;
448467 }
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+ }
449500} ;
0 commit comments