Skip to content

Commit

Permalink
💎 Bump version to 8.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
salmamali committed Oct 16, 2018
2 parents 481779a + 7976c82 commit 0e6f713
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "instabug-cordova",
"version": "8.0.3",
"version": "8.0.4",
"description": "The purpose of this plugin is to simplify the process of integrating the Instabug SDK in a hybrid application, as well as to provide an interface to interfacing with the SDK through JavaScript.",
"main": "index.js",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="instabug-cordova"
version="1.10.0">
version="8.0.4">

<name>instabug-cordova</name>

Expand Down Expand Up @@ -82,7 +82,7 @@
<source-file src="src/android/IBGPluginActivity.java" target-dir="src/com/instabug/cordova/plugin"/>
<source-file src="src/android/IBGPlugin.java" target-dir="src/com/instabug/cordova/plugin"/>
<source-file src="src/android/MyApplication.java" target-dir="src/com/instabug/cordova/plugin"/>

<hook type="before_plugin_install" src="scripts/android/before_plugin_install.js"/>
</platform>

<!-- ios -->
Expand Down
57 changes: 57 additions & 0 deletions scripts/android/before_plugin_install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
var fs = require('fs');
var path = require('path');

const ibgBuildGradleExists = () => {
var target = path.join('plugins', 'instabug-cordova', 'build.gradle');
return fs.existsSync(target);
};

const readIbgBuildGradle = () => {
var target = path.join('plugins', 'instabug-cordova', 'build.gradle');
return fs.readFileSync(target, 'utf-8');
};

const writeIbgBuildGradle = (contents) => {
var target = path.join('plugins', 'instabug-cordova', 'build.gradle');
fs.writeFileSync(target, contents);
};

const getAndroidVersion = () => {
const target = path.join('config.xml');
let file = fs.readFileSync(target, 'utf-8');
const androidEngine = file.match(/engine name="android" spec="\^[1-9]+.[0-9]+.[0-9]+"/g);
if (androidEngine) {
const version = androidEngine[0].match(/[1-9]+.[0-9]+.[0-9]+/g);
if (version) {
return version[0];
} else {
console.log('Instabug: ', 'Error retrieving cordova-android version.');

}
} else {
console.log(
'Instabug: ',
'Cordova-android not installed. Skipping android preparation steps.'
);
}
};

const isAndroid7 = version => {
if (version) {
const major = parseInt(version.split('.')[0]);
return major >= 7;
}
};

module.exports = function(ctx) {
if (ibgBuildGradleExists) {
let buildGradle = readIbgBuildGradle();
if (isAndroid7(getAndroidVersion())) {
buildGradle = buildGradle.replace(
"manifest.srcFile 'AndroidManifest.xml'",
"manifest.srcFile 'src/main/AndroidManifest.xml'"
);
writeIbgBuildGradle(buildGradle);
}
}
};

0 comments on commit 0e6f713

Please sign in to comment.