UNPKG

react-native-scanbot-sdk

Version:

Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS

45 lines (44 loc) 2.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addMavenRepo = exports.withAndroidMavenURLs = void 0; const config_plugins_1 = require("@expo/config-plugins"); const android_plugins_1 = require("@expo/config-plugins/build/plugins/android-plugins"); const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode"); const withAndroidMavenURLs = (config, { mavenURLs }) => { if (mavenURLs) { config = (0, android_plugins_1.withProjectBuildGradle)(config, (gradleProps) => { try { gradleProps.modResults.contents = (0, exports.addMavenRepo)(gradleProps.modResults.contents); } catch (error) { config_plugins_1.WarningAggregator.addWarningAndroid('react-native-scanbot-sdk', `Could not add maven URL to project build.gradle. Please insert the following\n` + 'maven { url "https://nexus.scanbot.io/nexus/content/repositories/releases/" }\n' + 'maven { url "https://nexus.scanbot.io/nexus/content/repositories/snapshots/" }\n' + error.message ?? ''); } return gradleProps; }); } return config; }; exports.withAndroidMavenURLs = withAndroidMavenURLs; const addMavenRepo = (projectBuildGradle) => { const regex = new RegExp(/(?=allprojects\s*\{\s*\s*repositories\s*)[\s\S]*/, 'gm'); const allProjectRepositories = projectBuildGradle.match(regex); if (allProjectRepositories && allProjectRepositories.length > 0) { const merged = (0, generateCode_1.mergeContents)({ src: allProjectRepositories[0], newSrc: ' maven { url "https://nexus.scanbot.io/nexus/content/repositories/releases/" }\n' + ' maven { url "https://nexus.scanbot.io/nexus/content/repositories/snapshots/" }', tag: 'react-native-scanbot-sdk', anchor: new RegExp('repositories {', 'gm'), offset: 1, comment: '//', }).contents; return projectBuildGradle.replace(regex, merged); } else { throw new Error('Could not find project repositories'); } }; exports.addMavenRepo = addMavenRepo;