Different Leanplum settings for dev and prod.
This commit is contained in:
parent
ff01933151
commit
8d8a5421bb
1 changed files with 41 additions and 25 deletions
64
Gruntfile.js
64
Gruntfile.js
|
|
@ -29,7 +29,7 @@ module.exports = function(grunt) {
|
||||||
build_ios_release: {
|
build_ios_release: {
|
||||||
command: 'cordova prepare ios && cordova build ios --release',
|
command: 'cordova prepare ios && cordova build ios --release',
|
||||||
options: {
|
options: {
|
||||||
maxBuffer: 1600 * 1024
|
maxBuffer: 3200 * 1024
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
chrome: {
|
chrome: {
|
||||||
|
|
@ -243,23 +243,21 @@ module.exports = function(grunt) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
copy: {
|
copy: {
|
||||||
gen_constant_leanplum: {
|
gen_constant_leanplum_dev: {
|
||||||
src: 'src/js/templates/constants/leanplum-config.constant.js',
|
src: 'src/js/templates/constants/leanplum-config.constant.js',
|
||||||
dest: 'src/js/generated/constants/leanplum-config.constant.js',
|
dest: 'src/js/generated/constants/leanplum-config.constant.js',
|
||||||
options: {
|
options: {
|
||||||
process: function (content, srcpath) {
|
process: function (content, srcpath) {
|
||||||
var leanplumConfig = {};
|
return processLeanplumConfig(content, 'dev');
|
||||||
try {
|
},
|
||||||
leanplumConfig = grunt.file.readJSON('../leanplum-config.json');
|
},
|
||||||
} catch (e) {
|
},
|
||||||
// Without this, there is no clue on the console about what happened.
|
gen_constant_leanplum_prod: {
|
||||||
console.error('Error reading JSON', e);
|
src: 'src/js/templates/constants/leanplum-config.constant.js',
|
||||||
throw e;
|
dest: 'src/js/generated/constants/leanplum-config.constant.js',
|
||||||
}
|
options: {
|
||||||
var newContent = '// Generated\n' + content
|
process: function (content, srcpath) {
|
||||||
.replace("appId: ''","appId: '" + leanplumConfig.dev.appId + "'")
|
return processLeanplumConfig(content, 'prod');
|
||||||
.replace("key: ''", "key: '" + leanplumConfig.dev.key + "'");
|
|
||||||
return newContent;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -367,13 +365,12 @@ module.exports = function(grunt) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerTask('default', ['nggettext_compile', 'exec:appConfig', 'exec:externalServices', 'browserify', 'sass', 'copy:gen_constant_leanplum', 'concat', 'copy:ionic_fonts', 'copy:ionic_js']);
|
grunt.registerTask('default', ['pre-dev', 'main']);
|
||||||
grunt.registerTask('prod', ['default', 'uglify']);
|
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('translate', ['nggettext_extract']);
|
||||||
grunt.registerTask('chrome', ['default','exec:chrome']);
|
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']);
|
grunt.registerTask('cordovaclean', ['exec:cordovaclean']);
|
||||||
|
|
||||||
// Build all
|
// Build all
|
||||||
|
|
@ -387,14 +384,14 @@ module.exports = function(grunt) {
|
||||||
grunt.registerTask('build-mobile-release', ['build-ios-release', 'build-android-release']);
|
grunt.registerTask('build-mobile-release', ['build-ios-release', 'build-android-release']);
|
||||||
|
|
||||||
// Build ios
|
// Build ios
|
||||||
grunt.registerTask('start-ios', ['exec:build_ios_debug', 'exec:xcode']);
|
grunt.registerTask('start-ios', ['pre-dev', 'exec:build_ios_debug', 'exec:xcode']);
|
||||||
grunt.registerTask('build-ios-debug', ['exec:build_ios_debug']);
|
grunt.registerTask('build-ios-debug', ['pre-dev', 'exec:build_ios_debug']);
|
||||||
grunt.registerTask('build-ios-release', ['prod', 'exec:build_ios_release']);
|
grunt.registerTask('build-ios-release', ['prod', 'exec:build_ios_release']);
|
||||||
|
|
||||||
// Build android
|
// Build android
|
||||||
grunt.registerTask('start-android', ['build-android-debug', 'exec:run_android']);
|
grunt.registerTask('start-android', ['pre-dev', 'build-android-debug', 'exec:run_android']);
|
||||||
grunt.registerTask('build-android-debug', ['exec:build_android_debug']);
|
grunt.registerTask('build-android-debug', ['pre-dev', 'exec:build_android_debug']);
|
||||||
grunt.registerTask('start-android-emulator', ['build-android-debug', 'exec:run_android_emulator']);
|
grunt.registerTask('start-android-emulator', ['pre-dev', 'build-android-debug', 'exec:run_android_emulator']);
|
||||||
grunt.registerTask('build-android-release', ['prod', 'exec:build_android_release', 'sign-android']);
|
grunt.registerTask('build-android-release', ['prod', 'exec:build_android_release', 'sign-android']);
|
||||||
grunt.registerTask('sign-android', ['exec:sign_android']);
|
grunt.registerTask('sign-android', ['exec:sign_android']);
|
||||||
|
|
||||||
|
|
@ -419,4 +416,23 @@ module.exports = function(grunt) {
|
||||||
|
|
||||||
// Release desktop
|
// 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.
|
||||||
|
console.error('Error reading JSON', e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
var leanplumForEnv = env === 'prod' ? leanplumConfig.prod : leanplumConfig.dev;
|
||||||
|
|
||||||
|
var newContent = '// Generated\n' + content
|
||||||
|
.replace("appId: ''","appId: '" + leanplumForEnv.appId + "'")
|
||||||
|
.replace("key: ''", "key: '" + leanplumForEnv.key + "'");
|
||||||
|
return newContent;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue