mirror of
https://github.com/expo/config-plugins.git
synced 2026-11-13 20:28:07 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ff7299176 | ||
|
|
f1bd9a7e27 | ||
|
|
83b52a3b61 | ||
|
|
16dfad4dc8 | ||
|
|
0f6493e28d | ||
|
|
0d55f9c8c9 | ||
|
|
fa85f7cf36 |
No files matched your search
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/android-jsc-intl [1.0.3](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/android-jsc-intl [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
/**
|
||||
* Apply android-jsc-intl configuration for Expo SDK 42 projects.
|
||||
*
|
||||
* This plugin lets you access the `Intl` API in Android apps (without Hermes).
|
||||
*/
|
||||
declare const withAndroidJscIntl: ConfigPlugin;
|
||||
export default withAndroidJscIntl;
|
||||
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
/**
|
||||
* Apply android-jsc-intl configuration for Expo SDK 42 projects.
|
||||
*
|
||||
* This plugin lets you access the `Intl` API in Android apps (without Hermes).
|
||||
*/
|
||||
const withAndroidJscIntl = (config) => {
|
||||
// Return the modified config.
|
||||
return config_plugins_1.withAppBuildGradle(config, config => {
|
||||
if (config.modResults.language === 'groovy') {
|
||||
config.modResults.contents = config.modResults.contents.replace('org.webkit:android-jsc:+', 'org.webkit:android-jsc-intl:+');
|
||||
}
|
||||
else {
|
||||
throw new Error('[@expo/config-plugins][withAndroidJscIntl] Cannot enable Intl in Android JSC app gradle because the build.gradle is not groovy.');
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.default = withAndroidJscIntl;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/android-jsc-intl",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Config plugin for android-jsc-intl package",
|
||||
"main": "build/withAndroidJscIntl.js",
|
||||
"types": "build/withAndroidJscIntl.d.ts",
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/detox [1.2.3](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/detox [1.2.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
import { SubdomainsType } from "./withNetworkSecurityConfig";
|
||||
declare const _default: ConfigPlugin<void | {
|
||||
/**
|
||||
* Disable adding proguard minification to the `app/build.gradle`.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
skipProguard?: boolean | undefined;
|
||||
/**
|
||||
* Subdomains to add to the network security config.
|
||||
* Pass `['10.0.3.2', 'localhost']` to use Genymotion emulators instead of Google emulators.
|
||||
* Pass `*` to allow all domains.
|
||||
*
|
||||
* @default ['10.0.2.2', 'localhost'] // (Google emulators)
|
||||
*/
|
||||
subdomains?: SubdomainsType | undefined;
|
||||
}>;
|
||||
export default _default;
|
||||
Generated
+42
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const withDetoxProjectGradle_1 = __importDefault(require("./withDetoxProjectGradle"));
|
||||
const withDetoxTestAppGradle_1 = __importDefault(require("./withDetoxTestAppGradle"));
|
||||
const withDetoxTestClass_1 = require("./withDetoxTestClass");
|
||||
const withKotlinGradle_1 = __importDefault(require("./withKotlinGradle"));
|
||||
const withNetworkSecurityConfig_1 = require("./withNetworkSecurityConfig");
|
||||
const withProguardGradle_1 = __importDefault(require("./withProguardGradle"));
|
||||
const withDetox = (config, { skipProguard, subdomains } = {}) => {
|
||||
return config_plugins_1.withPlugins(config, [
|
||||
// 3.
|
||||
withDetoxProjectGradle_1.default,
|
||||
// 3.
|
||||
withDetoxTestAppGradle_1.default,
|
||||
// 4.
|
||||
[
|
||||
withKotlinGradle_1.default,
|
||||
// Minimum version of Kotlin required to work with expo packages in SDK 43
|
||||
"1.4.21",
|
||||
],
|
||||
// 5.
|
||||
withDetoxTestClass_1.withDetoxTestClass,
|
||||
// 6.
|
||||
[withNetworkSecurityConfig_1.withNetworkSecurityConfigManifest, { subdomains }],
|
||||
// 7.
|
||||
!skipProguard && withProguardGradle_1.default,
|
||||
].filter(Boolean));
|
||||
};
|
||||
let pkg = {
|
||||
name: "detox",
|
||||
// UNVERSIONED...
|
||||
};
|
||||
try {
|
||||
const detoxPkg = require("detox/package.json");
|
||||
pkg = detoxPkg;
|
||||
}
|
||||
catch (_a) { }
|
||||
exports.default = config_plugins_1.createRunOncePlugin(withDetox, pkg.name, pkg.version);
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
import { MergeResults } from "@expo/config-plugins/build/utils/generateCode";
|
||||
/**
|
||||
* [Step 3](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#3-add-the-native-detox-dependency) Add detox to the project build.gradle.
|
||||
* @param config
|
||||
*/
|
||||
declare const withDetoxProjectGradle: ConfigPlugin;
|
||||
export declare function addDetoxImport(src: string): MergeResults;
|
||||
export default withDetoxProjectGradle;
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addDetoxImport = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
||||
// Because we need the package to be added AFTER the React and Google maven packages, we create a new allprojects.
|
||||
// It's ok to have multiple allprojects.repositories, so we create a new one since it's cheaper than tokenizing
|
||||
// the existing block to find the correct place to insert our camera maven.
|
||||
const gradleMaven = [
|
||||
`def detoxMavenPath = new File(["node", "--print", "require.resolve('detox/package.json')"].execute(null, rootDir).text.trim(), "../Detox-android")`,
|
||||
`allprojects { repositories { maven { url(detoxMavenPath) } } }`,
|
||||
].join("\n");
|
||||
/**
|
||||
* [Step 3](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#3-add-the-native-detox-dependency) Add detox to the project build.gradle.
|
||||
* @param config
|
||||
*/
|
||||
const withDetoxProjectGradle = (config) => {
|
||||
return config_plugins_1.withProjectBuildGradle(config, (config) => {
|
||||
if (config.modResults.language === "groovy") {
|
||||
config.modResults.contents = addDetoxImport(config.modResults.contents).contents;
|
||||
}
|
||||
else {
|
||||
throw new Error("Cannot add Detox maven gradle because the project build.gradle is not groovy");
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
function addDetoxImport(src) {
|
||||
return appendContents({
|
||||
tag: "detox-import",
|
||||
src,
|
||||
newSrc: gradleMaven,
|
||||
comment: "//",
|
||||
});
|
||||
}
|
||||
exports.addDetoxImport = addDetoxImport;
|
||||
// Fork of config-plugins mergeContents, but appends the contents to the end of the file.
|
||||
function appendContents({ src, newSrc, tag, comment, }) {
|
||||
const header = generateCode_1.createGeneratedHeaderComment(newSrc, tag, comment);
|
||||
if (!src.includes(header)) {
|
||||
// Ensure the old generated contents are removed.
|
||||
const sanitizedTarget = generateCode_1.removeGeneratedContents(src, tag);
|
||||
const contentsToAdd = [
|
||||
// @something
|
||||
header,
|
||||
// contents
|
||||
newSrc,
|
||||
// @end
|
||||
`${comment} @generated end ${tag}`,
|
||||
].join("\n");
|
||||
return {
|
||||
contents: sanitizedTarget !== null && sanitizedTarget !== void 0 ? sanitizedTarget : src + contentsToAdd,
|
||||
didMerge: true,
|
||||
didClear: !!sanitizedTarget,
|
||||
};
|
||||
}
|
||||
return { contents: src, didClear: false, didMerge: false };
|
||||
}
|
||||
exports.default = withDetoxProjectGradle;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
/**
|
||||
* [Step 3](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#3-add-the-native-detox-dependency). Add the Native Detox dependency.
|
||||
*
|
||||
* 1. Add `androidTestImplementation` to the app/build.gradle
|
||||
* 2. Add `testInstrumentationRunner` to the app/build.gradle
|
||||
* @param config
|
||||
*/
|
||||
declare const withDetoxTestAppGradle: ConfigPlugin;
|
||||
export declare function setGradleAndroidTestImplementation(buildGradle: string): string;
|
||||
export declare function addDetoxDefaultConfigBlock(buildGradle: string): string;
|
||||
export default withDetoxTestAppGradle;
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addDetoxDefaultConfigBlock = exports.setGradleAndroidTestImplementation = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
/**
|
||||
* [Step 3](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#3-add-the-native-detox-dependency). Add the Native Detox dependency.
|
||||
*
|
||||
* 1. Add `androidTestImplementation` to the app/build.gradle
|
||||
* 2. Add `testInstrumentationRunner` to the app/build.gradle
|
||||
* @param config
|
||||
*/
|
||||
const withDetoxTestAppGradle = (config) => {
|
||||
return config_plugins_1.withAppBuildGradle(config, (config) => {
|
||||
if (config.modResults.language === "groovy") {
|
||||
config.modResults.contents = setGradleAndroidTestImplementation(config.modResults.contents);
|
||||
config.modResults.contents = addDetoxDefaultConfigBlock(config.modResults.contents);
|
||||
}
|
||||
else {
|
||||
throw new Error("Cannot add Detox maven gradle because the project build.gradle is not groovy");
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
function setGradleAndroidTestImplementation(buildGradle) {
|
||||
const pattern = /androidTestImplementation\(\'com.wix:detox:\+\'\)/g;
|
||||
if (buildGradle.match(pattern)) {
|
||||
return buildGradle;
|
||||
}
|
||||
return buildGradle.replace(/dependencies\s?{/, `dependencies {
|
||||
androidTestImplementation('com.wix:detox:+')`);
|
||||
}
|
||||
exports.setGradleAndroidTestImplementation = setGradleAndroidTestImplementation;
|
||||
function addDetoxDefaultConfigBlock(buildGradle) {
|
||||
const pattern = /detox-plugin-default-config/g;
|
||||
if (buildGradle.match(pattern)) {
|
||||
return buildGradle;
|
||||
}
|
||||
return buildGradle.replace(/defaultConfig\s?{/, `defaultConfig {
|
||||
// detox-plugin-default-config
|
||||
testBuildType System.getProperty('testBuildType', 'debug')
|
||||
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'`);
|
||||
}
|
||||
exports.addDetoxDefaultConfigBlock = addDetoxDefaultConfigBlock;
|
||||
exports.default = withDetoxTestAppGradle;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
/**
|
||||
* [Step 5](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#5-create-a-detox-test-class). Create `DetoxTest.java`
|
||||
*/
|
||||
export declare const withDetoxTestClass: ConfigPlugin;
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withDetoxTestClass = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const path = __importStar(require("path"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const assert_1 = __importDefault(require("assert"));
|
||||
/**
|
||||
* Copied from the [official template file](https://github.com/wix/Detox/blob/master/examples/demo-react-native/android/app/src/androidTest/java/com/example/DetoxTest.java).
|
||||
*
|
||||
* @param androidPackage
|
||||
*/
|
||||
function getTemplateFile(androidPackage) {
|
||||
// This shouldn't change in standard Expo apps.
|
||||
// Replace 'MainActivity' with the value of android:name entry in
|
||||
// <activity> in AndroidManifest.xml
|
||||
const mainApplicationClassName = "MainActivity";
|
||||
return `package ${androidPackage};
|
||||
|
||||
import com.wix.detox.Detox;
|
||||
import com.wix.detox.config.DetoxConfig;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@LargeTest
|
||||
public class DetoxTest {
|
||||
@Rule
|
||||
public ActivityTestRule<${mainApplicationClassName}> mActivityRule = new ActivityTestRule<>(${mainApplicationClassName}.class, false, false);
|
||||
|
||||
@Test
|
||||
public void runDetoxTests() {
|
||||
DetoxConfig detoxConfig = new DetoxConfig();
|
||||
detoxConfig.idlePolicyConfig.masterTimeoutSec = 90;
|
||||
detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60;
|
||||
detoxConfig.rnContextLoadTimeoutSec = (${androidPackage}.BuildConfig.DEBUG ? 180 : 60);
|
||||
|
||||
Detox.runTests(mActivityRule, detoxConfig);
|
||||
}
|
||||
}
|
||||
`;
|
||||
}
|
||||
/**
|
||||
* [Step 5](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#5-create-a-detox-test-class). Create `DetoxTest.java`
|
||||
*/
|
||||
const withDetoxTestClass = (config) => {
|
||||
return config_plugins_1.withDangerousMod(config, [
|
||||
"android",
|
||||
async (config) => {
|
||||
var _a;
|
||||
const packageName = (_a = config.android) === null || _a === void 0 ? void 0 : _a.package;
|
||||
assert_1.default(packageName, "android.package must be defined");
|
||||
const folder = path.join(config.modRequest.platformProjectRoot, `app/src/androidTest/java/${packageName.split(".").join("/")}`);
|
||||
fs.mkdirSync(folder, { recursive: true });
|
||||
fs.writeFileSync(path.join(folder, "DetoxTest.java"), getTemplateFile(packageName), { encoding: "utf8" });
|
||||
return config;
|
||||
},
|
||||
]);
|
||||
};
|
||||
exports.withDetoxTestClass = withDetoxTestClass;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
/**
|
||||
* [Step 4](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#4-add-kotlin). Add Kotlin.
|
||||
*
|
||||
* Lifted from [unimodules-test-core](https://github.com/expo/expo/blob/master/packages/unimodules-test-core/app.plugin.js).
|
||||
*
|
||||
* @param config Expo config
|
||||
* @param version Kotlin version to use
|
||||
*/
|
||||
declare const withKotlinGradle: ConfigPlugin<string>;
|
||||
export default withKotlinGradle;
|
||||
Generated
+43
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const kotlinClassPath = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion";
|
||||
/**
|
||||
* [Step 4](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#4-add-kotlin). Add Kotlin.
|
||||
*
|
||||
* Lifted from [unimodules-test-core](https://github.com/expo/expo/blob/master/packages/unimodules-test-core/app.plugin.js).
|
||||
*
|
||||
* @param config Expo config
|
||||
* @param version Kotlin version to use
|
||||
*/
|
||||
const withKotlinGradle = (config, version) => {
|
||||
return config_plugins_1.withProjectBuildGradle(config, (config) => {
|
||||
console.log(`[config-plugins/detox] Setting Kotlin version to: ${version}. This could lead to Android build issues.`);
|
||||
if (config.modResults.language === "groovy") {
|
||||
config.modResults.contents = setKotlinVersion(config.modResults.contents, version);
|
||||
config.modResults.contents = setKotlinClassPath(config.modResults.contents);
|
||||
}
|
||||
else {
|
||||
throw new Error("Cannot setup kotlin because the build.gradle is not groovy");
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
function setKotlinVersion(buildGradle, version) {
|
||||
const pattern = /kotlinVersion\s?=\s?(["'])(?:(?=(\\?))\2.)*?\1/g;
|
||||
const replacement = `kotlinVersion = "${version}"`;
|
||||
if (buildGradle.match(pattern)) {
|
||||
// Select kotlinVersion = '***' and replace the contents between the quotes.
|
||||
return buildGradle.replace(pattern, replacement);
|
||||
}
|
||||
return buildGradle.replace(/ext\s?{/, `ext {
|
||||
${replacement}`);
|
||||
}
|
||||
function setKotlinClassPath(buildGradle) {
|
||||
if (buildGradle.includes(kotlinClassPath)) {
|
||||
return buildGradle;
|
||||
}
|
||||
return buildGradle.replace(/dependencies\s?{/, `dependencies {
|
||||
classpath "${kotlinClassPath}"`);
|
||||
}
|
||||
exports.default = withKotlinGradle;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare type SubdomainsType = string[] | "*";
|
||||
export declare function getTemplateFile(subdomains: SubdomainsType): string;
|
||||
/**
|
||||
* [Step 6](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#6-enable-clear-text-unencrypted-traffic-for-detox). Link the `network_security_config.xml` file to the `AndroidManifest.xml`.
|
||||
*/
|
||||
export declare const withNetworkSecurityConfigManifest: ConfigPlugin<{
|
||||
subdomains: SubdomainsType;
|
||||
} | void>;
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withNetworkSecurityConfigManifest = exports.getTemplateFile = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const path = __importStar(require("path"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const assert_1 = __importDefault(require("assert"));
|
||||
function getTemplateConfigContent(subdomains) {
|
||||
if (subdomains === "*") {
|
||||
// allow all domains
|
||||
return '<base-config cleartextTrafficPermitted="true" />';
|
||||
}
|
||||
return `
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
${subdomains
|
||||
.map((subdomain) => `<domain includeSubdomains="true">${subdomain}</domain>`)
|
||||
.join("")}
|
||||
</domain-config>
|
||||
`;
|
||||
}
|
||||
function getTemplateFile(subdomains) {
|
||||
const content = getTemplateConfigContent(subdomains);
|
||||
/**
|
||||
* May not have new lines or spaces in the beginning.
|
||||
* Otherwise build fails with:
|
||||
* "AAPT: error: XML or text declaration not at start of entity"
|
||||
*/
|
||||
return `<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
${content}
|
||||
</network-security-config>`;
|
||||
}
|
||||
exports.getTemplateFile = getTemplateFile;
|
||||
/**
|
||||
* Create `network_security_config.xml` resource file.
|
||||
*/
|
||||
const withNetworkSecurityConfigFile = (config, { subdomains }) => {
|
||||
return config_plugins_1.withDangerousMod(config, [
|
||||
"android",
|
||||
async (config) => {
|
||||
var _a;
|
||||
const packageName = (_a = config.android) === null || _a === void 0 ? void 0 : _a.package;
|
||||
assert_1.default(packageName, "android.package must be defined");
|
||||
const folder = path.join(config.modRequest.platformProjectRoot, `app/src/main/res/xml`);
|
||||
fs.mkdirSync(folder, { recursive: true });
|
||||
fs.writeFileSync(path.join(folder, "network_security_config.xml"), getTemplateFile(subdomains), { encoding: "utf8" });
|
||||
return config;
|
||||
},
|
||||
]);
|
||||
};
|
||||
/**
|
||||
* [Step 6](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#6-enable-clear-text-unencrypted-traffic-for-detox). Link the `network_security_config.xml` file to the `AndroidManifest.xml`.
|
||||
*/
|
||||
const withNetworkSecurityConfigManifest = (config, props) => {
|
||||
if (!props || !props.subdomains) {
|
||||
// (*) 10.0.2.2 for Google emulators, 10.0.3.2 for Genymotion emulators.
|
||||
// https://developer.android.com/training/articles/security-config
|
||||
props = { subdomains: ["10.0.2.2", "localhost"] };
|
||||
}
|
||||
if (typeof props.subdomains === "object" && !props.subdomains.length) {
|
||||
// if subdomains is an empty array, skip network config mod
|
||||
return config;
|
||||
}
|
||||
config = withNetworkSecurityConfigFile(config, props);
|
||||
return config_plugins_1.withAndroidManifest(config, (config) => {
|
||||
const application = config_plugins_1.AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults);
|
||||
application.$["android:networkSecurityConfig"] =
|
||||
"@xml/network_security_config";
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withNetworkSecurityConfigManifest = withNetworkSecurityConfigManifest;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
/**
|
||||
* [Step 7](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#7-proguard-minification-obfuscation). Add Proguard (Minification, Obfuscation) to the app/build.gradle.
|
||||
*
|
||||
* 1. Add `androidTestImplementation` to the app/build.gradle
|
||||
* 2. Add `testInstrumentationRunner` to the app/build.gradle
|
||||
* @param config
|
||||
*/
|
||||
declare const withProguardGradle: ConfigPlugin;
|
||||
export declare function addDetoxProguardRules(buildGradle: string): string;
|
||||
export default withProguardGradle;
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addDetoxProguardRules = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
/**
|
||||
* [Step 7](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#7-proguard-minification-obfuscation). Add Proguard (Minification, Obfuscation) to the app/build.gradle.
|
||||
*
|
||||
* 1. Add `androidTestImplementation` to the app/build.gradle
|
||||
* 2. Add `testInstrumentationRunner` to the app/build.gradle
|
||||
* @param config
|
||||
*/
|
||||
const withProguardGradle = (config) => {
|
||||
return config_plugins_1.withAppBuildGradle(config, (config) => {
|
||||
if (config.modResults.language === "groovy") {
|
||||
config.modResults.contents = addDetoxProguardRules(config.modResults.contents);
|
||||
}
|
||||
else {
|
||||
throw new Error("Cannot add Detox maven gradle because the project build.gradle is not groovy");
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
function addDetoxProguardRules(buildGradle) {
|
||||
const pattern = /detox\/proguard\-rules\-app\.pro/g;
|
||||
if (buildGradle.match(pattern)) {
|
||||
return buildGradle;
|
||||
}
|
||||
return buildGradle.replace(/proguardFiles getDefaultProguardFile\("proguard-android.txt"\),\s?"proguard-rules.pro"/, `proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
||||
// Detox-specific additions to pro-guard
|
||||
def detoxProguardRulesPath = new File(["node", "--print", "require.resolve('detox/package.json')"].execute(null, rootDir).text.trim(), "../android/detox/proguard-rules-app.pro")
|
||||
proguardFile(detoxProguardRulesPath)
|
||||
`);
|
||||
}
|
||||
exports.addDetoxProguardRules = addDetoxProguardRules;
|
||||
exports.default = withProguardGradle;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/detox",
|
||||
"version": "1.2.2",
|
||||
"version": "1.2.3",
|
||||
"description": "Config plugin to auto configure detox on prebuild",
|
||||
"main": "build/withDetox.js",
|
||||
"types": "build/withDetox.d.ts",
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/ffmpeg-kit-react-native [1.0.3](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/ffmpeg-kit-react-native [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare const withAndroidFFMPEGPackage: ConfigPlugin<string | undefined>;
|
||||
export declare function addPackageName(src: string, packageName?: string): string;
|
||||
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addPackageName = exports.withAndroidFFMPEGPackage = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
||||
const withAndroidFFMPEGPackage = (config, packageName) => {
|
||||
return config_plugins_1.withProjectBuildGradle(config, (config) => {
|
||||
if (config.modResults.language === "groovy") {
|
||||
config.modResults.contents = addPackageName(config.modResults.contents, packageName);
|
||||
}
|
||||
else {
|
||||
throw new Error("Cannot add camera maven gradle because the build.gradle is not groovy");
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withAndroidFFMPEGPackage = withAndroidFFMPEGPackage;
|
||||
function addPackageName(src, packageName) {
|
||||
const tag = "ffmpeg-kit-react-native-package";
|
||||
const gradleMaven = packageName
|
||||
? `ext { ffmpegKitPackage = "${packageName}" }`
|
||||
: "";
|
||||
return appendContents({
|
||||
tag,
|
||||
src,
|
||||
newSrc: gradleMaven,
|
||||
comment: "//",
|
||||
}).contents;
|
||||
}
|
||||
exports.addPackageName = addPackageName;
|
||||
// Fork of config-plugins mergeContents, but appends the contents to the end of the file.
|
||||
function appendContents({ src, newSrc, tag, comment, }) {
|
||||
const header = generateCode_1.createGeneratedHeaderComment(newSrc, tag, comment);
|
||||
if (!src.includes(header)) {
|
||||
// Ensure the old generated contents are removed.
|
||||
let sanitizedTarget = generateCode_1.removeGeneratedContents(src, tag);
|
||||
if (sanitizedTarget)
|
||||
sanitizedTarget += "\n";
|
||||
const contentsToAdd = [
|
||||
// @something
|
||||
header,
|
||||
// contents
|
||||
newSrc,
|
||||
// @end
|
||||
`${comment} @generated end ${tag}`,
|
||||
].join("\n");
|
||||
return {
|
||||
contents: (sanitizedTarget !== null && sanitizedTarget !== void 0 ? sanitizedTarget : src) + contentsToAdd,
|
||||
didMerge: true,
|
||||
didClear: !!sanitizedTarget,
|
||||
};
|
||||
}
|
||||
return { contents: src, didClear: false, didMerge: false };
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare const withPodfilePropertiesPackage: ConfigPlugin<string>;
|
||||
/** Dangerously adds the custom import to the CocoaPods. */
|
||||
export declare const withCocoaPodsImport: ConfigPlugin;
|
||||
export declare function addCocoaPodsImport(src: string): string;
|
||||
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addCocoaPodsImport = exports.withCocoaPodsImport = exports.withPodfilePropertiesPackage = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const ios_plugins_1 = require("@expo/config-plugins/build/plugins/ios-plugins");
|
||||
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const withPodfilePropertiesPackage = (config, packageName) => {
|
||||
return ios_plugins_1.withPodfileProperties(config, (config) => {
|
||||
// @ts-ignore: wrong type
|
||||
config.modResults["ffmpeg-kit-react-native.subspecs"] = [
|
||||
packageName,
|
||||
].filter(Boolean);
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withPodfilePropertiesPackage = withPodfilePropertiesPackage;
|
||||
/** Dangerously adds the custom import to the CocoaPods. */
|
||||
const withCocoaPodsImport = (c) => {
|
||||
return config_plugins_1.withDangerousMod(c, [
|
||||
"ios",
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
async (config) => {
|
||||
const file = path_1.default.join(config.modRequest.platformProjectRoot, "Podfile");
|
||||
const contents = await fs_1.promises.readFile(file, "utf8");
|
||||
await fs_1.promises.writeFile(file, addCocoaPodsImport(contents), "utf-8");
|
||||
return config;
|
||||
},
|
||||
]);
|
||||
};
|
||||
exports.withCocoaPodsImport = withCocoaPodsImport;
|
||||
function addCocoaPodsImport(src) {
|
||||
return generateCode_1.mergeContents({
|
||||
tag: `ffmpeg-kit-react-native-import`,
|
||||
src,
|
||||
newSrc: ` pod 'ffmpeg-kit-react-native', :subspecs => podfile_properties['ffmpeg-kit-react-native.subspecs'] || [], :podspec => File.join(File.dirname(\`node --print "require.resolve('ffmpeg-kit-react-native/package.json')"\`), "ffmpeg-kit-react-native.podspec")`,
|
||||
anchor: /use_native_modules/,
|
||||
// We can't go after the use_native_modules block because it might have parameters, causing it to be multi-line (see react-native template).
|
||||
offset: 0,
|
||||
comment: "#",
|
||||
}).contents;
|
||||
}
|
||||
exports.addCocoaPodsImport = addCocoaPodsImport;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
declare type Package = "min" | "min-gpl" | "https" | "https-gpl" | "audio" | "video" | "full" | "full-gpl";
|
||||
export declare type Props = {
|
||||
package?: Package;
|
||||
ios?: {
|
||||
package?: Package;
|
||||
};
|
||||
android?: {
|
||||
package?: Package;
|
||||
};
|
||||
};
|
||||
export {};
|
||||
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const withAndroidFFMPEGPackage_1 = require("./withAndroidFFMPEGPackage");
|
||||
const withCocoaPodsImport_1 = require("./withCocoaPodsImport");
|
||||
const withIosDeploymentTarget_1 = require("./withIosDeploymentTarget");
|
||||
let pkg = {
|
||||
name: "ffmpeg-kit-react-native",
|
||||
};
|
||||
try {
|
||||
pkg = require("ffmpeg-kit-react-native/package.json");
|
||||
}
|
||||
catch (_a) {
|
||||
// empty catch block
|
||||
}
|
||||
const withFFMPEG = (config, _props) => {
|
||||
var _a, _b;
|
||||
const props = _props || {};
|
||||
const iosPackage = ((_a = props.ios) === null || _a === void 0 ? void 0 : _a.package) || props.package;
|
||||
const androidPackage = ((_b = props.android) === null || _b === void 0 ? void 0 : _b.package) || props.package;
|
||||
return config_plugins_1.withPlugins(config, [
|
||||
// iOS
|
||||
[withCocoaPodsImport_1.withPodfilePropertiesPackage, iosPackage],
|
||||
[
|
||||
withIosDeploymentTarget_1.withIosDeploymentTarget,
|
||||
// https://github.com/tanersener/ffmpeg-kit/tree/main/react-native#211-package-names
|
||||
{ deploymentTarget: "12.1" },
|
||||
],
|
||||
withCocoaPodsImport_1.withCocoaPodsImport,
|
||||
// Android
|
||||
// Set min SDK Version to 24.
|
||||
[
|
||||
config_plugins_1.AndroidConfig.Version.withBuildScriptExtMinimumVersion,
|
||||
{
|
||||
name: "minSdkVersion",
|
||||
minVersion: 24,
|
||||
},
|
||||
],
|
||||
[withAndroidFFMPEGPackage_1.withAndroidFFMPEGPackage, androidPackage],
|
||||
]);
|
||||
};
|
||||
module.exports = config_plugins_1.createRunOncePlugin(withFFMPEG, pkg.name, pkg.version);
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { ConfigPlugin, XcodeProject } from "@expo/config-plugins";
|
||||
declare type IosDeploymentTargetConfigPlugin = ConfigPlugin<{
|
||||
deploymentTarget: string;
|
||||
}>;
|
||||
export declare const withIosDeploymentTarget: IosDeploymentTargetConfigPlugin;
|
||||
export declare function updateDeploymentTargetPodfile(contents: string, deploymentTarget: string): string;
|
||||
export declare function updateDeploymentTargetXcodeProject(project: XcodeProject, deploymentTarget: string): XcodeProject;
|
||||
export {};
|
||||
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.updateDeploymentTargetXcodeProject = exports.updateDeploymentTargetPodfile = exports.withIosDeploymentTarget = void 0;
|
||||
// Copied from https://github.com/expo/expo-cli/blob/main/packages/install-expo-modules/src/plugins/ios/withIosDeploymentTarget.ts
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const semver_1 = __importDefault(require("semver"));
|
||||
const withIosDeploymentTarget = (config, props) => {
|
||||
config = withIosDeploymentTargetPodfile(config, props);
|
||||
config = withIosDeploymentTargetXcodeProject(config, props);
|
||||
return config;
|
||||
};
|
||||
exports.withIosDeploymentTarget = withIosDeploymentTarget;
|
||||
const withIosDeploymentTargetPodfile = (config, props) => {
|
||||
return config_plugins_1.withDangerousMod(config, [
|
||||
"ios",
|
||||
async (config) => {
|
||||
const podfile = path_1.default.join(config.modRequest.platformProjectRoot, "Podfile");
|
||||
let contents = await fs_1.default.promises.readFile(podfile, "utf8");
|
||||
contents = updateDeploymentTargetPodfile(contents, props.deploymentTarget);
|
||||
await fs_1.default.promises.writeFile(podfile, contents);
|
||||
return config;
|
||||
},
|
||||
]);
|
||||
};
|
||||
function updateDeploymentTargetPodfile(contents, deploymentTarget) {
|
||||
return contents.replace(/^(\s*platform :ios, ['"])([\d.]+)(['"])/gm, (match, prefix, version, suffix) => {
|
||||
if (semver_1.default.lt(toSemVer(version), toSemVer(deploymentTarget))) {
|
||||
return `${prefix}${deploymentTarget}${suffix}`;
|
||||
}
|
||||
return match;
|
||||
});
|
||||
}
|
||||
exports.updateDeploymentTargetPodfile = updateDeploymentTargetPodfile;
|
||||
const withIosDeploymentTargetXcodeProject = (config, props) => {
|
||||
return config_plugins_1.withXcodeProject(config, (config) => {
|
||||
config.modResults = updateDeploymentTargetXcodeProject(config.modResults, props.deploymentTarget);
|
||||
return config;
|
||||
});
|
||||
};
|
||||
function updateDeploymentTargetXcodeProject(project, deploymentTarget) {
|
||||
const configurations = project.pbxXCBuildConfigurationSection();
|
||||
// @ts-ignore
|
||||
for (const { buildSettings } of Object.values(configurations !== null && configurations !== void 0 ? configurations : {})) {
|
||||
const currDeploymentTarget = buildSettings === null || buildSettings === void 0 ? void 0 : buildSettings.IPHONEOS_DEPLOYMENT_TARGET;
|
||||
if (currDeploymentTarget &&
|
||||
semver_1.default.lt(toSemVer(currDeploymentTarget), toSemVer(deploymentTarget))) {
|
||||
buildSettings.IPHONEOS_DEPLOYMENT_TARGET = deploymentTarget;
|
||||
}
|
||||
}
|
||||
return project;
|
||||
}
|
||||
exports.updateDeploymentTargetXcodeProject = updateDeploymentTargetXcodeProject;
|
||||
function toSemVer(version) {
|
||||
var _a;
|
||||
return (_a = semver_1.default.coerce(version)) !== null && _a !== void 0 ? _a : new semver_1.default.SemVer("0.0.0");
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/ffmpeg-kit-react-native",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Config plugin to auto configure FFMPEG on prebuild",
|
||||
"main": "build/withFFMPEG.js",
|
||||
"types": "build/withFFMPEG.d.ts",
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/react-native-adjust [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-adjust [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 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
declare const _default: ConfigPlugin<void | {
|
||||
targetAndroid12?: boolean | undefined;
|
||||
}>;
|
||||
export default _default;
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
||||
const withXcodeLinkBinaryWithLibraries = (config, { library, status }) => {
|
||||
return config_plugins_1.withXcodeProject(config, (config) => {
|
||||
const options = status === "optional" ? { weak: true } : {};
|
||||
const target = config_plugins_1.IOSConfig.XcodeUtils.getApplicationNativeTarget({
|
||||
project: config.modResults,
|
||||
projectName: config.modRequest.projectName,
|
||||
});
|
||||
config.modResults.addFramework(library, {
|
||||
target: target.uuid,
|
||||
...options,
|
||||
});
|
||||
return config;
|
||||
});
|
||||
};
|
||||
const addAndroidPackagingOptions = (src) => {
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "react-native-play-services-analytics",
|
||||
src,
|
||||
newSrc: `
|
||||
implementation 'com.google.android.gms:play-services-analytics:18.0.0'
|
||||
implementation 'com.android.installreferrer:installreferrer:2.2'
|
||||
`,
|
||||
anchor: /dependencies(?:\s+)?\{/,
|
||||
// Inside the dependencies block.
|
||||
offset: 1,
|
||||
comment: "//",
|
||||
});
|
||||
};
|
||||
const withGradle = (config) => {
|
||||
return config_plugins_1.withAppBuildGradle(config, (config) => {
|
||||
if (config.modResults.language === "groovy") {
|
||||
config.modResults.contents = addAndroidPackagingOptions(config.modResults.contents).contents;
|
||||
}
|
||||
else {
|
||||
throw new Error("Cannot add Play Services maven gradle because the project build.gradle is not groovy");
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Apply react-native-adjust configuration for Expo SDK +44 projects.
|
||||
*/
|
||||
const withAdjustPlugin = (config, _props) => {
|
||||
const props = _props || {};
|
||||
config = withXcodeLinkBinaryWithLibraries(config, {
|
||||
library: "iAd.framework",
|
||||
status: "optional",
|
||||
});
|
||||
config = withXcodeLinkBinaryWithLibraries(config, {
|
||||
library: "AdServices.framework",
|
||||
status: "optional",
|
||||
});
|
||||
config = withXcodeLinkBinaryWithLibraries(config, {
|
||||
library: "AdSupport.framework",
|
||||
status: "optional",
|
||||
});
|
||||
config = withXcodeLinkBinaryWithLibraries(config, {
|
||||
library: "StoreKit.framework",
|
||||
status: "optional",
|
||||
});
|
||||
config = withXcodeLinkBinaryWithLibraries(config, {
|
||||
library: "AppTrackingTransparency.framework",
|
||||
status: "optional",
|
||||
});
|
||||
if (props.targetAndroid12) {
|
||||
config = config_plugins_1.AndroidConfig.Version.withBuildScriptExtMinimumVersion(config, {
|
||||
name: "compileSdkVersion",
|
||||
minVersion: 31,
|
||||
});
|
||||
config = config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [
|
||||
"com.google.android.gms.permission.AD_ID",
|
||||
]);
|
||||
}
|
||||
config = withGradle(config);
|
||||
// Return the modified config.
|
||||
return config;
|
||||
};
|
||||
const pkg = {
|
||||
// Prevent this plugin from being run more than once.
|
||||
// This pattern enables users to safely migrate off of this
|
||||
// out-of-tree `@config-plugins/react-native-adjust` to a future
|
||||
// upstream plugin in `react-native-adjust`
|
||||
name: "react-native-adjust",
|
||||
// Indicates that this plugin is dangerously linked to a module,
|
||||
// and might not work with the latest version of that module.
|
||||
version: "UNVERSIONED",
|
||||
};
|
||||
exports.default = config_plugins_1.createRunOncePlugin(withAdjustPlugin, pkg.name, pkg.version);
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-adjust",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Config plugin to auto configure Adjust SDK on prebuild",
|
||||
"main": "build/withReactNativeAdjust.js",
|
||||
"types": "build/withReactNativeAdjust.d.ts",
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/react-native-ble-plx [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-ble-plx [1.0.1](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
import { BackgroundMode } from "./withBLEBackgroundModes";
|
||||
export { BackgroundMode };
|
||||
declare const _default: ConfigPlugin<void | {
|
||||
isBackgroundEnabled?: boolean | undefined;
|
||||
modes?: BackgroundMode[] | undefined;
|
||||
bluetoothAlwaysPermission?: string | false | undefined;
|
||||
bluetoothPeripheralPermission?: string | false | undefined;
|
||||
}>;
|
||||
export default _default;
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
/* eslint-disable flowtype/no-types-missing-file-annotation */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BackgroundMode = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const withBLEAndroidManifest_1 = require("./withBLEAndroidManifest");
|
||||
const withBLEBackgroundModes_1 = require("./withBLEBackgroundModes");
|
||||
Object.defineProperty(exports, "BackgroundMode", { enumerable: true, get: function () { return withBLEBackgroundModes_1.BackgroundMode; } });
|
||||
const withBluetoothPermissions_1 = require("./withBluetoothPermissions");
|
||||
const pkg = { name: "react-native-ble-plx", version: "UNVERSIONED" }; //require('react-native-ble-plx/package.json')
|
||||
/**
|
||||
* Apply BLE configuration for Expo SDK 42 projects.
|
||||
*/
|
||||
const withBLE = (config, props = {}) => {
|
||||
var _a;
|
||||
const _props = props || {};
|
||||
const isBackgroundEnabled = (_a = _props.isBackgroundEnabled) !== null && _a !== void 0 ? _a : false;
|
||||
// iOS
|
||||
config = withBluetoothPermissions_1.withBluetoothPermissions(config, _props);
|
||||
config = withBLEBackgroundModes_1.withBLEBackgroundModes(config, _props.modes || []);
|
||||
// Android
|
||||
config = config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [
|
||||
"android.permission.BLUETOOTH",
|
||||
"android.permission.BLUETOOTH_ADMIN",
|
||||
]);
|
||||
config = withBLEAndroidManifest_1.withBLEAndroidManifest(config, { isBackgroundEnabled });
|
||||
return config;
|
||||
};
|
||||
exports.default = config_plugins_1.createRunOncePlugin(withBLE, pkg.name, pkg.version);
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { ConfigPlugin, AndroidConfig } from "@expo/config-plugins";
|
||||
declare type InnerManifest = AndroidConfig.Manifest.AndroidManifest['manifest'];
|
||||
declare type ManifestPermission = InnerManifest["permission"];
|
||||
declare type AndroidManifest = {
|
||||
manifest: InnerManifest & {
|
||||
permission?: ManifestPermission;
|
||||
"uses-permission"?: InnerManifest["uses-permission"];
|
||||
"uses-permission-sdk-23"?: InnerManifest["uses-permission"];
|
||||
"uses-feature"?: InnerManifest["uses-feature"];
|
||||
};
|
||||
};
|
||||
export declare const withBLEAndroidManifest: ConfigPlugin<{
|
||||
isBackgroundEnabled: boolean;
|
||||
}>;
|
||||
export declare function addFineControlPermissionToManifest(androidManifest: AndroidManifest): AndroidManifest;
|
||||
export declare function addBLEHardwareFeatureToManifest(androidManifest: AndroidConfig.Manifest.AndroidManifest): AndroidConfig.Manifest.AndroidManifest;
|
||||
export {};
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
/* eslint-disable flowtype/no-types-missing-file-annotation */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addBLEHardwareFeatureToManifest = exports.addFineControlPermissionToManifest = exports.withBLEAndroidManifest = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const withBLEAndroidManifest = (config, { isBackgroundEnabled }) => {
|
||||
return config_plugins_1.withAndroidManifest(config, (config) => {
|
||||
config.modResults = addFineControlPermissionToManifest(config.modResults);
|
||||
if (isBackgroundEnabled) {
|
||||
config.modResults = addBLEHardwareFeatureToManifest(config.modResults);
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withBLEAndroidManifest = withBLEAndroidManifest;
|
||||
function addFineControlPermissionToManifest(androidManifest) {
|
||||
var _a;
|
||||
// Add `<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/>` to the AndroidManifest.xml
|
||||
if (!Array.isArray(androidManifest.manifest["uses-permission-sdk-23"])) {
|
||||
androidManifest.manifest["uses-permission-sdk-23"] = [];
|
||||
}
|
||||
if (!androidManifest.manifest["uses-permission-sdk-23"].find((item) => item.$["android:name"] === "android.permission.ACCESS_FINE_LOCATION")) {
|
||||
(_a = androidManifest.manifest["uses-permission-sdk-23"]) === null || _a === void 0 ? void 0 : _a.push({
|
||||
$: {
|
||||
"android:name": "android.permission.ACCESS_FINE_LOCATION",
|
||||
},
|
||||
});
|
||||
}
|
||||
return androidManifest;
|
||||
}
|
||||
exports.addFineControlPermissionToManifest = addFineControlPermissionToManifest;
|
||||
// Add this line if your application always requires BLE. More info can be found on: https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#permissions
|
||||
function addBLEHardwareFeatureToManifest(androidManifest) {
|
||||
var _a;
|
||||
// Add `<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>` to the AndroidManifest.xml
|
||||
if (!Array.isArray(androidManifest.manifest["uses-feature"])) {
|
||||
androidManifest.manifest["uses-feature"] = [];
|
||||
}
|
||||
if (!androidManifest.manifest["uses-feature"].find((item) => item.$["android:name"] === "android.hardware.bluetooth_le")) {
|
||||
(_a = androidManifest.manifest["uses-feature"]) === null || _a === void 0 ? void 0 : _a.push({
|
||||
$: {
|
||||
"android:name": "android.hardware.bluetooth_le",
|
||||
"android:required": "true",
|
||||
},
|
||||
});
|
||||
}
|
||||
return androidManifest;
|
||||
}
|
||||
exports.addBLEHardwareFeatureToManifest = addBLEHardwareFeatureToManifest;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { ConfigPlugin } from '@expo/config-plugins';
|
||||
export declare enum BackgroundMode {
|
||||
Central = "central",
|
||||
Peripheral = "peripheral"
|
||||
}
|
||||
/**
|
||||
* Append `UIBackgroundModes` to the `Info.plist`.
|
||||
*/
|
||||
export declare const withBLEBackgroundModes: ConfigPlugin<BackgroundMode[]>;
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withBLEBackgroundModes = exports.BackgroundMode = void 0;
|
||||
/* eslint-disable flowtype/no-types-missing-file-annotation */
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
var BackgroundMode;
|
||||
(function (BackgroundMode) {
|
||||
BackgroundMode["Central"] = "central";
|
||||
BackgroundMode["Peripheral"] = "peripheral";
|
||||
})(BackgroundMode = exports.BackgroundMode || (exports.BackgroundMode = {}));
|
||||
function ensureKey(arr, key) {
|
||||
if (!arr.find(mode => mode === key)) {
|
||||
arr.push(key);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
const centralKey = 'bluetooth-central';
|
||||
const peripheralKey = 'bluetooth-peripheral';
|
||||
/**
|
||||
* Append `UIBackgroundModes` to the `Info.plist`.
|
||||
*/
|
||||
const withBLEBackgroundModes = (c, modes) => {
|
||||
return config_plugins_1.withInfoPlist(c, config => {
|
||||
if (!Array.isArray(config.modResults.UIBackgroundModes)) {
|
||||
config.modResults.UIBackgroundModes = [];
|
||||
}
|
||||
if (modes.includes(BackgroundMode.Central)) {
|
||||
config.modResults.UIBackgroundModes = ensureKey(config.modResults.UIBackgroundModes, centralKey);
|
||||
}
|
||||
if (modes.includes(BackgroundMode.Peripheral)) {
|
||||
config.modResults.UIBackgroundModes = ensureKey(config.modResults.UIBackgroundModes, peripheralKey);
|
||||
}
|
||||
// Prevent empty array
|
||||
if (!config.modResults.UIBackgroundModes.length) {
|
||||
delete config.modResults.UIBackgroundModes;
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withBLEBackgroundModes = withBLEBackgroundModes;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare const withBluetoothPermissions: ConfigPlugin<{
|
||||
bluetoothAlwaysPermission?: string | false;
|
||||
bluetoothPeripheralPermission?: string | false;
|
||||
}>;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withBluetoothPermissions = void 0;
|
||||
/* eslint-disable flowtype/no-types-missing-file-annotation */
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const BLUETOOTH_ALWAYS = "Allow $(PRODUCT_NAME) to connect to bluetooth devices";
|
||||
const BLUETOOTH_PERIPHERAL_USAGE = "Allow $(PRODUCT_NAME) to connect to bluetooth devices";
|
||||
const withBluetoothPermissions = (c, { bluetoothAlwaysPermission, bluetoothPeripheralPermission } = {}) => {
|
||||
return config_plugins_1.withInfoPlist(c, (config) => {
|
||||
if (bluetoothAlwaysPermission !== false) {
|
||||
config.modResults.NSBluetoothAlwaysUsageDescription =
|
||||
bluetoothAlwaysPermission ||
|
||||
config.modResults.NSBluetoothAlwaysUsageDescription ||
|
||||
BLUETOOTH_ALWAYS;
|
||||
}
|
||||
if (bluetoothPeripheralPermission !== false) {
|
||||
config.modResults.NSBluetoothPeripheralUsageDescription =
|
||||
bluetoothPeripheralPermission ||
|
||||
config.modResults.NSBluetoothPeripheralUsageDescription ||
|
||||
BLUETOOTH_PERIPHERAL_USAGE;
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withBluetoothPermissions = withBluetoothPermissions;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-ble-plx",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Config plugin to auto configure react-native-ble-plx on prebuild",
|
||||
"main": "build/withBLE.js",
|
||||
"types": "build/withBLE.d.ts",
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/react-native-blob-util [1.0.3](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-blob-util [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import { AndroidConfig, ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare function appendDownloadCompleteAction(androidManifest: AndroidConfig.Manifest.AndroidManifest): AndroidConfig.Manifest.AndroidManifest;
|
||||
declare const _default: ConfigPlugin<void>;
|
||||
export default _default;
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.appendDownloadCompleteAction = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
let pkg = {
|
||||
name: "react-native-blob-util",
|
||||
};
|
||||
try {
|
||||
pkg = require("react-native-blob-util/package.json");
|
||||
}
|
||||
catch (_a) {
|
||||
// empty catch block
|
||||
}
|
||||
function appendDownloadCompleteAction(androidManifest) {
|
||||
var _a, _b;
|
||||
if (!Array.isArray(androidManifest.manifest.application)) {
|
||||
return androidManifest;
|
||||
}
|
||||
for (const application of androidManifest.manifest.application) {
|
||||
for (const activity of application.activity || []) {
|
||||
if (((_a = activity === null || activity === void 0 ? void 0 : activity.$) === null || _a === void 0 ? void 0 : _a["android:launchMode"]) === "singleTask") {
|
||||
for (const intentFilter of activity["intent-filter"] || []) {
|
||||
const isLauncher = (_b = intentFilter.category) === null || _b === void 0 ? void 0 : _b.some((action) => action.$["android:name"] === "android.intent.category.LAUNCHER");
|
||||
if (!isLauncher)
|
||||
continue;
|
||||
intentFilter.action = intentFilter.action || [];
|
||||
const hasDownloadCompleteAction = intentFilter.action.some((action) => action.$["android:name"] ===
|
||||
"android.intent.action.DOWNLOAD_COMPLETE");
|
||||
if (!hasDownloadCompleteAction) {
|
||||
intentFilter.action.push({
|
||||
$: {
|
||||
"android:name": "android.intent.action.DOWNLOAD_COMPLETE",
|
||||
},
|
||||
});
|
||||
return androidManifest;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return androidManifest;
|
||||
}
|
||||
exports.appendDownloadCompleteAction = appendDownloadCompleteAction;
|
||||
const withReactNativeBlobUtil = (config) => {
|
||||
config = config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [
|
||||
"android.permission.READ_EXTERNAL_STORAGE",
|
||||
"android.permission.WRITE_EXTERNAL_STORAGE",
|
||||
"android.permission.DOWNLOAD_WITHOUT_NOTIFICATION",
|
||||
// Wifi-only mode.
|
||||
"android.permission.ACCESS_NETWORK_STATE",
|
||||
]);
|
||||
config = config_plugins_1.withAndroidManifest(config, (config) => {
|
||||
config.modResults = appendDownloadCompleteAction(config.modResults);
|
||||
return config;
|
||||
});
|
||||
return config;
|
||||
};
|
||||
exports.default = config_plugins_1.createRunOncePlugin(withReactNativeBlobUtil, pkg.name, pkg.version);
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-blob-util",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Config plugin to auto configure react-native-blob-util on prebuild",
|
||||
"main": "build/withReactNativeBlobUtil.js",
|
||||
"types": "build/withReactNativeBlobUtil.d.ts",
|
||||
|
||||
@@ -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