@oxy.so/app-preset 6.0.0 → 6.1.1
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/README.md +40 -1
- package/package.json +1 -1
- package/plugin/withOxyAbiSplits.js +122 -0
- package/plugin/withOxyAppPreset.js +4 -0
- package/plugin/withOxyUpdates.js +4 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ and JSON.
|
|
|
14
14
|
|
|
15
15
|
| Piece | Import | Replaces |
|
|
16
16
|
| --- | --- | --- |
|
|
17
|
-
| Config plugin | `['@oxy.so/app-preset', {}]` | iOS keychain entitlement + `expo-build-properties` + `@oxy.so/services/plugins/withOxySharedPermissions` (which signs every release with the ecosystem key, see below) + the R8 `-optimize` ProGuard file |
|
|
17
|
+
| Config plugin | `['@oxy.so/app-preset', {}]` | iOS keychain entitlement + `expo-build-properties` + `@oxy.so/services/plugins/withOxySharedPermissions` (which signs every release with the ecosystem key, see below) + the R8 `-optimize` ProGuard file + one APK per ABI |
|
|
18
18
|
| Android WebP resources | `@oxy.so/app-preset/plugin/withOxyAndroidWebp` | re-encoding generated mipmaps/splash bitmaps to real lossless WebP (opt-in, needs `sharp`) |
|
|
19
19
|
| Oxy Updates (OTA) | `@oxy.so/app-preset/plugin/withOxyUpdates` | the `expo-updates` manifest URL, release channel, `runtimeVersion` policy and the shared code-signing certificate, required (opt-in, see below) |
|
|
20
20
|
| Metro | `@oxy.so/app-preset/metro` | monorepo watch folders, block list, symlink + package-exports resolution, web-font/wasm asset exts, release minifier, NativeWind wrapper |
|
|
@@ -186,6 +186,45 @@ bump it for a native change and the next push to main releases a new binary
|
|
|
186
186
|
(oxy's `android-release.yml`, docs/engineering/build-and-deploy.md#native-android-releases);
|
|
187
187
|
a JS-only change keeps the version and ships as an OTA update.
|
|
188
188
|
|
|
189
|
+
#### One APK per ABI (always on, 6.1.1+)
|
|
190
|
+
|
|
191
|
+
`withOxyAbiSplits`, applied by the preset and by `withOxyUpdates`, adds Gradle
|
|
192
|
+
ABI splits to `android/app/build.gradle`, so `assembleRelease` writes one APK per
|
|
193
|
+
ABI and no universal APK:
|
|
194
|
+
|
|
195
|
+
| APK | For |
|
|
196
|
+
| --- | --- |
|
|
197
|
+
| `app-arm64-v8a-release.apk` | almost every phone and tablet, anything from about 2017 on |
|
|
198
|
+
| `app-armeabi-v7a-release.apk` | older phones, and Android TVs and TV boxes |
|
|
199
|
+
|
|
200
|
+
A universal APK carries every ABI's native libraries and a phone loads one
|
|
201
|
+
(Mention: 126 MB, of which 55 MB arm64-v8a and 37 MB armeabi-v7a libraries).
|
|
202
|
+
`bundleRelease` is unaffected: the AAB keeps every ABI and Google Play serves
|
|
203
|
+
each device its slice.
|
|
204
|
+
|
|
205
|
+
Build the AAB and the APKs in **two Gradle invocations**
|
|
206
|
+
(`./gradlew :app:bundleRelease`, then `./gradlew :app:assembleRelease`). When R8
|
|
207
|
+
shrinks resources, AGP fails a build that makes split APKs next to an app bundle
|
|
208
|
+
("Multiple shrunk-resources files found … Please disable building multiple APKs
|
|
209
|
+
when building an Android app bundle",
|
|
210
|
+
[issuetracker 402800800](https://issuetracker.google.com/402800800)), so the
|
|
211
|
+
splits are off in any invocation that builds a bundle, and that invocation's
|
|
212
|
+
`assembleRelease` gives a universal APK.
|
|
213
|
+
|
|
214
|
+
A build that compiles none of those ABIs splits to the ones it compiles, so
|
|
215
|
+
`expo run:android` on an x86_64 emulator (it passes
|
|
216
|
+
`-PreactNativeArchitectures=x86_64`) still gets `app-x86_64-debug.apk`, which the
|
|
217
|
+
Expo CLI installs by the device's ABI. An ABI that is not compiled never gets
|
|
218
|
+
an APK of its own, since it would carry no native libraries.
|
|
219
|
+
|
|
220
|
+
Both release APKs have the app's one `versionCode`. They are the same version of
|
|
221
|
+
the same app, so Android installs either over the other; Google Play's rule of a
|
|
222
|
+
distinct versionCode per APK applies only to APKs uploaded to Play, and Play
|
|
223
|
+
gets the AAB. A `build.gradle` that already has a `splits {}` block (an app's own
|
|
224
|
+
plugin) fails prebuild: remove it. The release workflow
|
|
225
|
+
(docs/engineering/build-and-deploy.md#native-android-releases) publishes the two
|
|
226
|
+
APKs and fails a build without them.
|
|
227
|
+
|
|
189
228
|
#### Android WebP resources (opt-in)
|
|
190
229
|
|
|
191
230
|
`withOxyAndroidWebp` needs `sharp` installed, so it is registered explicitly:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/app-preset",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"description": "The Oxy distro of Expo — centralized Expo config plugin, Metro/Babel/ESLint factories, Tailwind base CSS and TypeScript bases shared by every Oxy app (Mention, Homiio, Allo, accounts, …). A zero-build package: apps replace copy-pasted config with a single dependency bump.",
|
|
5
5
|
"main": "./app.plugin.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expo Config Plugin: withOxyAbiSplits (always applied by the preset)
|
|
3
|
+
*
|
|
4
|
+
* Builds one APK per ABI instead of one universal APK. A universal Oxy APK
|
|
5
|
+
* carries the native libraries of every ABI, of which a phone loads one
|
|
6
|
+
* (Mention 126 MB: 55 MB of arm64-v8a libraries, 37 MB of armeabi-v7a), so a
|
|
7
|
+
* release ships
|
|
8
|
+
*
|
|
9
|
+
* app-arm64-v8a-release.apk every phone from about 2017 on
|
|
10
|
+
* app-armeabi-v7a-release.apk older phones and many Android TVs
|
|
11
|
+
*
|
|
12
|
+
* and no universal APK. Gradle's ABI splits only affect APKs: `bundleRelease`
|
|
13
|
+
* still builds one AAB with every ABI, and Google Play serves each device its
|
|
14
|
+
* own slice of it.
|
|
15
|
+
*
|
|
16
|
+
* The splits are OFF in a Gradle invocation that builds a bundle. When R8
|
|
17
|
+
* shrinks resources (`shrinkResources`, which every Oxy release does), AGP
|
|
18
|
+
* fails `buildReleasePreBundle` with "Multiple shrunk-resources files found …
|
|
19
|
+
* Please disable building multiple APKs when building an Android app bundle"
|
|
20
|
+
* (https://issuetracker.google.com/402800800). So the AAB and the APKs are
|
|
21
|
+
* two invocations, `./gradlew :app:bundleRelease` then
|
|
22
|
+
* `./gradlew :app:assembleRelease`; one invocation asking for both builds a
|
|
23
|
+
* universal APK, which Oxy's release workflow refuses.
|
|
24
|
+
*
|
|
25
|
+
* A build for ONE device keeps working: `expo run:android` passes
|
|
26
|
+
* `-PreactNativeArchitectures=<the device's ABI>` for a debug build, so the
|
|
27
|
+
* split follows the ABIs Gradle compiles whenever none of the release ABIs is
|
|
28
|
+
* among them (an x86_64 emulator gets `app-x86_64-debug.apk`, which the Expo
|
|
29
|
+
* CLI finds by the device's ABI). A release ABI that is not compiled is never
|
|
30
|
+
* split out, because its APK would carry no native libraries.
|
|
31
|
+
*
|
|
32
|
+
* Every split APK has the app's one `versionCode` (`withOxyReleaseVersion`).
|
|
33
|
+
* That is what sideloading needs: they are the same version of the same app,
|
|
34
|
+
* and Android installs either over the other. Unique versionCodes per APK are
|
|
35
|
+
* a Google Play rule for publishing several APKs to Play; Play gets the AAB.
|
|
36
|
+
*
|
|
37
|
+
* Applied by the preset and by `withOxyUpdates`, the entry every app on the
|
|
38
|
+
* release pipeline lists, so it is idempotent: the second run finds its marker
|
|
39
|
+
* and changes nothing. A build.gradle that already has a `splits {}` block
|
|
40
|
+
* (another plugin's, or a hand edit) fails: two sources for the APK layout is
|
|
41
|
+
* how a release ends up shipping the wrong files.
|
|
42
|
+
*/
|
|
43
|
+
const { withAppBuildGradle } = require('expo/config-plugins');
|
|
44
|
+
|
|
45
|
+
const PLUGIN = '[@oxy.so/app-preset withOxyAbiSplits]';
|
|
46
|
+
const MARKER = '@generated oxy-abi-splits';
|
|
47
|
+
|
|
48
|
+
/** The ABIs every Oxy release ships an APK for, in the order people should pick them. */
|
|
49
|
+
const RELEASE_ABIS = ['arm64-v8a', 'armeabi-v7a'];
|
|
50
|
+
|
|
51
|
+
/** Inserted before `android {`: which APKs this build splits out. */
|
|
52
|
+
const RESOLVE_ABIS = `// ${MARKER}: one APK per ABI, no universal APK (@oxy.so/app-preset
|
|
53
|
+
// withOxyAbiSplits). Edit the plugin, never this file. A release ships ${RELEASE_ABIS.join(' and ')};
|
|
54
|
+
// a build that compiles none of them (-PreactNativeArchitectures=x86_64, as \`expo run:android\`
|
|
55
|
+
// passes for an emulator) splits to the ABIs it compiles, so that device still gets an APK.
|
|
56
|
+
def oxyBuiltAbis = (findProperty('reactNativeArchitectures') ?: 'armeabi-v7a,arm64-v8a,x86,x86_64').toString().split(',').collect { it.trim() }.findAll { it }
|
|
57
|
+
def oxyReleaseAbis = [${RELEASE_ABIS.map((abi) => `'${abi}'`).join(', ')}].findAll { oxyBuiltAbis.contains(it) }
|
|
58
|
+
def oxyApkAbis = oxyReleaseAbis ?: oxyBuiltAbis
|
|
59
|
+
// AGP refuses ABI splits in an invocation that also builds an app bundle while R8 shrinks
|
|
60
|
+
// resources (https://issuetracker.google.com/402800800), and a bundle never uses them: build
|
|
61
|
+
// the AAB and the APKs in two invocations.
|
|
62
|
+
def oxyBuildsBundle = gradle.startParameter.taskNames.any { it.tokenize(':').last().toLowerCase().startsWith('bundle') }
|
|
63
|
+
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
/** Inserted as the first entry of `android {`. */
|
|
67
|
+
const SPLITS = `
|
|
68
|
+
// ${MARKER}: the APKs are oxyApkAbis, one each; off while building a bundle.
|
|
69
|
+
splits {
|
|
70
|
+
abi {
|
|
71
|
+
reset()
|
|
72
|
+
enable !oxyBuildsBundle
|
|
73
|
+
universalApk false
|
|
74
|
+
include(*oxyApkAbis)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
function fail(message) {
|
|
80
|
+
throw new Error(`${PLUGIN} ${message}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Apply the split to the text of a Groovy `android/app/build.gradle`. Idempotent.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} contents
|
|
87
|
+
* @returns {string}
|
|
88
|
+
*/
|
|
89
|
+
function applyAbiSplits(contents) {
|
|
90
|
+
if (contents.includes(MARKER)) return contents;
|
|
91
|
+
|
|
92
|
+
if (/^\s*splits\s*\{/m.test(contents)) {
|
|
93
|
+
fail(
|
|
94
|
+
'app/build.gradle already has a `splits {}` block written by another plugin or by hand. ' +
|
|
95
|
+
'Remove it: the preset splits every Oxy APK by ABI.',
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const androidBlock = /^android \{$/m;
|
|
100
|
+
if (!androidBlock.test(contents)) {
|
|
101
|
+
fail(
|
|
102
|
+
'Could not find the top-level `android {` block in app/build.gradle. The Expo template changed: update this plugin instead of editing android/ by hand.',
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return contents.replace(androidBlock, `${RESOLVE_ABIS}android {${SPLITS}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** @param {import('expo/config').ExpoConfig} config */
|
|
109
|
+
module.exports = function withOxyAbiSplits(config) {
|
|
110
|
+
return withAppBuildGradle(config, (modConfig) => {
|
|
111
|
+
if (modConfig.modResults.language !== 'groovy') {
|
|
112
|
+
fail(
|
|
113
|
+
`app/build.gradle is ${modConfig.modResults.language}, not Groovy. Oxy releases ship one APK per ABI; ` +
|
|
114
|
+
'add the split to this plugin for that language instead of shipping a universal APK.',
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
modConfig.modResults.contents = applyAbiSplits(modConfig.modResults.contents);
|
|
118
|
+
return modConfig;
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
module.exports.applyAbiSplits = applyAbiSplits;
|
|
122
|
+
module.exports.RELEASE_ABIS = RELEASE_ABIS;
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
* does not carry its certificate; an app lists no signing plugin of its own.
|
|
36
36
|
* `withOxyReleaseVersion` (always applied) derives Android `versionCode` and iOS
|
|
37
37
|
* `buildNumber` from `version` (1.2.3 → 1002003); an app sets neither.
|
|
38
|
+
* `withOxyAbiSplits` (always applied) builds one APK per ABI (arm64-v8a,
|
|
39
|
+
* armeabi-v7a) instead of a universal APK; the AAB is unaffected.
|
|
38
40
|
* `withOxyR8Optimize` (always applied) swaps in R8's `-optimize` ProGuard file on
|
|
39
41
|
* Expo SDK 56/57 and is a no-op on 58.
|
|
40
42
|
*
|
|
@@ -58,6 +60,7 @@ const withOxyKeychain = require('./withOxyKeychain');
|
|
|
58
60
|
const withOxyBuildProperties = require('./withOxyBuildProperties');
|
|
59
61
|
const withOxyR8Optimize = require('./withOxyR8Optimize');
|
|
60
62
|
const withOxyReleaseVersion = require('./withOxyReleaseVersion');
|
|
63
|
+
const withOxyAbiSplits = require('./withOxyAbiSplits');
|
|
61
64
|
const { dirname, join } = require('node:path');
|
|
62
65
|
const { projectRootOf, requireFromProject, resolveFromProject } = require('./requireFromProject');
|
|
63
66
|
|
|
@@ -107,6 +110,7 @@ module.exports = function withOxyAppPreset(config, options = {}) {
|
|
|
107
110
|
|
|
108
111
|
next = withOxyR8Optimize(next);
|
|
109
112
|
next = withOxyReleaseVersion(next);
|
|
113
|
+
next = withOxyAbiSplits(next);
|
|
110
114
|
|
|
111
115
|
let withOxySharedPermissions;
|
|
112
116
|
try {
|
package/plugin/withOxyUpdates.js
CHANGED
|
@@ -69,6 +69,7 @@ const fs = require('fs');
|
|
|
69
69
|
const path = require('path');
|
|
70
70
|
const { WarningAggregator } = require('expo/config-plugins');
|
|
71
71
|
const withOxyReleaseVersion = require('./withOxyReleaseVersion');
|
|
72
|
+
const withOxyAbiSplits = require('./withOxyAbiSplits');
|
|
72
73
|
|
|
73
74
|
/** Origin of the Oxy Updates server. `updates.oxy.so` does not exist; oxy-api serves it. */
|
|
74
75
|
const DEFAULT_API_ORIGIN = 'https://api.oxy.so';
|
|
@@ -182,6 +183,7 @@ module.exports = function withOxyUpdates(config, options = {}) {
|
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
// `version` is the OTA boundary, so it also numbers the store build: an
|
|
185
|
-
// OTA-enabled app that skips the preset's main plugin gets the same rule
|
|
186
|
-
|
|
186
|
+
// OTA-enabled app that skips the preset's main plugin gets the same rule,
|
|
187
|
+
// and the same per-ABI APKs (every app on the release pipeline lists this).
|
|
188
|
+
return withOxyAbiSplits(withOxyReleaseVersion(next));
|
|
187
189
|
};
|