Skip to content

Commit

Permalink
Merge pull request #454 from BranchMetrics/no-prefix-for-custom-link-…
Browse files Browse the repository at this point in the history
…domains

No prefix for custom link domains
  • Loading branch information
ethanneff authored May 3, 2018
2 parents 1f7ec5a + 84e6fbf commit 4e0ccb8
Show file tree
Hide file tree
Showing 16 changed files with 183 additions and 269 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@
]
},
"devDependencies": {
"@commitlint/cli": "^6.1.3",
"@commitlint/cli": "^6.2.0",
"@commitlint/config-conventional": "^6.1.3",
"@semantic-release/changelog": "^2.0.1",
"@semantic-release/exec": "^2.2.3",
"@semantic-release/git": "^4.0.2",
"@semantic-release/github": "^4.2.11",
"@semantic-release/npm": "^3.2.4",
"@semantic-release/changelog": "^2.0.2",
"@semantic-release/exec": "^2.2.4",
"@semantic-release/git": "^4.0.3",
"@semantic-release/github": "^4.2.15",
"@semantic-release/npm": "^3.2.5",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-config-prettier": "^2.9.0",
Expand All @@ -100,7 +100,7 @@
"husky": "^0.14.3",
"lint-staged": "^7.0.5",
"prettier": "^1.12.1",
"semantic-release": "^15.1.7",
"travis-deploy-once": "^4.4.1"
"semantic-release": "^15.2.0",
"travis-deploy-once": "^5.0.0"
}
}
29 changes: 14 additions & 15 deletions src/scripts/android/updateAndroidManifest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
// properties



const path = require("path");
const xmlHelper = require("../lib/xmlHelper.js");
Expand Down Expand Up @@ -67,7 +65,7 @@
);
manifest = xmlHelper.readXmlAsJson(pathToManifest);
} catch (e) {
throw new Error(`BRANCH SDK: Cannot read AndroidManfiest.xml ${ e}`);
throw new Error(`BRANCH SDK: Cannot read AndroidManfiest.xml ${e}`);
}
}
const mainActivityIndex = getMainLaunchActivityIndex(
Expand All @@ -91,7 +89,10 @@
let metadatas = manifest.manifest.application[0]["meta-data"] || [];
const metadata = [];
const keys = ["io.branch.sdk.BranchKey", "io.branch.sdk.TestMode"];
const vals = [preferences.branchKey, preferences.androidTestMode || "false"];
const vals = [
preferences.branchKey,
preferences.androidTestMode || "false"
];

// remove old
for (var i = 0; i < keys.length; i++) {
Expand All @@ -109,9 +110,7 @@
}
});
}
manifest.manifest.application[0]["meta-data"] = metadatas.concat(
metadata
);
manifest.manifest.application[0]["meta-data"] = metadatas.concat(metadata);

return manifest;
}
Expand Down Expand Up @@ -298,13 +297,16 @@
.split(".")
.slice(1)
.join(".");
const alternate = `${first }-alternate` + `.${ rest}`;
const alternate = `${first}-alternate` + `.${rest}`;

intentFilterData.push(getAppLinkIntentFilterDictionary(linkDomain));
intentFilterData.push(getAppLinkIntentFilterDictionary(alternate));
} else {
// bnc.lt and custom domains
if (preferences.androidPrefix === null) {
// bnc.lt
if (
linkDomain.indexOf("bnc.lt") !== -1 &&
preferences.androidPrefix === null
) {
throw new Error(
'BRANCH SDK: Invalid "android-prefix" in <branch-config> in your config.xml. Docs https://goo.gl/GijGKP'
);
Expand Down Expand Up @@ -343,10 +345,7 @@
const without = [];
for (let i = 0; i < items.length; i++) {
const item = items[i];
if (
item.hasOwnProperty("$") &&
item.$.hasOwnProperty("android:name")
) {
if (item.hasOwnProperty("$") && item.$.hasOwnProperty("android:name")) {
const key = item.$["android:name"];
if (key === androidName) {
continue;
Expand Down Expand Up @@ -383,7 +382,7 @@
return false;
}

isLauncher = intentFilters.some((intentFilter) => {
isLauncher = intentFilters.some(intentFilter => {
const action = intentFilter.action;
const category = intentFilter.category;

Expand Down
4 changes: 1 addition & 3 deletions src/scripts/hooks/afterPrepare.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
// properties



const configPreferences = require("../npm/processConfigXml.js");
const iosDevelopmentTeam = require("../ios/updateDevelopmentTeam.js");
Expand All @@ -17,7 +15,7 @@
const preferences = configPreferences.read(context);
const platforms = context.opts.cordova.platforms;

platforms.forEach((platform) => {
platforms.forEach(platform => {
if (platform === ANDROID) {
androidManifest.writePreferences(context, preferences);
}
Expand Down
2 changes: 0 additions & 2 deletions src/scripts/hooks/beforePluginInstall.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
// properties



const nodeDependencies = require("../npm/downloadNpmDependencies.js");

Expand Down
4 changes: 1 addition & 3 deletions src/scripts/hooks/beforePrepare.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
// properties



const configPreferences = require("../npm/processConfigXml.js");
const iosPlist = require("../ios/updatePlist.js");
Expand All @@ -17,7 +15,7 @@
const preferences = configPreferences.read(context);
const platforms = context.opts.cordova.platforms;

platforms.forEach((platform) => {
platforms.forEach(platform => {
if (platform === IOS) {
iosPlist.addBranchSettings(preferences);
iosCapabilities.enableAssociatedDomains(preferences);
Expand Down
8 changes: 3 additions & 5 deletions src/scripts/ios/enableEntitlements.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
// properties



const path = require("path");
const compare = require("node-version-compare");
Expand All @@ -22,7 +20,7 @@
"ios",
preferences.projectName,
"Resources",
`${preferences.projectName }.entitlements`
`${preferences.projectName}.entitlements`
);

activateAssociativeDomains(
Expand All @@ -43,8 +41,8 @@

for (config in configurations) {
buildSettings = configurations[config].buildSettings;
buildSettings.CODE_SIGN_IDENTITY = `"${ CODESIGNIDENTITY }"`;
buildSettings.CODE_SIGN_ENTITLEMENTS = `"${ entitlementsFile }"`;
buildSettings.CODE_SIGN_IDENTITY = `"${CODESIGNIDENTITY}"`;
buildSettings.CODE_SIGN_ENTITLEMENTS = `"${entitlementsFile}"`;

// if deployment target is less then the required one - increase it
if (buildSettings.IPHONEOS_DEPLOYMENT_TARGET) {
Expand Down
18 changes: 8 additions & 10 deletions src/scripts/ios/updateAssociatedDomains.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
// properties



const path = require("path");
const fs = require("fs");
Expand Down Expand Up @@ -37,15 +35,15 @@
"ios",
preferences.projectName,
"Resources",
`${preferences.projectName }.entitlements`
`${preferences.projectName}.entitlements`
);
files.push(
path.join(
preferences.projectRoot,
"platforms",
"ios",
preferences.projectName,
`${preferences.projectName }.entitlements`
`${preferences.projectName}.entitlements`
)
);
files.push(entitlements);
Expand All @@ -57,7 +55,7 @@
"platforms",
"ios",
preferences.projectName,
`Entitlements-${ buildType }.plist`
`Entitlements-${buildType}.plist`
);
files.push(plist);
}
Expand Down Expand Up @@ -117,11 +115,11 @@
if (domain.indexOf("applinks:") === 0) {
domain = domain.replace("applinks:", "");
if (isBranchAssociatedDomains(domain, linkDomains)) {
output.push(`applinks:${ domain}`);
output.push(`applinks:${domain}`);
}
} else if (isBranchAssociatedDomains(domain, linkDomains)) {
output.push(domain);
}
output.push(domain);
}
}

return output;
Expand Down Expand Up @@ -156,9 +154,9 @@
.split(".")
.slice(2)
.join(".");
const alternate = `${first }-alternate`;
const alternate = `${first}-alternate`;

domainList.push(`${prefix + alternate }.${ second }.${ rest}`);
domainList.push(`${prefix + alternate}.${second}.${rest}`);
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/scripts/ios/updateDevelopmentTeam.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
// properties



const fs = require("fs");
const path = require("path");
Expand Down
11 changes: 3 additions & 8 deletions src/scripts/ios/updatePlist.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
// properties



const fs = require("fs");
const plist = require("plist");
Expand All @@ -14,12 +12,9 @@

// updates the platforms/ios/app.plist file with branch settings within app/config.xml
function addBranchSettings(preferences) {
const filePath =
`platforms/ios/${
preferences.projectName
}/${
preferences.projectName
}-Info.plist`;
const filePath = `platforms/ios/${preferences.projectName}/${
preferences.projectName
}-Info.plist`;
let xml = readPlist(filePath);
let obj = convertXmlToObject(xml);

Expand Down
8 changes: 3 additions & 5 deletions src/scripts/lib/fileHelper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
// properties



const fs = require("fs");

Expand All @@ -17,7 +15,7 @@
try {
return fs.accessSync(file);
} catch (err) {
throw new Error(`BRANCH SDK: Cannot access file ${ file}`);
throw new Error(`BRANCH SDK: Cannot access file ${file}`);
}
}

Expand All @@ -26,7 +24,7 @@
try {
return fs.readFileSync(file, "utf8");
} catch (err) {
throw new Error(`BRANCH SDK: Cannot read file ${ file}`);
throw new Error(`BRANCH SDK: Cannot read file ${file}`);
}
}

Expand All @@ -36,7 +34,7 @@
fs.writeFileSync(file, content, "utf8");
} catch (err) {
throw new Error(
`BRANCH SDK: Cannot write file ${ file } with content ${ content}`
`BRANCH SDK: Cannot write file ${file} with content ${content}`
);
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/scripts/lib/xmlHelper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
// properties



const fs = require("fs");
const xml2js = require("xml2js");
Expand All @@ -27,7 +25,7 @@
}
});
} catch (err) {
throw new Error(`BRANCH SDK: Cannot write file ${ file}`);
throw new Error(`BRANCH SDK: Cannot write file ${file}`);
}

return parsedData;
Expand All @@ -43,7 +41,7 @@
fs.writeFileSync(file, changedXmlData);
} catch (err) {
isSaved = false;
throw new Error(`BRANCH SDK: Cannot write file ${ file}`);
throw new Error(`BRANCH SDK: Cannot write file ${file}`);
}

return isSaved;
Expand Down
12 changes: 4 additions & 8 deletions src/scripts/npm/downloadNpmDependencies.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
// properties



const SDK = "branch-cordova-sdk";
const fs = require("fs");
Expand Down Expand Up @@ -59,16 +57,14 @@

// install one at a time
const module = modules.pop();
console.log(`BRANCH SDK: Installing node dependency ${ module}`);
console.log(`BRANCH SDK: Installing node dependency ${module}`);

const install = `npm install --prefix ./plugins/${ SDK } -D ${ module}`;
const install = `npm install --prefix ./plugins/${SDK} -D ${module}`;
exec(install, (err, stdout, stderr) => {
// handle error
if (err) {
throw new Error(
`BRANCH SDK: Failed to install Branch node dependency ${
module
}. Docs https://goo.gl/GijGKP`
`BRANCH SDK: Failed to install Branch node dependency ${module}. Docs https://goo.gl/GijGKP`
);
} else {
// next module
Expand Down Expand Up @@ -109,7 +105,7 @@

// artifact caused by 'npm install --prefix'
function removeEtcDirectory() {
const remove = `rm -r ./plugins/${ SDK }/etc`;
const remove = `rm -r ./plugins/${SDK}/etc`;
exec(remove);
}
})();
Loading

0 comments on commit 4e0ccb8

Please sign in to comment.