1"use strict"; 2var __importDefault = (this && this.__importDefault) || function (mod) { 3 return (mod && mod.__esModule) ? mod : { "default": mod }; 4}; 5Object.defineProperty(exports, "__esModule", { value: true }); 6const config_plugins_1 = require("@expo/config-plugins"); 7// @ts-expect-error missing types 8const app_plugin_1 = __importDefault(require("expo-dev-launcher/app.plugin")); 9// @ts-expect-error missing types 10const app_plugin_2 = __importDefault(require("expo-dev-menu/app.plugin")); 11const fs_1 = __importDefault(require("fs")); 12const path_1 = __importDefault(require("path")); 13const withGeneratedAndroidScheme_1 = __importDefault(require("./withGeneratedAndroidScheme")); 14const withGeneratedIosScheme_1 = __importDefault(require("./withGeneratedIosScheme")); 15const pkg = require('expo-dev-client/package.json'); 16const REACT_NATIVE_CONFIG_JS = `// File created by expo-dev-client/app.plugin.js 17 18module.exports = { 19 dependencies: { 20 ...require('expo-dev-client/dependencies'), 21 }, 22}; 23`; 24function withReactNativeConfigJs(config) { 25 config = config_plugins_1.withDangerousMod(config, ['android', addReactNativeConfigAsync]); 26 config = config_plugins_1.withDangerousMod(config, ['ios', addReactNativeConfigAsync]); 27 return config; 28} 29const addReactNativeConfigAsync = async (config) => { 30 const filename = path_1.default.join(config.modRequest.projectRoot, 'react-native.config.js'); 31 try { 32 const config = fs_1.default.readFileSync(filename, 'utf8'); 33 if (!config.includes('expo-dev-client/dependencies')) { 34 throw new Error(`Could not add expo-dev-client dependencies to existing file ${filename}. See expo-dev-client installation instructions to add them manually.`); 35 } 36 } 37 catch (error) { 38 if (error.code === 'ENOENT') { 39 // The file doesn't exist, so we create it. 40 fs_1.default.writeFileSync(filename, REACT_NATIVE_CONFIG_JS); 41 } 42 else { 43 throw error; 44 } 45 } 46 return config; 47}; 48function withDevClient(config) { 49 config = app_plugin_2.default(config); 50 config = app_plugin_1.default(config); 51 config = withReactNativeConfigJs(config); 52 config = withGeneratedAndroidScheme_1.default(config); 53 config = withGeneratedIosScheme_1.default(config); 54 return config; 55} 56exports.default = config_plugins_1.createRunOncePlugin(withDevClient, pkg.name, pkg.version); 57