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 4d1848f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run: rm -rf sample

- name: Generate the new sample project
run: ./make.sh --bundle-id co.nimblehq.kmm.template --bundle-id-staging co.nimblehq.kmm.template.staging --project-name sample --ios-version 14.0
run: ./make.sh --bundle-id co.nimblehq.kmm.sample --bundle-id-staging co.nimblehq.kmm.sample.staging --project-name sample --ios-version 14.0

- name: Restore the previous ArkanaKeys's keys
run: |
Expand Down
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 4d1848f

Please sign in to comment.