UNPKG

karte-expo-plugin

Version:

Config plugin for karte-react-native package

38 lines (37 loc) 1.82 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.withKarteiOS = void 0; const config_plugins_1 = require("expo/config-plugins"); const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const withKarteiOS = (config, props) => { return (0, config_plugins_1.withXcodeProject)(config, (config) => { if (!props?.karteInfoPlist) { throw new Error("Path to Karte-Info.plist is not defined. Please specify the path in app.json."); } config.modResults = setKarteInfoPlist(config.modRequest.projectRoot, config.modResults, props.karteInfoPlist); return config; }); }; exports.withKarteiOS = withKarteiOS; function setKarteInfoPlist(projectRoot, project, karteInfoPlistPath) { const karteInfoPlistFilePath = path_1.default.resolve(projectRoot, karteInfoPlistPath); if (!fs_1.default.existsSync(karteInfoPlistFilePath)) { throw new Error(`Karte-Info.plist doesn't exist in ${karteInfoPlistFilePath}. Place it there or configure the path in app.json`); } fs_1.default.copyFileSync(karteInfoPlistFilePath, path_1.default.join(config_plugins_1.IOSConfig.Paths.getSourceRoot(projectRoot), "Karte-Info.plist")); const projectName = config_plugins_1.IOSConfig.XcodeUtils.getProjectName(projectRoot); const plistFilePath = `${projectName}/Karte-Info.plist`; if (!project.hasFile(plistFilePath)) { project = config_plugins_1.IOSConfig.XcodeUtils.addResourceFileToGroup({ filepath: plistFilePath, groupName: projectName, project, isBuildFile: true, }); } return project; }