38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
const { withAppBuildGradle } = require('@expo/config-plugins');
|
|
|
|
module.exports = function withAndroidSigning(config) {
|
|
return withAppBuildGradle(config, (config) => {
|
|
if (config.modResults.language === 'groovy') {
|
|
let buildGradle = config.modResults.contents;
|
|
|
|
const signingConfig = `
|
|
release {
|
|
if (project.hasProperty('SCHNAPPIX_RELEASE_STORE_FILE')) {
|
|
storeFile file("../../" + SCHNAPPIX_RELEASE_STORE_FILE)
|
|
storePassword SCHNAPPIX_RELEASE_STORE_PASSWORD
|
|
keyAlias SCHNAPPIX_RELEASE_KEY_ALIAS
|
|
keyPassword SCHNAPPIX_RELEASE_KEY_PASSWORD
|
|
}
|
|
}
|
|
`;
|
|
|
|
if (!buildGradle.includes('SCHNAPPIX_RELEASE_STORE_FILE')) {
|
|
// Inject inside signingConfigs { ... }
|
|
buildGradle = buildGradle.replace(
|
|
/signingConfigs\s*\{([\s\S]*?)debug\s*\{([\s\S]*?)\}/,
|
|
`signingConfigs {$1debug {$2}\n${signingConfig}`
|
|
);
|
|
|
|
// Change buildTypes release to use signingConfigs.release
|
|
buildGradle = buildGradle.replace(
|
|
/signingConfig signingConfigs\.debug/g,
|
|
`signingConfig signingConfigs.release`
|
|
);
|
|
}
|
|
|
|
config.modResults.contents = buildGradle;
|
|
}
|
|
return config;
|
|
});
|
|
};
|