UNPKG

@armanatz/expo-hms-location

Version:

Expo config plugin to configure @hmscore/react-native-hms-location on prebuild

60 lines (59 loc) 2.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._applyHMSAGConnectServicesPlugin = _applyHMSAGConnectServicesPlugin; exports._addHMSImplementation = _addHMSImplementation; exports._applyBouncyCastleResolutionFix = _applyBouncyCastleResolutionFix; exports.default = withHMSLocationSDK; const config_plugins_1 = require("expo/config-plugins"); const utils_1 = require("../utils"); function _applyHMSAGConnectServicesPlugin(appBuildGradle) { return (0, utils_1.mergeContents)({ tag: '@armanatz/expo-hms-location-agconnect', src: appBuildGradle, newSrc: `apply plugin: "com.huawei.agconnect"`, anchor: new RegExp(`apply plugin: "com.facebook.react"`), offset: 1, comment: '//', }); } function _addHMSImplementation(appBuildGradle) { return (0, utils_1.mergeContents)({ tag: '@armanatz/expo-hms-location-implementation', src: appBuildGradle, newSrc: ` implementation("com.huawei.hms:location:6.12.0.300")`, anchor: new RegExp('^\\s*dependencies\\s*{'), offset: 1, comment: ' //', }); } function _applyBouncyCastleResolutionFix(appBuildGradle) { return (0, utils_1.mergeContents)({ tag: '@armanatz/expo-hms-location-bouncycastle-fix', src: appBuildGradle, newSrc: ` configurations.all { c -> c.resolutionStrategy.eachDependency { DependencyResolveDetails dependency -> if (dependency.requested.group == 'org.bouncycastle') { dependency.useTarget 'org.bouncycastle:bcprov-jdk15to18:1.70' } } }`, anchor: new RegExp('^\\s*android\\s*{'), offset: 1, comment: ' //', }); } function withHMSLocationSDK(config, enableBouncyCastleFix) { return (0, config_plugins_1.withAppBuildGradle)(config, ({ modResults, ...exportedConfig }) => { if (modResults.language !== 'groovy') { config_plugins_1.WarningAggregator.addWarningAndroid('withHMSLocationAndroid', "Cannot automatically configure app build.gradle if it's not groovy"); return { modResults, ...exportedConfig }; } if (enableBouncyCastleFix) { modResults.contents = _applyBouncyCastleResolutionFix(modResults.contents).contents; } modResults.contents = _applyHMSAGConnectServicesPlugin(modResults.contents).contents; modResults.contents = _addHMSImplementation(modResults.contents).contents; return { modResults, ...exportedConfig }; }); }