Skip to content

Commit

Permalink
Merge pull request #680 from BranchMetrics/staging
Browse files Browse the repository at this point in the history
Prep update
  • Loading branch information
echo-branch authored Apr 28, 2021
2 parents 01ae4ec + 556a059 commit d16b4ff
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "branch-cordova-sdk",
"description": "Branch Metrics Cordova SDK",
"main": "src/index.js",
"version": "4.2.1",
"version": "4.2.2",
"homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking",
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="branch-cordova-sdk"
version="4.2.1">
version="4.2.2">

<!-- Description -->
<name>branch-cordova-sdk</name>
Expand Down Expand Up @@ -63,7 +63,7 @@ SOFTWARE.
<!-- Manifest configuration is done via a js script. We should move it to this config in the future. -->

<source-file src="src/android/io/branch/BranchSDK.java" target-dir="src/io/branch" />
<framework src="io.branch.sdk.android:library:4.4.0"/>
<framework src="io.branch.sdk.android:library:5.0.7"/>
</platform>

<!-- iOS -->
Expand All @@ -87,7 +87,7 @@ SOFTWARE.
<source url="https://github.com/CocoaPods/Specs.git"/>
</config>
<pods>
<pod name="Branch" spec="~> 0.35.0" />
<pod name="Branch" spec="~> 1.39.2" />
</pods>
</podspec>
</platform>
Expand Down
28 changes: 28 additions & 0 deletions src/scripts/android/updateAssets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(function() {
// properties

const fs = require("fs");
const path = require("path");

// entry
module.exports = {
addBranchJson: addBranchJson
};

// updates the platforms/ios/*.xcodeproj/project.pbxproj file and adds branch.json file
function addBranchJson(context, preferences) {
if (preferences.branchJson.exists) {
const destination = path.join(
context.opts.projectRoot,
"platforms",
"android",
"app",
"src",
"main",
"assets",
"branch.json"
);
fs.copyFileSync(preferences.branchJson.path, destination);
}
}
})();
8 changes: 8 additions & 0 deletions src/scripts/hooks/beforePrepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
const iosPlist = require("../ios/updatePlist.js");
const iosAssociatedDomains = require("../ios/updateAssociatedDomains.js");
const iosHeaderPaths = require("../ios/updateHeaderPaths.js");
const iosPbxproj = require("../ios/updatePbxproj.js");
const androidAssets = require("../android/updateAssets.js");
const IOS = "ios";
const ANDROID = "android";

// entry
module.exports = run;
Expand All @@ -16,10 +19,15 @@
const platforms = context.opts.cordova.platforms;

platforms.forEach(platform => {
if (platform === ANDROID) {
androidAssets.addBranchJson(context, preferences);
}

if (platform === IOS) {
iosPlist.addBranchSettings(preferences);
iosAssociatedDomains.addAssociatedDomains(preferences);
iosHeaderPaths.addHeaderPaths();
iosPbxproj.addBranchJson(context, preferences);
}
});
}
Expand Down
26 changes: 26 additions & 0 deletions src/scripts/ios/updatePbxproj.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(function() {
// properties

const fs = require("fs");
const path = require("path");

// entry
module.exports = {
addBranchJson: addBranchJson
};

// updates the platforms/ios/*.xcodeproj/project.pbxproj file and adds branch.json file
function addBranchJson(context, preferences) {
if (preferences.branchJson.exists && preferences.iosProjectModule.xcode) {
const destination = path.join(
context.opts.projectRoot,
"platforms",
"ios",
"branch.json"
);
fs.copyFileSync(preferences.branchJson.path, destination);
preferences.iosProjectModule.xcode.addResourceFile(destination);
preferences.iosProjectModule.write();
}
}
})();
20 changes: 20 additions & 0 deletions src/scripts/npm/processConfigXml.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(function() {
// properties

const fs = require("fs");
const path = require("path");
const xmlHelper = require("../lib/xmlHelper.js");

Expand Down Expand Up @@ -57,6 +58,7 @@
return {
projectRoot: getProjectRoot(context),
projectName: getProjectName(configXml),
branchJson: getBranchJson(context),
branchKey: getBranchKey(branchXml, "branch-key-live"),
branchKeyTest: getBranchValue(branchXml, "branch-key-test"),
branchTestMode: getBranchValue(branchXml, "branch-test-mode"),
Expand Down Expand Up @@ -96,6 +98,24 @@
return output;
}

// Checks if branch.json exists in projectRoot and returns its path
function getBranchJson(context) {
const pathToBranchJson = path.join(context.opts.projectRoot, "branch.json");
let exists;

try {
fs.existsSync(pathToBranchJson);
exists = true;
} catch(err) {
exists = false;
}

return {
exists: exists,
path: pathToBranchJson
};
}

// read branch value from <branch-config>
function getBranchValue(branchXml, key) {
return branchXml.hasOwnProperty(key) ? branchXml[key][0].$.value : null;
Expand Down

0 comments on commit d16b4ff

Please sign in to comment.