Skip to content

Commit de528cf

Browse files
authored
Merge pull request #168 from appodeal/fix/android-deps-strip-repositories
fix: drop duplicated repositories block from generated Android deps
1 parent 822a0cb commit de528cf

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,6 @@ Add dependencies into `android/app/build.gradle`
281281

282282
<!-- appodeal-deps:android:start -->
283283
``` kotlin
284-
repositories {
285-
maven { url = uri("https://artifactory.appodeal.com/appodeal") }
286-
}
287-
/* build.gradle.kts */
288284
dependencies {
289285
implementation("com.appodeal.ads.sdk:core:4.1.0")
290286
// Bidon

scripts/update-readme-deps.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ function fenced(lang, body) {
8080
return `${lang}\n${body.trimEnd()}\n\`\`\``;
8181
}
8282

83+
/**
84+
* Keep only the `dependencies { ... }` block from the Android response. The Wizard
85+
* prepends a `repositories { ... }` block (already documented separately in the README's
86+
* "Add repository into android/build.gradle" section) and a build.gradle.kts label
87+
* comment, which would otherwise duplicate the repository setup and mislead readers.
88+
*/
89+
function androidDependenciesOnly(text) {
90+
const idx = text.search(/^dependencies\s*\{/m);
91+
if (idx === -1) {
92+
throw new Error('Could not find `dependencies {` in the Android API response');
93+
}
94+
return text.slice(idx);
95+
}
96+
8397
/**
8498
* Inject the React Native linking lines into the iOS Podfile target. The Wizard renders
8599
* a plain native target (`target 'Sample' do ... end`); RN apps additionally need the
@@ -128,7 +142,7 @@ async function main() {
128142

129143
// android uses kts (`kt`) verbatim; ios ignores the language, returns Ruby, and gets
130144
// the React Native linking injected into its target.
131-
const android = await fetchDependencyBlock('android', version, 'kt');
145+
const android = androidDependenciesOnly(await fetchDependencyBlock('android', version, 'kt'));
132146
const ios = addReactNativeLinking(await fetchDependencyBlock('ios', version));
133147

134148
let readme = await readFile(README, 'utf8');

0 commit comments

Comments
 (0)