Created
December 22, 2024 05:32
-
-
Save mym0404/34561c1cbd6c85f0d1bcd66ae3fa0793 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZX Utility... | |
const projectRoot = cwd(); | |
export let VERSION_NAME = ''; | |
export let VERSION_CODE = ''; | |
async function init() { | |
const content = read(resolve(projectRoot, 'app.config.ts')); | |
VERSION_NAME = /const VERSION_NAME = '(.*?)';/.exec(content)[1]; | |
VERSION_CODE = /const VERSION_CODE = (.*?);/.exec(content)[1]; | |
} | |
async function prepareAndroid() { | |
await spinner('Prebuild Android', () => $`expo prebuild -p android --no-install`); | |
await remove('android/fastlane'); | |
await iterateDir('fastlane-android', async (file) => { | |
const filePath = path.resolve('fastlane-android', file); | |
await $`cp -r ${filePath} android/${file}`; | |
}); | |
printSuccess('Inject Android Fastlane files'); | |
await replaceAndroidSigningConfig(); | |
async function replaceAndroidSigningConfig() { | |
const buildGradlePath = resolve('android', 'app', 'build.gradle'); | |
const content = read(buildGradlePath).replace( | |
/signingConfigs.*?{.*?debug.*?{.*?}.*?}/s, | |
` | |
signingConfigs { | |
debug { | |
storeFile file('${resolve(projectRoot, 'key', 'release-keystore.jks')}') | |
storePassword '...' | |
keyAlias '...' | |
keyPassword '...' | |
} | |
} | |
`, | |
); | |
write(buildGradlePath, content); | |
printSuccess('Replace Android Signing Config'); | |
} | |
} | |
async function prepareIos() { | |
await spinner('Prebuild iOS', () => $`expo prebuild -p ios --no-install`); | |
await remove('ios/fastlane'); | |
await iterateDir('fastlane-ios', async (file) => { | |
const filePath = path.resolve('fastlane-ios', file); | |
await $`rm -rf ios/${file} && cp -r ${filePath} ios/${file}`; | |
}); | |
printSuccess('Inject iOS Fastlane files'); | |
} | |
export const ReleaseScriptUtil = { | |
prepareAndroid, | |
prepareIos, | |
init, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment