@livx.cc/appwrap 0.46.3 → 0.46.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli.ts +17 -1
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -1097,12 +1097,28 @@ function stampAndroidAppName(outDir: string, cfg: AppwrapConfig, req: NativeReqs
|
|
|
1097
1097
|
}
|
|
1098
1098
|
}
|
|
1099
1099
|
|
|
1100
|
+
/** Google Play's hard versionCode ceiling (a 32-bit int, but Play caps it here). */
|
|
1101
|
+
const ANDROID_VERSION_CODE_MAX = 2_100_000_000;
|
|
1102
|
+
|
|
1103
|
+
/** Android versionCode must fit ANDROID_VERSION_CODE_MAX. The default 'timestamp' build strategy yields
|
|
1104
|
+
* a 10-digit YYMMDDHHMM (~2.6e9) that's fine for iOS's CFBundleVersion but OVERFLOWS here — gradle then
|
|
1105
|
+
* fails cryptically ("app.gradle … Value is null") on every local `appwrap deploy android`. When the
|
|
1106
|
+
* resolved build exceeds the cap, fall back to unix-epoch seconds (~1.78e9, monotonic, Android-safe).
|
|
1107
|
+
* CI passes an explicit small APPWRAP_BUILD_NUMBER, so it never trips this. */
|
|
1108
|
+
function androidVersionCodeOf(cfg: AppwrapConfig): number {
|
|
1109
|
+
const n = buildNumberOf(cfg);
|
|
1110
|
+
if (n <= ANDROID_VERSION_CODE_MAX) return n;
|
|
1111
|
+
const safe = Math.floor(Date.now() / 1000);
|
|
1112
|
+
console.warn(` ⚠ build ${n} exceeds Android's versionCode cap (${ANDROID_VERSION_CODE_MAX}); using epoch ${safe}. Set APPWRAP_BUILD_NUMBER for a deterministic value.`);
|
|
1113
|
+
return safe;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1100
1116
|
/** Stamp Android marketing version (versionName) + monotonic build (versionCode) into app.gradle. */
|
|
1101
1117
|
function stampAndroidVersion(outDir: string, cfg: AppwrapConfig): void {
|
|
1102
1118
|
const gradle = join(outDir, 'App_Resources/Android/app.gradle');
|
|
1103
1119
|
if (!existsSync(gradle)) return;
|
|
1104
1120
|
let src = readFileSync(gradle, 'utf8');
|
|
1105
|
-
src = src.replace(/versionCode\s+\d+/, `versionCode ${
|
|
1121
|
+
src = src.replace(/versionCode\s+\d+/, `versionCode ${androidVersionCodeOf(cfg)}`);
|
|
1106
1122
|
src = src.replace(/versionName\s+"[^"]*"/, `versionName "${cfg.version}"`);
|
|
1107
1123
|
writeFileSync(gradle, src);
|
|
1108
1124
|
}
|