@oxy.so/app-preset 4.1.0 → 5.0.0
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 +52 -18
- package/package.json +3 -3
- package/plugin/requireFromProject.js +14 -6
- package/plugin/withOxyAndroidRelease.js +15 -122
- package/plugin/withOxyAppPreset.js +18 -3
- package/plugin/withOxyR8Optimize.js +40 -0
package/README.md
CHANGED
|
@@ -14,8 +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` |
|
|
18
|
-
| Android release build | `@oxy.so/app-preset/plugin/withOxyAndroidRelease` | R8 `-optimize` ProGuard file + shared-keystore release signing (opt-in, see below) |
|
|
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 |
|
|
19
18
|
| Android WebP resources | `@oxy.so/app-preset/plugin/withOxyAndroidWebp` | re-encoding generated mipmaps/splash bitmaps to real lossless WebP (opt-in, needs `sharp`) |
|
|
20
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 (opt-in, see below) |
|
|
21
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 |
|
|
@@ -120,17 +119,61 @@ react-native's `Image` renders nothing for it, with no error. The keys exist fro
|
|
|
120
119
|
`expo-build-properties` 58 (Expo SDK 58); older versions ignore them silently.
|
|
121
120
|
|
|
122
121
|
The `sharedUserId` and `sharedIdentityReader` options were removed in 3.0.0 and
|
|
123
|
-
throw if passed. `@oxy.so/services`
|
|
122
|
+
throw if passed. `@oxy.so/services` 13.4.0+ is a required peer (the preset refuses an older one: it would declare the permissions without release signing).
|
|
124
123
|
|
|
125
124
|
`webgpu: true` (opt-in, 3.2.0+) also applies `react-native-webgpu`'s config
|
|
126
125
|
plugin, for an app that draws with WebGPU on native. Install
|
|
127
126
|
`react-native-webgpu` in the app first; the option throws without it.
|
|
128
127
|
|
|
129
|
-
#### Android release
|
|
128
|
+
#### Android release signing (always on, fails closed)
|
|
129
|
+
|
|
130
|
+
Every Oxy Android release is signed with the ONE ecosystem key (certificate
|
|
131
|
+
SHA-256 `b8ab3746466ce4569d7a6a0ffa1eed91bc375174d503613987ca09cb33d6a58d`,
|
|
132
|
+
alias `oxy`). It is not a preset plugin: `@oxy.so/services/plugins/withOxySharedPermissions`
|
|
133
|
+
applies `withOxyReleaseSigning` (services 13.4.0+), because the signature
|
|
134
|
+
permissions it declares are what make the certificate load-bearing. A release
|
|
135
|
+
signed with anything else takes ownership of `so.oxy.permission.IDENTITY` /
|
|
136
|
+
`DEVICE_SESSION`, after which every correctly signed Oxy app fails to install
|
|
137
|
+
(`INSTALL_FAILED_DUPLICATE_PERMISSION`), and Commons refuses it. So every app
|
|
138
|
+
that declares the permissions, through the preset or directly, gets the rule;
|
|
139
|
+
**list no signing plugin**.
|
|
140
|
+
|
|
141
|
+
The keystore comes from Gradle properties (`~/.gradle/gradle.properties`, `-P`,
|
|
142
|
+
or `ORG_GRADLE_PROJECT_<name>` environment variables), never from the repo:
|
|
143
|
+
|
|
144
|
+
```properties
|
|
145
|
+
OXY_UPLOAD_STORE_FILE=~/.config/oxy/oxy-ecosystem-release.keystore
|
|
146
|
+
OXY_UPLOAD_STORE_PASSWORD_FILE=~/.config/oxy/oxy-ecosystem-release-keystore.pass
|
|
147
|
+
OXY_UPLOAD_KEY_ALIAS=oxy
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
`OXY_UPLOAD_STORE_PASSWORD` takes the password itself instead of a file;
|
|
151
|
+
`OXY_UPLOAD_KEY_PASSWORD` (or `_FILE`) is needed only when the key's password
|
|
152
|
+
differs from the store's. `~/` is expanded, a password file is trimmed.
|
|
153
|
+
|
|
154
|
+
Release always uses `signingConfigs.release`; nothing falls back to the debug
|
|
155
|
+
key. A task, `oxyVerifyReleaseSigning`, runs before every release variant
|
|
156
|
+
(`pre…ReleaseBuild`, `validateSigning…Release`, so `assembleRelease`,
|
|
157
|
+
`bundleRelease`, `expo run:android --variant release` and EAS's release
|
|
158
|
+
builds) and fails the build, saying how to provide the key, unless the release
|
|
159
|
+
buildType's EFFECTIVE signing config opens and its certificate is the ecosystem
|
|
160
|
+
one. It checks the outcome, not the properties, so it also refuses EAS-managed
|
|
161
|
+
or per-app keys and a wrong alias. Debug builds never run it. There is no
|
|
162
|
+
opt-out for release.
|
|
163
|
+
|
|
164
|
+
Debug builds keep Expo's debug key unless `OXY_UPLOAD_SIGN_DEBUG=true` is set:
|
|
165
|
+
then debug is signed with the same key and checked by the same task, so a dev
|
|
166
|
+
client can be installed next to real Oxy apps and be granted the permissions
|
|
167
|
+
(this replaces Willo's `withOxyDebugSigning`, which prebuild now refuses). An app
|
|
168
|
+
that declares no Oxy permission (Authenticator) lists
|
|
169
|
+
`@oxy.so/services/plugins/withOxyReleaseSigning` directly for the same release
|
|
170
|
+
signing.
|
|
130
171
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
172
|
+
`withOxyAndroidRelease` was removed in 5.0.0; listing it throws and says to delete it.
|
|
173
|
+
|
|
174
|
+
#### Android WebP resources (opt-in)
|
|
175
|
+
|
|
176
|
+
`withOxyAndroidWebp` needs `sharp` installed, so it is registered explicitly:
|
|
134
177
|
|
|
135
178
|
```js
|
|
136
179
|
plugins: [
|
|
@@ -138,17 +181,9 @@ plugins: [
|
|
|
138
181
|
// order, and this has to run after every image generator (splash included).
|
|
139
182
|
'@oxy.so/app-preset/plugin/withOxyAndroidWebp',
|
|
140
183
|
// …app-specific plugins…
|
|
141
|
-
'@oxy.so/app-preset/plugin/withOxyAndroidRelease',
|
|
142
184
|
]
|
|
143
185
|
```
|
|
144
186
|
|
|
145
|
-
`withOxyAndroidRelease` reads the release keystore from four Gradle properties
|
|
146
|
-
(`OXY_UPLOAD_STORE_FILE`, `OXY_UPLOAD_STORE_PASSWORD`, `OXY_UPLOAD_KEY_ALIAS`,
|
|
147
|
-
`OXY_UPLOAD_KEY_PASSWORD`) in `~/.gradle/gradle.properties` or CI secrets — never
|
|
148
|
-
from the repo. When they are absent the release buildType falls back to the debug
|
|
149
|
-
keystore, so **always verify the artefact's certificate** (`keytool -printcert
|
|
150
|
-
-jarfile <aab>`, `apksigner verify --print-certs <apk>`) instead of assuming.
|
|
151
|
-
|
|
152
187
|
`withOxyAndroidWebp` requires `sharp` as a devDependency of the app.
|
|
153
188
|
|
|
154
189
|
#### Oxy Updates (OTA) (opt-in)
|
|
@@ -336,6 +371,5 @@ Requires **Expo SDK 56+**; validated against **Expo SDK 58 / React Native 0.88**
|
|
|
336
371
|
(the current Oxy ecosystem target) with a clean `expo prebuild` of `test-app-expo`,
|
|
337
372
|
`accounts` and `commons` (Android and iOS). SDK 58's Android template already
|
|
338
373
|
uses `proguard-android-optimize.txt` and turns R8 on through `gradle.properties`
|
|
339
|
-
(`android.enableMinifyInReleaseBuilds`), so
|
|
340
|
-
only
|
|
341
|
-
`-optimize` ProGuard file.
|
|
374
|
+
(`android.enableMinifyInReleaseBuilds`), so the preset's `-optimize` ProGuard
|
|
375
|
+
swap only changes anything on SDK 56/57.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/app-preset",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
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": {
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"scripts": {
|
|
63
63
|
"test": "node --test __tests__/*.test.js"
|
|
64
64
|
},
|
|
65
|
-
"//peerDependencies": "THE TWO @oxy.so PEERS ARE DELIBERATE. This package couples to them by FILE PATH, not by API: `css/base.css` imports `@oxy.so/bloom/design-tokens/theme.css`, and `plugin/withOxyAppPreset.js` requires `@oxy.so/services/plugins/withOxySharedPermissions` (services
|
|
65
|
+
"//peerDependencies": "THE TWO @oxy.so PEERS ARE DELIBERATE. This package couples to them by FILE PATH, not by API: `css/base.css` imports `@oxy.so/bloom/design-tokens/theme.css`, and `plugin/withOxyAppPreset.js` requires `@oxy.so/services/plugins/withOxySharedPermissions` together with the `withOxyReleaseSigning` it applies (services 13.4.0+, the first release whose permissions plugin signs and checks the release; the floor is that release). Both peers retain a measured floor and are deliberately OPEN-ENDED above it: Oxy apps always run the latest Bloom and Services, so a new release of either must never need a preset release first. A release that breaks this package's file-path coupling is caught by its own tests and the apps' CI, not by a cap. Never replace either constraint with `*`.",
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"@oxy.so/bloom": "^2.0.0 || ^3.0.0 || ^4.2.0 || ^5.1.0 || >=6.0.0",
|
|
68
|
-
"@oxy.so/services": ">=
|
|
68
|
+
"@oxy.so/services": ">=13.4.0",
|
|
69
69
|
"babel-preset-expo": "*",
|
|
70
70
|
"eslint": ">=9.0.0",
|
|
71
71
|
"eslint-config-expo": "*",
|
|
@@ -12,16 +12,24 @@
|
|
|
12
12
|
* @param {string | undefined} projectRoot The app's directory.
|
|
13
13
|
*/
|
|
14
14
|
function requireFromProject(specifier, projectRoot) {
|
|
15
|
+
return require(resolveFromProject(specifier, projectRoot));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The file `requireFromProject` would load, resolved the same way.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} specifier
|
|
22
|
+
* @param {string | undefined} projectRoot
|
|
23
|
+
*/
|
|
24
|
+
function resolveFromProject(specifier, projectRoot) {
|
|
15
25
|
if (projectRoot) {
|
|
16
|
-
let resolved;
|
|
17
26
|
try {
|
|
18
|
-
|
|
27
|
+
return require.resolve(specifier, { paths: [projectRoot] });
|
|
19
28
|
} catch {
|
|
20
|
-
|
|
29
|
+
// Fall through to the preset's own resolution.
|
|
21
30
|
}
|
|
22
|
-
if (resolved) return require(resolved);
|
|
23
31
|
}
|
|
24
|
-
return require(specifier);
|
|
32
|
+
return require.resolve(specifier);
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
/**
|
|
@@ -34,4 +42,4 @@ function projectRootOf(config) {
|
|
|
34
42
|
return config?._internal?.projectRoot ?? process.cwd();
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
module.exports = { requireFromProject, projectRootOf };
|
|
45
|
+
module.exports = { requireFromProject, resolveFromProject, projectRootOf };
|
|
@@ -1,127 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Removed in `@oxy.so/app-preset` 5.0.0. It stays only to fail with the fix
|
|
3
|
+
* instead of an unresolvable module path; it does nothing else.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `android/` is gitignored and regenerated by `expo prebuild`, so these edits
|
|
11
|
-
* have to live in a plugin or they are lost on the next prebuild.
|
|
12
|
-
*
|
|
13
|
-
* 1. R8 optimization passes
|
|
14
|
-
* Expo generates `getDefaultProguardFile("proguard-android.txt")`, whose
|
|
15
|
-
* only meaningful line is `-dontoptimize`. Swapping to the `-optimize`
|
|
16
|
-
* variant drops that and adds `-allowaccessmodification`, which is what lets
|
|
17
|
-
* R8 inline and merge classes. Worth a few MB of dex on a typical Oxy app.
|
|
18
|
-
* Expo SDK 58's template already generates the `-optimize` file, so on SDK
|
|
19
|
-
* 58 this step is a no-op and only the signing config below changes.
|
|
20
|
-
*
|
|
21
|
-
* 2. Release signing
|
|
22
|
-
* Expo generates `signingConfig signingConfigs.debug` for release, and Play
|
|
23
|
-
* rejects a debug-signed AAB. The real credentials are read from Gradle
|
|
24
|
-
* properties (set in the developer's `~/.gradle/gradle.properties` or CI
|
|
25
|
-
* secrets) so nothing secret ever lands in the repo. When those properties
|
|
26
|
-
* are absent the build falls back to the debug keystore, so a contributor
|
|
27
|
-
* without the keystore can still build — which is exactly why the shipped
|
|
28
|
-
* artefact's certificate must ALWAYS be verified (`keytool -printcert
|
|
29
|
-
* -jarfile <aab>` / `apksigner verify --print-certs <apk>`) rather than
|
|
30
|
-
* assumed.
|
|
31
|
-
*
|
|
32
|
-
* The certificate MUST be the shared Oxy ecosystem one: Oxy apps share the
|
|
33
|
-
* identity and the device session through `signature`-level permissions
|
|
34
|
-
* (`withOxySharedPermissions`) and providers that check the caller's
|
|
35
|
-
* certificate. An app-specific key is refused by Commons, and its duplicate
|
|
36
|
-
* permission declaration makes Android refuse to install it next to its
|
|
37
|
-
* siblings (INSTALL_FAILED_DUPLICATE_PERMISSION).
|
|
38
|
-
*
|
|
39
|
-
* @param {import('expo/config').ExpoConfig} config
|
|
5
|
+
* Release signing moved to `@oxy.so/services/plugins/withOxySharedPermissions`
|
|
6
|
+
* (services 13.4.0), which every Oxy Android app already applies (directly or
|
|
7
|
+
* through `['@oxy.so/app-preset', {}]`): an app cannot declare the Oxy signature
|
|
8
|
+
* permissions without its release being signed with, and checked against, the
|
|
9
|
+
* ecosystem certificate. The R8 `-optimize` swap moved into
|
|
10
|
+
* `['@oxy.so/app-preset', {}]`.
|
|
40
11
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const KEY_PASSWORD = 'OXY_UPLOAD_KEY_PASSWORD';
|
|
49
|
-
|
|
50
|
-
const DEFAULT_PROGUARD = 'getDefaultProguardFile("proguard-android.txt")';
|
|
51
|
-
const OPTIMIZED_PROGUARD = 'getDefaultProguardFile("proguard-android-optimize.txt")';
|
|
52
|
-
|
|
53
|
-
const DEBUG_SIGNING_CONFIG = 'signingConfig signingConfigs.debug';
|
|
54
|
-
const CONDITIONAL_SIGNING_CONFIG = `signingConfig project.hasProperty('${STORE_FILE}') ? signingConfigs.release : signingConfigs.debug`;
|
|
55
|
-
|
|
56
|
-
const RELEASE_SIGNING_CONFIG = ` release {
|
|
57
|
-
// Populated only when the Oxy release keystore properties are
|
|
58
|
-
// available; otherwise this config stays empty and the release
|
|
59
|
-
// buildType falls back to signingConfigs.debug below.
|
|
60
|
-
if (project.hasProperty('${STORE_FILE}')) {
|
|
61
|
-
storeFile file(project.property('${STORE_FILE}'))
|
|
62
|
-
storePassword project.property('${STORE_PASSWORD}')
|
|
63
|
-
keyAlias project.property('${KEY_ALIAS}')
|
|
64
|
-
keyPassword project.property('${KEY_PASSWORD}')
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
`;
|
|
68
|
-
|
|
69
|
-
function useOptimizedProguardFile(contents) {
|
|
70
|
-
if (contents.includes(OPTIMIZED_PROGUARD)) return contents;
|
|
71
|
-
if (!contents.includes(DEFAULT_PROGUARD)) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`[withOxyAndroidRelease] Could not find ${DEFAULT_PROGUARD} in app/build.gradle. ` +
|
|
74
|
-
'The Expo template changed — update this plugin instead of editing android/ by hand.',
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
return contents.replace(DEFAULT_PROGUARD, OPTIMIZED_PROGUARD);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function addReleaseSigningConfig(contents) {
|
|
81
|
-
if (contents.includes(CONDITIONAL_SIGNING_CONFIG)) return contents;
|
|
82
|
-
|
|
83
|
-
// Declare signingConfigs.release immediately after the generated debug entry.
|
|
84
|
-
const debugSigningBlock = /(signingConfigs\s*\{\s*\n\s*debug\s*\{[\s\S]*?\n\s{8}\}\n)/;
|
|
85
|
-
if (!debugSigningBlock.test(contents)) {
|
|
86
|
-
throw new Error(
|
|
87
|
-
'[withOxyAndroidRelease] Could not find the generated signingConfigs.debug block in ' +
|
|
88
|
-
'app/build.gradle. The Expo template changed — update this plugin.',
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
const next = contents.replace(debugSigningBlock, `$1${RELEASE_SIGNING_CONFIG}`);
|
|
92
|
-
|
|
93
|
-
// Point the release buildType at it. The debug buildType also contains
|
|
94
|
-
// `signingConfig signingConfigs.debug`, so only replace the occurrence that
|
|
95
|
-
// follows the `release {` marker.
|
|
96
|
-
const releaseBuildType = next.indexOf('release {', next.indexOf('buildTypes'));
|
|
97
|
-
if (releaseBuildType === -1) {
|
|
98
|
-
throw new Error(
|
|
99
|
-
'[withOxyAndroidRelease] Could not find the release buildType in app/build.gradle.',
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
const target = next.indexOf(DEBUG_SIGNING_CONFIG, releaseBuildType);
|
|
103
|
-
if (target === -1) {
|
|
104
|
-
throw new Error(
|
|
105
|
-
'[withOxyAndroidRelease] Could not find the release buildType signingConfig line.',
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
return (
|
|
109
|
-
next.slice(0, target) +
|
|
110
|
-
CONDITIONAL_SIGNING_CONFIG +
|
|
111
|
-
next.slice(target + DEBUG_SIGNING_CONFIG.length)
|
|
12
|
+
module.exports = function withOxyAndroidRelease() {
|
|
13
|
+
throw new Error(
|
|
14
|
+
'[@oxy.so/app-preset] plugin/withOxyAndroidRelease was removed in 5.0.0. Delete it from the ' +
|
|
15
|
+
'app config: release signing is applied by @oxy.so/services/plugins/withOxySharedPermissions ' +
|
|
16
|
+
"(@oxy.so/services 13.4.0 or later, also applied by ['@oxy.so/app-preset', {}]), and it now " +
|
|
17
|
+
'FAILS a release build that is not signed with the Oxy ecosystem key. The R8 -optimize ' +
|
|
18
|
+
"ProGuard swap is applied by ['@oxy.so/app-preset', {}].",
|
|
112
19
|
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
module.exports = function withOxyAndroidRelease(config) {
|
|
116
|
-
return withAppBuildGradle(config, (config) => {
|
|
117
|
-
if (config.modResults.language !== 'groovy') {
|
|
118
|
-
throw new Error(
|
|
119
|
-
`[withOxyAndroidRelease] Expected a Groovy app/build.gradle, got ${config.modResults.language}.`,
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
config.modResults.contents = addReleaseSigningConfig(
|
|
123
|
-
useOptimizedProguardFile(config.modResults.contents),
|
|
124
|
-
);
|
|
125
|
-
return config;
|
|
126
|
-
});
|
|
127
20
|
};
|
|
@@ -30,6 +30,12 @@
|
|
|
30
30
|
* options throw, so an app config that still passes them fails loudly instead
|
|
31
31
|
* of silently doing something else.
|
|
32
32
|
*
|
|
33
|
+
* `withOxySharedPermissions` also signs every release build with the ONE Oxy
|
|
34
|
+
* ecosystem key (the `OXY_UPLOAD_*` Gradle properties) and fails a release that
|
|
35
|
+
* does not carry its certificate; an app lists no signing plugin of its own.
|
|
36
|
+
* `withOxyR8Optimize` (always applied) swaps in R8's `-optimize` ProGuard file on
|
|
37
|
+
* Expo SDK 56/57 and is a no-op on 58.
|
|
38
|
+
*
|
|
33
39
|
* @param {import('expo/config').ExpoConfig} config
|
|
34
40
|
* @param {object} [options]
|
|
35
41
|
* @param {string|false} [options.keychainGroup='group.so.oxy.shared']
|
|
@@ -48,7 +54,9 @@
|
|
|
48
54
|
*/
|
|
49
55
|
const withOxyKeychain = require('./withOxyKeychain');
|
|
50
56
|
const withOxyBuildProperties = require('./withOxyBuildProperties');
|
|
51
|
-
const
|
|
57
|
+
const withOxyR8Optimize = require('./withOxyR8Optimize');
|
|
58
|
+
const { dirname, join } = require('node:path');
|
|
59
|
+
const { projectRootOf, requireFromProject, resolveFromProject } = require('./requireFromProject');
|
|
52
60
|
|
|
53
61
|
const REMOVED_OPTIONS = {
|
|
54
62
|
sharedUserId:
|
|
@@ -94,15 +102,22 @@ module.exports = function withOxyAppPreset(config, options = {}) {
|
|
|
94
102
|
next = withOxyBuildProperties(next, { ios, android });
|
|
95
103
|
}
|
|
96
104
|
|
|
105
|
+
next = withOxyR8Optimize(next);
|
|
106
|
+
|
|
97
107
|
let withOxySharedPermissions;
|
|
98
108
|
try {
|
|
99
|
-
|
|
109
|
+
const permissionsPlugin = resolveFromProject(
|
|
100
110
|
'@oxy.so/services/plugins/withOxySharedPermissions',
|
|
101
111
|
projectRootOf(config),
|
|
102
112
|
);
|
|
113
|
+
// A Services older than 13.4.0 declares the permissions WITHOUT release
|
|
114
|
+
// signing, and Expo's template then signs release with the debug key: refuse
|
|
115
|
+
// it. Its sibling, because withOxySharedPermissions loads that very file.
|
|
116
|
+
require.resolve(join(dirname(permissionsPlugin), 'withOxyReleaseSigning'));
|
|
117
|
+
withOxySharedPermissions = require(permissionsPlugin);
|
|
103
118
|
} catch (error) {
|
|
104
119
|
throw new Error(
|
|
105
|
-
"[@oxy.so/app-preset] needs '@oxy.so/services'
|
|
120
|
+
"[@oxy.so/app-preset] needs '@oxy.so/services' 13.4.0 or later (for plugins/withOxySharedPermissions and withOxyReleaseSigning). " +
|
|
106
121
|
`Install it in the app. (${error instanceof Error ? error.message : String(error)})`,
|
|
107
122
|
);
|
|
108
123
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expo Config Plugin: withOxyR8Optimize (applied by `['@oxy.so/app-preset', {}]`).
|
|
3
|
+
*
|
|
4
|
+
* Expo SDK 56/57 generate `getDefaultProguardFile("proguard-android.txt")` for
|
|
5
|
+
* the release buildType, whose only meaningful line is `-dontoptimize`. The
|
|
6
|
+
* `-optimize` variant drops it and adds `-allowaccessmodification`, which is what
|
|
7
|
+
* lets R8 inline and merge classes (measured on Mention: dex 22,814,960 →
|
|
8
|
+
* 15,290,636 bytes uncompressed, -33%, 4 dex files → 2). SDK 58's template
|
|
9
|
+
* already generates the `-optimize` file, so there this is a no-op.
|
|
10
|
+
*
|
|
11
|
+
* Release signing is not here: `@oxy.so/services/plugins/withOxySharedPermissions`
|
|
12
|
+
* (which the preset applies) owns it, because the signature permissions it
|
|
13
|
+
* declares are what make the certificate load-bearing.
|
|
14
|
+
*/
|
|
15
|
+
const { withAppBuildGradle } = require('expo/config-plugins');
|
|
16
|
+
|
|
17
|
+
const DEFAULT_PROGUARD = 'getDefaultProguardFile("proguard-android.txt")';
|
|
18
|
+
const OPTIMIZED_PROGUARD = 'getDefaultProguardFile("proguard-android-optimize.txt")';
|
|
19
|
+
|
|
20
|
+
/** @param {string} contents */
|
|
21
|
+
function optimizeProguardFile(contents) {
|
|
22
|
+
if (contents.includes(OPTIMIZED_PROGUARD)) return contents;
|
|
23
|
+
if (!contents.includes(DEFAULT_PROGUARD)) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`[@oxy.so/app-preset withOxyR8Optimize] Could not find ${DEFAULT_PROGUARD} in app/build.gradle. ` +
|
|
26
|
+
'The Expo template changed: update this plugin instead of editing android/ by hand.',
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return contents.replace(DEFAULT_PROGUARD, OPTIMIZED_PROGUARD);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = function withOxyR8Optimize(config) {
|
|
33
|
+
return withAppBuildGradle(config, (modConfig) => {
|
|
34
|
+
if (modConfig.modResults.language === 'groovy') {
|
|
35
|
+
modConfig.modResults.contents = optimizeProguardFile(modConfig.modResults.contents);
|
|
36
|
+
}
|
|
37
|
+
return modConfig;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
module.exports.optimizeProguardFile = optimizeProguardFile;
|