()
| 66 | } |
| 67 | |
| 68 | function patchTargetSdkVersion() { |
| 69 | const prefix = execSync('npm prefix').toString().trim(); |
| 70 | const gradleFile = path.join(prefix, 'platforms/android/app/build.gradle'); |
| 71 | |
| 72 | if (!fs.existsSync(gradleFile)) { |
| 73 | console.warn('[Cordova Hook] ⚠️ build.gradle not found'); |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | let content = fs.readFileSync(gradleFile, 'utf-8'); |
| 78 | |
| 79 | const sdkRegex = /targetSdkVersion\s+(cordovaConfig\.SDK_VERSION|\d+)/; |
| 80 | |
| 81 | if (sdkRegex.test(content)) { |
| 82 | let api = "36"; |
| 83 | const tmp = getTmpDir(); |
| 84 | if (tmp == null) { |
| 85 | console.warn("---------------------------------------------------------------------------------\n\n\n\n"); |
| 86 | console.warn(`⚠️ fdroid.bool not found`); |
| 87 | console.warn("⚠️ Fdroid flavour will be built"); |
| 88 | api = "28"; |
| 89 | console.warn("\n\n\n\n---------------------------------------------------------------------------------"); |
| 90 | } else { |
| 91 | const froidFlag = path.join(getTmpDir(), 'fdroid.bool'); |
| 92 | |
| 93 | if (fs.existsSync(froidFlag)) { |
| 94 | const fdroid = fs.readFileSync(froidFlag, 'utf-8').trim(); |
| 95 | if (fdroid == "true") { |
| 96 | api = "28"; |
| 97 | } |
| 98 | } else { |
| 99 | console.warn("---------------------------------------------------------------------------------\n\n\n\n"); |
| 100 | console.warn(`⚠️ fdroid.bool not found`); |
| 101 | console.warn("⚠️ Fdroid flavour will be built"); |
| 102 | api = "28"; |
| 103 | console.warn("\n\n\n\n---------------------------------------------------------------------------------"); |
| 104 | //process.exit(1); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | |
| 109 | content = content.replace(sdkRegex, 'targetSdkVersion ' + api); |
| 110 | fs.writeFileSync(gradleFile, content, 'utf-8'); |
| 111 | console.log('[Cordova Hook] ✅ Patched targetSdkVersion to ' + api); |
| 112 | } else { |
| 113 | console.warn('[Cordova Hook] ⚠️ targetSdkVersion not found'); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | |
| 118 | function enableLegacyJni() { |
no test coverage detected