mirror of
https://github.com/expo/config-plugins.git
synced 2026-11-13 20:28:07 -10:00
chore: latest cleanup
This commit is contained in:
8 files changed
+62
-43
No files matched your search
+6
-2
@@ -3,9 +3,13 @@ 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 } = {}) => {
|
||||
const withBranch = (config, { apiKey, iosAppDomain, iosUniversalLinkDomains } = {}) => {
|
||||
config = withBranchAndroid_1.withBranchAndroid(config, { apiKey });
|
||||
config = withBranchIOS_1.withBranchIOS(config, { apiKey, iosAppDomain });
|
||||
config = withBranchIOS_1.withBranchIOS(config, {
|
||||
apiKey,
|
||||
iosAppDomain,
|
||||
iosUniversalLinkDomains,
|
||||
});
|
||||
return config;
|
||||
};
|
||||
let pkg = {
|
||||
|
||||
+6
-6
@@ -86,7 +86,7 @@ exports.editProguardRules = editProguardRules;
|
||||
function addBranchMainApplicationImport(src, packageId) {
|
||||
const newSrc = ["import io.branch.rnbranch.RNBranchModule;"];
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "rn-branch-import",
|
||||
tag: "react-native-branch-import",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: `package ${packageId};`,
|
||||
@@ -98,7 +98,7 @@ exports.addBranchMainApplicationImport = addBranchMainApplicationImport;
|
||||
function addBranchGetAutoInstance(src) {
|
||||
const newSrc = [" RNBranchModule.getAutoInstance(this);"];
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "rn-branch-auto-instance",
|
||||
tag: "react-native-branch-auto-instance",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /super\.onCreate\(\);/,
|
||||
@@ -113,7 +113,7 @@ function addBranchMainActivityImport(src, packageId) {
|
||||
"import io.branch.rnbranch.*;",
|
||||
];
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "rn-branch-import",
|
||||
tag: "react-native-branch-import",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: `package ${packageId};`,
|
||||
@@ -123,7 +123,7 @@ function addBranchMainActivityImport(src, packageId) {
|
||||
}
|
||||
exports.addBranchMainActivityImport = addBranchMainActivityImport;
|
||||
function addBranchInitSession(src) {
|
||||
const tag = "rn-branch-init-session";
|
||||
const tag = "react-native-branch-init-session";
|
||||
try {
|
||||
const newSrc = [
|
||||
" RNBranchModule.initSession(getIntent().getData(), this);",
|
||||
@@ -160,7 +160,7 @@ function addBranchInitSession(src) {
|
||||
}
|
||||
exports.addBranchInitSession = addBranchInitSession;
|
||||
function addBranchOnNewIntent(src) {
|
||||
const tag = "rn-branch-on-new-intent";
|
||||
const tag = "react-native-branch-on-new-intent";
|
||||
try {
|
||||
const newSrc = [" RNBranchModule.onNewIntent(intent);"];
|
||||
return generateCode_1.mergeContents({
|
||||
@@ -243,7 +243,7 @@ const withBranchAndroid = (config, data) => {
|
||||
async (config) => {
|
||||
await editProguardRules(config, (proguardRules) => {
|
||||
return appendContents({
|
||||
tag: "rn-branch-dont-warn",
|
||||
tag: "react-native-branch-dont-warn",
|
||||
src: proguardRules,
|
||||
newSrc: ["-dontwarn io.branch.**"].join("\n"),
|
||||
comment: "#",
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
import type { ConfigPlugin, InfoPlist } from "@expo/config-plugins";
|
||||
import type { ExpoConfig } from '@expo/config-types';
|
||||
import type { ExpoConfig } from "@expo/config-types";
|
||||
import type { MergeResults } from "@expo/config-plugins/build/utils/generateCode";
|
||||
import type { ConfigData } from "./types";
|
||||
export declare function addBranchAppDelegateImport(src: string): MergeResults;
|
||||
export declare function addBranchAppDelegateInit(src: string): MergeResults;
|
||||
export declare function addBranchAppDelegateOpenURL(src: string): MergeResults;
|
||||
export declare function addBranchAppDelegateContinueUserActivity(src: string): MergeResults;
|
||||
export declare function getBranchApiKey(config: Pick<ExpoConfig, 'ios'>): string | null;
|
||||
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>;
|
||||
+6
-5
@@ -6,7 +6,7 @@ const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
||||
function addBranchAppDelegateImport(src) {
|
||||
const newSrc = ["#import <RNBranch/RNBranch.h>"];
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "rn-branch-import",
|
||||
tag: "react-native-branch-import",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /#import "AppDelegate\.h"/,
|
||||
@@ -21,7 +21,7 @@ function addBranchAppDelegateInit(src) {
|
||||
const newSrc = [];
|
||||
newSrc.push(" [RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];");
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "rn-branch-init",
|
||||
tag: "react-native-branch-init",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: MATCH_INIT,
|
||||
@@ -37,7 +37,7 @@ function addBranchAppDelegateOpenURL(src) {
|
||||
" }",
|
||||
];
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "rn-branch-open-url",
|
||||
tag: "react-native-branch-open-url",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /\(UIApplication \*\)application openURL:/,
|
||||
@@ -53,7 +53,7 @@ function addBranchAppDelegateContinueUserActivity(src) {
|
||||
" }",
|
||||
];
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "rn-branch-continue-user-activity",
|
||||
tag: "react-native-branch-continue-user-activity",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /\(UIApplication \*\)application continueUserActivity:/,
|
||||
@@ -99,7 +99,8 @@ const withBranchIOS = (config, data) => {
|
||||
delete config.modResults.branch_app_domain;
|
||||
}
|
||||
if (data.iosUniversalLinkDomains) {
|
||||
config.modResults.branch_universal_link_domains = data.iosUniversalLinkDomains;
|
||||
config.modResults.branch_universal_link_domains =
|
||||
data.iosUniversalLinkDomains;
|
||||
}
|
||||
else {
|
||||
delete config.modResults.branch_universal_link_domains;
|
||||
|
||||
@@ -2,4 +2,4 @@ export type ConfigData = {
|
||||
apiKey?: string;
|
||||
iosAppDomain?: string;
|
||||
iosUniversalLinkDomains?: string[];
|
||||
}
|
||||
};
|
||||
@@ -5,9 +5,16 @@ import { withBranchAndroid } from "./withBranchAndroid";
|
||||
import { withBranchIOS } from "./withBranchIOS";
|
||||
import type { ConfigData } from "./types";
|
||||
|
||||
const withBranch: ConfigPlugin<ConfigData> = (config, { apiKey, iosAppDomain } = {}) => {
|
||||
const withBranch: ConfigPlugin<ConfigData> = (
|
||||
config,
|
||||
{ apiKey, iosAppDomain, iosUniversalLinkDomains } = {}
|
||||
) => {
|
||||
config = withBranchAndroid(config, { apiKey });
|
||||
config = withBranchIOS(config, { apiKey, iosAppDomain });
|
||||
config = withBranchIOS(config, {
|
||||
apiKey,
|
||||
iosAppDomain,
|
||||
iosUniversalLinkDomains,
|
||||
});
|
||||
return config;
|
||||
};
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ export function addBranchMainApplicationImport(
|
||||
const newSrc = ["import io.branch.rnbranch.RNBranchModule;"];
|
||||
|
||||
return mergeContents({
|
||||
tag: "rn-branch-import",
|
||||
tag: "react-native-branch-import",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: `package ${packageId};`,
|
||||
@@ -139,7 +139,7 @@ export function addBranchGetAutoInstance(src: string): MergeResults {
|
||||
const newSrc = [" RNBranchModule.getAutoInstance(this);"];
|
||||
|
||||
return mergeContents({
|
||||
tag: "rn-branch-auto-instance",
|
||||
tag: "react-native-branch-auto-instance",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /super\.onCreate\(\);/,
|
||||
@@ -158,7 +158,7 @@ export function addBranchMainActivityImport(
|
||||
];
|
||||
|
||||
return mergeContents({
|
||||
tag: "rn-branch-import",
|
||||
tag: "react-native-branch-import",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: `package ${packageId};`,
|
||||
@@ -168,7 +168,7 @@ export function addBranchMainActivityImport(
|
||||
}
|
||||
|
||||
export function addBranchInitSession(src: string): MergeResults {
|
||||
const tag = "rn-branch-init-session";
|
||||
const tag = "react-native-branch-init-session";
|
||||
|
||||
try {
|
||||
const newSrc = [
|
||||
@@ -207,7 +207,7 @@ export function addBranchInitSession(src: string): MergeResults {
|
||||
}
|
||||
|
||||
export function addBranchOnNewIntent(src: string): MergeResults {
|
||||
const tag = "rn-branch-on-new-intent";
|
||||
const tag = "react-native-branch-on-new-intent";
|
||||
|
||||
try {
|
||||
const newSrc = [" RNBranchModule.onNewIntent(intent);"];
|
||||
@@ -243,14 +243,13 @@ export function addBranchOnNewIntent(src: string): MergeResults {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export function getBranchApiKey(config: ExpoConfig) {
|
||||
return config.android?.config?.branch?.apiKey ?? null;
|
||||
}
|
||||
|
||||
export function setBranchApiKey(
|
||||
apiKey: string,
|
||||
androidManifest: AndroidConfig.Manifest.AndroidManifest,
|
||||
androidManifest: AndroidConfig.Manifest.AndroidManifest
|
||||
) {
|
||||
const mainApplication = getMainApplicationOrThrow(androidManifest);
|
||||
|
||||
@@ -275,10 +274,7 @@ export const withBranchAndroid: ConfigPlugin<{ apiKey?: string }> = (
|
||||
}
|
||||
|
||||
config = withAndroidManifest(config, (config) => {
|
||||
config.modResults = setBranchApiKey(
|
||||
apiKey,
|
||||
config.modResults,
|
||||
);
|
||||
config.modResults = setBranchApiKey(apiKey, config.modResults);
|
||||
return config;
|
||||
});
|
||||
|
||||
@@ -309,7 +305,7 @@ export const withBranchAndroid: ConfigPlugin<{ apiKey?: string }> = (
|
||||
async (config) => {
|
||||
await editProguardRules(config, (proguardRules) => {
|
||||
return appendContents({
|
||||
tag: "rn-branch-dont-warn",
|
||||
tag: "react-native-branch-dont-warn",
|
||||
src: proguardRules,
|
||||
newSrc: ["-dontwarn io.branch.**"].join("\n"),
|
||||
comment: "#",
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { withAppDelegate, withInfoPlist, IOSConfig } from "@expo/config-plugins";
|
||||
import {
|
||||
withAppDelegate,
|
||||
withInfoPlist,
|
||||
IOSConfig,
|
||||
} from "@expo/config-plugins";
|
||||
import type { ConfigPlugin, InfoPlist } from "@expo/config-plugins";
|
||||
import type { ExpoConfig } from '@expo/config-types';
|
||||
import type { ExpoConfig } from "@expo/config-types";
|
||||
import { mergeContents } from "@expo/config-plugins/build/utils/generateCode";
|
||||
import type { MergeResults } from "@expo/config-plugins/build/utils/generateCode";
|
||||
import type { ConfigData } from "./types";
|
||||
@@ -8,7 +12,7 @@ import type { ConfigData } from "./types";
|
||||
export function addBranchAppDelegateImport(src: string): MergeResults {
|
||||
const newSrc = ["#import <RNBranch/RNBranch.h>"];
|
||||
return mergeContents({
|
||||
tag: "rn-branch-import",
|
||||
tag: "react-native-branch-import",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /#import "AppDelegate\.h"/,
|
||||
@@ -18,7 +22,8 @@ export function addBranchAppDelegateImport(src: string): MergeResults {
|
||||
}
|
||||
|
||||
// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules).
|
||||
const MATCH_INIT = /(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[\[RCTBridge alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[self\.(\w+))/g;
|
||||
const MATCH_INIT =
|
||||
/(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[\[RCTBridge alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[self\.(\w+))/g;
|
||||
|
||||
export function addBranchAppDelegateInit(src: string): MergeResults {
|
||||
const newSrc = [];
|
||||
@@ -27,7 +32,7 @@ export function addBranchAppDelegateInit(src: string): MergeResults {
|
||||
);
|
||||
|
||||
return mergeContents({
|
||||
tag: "rn-branch-init",
|
||||
tag: "react-native-branch-init",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: MATCH_INIT,
|
||||
@@ -44,7 +49,7 @@ export function addBranchAppDelegateOpenURL(src: string): MergeResults {
|
||||
];
|
||||
|
||||
return mergeContents({
|
||||
tag: "rn-branch-open-url",
|
||||
tag: "react-native-branch-open-url",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /\(UIApplication \*\)application openURL:/,
|
||||
@@ -53,7 +58,9 @@ export function addBranchAppDelegateOpenURL(src: string): MergeResults {
|
||||
});
|
||||
}
|
||||
|
||||
export function addBranchAppDelegateContinueUserActivity(src: string): MergeResults {
|
||||
export function addBranchAppDelegateContinueUserActivity(
|
||||
src: string
|
||||
): MergeResults {
|
||||
const newSrc = [
|
||||
" if ([RNBranch continueUserActivity:userActivity]) {",
|
||||
" return YES;",
|
||||
@@ -61,7 +68,7 @@ export function addBranchAppDelegateContinueUserActivity(src: string): MergeResu
|
||||
];
|
||||
|
||||
return mergeContents({
|
||||
tag: "rn-branch-continue-user-activity",
|
||||
tag: "react-native-branch-continue-user-activity",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /\(UIApplication \*\)application continueUserActivity:/,
|
||||
@@ -70,11 +77,14 @@ export function addBranchAppDelegateContinueUserActivity(src: string): MergeResu
|
||||
});
|
||||
}
|
||||
|
||||
export function getBranchApiKey(config: Pick<ExpoConfig, 'ios'>) {
|
||||
export function getBranchApiKey(config: Pick<ExpoConfig, "ios">) {
|
||||
return config.ios?.config?.branch?.apiKey ?? null;
|
||||
}
|
||||
|
||||
export function setBranchApiKey(apiKey: string, infoPlist: InfoPlist): InfoPlist {
|
||||
export function setBranchApiKey(
|
||||
apiKey: string,
|
||||
infoPlist: InfoPlist
|
||||
): InfoPlist {
|
||||
if (apiKey === null) {
|
||||
return infoPlist;
|
||||
}
|
||||
@@ -87,7 +97,7 @@ export function setBranchApiKey(apiKey: string, infoPlist: InfoPlist): InfoPlist
|
||||
};
|
||||
}
|
||||
|
||||
export const withBranchIOS: ConfigPlugin<ConfigData> = (config, data) =>{
|
||||
export const withBranchIOS: ConfigPlugin<ConfigData> = (config, data) => {
|
||||
// Ensure object exist
|
||||
if (!config.ios) {
|
||||
config.ios = {};
|
||||
@@ -107,7 +117,8 @@ export const withBranchIOS: ConfigPlugin<ConfigData> = (config, data) =>{
|
||||
delete config.modResults.branch_app_domain;
|
||||
}
|
||||
if (data.iosUniversalLinkDomains) {
|
||||
config.modResults.branch_universal_link_domains = data.iosUniversalLinkDomains;
|
||||
config.modResults.branch_universal_link_domains =
|
||||
data.iosUniversalLinkDomains;
|
||||
} else {
|
||||
delete config.modResults.branch_universal_link_domains;
|
||||
}
|
||||
@@ -133,4 +144,4 @@ export const withBranchIOS: ConfigPlugin<ConfigData> = (config, data) =>{
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user