Skip to content

Commit

Permalink
Merge pull request #390 from Bitcoin-com/wallet/dev
Browse files Browse the repository at this point in the history
prod <- dev - 5.2-rc1
  • Loading branch information
Jean-Baptiste Dominguez authored Oct 17, 2018
2 parents 30b23d0 + 62fdcb2 commit 20a348f
Show file tree
Hide file tree
Showing 71 changed files with 6,381 additions and 433 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ www/img/app
## Firebase
/GoogleService-Info.plist
/google-services.json
src/js/generated
66 changes: 56 additions & 10 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ module.exports = function(grunt) {
command: 'cordova prepare android && cordova build android --release',
},
build_ios_debug: {
command: 'cordova prepare ios && cordova build ios --debug',
command: 'cordova prepare ios && cordova build ios --debug --buildFlag="-UseModernBuildSystem=0"',
options: {
maxBuffer: 3200 * 1024
}
},
build_ios_release: {
command: 'cordova prepare ios && cordova build ios --release',
command: 'cordova prepare ios && cordova build ios --release --buildFlag="-UseModernBuildSystem=0"',
options: {
maxBuffer: 1600 * 1024
maxBuffer: 3200 * 1024
}
},
chrome: {
Expand Down Expand Up @@ -175,6 +175,7 @@ module.exports = function(grunt) {
js: {
src: [
'src/js/app.js',
'src/js/generated/constants/*.js',
'src/js/routes.js',
'src/js/decorators/*.js',

Expand Down Expand Up @@ -242,6 +243,24 @@ module.exports = function(grunt) {
},
},
copy: {
gen_constant_leanplum_dev: {
src: 'src/js/templates/constants/leanplum-config.constant.js',
dest: 'src/js/generated/constants/leanplum-config.constant.js',
options: {
process: function (content, srcpath) {
return processLeanplumConfig(content, 'dev');
},
},
},
gen_constant_leanplum_prod: {
src: 'src/js/templates/constants/leanplum-config.constant.js',
dest: 'src/js/generated/constants/leanplum-config.constant.js',
options: {
process: function (content, srcpath) {
return processLeanplumConfig(content, 'prod');
},
},
},
ionic_fonts: {
expand: true,
flatten: true,
Expand Down Expand Up @@ -345,14 +364,13 @@ module.exports = function(grunt) {
}
}
});

grunt.registerTask('default', ['nggettext_compile', 'exec:appConfig', 'exec:externalServices', 'browserify', 'sass', 'concat', 'copy:ionic_fonts', 'copy:ionic_js']);
grunt.registerTask('prod', ['default', 'uglify']);

grunt.registerTask('default', ['pre-dev', 'main']);
grunt.registerTask('main', ['nggettext_compile', 'exec:appConfig', 'exec:externalServices', 'browserify', 'sass', 'concat', 'copy:ionic_fonts', 'copy:ionic_js']);
grunt.registerTask('pre-dev', ['copy:gen_constant_leanplum_dev']);
grunt.registerTask('prod', ['copy:gen_constant_leanplum_prod', 'main', 'uglify']);
grunt.registerTask('translate', ['nggettext_extract']);
grunt.registerTask('chrome', ['default','exec:chrome']);
grunt.registerTask('wp', ['prod', 'exec:wp']);
grunt.registerTask('wp-copy', ['default', 'exec:wpcopy']);
grunt.registerTask('wp-init', ['default', 'exec:wpinit']);
grunt.registerTask('cordovaclean', ['exec:cordovaclean']);

// Build all
Expand Down Expand Up @@ -397,5 +415,33 @@ module.exports = function(grunt) {
grunt.registerTask('sign-desktop', ['exec:sign_desktop_dist']);

// Release desktop
grunt.registerTask('build-desktop-release', ['build-desktop', 'sign-desktop']);
grunt.registerTask('build-desktop-release', ['build-desktop', 'sign-desktop']);


function processLeanplumConfig(content, env) {
var leanplumConfig = {};
try {
leanplumConfig = grunt.file.readJSON('../leanplum-config.json');
} catch (e) {
// Without this, there is no clue on the console about what happened.
if (env === 'prod') {
console.error('Error reading JSON', e);
throw e;
} else { // Allow people to build if they don't care about Leanplum
console.warn('Failed to read Leanplum config JSON', e);
return content;
}
}

var leanplumForEnv = env === 'prod' ? leanplumConfig.prod : leanplumConfig.dev;
var appId = leanplumForEnv.appId;
var key = leanplumForEnv.key;
console.log('Leanplum app ID: "' + appId + '"');
console.log('Leanplum key: "' + key + '"');

var newContent = '// Generated\n' + content
.replace("appId: ''","appId: '" + appId + "'")
.replace("key: ''", "key: '" + key + "'");
return newContent;
}
};
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ A watch task is also available to rebuild components of the app as changes are m
npm run watch
```

### External Config
When creating the production version, the build scripts expect a configuration file called `leanplum-config.json` to be in the directory that contains the project folder, with contents in the following format:

```json
{
"dev": {
"appId": "",
"key": ""
},
"prod": {
"appId": "",
"key": ""
}
}
```

## Testing on Real Devices

It's recommended that all final testing be done on a real device – both to assess performance and to enable features that are unavailable to the emulator (e.g. a device camera).
Expand Down
6 changes: 3 additions & 3 deletions app-template/bitcoincom/appConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"windowsAppId": "804636ee-b017-4cad-8719-e58ac97ffa5c",
"pushSenderId": "1036948132229",
"description": "A Secure Bitcoin Wallet",
"version": "5.1.6",
"fullVersion": "5.1-rc5",
"androidVersion": "501600",
"version": "5.2.0",
"fullVersion": "5.2-rc1",
"androidVersion": "502000",
"_extraCSS": "",
"_enabledExtensions": {
"coinbase": false,
Expand Down
7 changes: 7 additions & 0 deletions app-template/config-template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@
<icon src="resources/*PACKAGENAME*/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi" />
<icon src="resources/*PACKAGENAME*/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi" />

<resource-file src="resources/bitcoin.com/android/fcm_push_icon/drawable-ldpi/fcm_push_icon.png" target="res/drawable-ldpi/fcm_push_icon.png" />
<resource-file src="resources/bitcoin.com/android/fcm_push_icon/drawable-mdpi/fcm_push_icon.png" target="res/drawable-mdpi/fcm_push_icon.png" />
<resource-file src="resources/bitcoin.com/android/fcm_push_icon/drawable-hdpi/fcm_push_icon.png" target="res/drawable-hdpi/fcm_push_icon.png" />
<resource-file src="resources/bitcoin.com/android/fcm_push_icon/drawable-xhdpi/fcm_push_icon.png" target="res/drawable-xhdpi/fcm_push_icon.png" />
<resource-file src="resources/bitcoin.com/android/fcm_push_icon/drawable-xxhdpi/fcm_push_icon.png" target="res/drawable-xxhdpi/fcm_push_icon.png" />
<resource-file src="resources/bitcoin.com/android/fcm_push_icon/drawable-xxxhdpi/fcm_push_icon.png" target="res/drawable-xxxhdpi/fcm_push_icon.png" />

<splash src="resources/*PACKAGENAME*/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/>
<splash src="resources/*PACKAGENAME*/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/>
<splash src="resources/*PACKAGENAME*/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/>
Expand Down
2 changes: 1 addition & 1 deletion app-template/package-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"start": "npm run build:www && ionic serve --nolivereload --nogulp -s --address 0.0.0.0",
"start:chrome": "npm run build:www && ionic serve --nolivereload --nogulp -s --address 0.0.0.0 --browser \"google chrome\"",
"start:android": "grunt start-android",
"start:android-emulator": "grunt start-android",
"start:android-emulator": "grunt start-android-emulator",
"start:android-log": "grunt start-android && npm run log:android",
"start:ios": "grunt start-ios",
"start:windows": "npm run build:www && npm run build:windows",
Expand Down
Loading

0 comments on commit 20a348f

Please sign in to comment.