-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.plugin.js
More file actions
44 lines (38 loc) · 1.34 KB
/
Copy pathapp.plugin.js
File metadata and controls
44 lines (38 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const { withProjectBuildGradle } = require('@expo/config-plugins');
const MAVEN_LINE =
"maven { url 'https://github.com/pagseguro/PlugPagServiceWrapper/raw/master' }";
/**
* Config plugin do @lucasmaffei/react-native-plugpag.
*
* Adiciona o maven repo da PagBank ao android/build.gradle do projeto, que e
* necessario para resolver o PlugPagServiceWrapper (dependencia nativa da lib).
*
* Uso (app.json / app.config.js):
* { "expo": { "plugins": ["@lucasmaffei/react-native-plugpag"] } }
*/
function withPagBankMaven(config) {
return withProjectBuildGradle(config, (cfg) => {
if (cfg.modResults.language !== 'groovy') {
throw new Error(
'@lucasmaffei/react-native-plugpag: android/build.gradle nao e groovy; ' +
'adicione o maven da PagBank manualmente.'
);
}
let contents = cfg.modResults.contents;
if (contents.includes('PlugPagServiceWrapper/raw/master')) {
return cfg;
}
const anchor = /allprojects\s*\{\s*repositories\s*\{/;
if (anchor.test(contents)) {
contents = contents.replace(
anchor,
(match) => `${match}\n ${MAVEN_LINE}`
);
} else {
contents += `\n\nallprojects {\n repositories {\n ${MAVEN_LINE}\n }\n}\n`;
}
cfg.modResults.contents = contents;
return cfg;
});
}
module.exports = withPagBankMaven;