Skip to content

Commit

Permalink
[#30] Fix: generate the Android app module with the entered bundle id
Browse files Browse the repository at this point in the history
  • Loading branch information
luongvo committed Nov 1, 2023
1 parent 565f9b1 commit d66d1dd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions make_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,28 @@ sed -i '' "/ buildProjectAndRunTests()*/d" scripts/new_project.kts

kscript scripts/new_project.kts package-name=${bundle_id} app-name=${project_name} template=compose

# Convert bundle_id with dot to packake folder path, e.g., co.nimblehq.kmm.template -> co/nimblehq/kmm/template
package_path="${bundle_id//.//}"

# Correct dependencies
sed -i '' 's/Modules.DATA/Modules.SHARED/' sample/app/build.gradle.kts
sed -i '' "/implementation(project(Modules.DOMAIN))*/d" sample/app/build.gradle.kts
sed -i '' "/kover(project(Modules.DOMAIN))*/d" sample/app/build.gradle.kts

# Correct imports
sed -i '' 's/import co.nimblehq.kmm.template.data.di.initKoin/import co.nimblehq.kmm.template.di.initKoin/' sample/app/src/main/java/co/nimblehq/kmm/template/MainApplication.kt
sed -i '' 's/import '$bundle_id'.data.di.initKoin/import '$bundle_id'.di.initKoin/' sample/app/src/main/java/$package_path/MainApplication.kt

# Correct error mapping
sed -i '' 's/is ApiException -> error?.message/is ApiException -> message/' sample/app/src/main/java/co/nimblehq/kmm/template/ui/ErrorMapping.kt
sed -i '' 's/is ApiException -> error?.message/is ApiException -> message/' sample/app/src/main/java/$package_path/ui/ErrorMapping.kt

# Remove unnecessary definition of BASE_API_URL
sed -i '' "/buildConfigField(\"String\", \"BASE_API_URL\"*/d" sample/app/build.gradle.kts
sed -i '' "/import co.nimblehq.kmm.template.BuildConfig*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt
sed -i '' "/import co.nimblehq.kmm.template.data.di.modules.BASE_API_URL*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt
sed -i '' "/import org.koin.core.qualifier.named*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt
sed -i '' "/ single(named(BASE_API_URL)) {\n*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt
sed -i '' "/ BuildConfig.BASE_API_URL\n*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt
sed -i '' "/ }\n*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt
sed -i '' "/import $bundle_id.BuildConfig*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt
sed -i '' "/import $bundle_id.data.di.modules.BASE_API_URL*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt
sed -i '' "/import org.koin.core.qualifier.named*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt
sed -i '' "/ single(named(BASE_API_URL)) {\n*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt
sed -i '' "/ BuildConfig.BASE_API_URL\n*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt
sed -i '' "/ }\n*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt

# Overwrite custom files
rsync -av ../custom/android/ sample/app/
Expand Down

0 comments on commit d66d1dd

Please sign in to comment.