mirror of
https://github.com/expo/config-plugins.git
synced 2026-11-13 20:28:07 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ff7299176 |
No files matched your search
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/react-native-branch [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
|
||||
|
||||
### @config-plugins/react-native-branch [1.0.1](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export declare type ConfigData = {
|
||||
apiKey?: string;
|
||||
iosAppDomain?: string;
|
||||
iosUniversalLinkDomains?: string[];
|
||||
};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type { ConfigPlugin } from "@expo/config-plugins";
|
||||
import type { ConfigData } from "./types";
|
||||
declare const _default: ConfigPlugin<ConfigData>;
|
||||
export default _default;
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const withBranchAndroid_1 = require("./withBranchAndroid");
|
||||
const withBranchIOS_1 = require("./withBranchIOS");
|
||||
const withBranch = (config, { apiKey, iosAppDomain, iosUniversalLinkDomains } = {}) => {
|
||||
config = withBranchAndroid_1.withBranchAndroid(config, { apiKey });
|
||||
config = withBranchIOS_1.withBranchIOS(config, {
|
||||
apiKey,
|
||||
iosAppDomain,
|
||||
iosUniversalLinkDomains,
|
||||
});
|
||||
return config;
|
||||
};
|
||||
let pkg = {
|
||||
name: "react-native-branch",
|
||||
};
|
||||
try {
|
||||
const branchPkg = require("react-native-branch/package.json");
|
||||
pkg = branchPkg;
|
||||
}
|
||||
catch (_a) { }
|
||||
exports.default = config_plugins_1.createRunOncePlugin(withBranch, pkg.name, pkg.version);
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { AndroidConfig } from "@expo/config-plugins";
|
||||
import type { ConfigPlugin } from "@expo/config-plugins";
|
||||
import type { ExpoConfig } from "@expo/config-types";
|
||||
export declare function getBranchApiKey(config: ExpoConfig): string | null;
|
||||
export declare function setBranchApiKey(apiKey: string, androidManifest: AndroidConfig.Manifest.AndroidManifest): AndroidConfig.Manifest.AndroidManifest;
|
||||
export declare const withBranchAndroid: ConfigPlugin<{
|
||||
apiKey?: string;
|
||||
}>;
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withBranchAndroid = exports.setBranchApiKey = exports.getBranchApiKey = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const { addMetaDataItemToMainApplication, getMainApplicationOrThrow, removeMetaDataItemFromMainApplication, } = config_plugins_1.AndroidConfig.Manifest;
|
||||
const META_BRANCH_KEY = "io.branch.sdk.BranchKey";
|
||||
function getBranchApiKey(config) {
|
||||
var _a, _b, _c, _d;
|
||||
return (_d = (_c = (_b = (_a = config.android) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.branch) === null || _c === void 0 ? void 0 : _c.apiKey) !== null && _d !== void 0 ? _d : null;
|
||||
}
|
||||
exports.getBranchApiKey = getBranchApiKey;
|
||||
function setBranchApiKey(apiKey, androidManifest) {
|
||||
const mainApplication = getMainApplicationOrThrow(androidManifest);
|
||||
if (apiKey) {
|
||||
// If the item exists, add it back
|
||||
addMetaDataItemToMainApplication(mainApplication, META_BRANCH_KEY, apiKey);
|
||||
}
|
||||
else {
|
||||
// Remove any existing item
|
||||
removeMetaDataItemFromMainApplication(mainApplication, META_BRANCH_KEY);
|
||||
}
|
||||
return androidManifest;
|
||||
}
|
||||
exports.setBranchApiKey = setBranchApiKey;
|
||||
const withBranchAndroid = (config, data) => {
|
||||
var _a;
|
||||
const apiKey = (_a = data.apiKey) !== null && _a !== void 0 ? _a : getBranchApiKey(config);
|
||||
if (!apiKey) {
|
||||
throw new Error("Branch API key is required");
|
||||
}
|
||||
config = config_plugins_1.withAndroidManifest(config, (config) => {
|
||||
config.modResults = setBranchApiKey(apiKey, config.modResults);
|
||||
return config;
|
||||
});
|
||||
return config;
|
||||
};
|
||||
exports.withBranchAndroid = withBranchAndroid;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import type { ConfigPlugin, InfoPlist } from "@expo/config-plugins";
|
||||
import type { ExpoConfig } from "@expo/config-types";
|
||||
import type { ConfigData } from "./types";
|
||||
export declare function getBranchApiKey(config: Pick<ExpoConfig, "ios">): string | null;
|
||||
export declare function setBranchApiKey(apiKey: string, infoPlist: InfoPlist): InfoPlist;
|
||||
export declare const withBranchIOS: ConfigPlugin<ConfigData>;
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withBranchIOS = exports.setBranchApiKey = exports.getBranchApiKey = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
function getBranchApiKey(config) {
|
||||
var _a, _b, _c, _d;
|
||||
return (_d = (_c = (_b = (_a = config.ios) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.branch) === null || _c === void 0 ? void 0 : _c.apiKey) !== null && _d !== void 0 ? _d : null;
|
||||
}
|
||||
exports.getBranchApiKey = getBranchApiKey;
|
||||
function setBranchApiKey(apiKey, infoPlist) {
|
||||
if (apiKey === null) {
|
||||
return infoPlist;
|
||||
}
|
||||
return {
|
||||
...infoPlist,
|
||||
branch_key: {
|
||||
live: apiKey,
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.setBranchApiKey = setBranchApiKey;
|
||||
const withBranchIOS = (config, data) => {
|
||||
var _a;
|
||||
// Ensure object exist
|
||||
if (!config.ios) {
|
||||
config.ios = {};
|
||||
}
|
||||
const apiKey = (_a = data.apiKey) !== null && _a !== void 0 ? _a : getBranchApiKey(config);
|
||||
if (!apiKey) {
|
||||
throw new Error("Branch API key is required");
|
||||
}
|
||||
// Update the infoPlist with the branch key and branch domain
|
||||
config = config_plugins_1.withInfoPlist(config, (config) => {
|
||||
config.modResults = setBranchApiKey(apiKey, config.modResults);
|
||||
if (data.iosAppDomain) {
|
||||
config.modResults.branch_app_domain = data.iosAppDomain;
|
||||
}
|
||||
else {
|
||||
delete config.modResults.branch_app_domain;
|
||||
}
|
||||
if (data.iosUniversalLinkDomains) {
|
||||
config.modResults.branch_universal_link_domains =
|
||||
data.iosUniversalLinkDomains;
|
||||
}
|
||||
else {
|
||||
delete config.modResults.branch_universal_link_domains;
|
||||
}
|
||||
return config;
|
||||
});
|
||||
return config;
|
||||
};
|
||||
exports.withBranchIOS = withBranchIOS;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-branch",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Config plugin to auto configure react-native-branch on prebuild",
|
||||
"author": "650 Industries, Inc.",
|
||||
"license": "MIT",
|
||||
|
||||
Reference in new issue
Block a user