Skip to content

Commit f2b54d8

Browse files
committed
💎 Bump version to 8.0.7
2 parents 5c58a6e + 024ad52 commit f2b54d8

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "instabug-cordova",
3-
"version": "8.0.6",
3+
"version": "8.0.7",
44
"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.",
55
"main": "index.js",
66
"repository": {

‎plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<source-file src="src/android/IBGPlugin.java" target-dir="src/com/instabug/cordova/plugin"/>
8484
<source-file src="src/android/MyApplication.java" target-dir="src/com/instabug/cordova/plugin"/>
8585
<hook type="before_plugin_install" src="scripts/android/before_plugin_install.js"/>
86+
<hook type="before_plugin_uninstall" src="scripts/android/before_plugin_uninstall.js"/>
8687
</platform>
8788

8889
<!-- ios -->

‎scripts/android/before_plugin_install.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var fs = require('fs');
22
var path = require('path');
3+
const editManist = require('./edit_manifest');
34

45
const ibgBuildGradleExists = () => {
56
var target = path.join('plugins', 'instabug-cordova', 'build.gradle');
@@ -53,5 +54,6 @@ module.exports = function(ctx) {
5354
);
5455
writeIbgBuildGradle(buildGradle);
5556
}
57+
return editManist(ctx, true);
5658
}
5759
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const editManifest = require('./edit_manifest');
2+
module.exports = (ctx) => {
3+
return editManifest(ctx, false);
4+
}

‎scripts/android/edit_manifest.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module.exports = (ctx, isInstalling) => {
2+
const fs = ctx.requireCordovaModule('fs');
3+
const path = ctx.requireCordovaModule('path');
4+
const Q = ctx.requireCordovaModule('q');
5+
const xml = ctx.requireCordovaModule('cordova-common').xmlHelpers;
6+
7+
const deferred = Q.defer();
8+
const platformPath = path.join(ctx.opts.projectRoot, './platforms/android');
9+
const manifestPaths = [
10+
path.join(platformPath, './AndroidManifest.xml'),
11+
path.join(platformPath, './app/src/main/AndroidManifest.xml')
12+
];
13+
14+
const manifestPath = manifestPaths.find(filepath => {
15+
try {
16+
fs.accessSync(filepath, fs.constants.F_OK);
17+
return true;
18+
} catch (err) {
19+
return false;
20+
}
21+
});
22+
23+
if (manifestPath != null) {
24+
const appName = 'com.instabug.cordova.plugin.MyApplication';
25+
let doc = xml.parseElementtreeSync(manifestPath);
26+
let appAttr = doc.getroot().find('./application').attrib['android:name'];
27+
28+
if (isInstalling) {
29+
if (!appAttr) {
30+
doc.getroot().find('./application').attrib['android:name'] = appName;
31+
}
32+
} else {
33+
if (appAttr === appName) {
34+
delete doc.getroot().find('./application').attrib['android:name'];
35+
}
36+
}
37+
38+
fs.writeFileSync(manifestPath, doc.write({ indent: 4 }));
39+
deferred.resolve();
40+
} else {
41+
deferred.reject(new Error("Can't find AndroidManifest.xml"));
42+
}
43+
44+
return deferred.promise;
45+
};

0 commit comments

Comments
 (0)