@armanatz/expo-hms-location
Version:
Expo config plugin to configure @hmscore/react-native-hms-location on prebuild
67 lines (66 loc) • 2.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._addHuaweiMavenRepoToBuildScript = _addHuaweiMavenRepoToBuildScript;
exports._addHuaweiMavenRepoToAllProjects = _addHuaweiMavenRepoToAllProjects;
exports._addHMSAGConnectServicesPlugin = _addHMSAGConnectServicesPlugin;
exports._pinAndroidGradleBuildToolsVersion = _pinAndroidGradleBuildToolsVersion;
exports.default = withMavenRepo;
const config_plugins_1 = require("expo/config-plugins");
const utils_1 = require("../utils");
function _addHuaweiMavenRepoToBuildScript(projectBuildGradle) {
return (0, utils_1.insertOrReplaceContentInBlock)({
mode: 'insert',
tag: '@armanatz/expo-hms-location-maven-buildscript',
blockName: 'buildscript',
src: projectBuildGradle,
newSrc: ` maven { url 'https://developer.huawei.com/repo/' }`,
anchor: 'mavenCentral()',
comment: ' //',
});
}
function _addHuaweiMavenRepoToAllProjects(projectBuildGradle) {
return (0, utils_1.appendContents)({
tag: '@armanatz/expo-hms-location-maven-allprojects',
src: projectBuildGradle,
newSrc: `allprojects {
repositories {
maven { url 'https://developer.huawei.com/repo/' }
}
}`,
comment: '//',
});
}
function _addHMSAGConnectServicesPlugin(projectBuildGradle) {
return (0, utils_1.mergeContents)({
tag: '@armanatz/expo-hms-location-agconnect',
src: projectBuildGradle,
newSrc: ` classpath('com.huawei.agconnect:agcp:1.9.1.301')`,
anchor: new RegExp('^\\s*dependencies\\s*{'),
offset: 1,
comment: ' //',
});
}
function _pinAndroidGradleBuildToolsVersion(projectBuildGradle) {
return (0, utils_1.insertOrReplaceContentInBlock)({
mode: 'replace',
tag: '@armanatz/expo-hms-location-buildscript-buildtools',
blockName: 'buildscript',
src: projectBuildGradle,
newSrc: ` classpath('com.android.tools.build:gradle:8.6.0')`,
anchor: "classpath('com.android.tools.build:gradle')",
comment: ' //',
});
}
function withMavenRepo(config) {
return (0, config_plugins_1.withProjectBuildGradle)(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 };
}
modResults.contents = _addHuaweiMavenRepoToBuildScript(modResults.contents).contents;
modResults.contents = _addHuaweiMavenRepoToAllProjects(modResults.contents).contents;
modResults.contents = _pinAndroidGradleBuildToolsVersion(modResults.contents).contents;
modResults.contents = _addHMSAGConnectServicesPlugin(modResults.contents).contents;
return { modResults, ...exportedConfig };
});
}