@vvedantb/config 0.14.0 → 0.14.2
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/CHANGELOG.md +12 -0
- package/README.md +2 -2
- package/dist/android-release-cli.js +29 -4
- package/dist/android-release.d.ts +57 -0
- package/dist/android-release.js +117 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#338](https://github.com/vvedantb/packages/pull/338) [`5352f85`](https://github.com/vvedantb/packages/commit/5352f852ed51e4807e04fce84be83fbf522f7fe5) Thanks [@vvedantb](https://github.com/vvedantb)! - `vvedantb-android-release` supports opt-in Gradle ABI splits through the `abiSplits` and `publishArchitectures` config fields. One `assembleRelease` writes one APK per ABI; only the publish ABI APK is renamed, hashed into `release.json` and published, with an unchanged versionCode. The `startup_apk` GitHub output names the x86_64 split for the start-up test. Default behaviour is unchanged. New helpers: `withAbiSplits`, `abiSplitsGradle`, `resolveReleaseApkNames`, `splitApkFileName` and `splitArchitectures`.
|
|
8
|
+
|
|
9
|
+
## 0.14.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#337](https://github.com/vvedantb/packages/pull/337) [`8bb6944`](https://github.com/vvedantb/packages/commit/8bb69441de755f833033b02fb2a65d72d692dd24) Thanks [@vvedantb](https://github.com/vvedantb)! - `vvedantb-android-release` can request ABIs for `reactNativeArchitectures` through the `REACT_NATIVE_ARCHITECTURES` env var or the `reactNativeArchitectures` config field, in that order. The default stays `arm64-v8a`. New helpers: `resolveReactNativeArchitectures` and `buildGradlePropertyEdits`.
|
|
14
|
+
|
|
3
15
|
## 0.14.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -569,7 +569,7 @@ Paths and filters are as read from each app's current script. Check them against
|
|
|
569
569
|
|
|
570
570
|
### Gradle settings
|
|
571
571
|
|
|
572
|
-
The bin edits `android/gradle.properties` (`DEFAULT_GRADLE_PROPERTY_EDITS`): `reactNativeArchitectures=arm64-v8a` (published APKs run on phones; emulator builds in `apps/native-gallery` set `x86_64` themselves), `org.gradle.workers.max=8` and `org.gradle.parallel=true` (boat-large has 8 cores; both override Expo's defaults). `org.gradle.configuration-cache` stays off: ephemeral CI runners never reuse the cache, so a cold `assembleRelease` only pays the store cost, and Expo and third-party native modules can still be incompatible on release tasks. After prebuild the bin checks `versionCode`, `versionName` and signing in `android/app/build.gradle`.
|
|
572
|
+
The bin edits `android/gradle.properties` (`DEFAULT_GRADLE_PROPERTY_EDITS`): `reactNativeArchitectures=arm64-v8a` by default (published APKs run on phones; emulator builds in `apps/native-gallery` set `x86_64` themselves). The `REACT_NATIVE_ARCHITECTURES` env var, then the config field `reactNativeArchitectures`, override it, such as `arm64-v8a,x86_64` for an app whose start-up test runs on an x86_64 emulator. It also sets `org.gradle.workers.max=8` and `org.gradle.parallel=true` (boat-large has 8 cores; both override Expo's defaults). Set `abiSplits: true` and `publishArchitectures: ["arm64-v8a"]` to build one APK per ABI in a single `assembleRelease`: only the publish ABI APK is published (versionCode unchanged), and the other ABI APK (such as `x86_64`) is written to the `startup_apk` GitHub output for the start-up test. `org.gradle.configuration-cache` stays off: ephemeral CI runners never reuse the cache, so a cold `assembleRelease` only pays the store cost, and Expo and third-party native modules can still be incompatible on release tasks. After prebuild the bin checks `versionCode`, `versionName` and signing in `android/app/build.gradle`.
|
|
573
573
|
|
|
574
574
|
### Version pick
|
|
575
575
|
|
|
@@ -577,7 +577,7 @@ The bin edits `android/gradle.properties` (`DEFAULT_GRADLE_PROPERTY_EDITS`): `re
|
|
|
577
577
|
|
|
578
578
|
Not covered, so it stays local: the keystore location (a `withReleaseSigning` plugin option), velth's own signing-completeness pre-check (the Gradle plugin enforces it), and eva's Clerk native-API check (use the workflow's `pre_build_command`).
|
|
579
579
|
|
|
580
|
-
Pure helpers (`pickAndroidReleaseVersion`, `readExpoVersion`, `syncExpoVersion`, `syncPackageJsonVersion`, `gradleVersionNameOk`, `validateVersionName`, `validateVersionCode`, `publicEnvDefault`, `easProfileEntries`, `gradlePropertiesEdits`, `parseBadging`, `releaseJson`, `formatReleaseJson`, `formatGithubOutput`, `apkFileName`, `parseAndroidReleaseConfig`) are exported from the root and unit-tested. The full Android build was not exercised on Windows.
|
|
580
|
+
Pure helpers (`pickAndroidReleaseVersion`, `readExpoVersion`, `syncExpoVersion`, `syncPackageJsonVersion`, `gradleVersionNameOk`, `validateVersionName`, `validateVersionCode`, `publicEnvDefault`, `easProfileEntries`, `gradlePropertiesEdits`, `buildGradlePropertyEdits`, `resolveReactNativeArchitectures`, `withAbiSplits`, `abiSplitsGradle`, `resolveReleaseApkNames`, `splitApkFileName`, `splitArchitectures`, `parseBadging`, `releaseJson`, `formatReleaseJson`, `formatGithubOutput`, `apkFileName`, `parseAndroidReleaseConfig`) are exported from the root and unit-tested. The full Android build was not exercised on Windows.
|
|
581
581
|
|
|
582
582
|
## Versions
|
|
583
583
|
|
|
@@ -17,7 +17,7 @@ import { spawnSync } from "node:child_process";
|
|
|
17
17
|
import { createHash } from "node:crypto";
|
|
18
18
|
import { appendFileSync, chmodSync, copyFileSync, existsSync, readdirSync, readFileSync, rmSync, writeFileSync, } from "node:fs";
|
|
19
19
|
import { dirname, join, resolve } from "node:path";
|
|
20
|
-
import { apkFileName, easProfileEntries, formatGithubOutput, formatReleaseJson, gradlePropertiesEdits, gradleVersionNameOk, parseAndroidReleaseConfig, parseBadging, publicEnvDefault, readExpoVersion, releaseJson, syncExpoVersion, syncPackageJsonVersion, validateVersionCode, validateVersionName, } from "./android-release.js";
|
|
20
|
+
import { apkFileName, easProfileEntries, formatGithubOutput, formatReleaseJson, buildGradlePropertyEdits, gradlePropertiesEdits, resolveReactNativeArchitectures, resolveReleaseApkNames, splitArchitectures, withAbiSplits, gradleVersionNameOk, parseAndroidReleaseConfig, parseBadging, publicEnvDefault, readExpoVersion, releaseJson, syncExpoVersion, syncPackageJsonVersion, validateVersionCode, validateVersionName, } from "./android-release.js";
|
|
21
21
|
function fail(message) {
|
|
22
22
|
console.error(message);
|
|
23
23
|
process.exit(1);
|
|
@@ -220,12 +220,27 @@ if (config.gradleWrapperPin !== undefined) {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
+
// Architectures precedence: REACT_NATIVE_ARCHITECTURES env, config field, arm64-v8a.
|
|
224
|
+
const architectures = resolveReactNativeArchitectures(process.env.REACT_NATIVE_ARCHITECTURES, config.reactNativeArchitectures);
|
|
225
|
+
const apkNames = resolveReleaseApkNames({
|
|
226
|
+
abiSplits: config.abiSplits,
|
|
227
|
+
architectures,
|
|
228
|
+
publishArchitectures: config.publishArchitectures,
|
|
229
|
+
});
|
|
230
|
+
if (config.abiSplits === true) {
|
|
231
|
+
const publishAbi = config.publishArchitectures?.[0] ?? "";
|
|
232
|
+
if (!splitArchitectures(architectures).includes(publishAbi)) {
|
|
233
|
+
fail(`Publish ABI ${publishAbi} is not in reactNativeArchitectures (${architectures}).`);
|
|
234
|
+
}
|
|
235
|
+
writeFileSync(appGradle, withAbiSplits(appGradleText, splitArchitectures(architectures)));
|
|
236
|
+
}
|
|
223
237
|
const propsPath = join(appDir, "android", "gradle.properties");
|
|
224
238
|
const propsText = existsSync(propsPath) ? readFileSync(propsPath, "utf8") : "";
|
|
225
|
-
writeFileSync(propsPath, gradlePropertiesEdits(propsText));
|
|
239
|
+
writeFileSync(propsPath, gradlePropertiesEdits(propsText, buildGradlePropertyEdits(architectures)));
|
|
226
240
|
writeFileSync(join(appDir, "android", "local.properties"), `sdk.dir=${sdkRoot}\n`);
|
|
227
241
|
const outDir = join(appDir, "android", "app", "build", "outputs", "apk", "release");
|
|
228
|
-
const apk = join(outDir,
|
|
242
|
+
const apk = join(outDir, apkNames.publish);
|
|
243
|
+
const startupApk = apkNames.startup === undefined ? undefined : join(outDir, apkNames.startup);
|
|
229
244
|
// A failed run must not leave an older APK or release.json to publish.
|
|
230
245
|
for (const stale of [apk, join(outDir, "release.json")]) {
|
|
231
246
|
if (existsSync(stale))
|
|
@@ -233,7 +248,8 @@ for (const stale of [apk, join(outDir, "release.json")]) {
|
|
|
233
248
|
}
|
|
234
249
|
if (existsSync(outDir)) {
|
|
235
250
|
for (const name of readdirSync(outDir)) {
|
|
236
|
-
if (new RegExp(`^${config.apkPrefix}-.*-android\\.apk$`).test(name)
|
|
251
|
+
if (new RegExp(`^${config.apkPrefix}-.*-android\\.apk$`).test(name) ||
|
|
252
|
+
(config.abiSplits === true && /^app-.*release\.apk$/.test(name))) {
|
|
237
253
|
rmSync(join(outDir, name));
|
|
238
254
|
}
|
|
239
255
|
}
|
|
@@ -257,6 +273,14 @@ if (badging.name !== config.packageId ||
|
|
|
257
273
|
fail(`Built ${badging.name} ${badging.versionCode} ${badging.versionName} (package, versionCode, versionName); ` +
|
|
258
274
|
`expected ${config.packageId} ${versionCode} ${versionName}.`);
|
|
259
275
|
}
|
|
276
|
+
if (startupApk !== undefined) {
|
|
277
|
+
if (!existsSync(startupApk))
|
|
278
|
+
fail(`Gradle did not write the start-up APK ${startupApk}.`);
|
|
279
|
+
const other = parseBadging(capture(join(buildTools, "aapt2"), ["dump", "badging", startupApk], androidDir));
|
|
280
|
+
if (other.versionCode !== badging.versionCode || other.versionName !== badging.versionName) {
|
|
281
|
+
fail(`The start-up APK is ${other.versionCode} ${other.versionName}; the published APK is ${badging.versionCode} ${badging.versionName}.`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
260
284
|
const certs = capture(join(buildTools, "apksigner"), ["verify", "--print-certs", apk], androidDir);
|
|
261
285
|
if (certs.includes("CN=Android Debug")) {
|
|
262
286
|
fail("The APK is signed with the debug key. Not writing release.json.");
|
|
@@ -276,6 +300,7 @@ console.info(`Wrote ${manifest}`);
|
|
|
276
300
|
if (env.GITHUB_OUTPUT !== undefined && env.GITHUB_OUTPUT !== "") {
|
|
277
301
|
appendFileSync(env.GITHUB_OUTPUT, formatGithubOutput({
|
|
278
302
|
apk: named,
|
|
303
|
+
...(startupApk === undefined ? {} : { startup_apk: startupApk }),
|
|
279
304
|
release_json: manifest,
|
|
280
305
|
version_name: versionName,
|
|
281
306
|
version_code: String(versionCode),
|
|
@@ -53,7 +53,19 @@ export interface GradlePropertyEdit {
|
|
|
53
53
|
/** Replace an existing line (true) or only append when absent (false). */
|
|
54
54
|
replace: boolean;
|
|
55
55
|
}
|
|
56
|
+
/** Default `reactNativeArchitectures`: published APKs target phones. */
|
|
57
|
+
export declare const DEFAULT_REACT_NATIVE_ARCHITECTURES = "arm64-v8a";
|
|
58
|
+
/**
|
|
59
|
+
* Resolves the `reactNativeArchitectures` value. Precedence: explicit `option`
|
|
60
|
+
* (for example the `REACT_NATIVE_ARCHITECTURES` env var), then `fallback` (the
|
|
61
|
+
* config field), then `arm64-v8a`. Empty or blank values are skipped. The
|
|
62
|
+
* existing `gradle.properties` value is not preserved: Expo's prebuild default
|
|
63
|
+
* is fat, so keeping it would widen every app that relies on the arm64 force.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveReactNativeArchitectures(option?: string, fallback?: string): string;
|
|
56
66
|
/** The edits the release build makes to `gradle.properties`, in order. */
|
|
67
|
+
export declare function buildGradlePropertyEdits(reactNativeArchitectures?: string): readonly GradlePropertyEdit[];
|
|
68
|
+
/** The default edits (arm64-v8a only), in order. */
|
|
57
69
|
export declare const DEFAULT_GRADLE_PROPERTY_EDITS: readonly GradlePropertyEdit[];
|
|
58
70
|
/**
|
|
59
71
|
* Applies the release edits to `gradle.properties` contents and returns the new
|
|
@@ -124,6 +136,21 @@ export interface AndroidReleaseConfig {
|
|
|
124
136
|
ifContains: string;
|
|
125
137
|
distributionUrl: string;
|
|
126
138
|
};
|
|
139
|
+
/**
|
|
140
|
+
* ABIs for `reactNativeArchitectures` in `gradle.properties`, such as
|
|
141
|
+
* `"arm64-v8a,x86_64"`. The `REACT_NATIVE_ARCHITECTURES` env var wins over it.
|
|
142
|
+
* Default `"arm64-v8a"`.
|
|
143
|
+
*/
|
|
144
|
+
reactNativeArchitectures?: string;
|
|
145
|
+
/**
|
|
146
|
+
* Build one APK per ABI with Gradle ABI splits (no universal APK). Only the
|
|
147
|
+
* single `publishArchitectures` APK is renamed, hashed and published; another
|
|
148
|
+
* ABI in `reactNativeArchitectures` (such as `x86_64`) is the start-up test
|
|
149
|
+
* APK. versionCode is not changed per ABI. Default `false`.
|
|
150
|
+
*/
|
|
151
|
+
abiSplits?: boolean;
|
|
152
|
+
/** With `abiSplits`: the one ABI to publish, such as `["arm64-v8a"]`. */
|
|
153
|
+
publishArchitectures?: readonly string[];
|
|
127
154
|
/** Label and env var for the final summary line, such as `{ label: "Convex", envVar: "EXPO_PUBLIC_CONVEX_URL" }`. */
|
|
128
155
|
summary?: {
|
|
129
156
|
label: string;
|
|
@@ -146,3 +173,33 @@ export declare function syncExpoVersion(appJsonContents: string, versionName: st
|
|
|
146
173
|
export declare function syncPackageJsonVersion(packageJsonContents: string, versionName: string): string;
|
|
147
174
|
/** True when the generated `android/app/build.gradle` sets `versionName "<versionName>"`. */
|
|
148
175
|
export declare function gradleVersionNameOk(gradleText: string, versionName: string): boolean;
|
|
176
|
+
/** Splits a `reactNativeArchitectures` value such as `"arm64-v8a,x86_64"` into ABIs. */
|
|
177
|
+
export declare function splitArchitectures(value: string): string[];
|
|
178
|
+
/** Marker line that makes the ABI splits block idempotent. */
|
|
179
|
+
export declare const ABI_SPLITS_MARKER = "// vvedantb-android-release: abi splits";
|
|
180
|
+
/**
|
|
181
|
+
* The `android { splits { abi { ... } } }` block for `abis`. No universal APK,
|
|
182
|
+
* and no `versionCodeOverride`, so every ABI APK keeps the same versionCode.
|
|
183
|
+
*/
|
|
184
|
+
export declare function abiSplitsGradle(abis: readonly string[]): string;
|
|
185
|
+
/** Adds the ABI splits block to `build.gradle` text, or replaces an earlier one. */
|
|
186
|
+
export declare function withAbiSplits(gradleText: string, abis: readonly string[]): string;
|
|
187
|
+
/** The Gradle output name of an ABI split APK, such as `app-arm64-v8a-release.apk`. */
|
|
188
|
+
export declare function splitApkFileName(abi: string): string;
|
|
189
|
+
/** Which Gradle output APKs the release publishes and the start-up test installs. */
|
|
190
|
+
export interface ReleaseApkNames {
|
|
191
|
+
/** The APK renamed, hashed and published. */
|
|
192
|
+
publish: string;
|
|
193
|
+
/** The APK the start-up test installs, when it differs from `publish`. */
|
|
194
|
+
startup?: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Resolves the Gradle output file names. Without `abiSplits` it is
|
|
198
|
+
* `app-release.apk` and no start-up APK. With it, `publish` is the split for the
|
|
199
|
+
* publish ABI and `startup` the first other ABI in `architectures`, if any.
|
|
200
|
+
*/
|
|
201
|
+
export declare function resolveReleaseApkNames(options: {
|
|
202
|
+
abiSplits?: boolean;
|
|
203
|
+
architectures: string;
|
|
204
|
+
publishArchitectures?: readonly string[];
|
|
205
|
+
}): ReleaseApkNames;
|
package/dist/android-release.js
CHANGED
|
@@ -97,10 +97,24 @@ export function publicEnvDefault(name, options) {
|
|
|
97
97
|
}
|
|
98
98
|
return "";
|
|
99
99
|
}
|
|
100
|
-
/**
|
|
101
|
-
export const
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
/** Default `reactNativeArchitectures`: published APKs target phones. */
|
|
101
|
+
export const DEFAULT_REACT_NATIVE_ARCHITECTURES = "arm64-v8a";
|
|
102
|
+
/**
|
|
103
|
+
* Resolves the `reactNativeArchitectures` value. Precedence: explicit `option`
|
|
104
|
+
* (for example the `REACT_NATIVE_ARCHITECTURES` env var), then `fallback` (the
|
|
105
|
+
* config field), then `arm64-v8a`. Empty or blank values are skipped. The
|
|
106
|
+
* existing `gradle.properties` value is not preserved: Expo's prebuild default
|
|
107
|
+
* is fat, so keeping it would widen every app that relies on the arm64 force.
|
|
108
|
+
*/
|
|
109
|
+
export function resolveReactNativeArchitectures(option, fallback) {
|
|
110
|
+
for (const candidate of [option, fallback]) {
|
|
111
|
+
const trimmed = candidate?.trim();
|
|
112
|
+
if (trimmed !== undefined && trimmed !== "")
|
|
113
|
+
return trimmed;
|
|
114
|
+
}
|
|
115
|
+
return DEFAULT_REACT_NATIVE_ARCHITECTURES;
|
|
116
|
+
}
|
|
117
|
+
const BASE_GRADLE_PROPERTY_EDITS = [
|
|
104
118
|
{ key: "org.gradle.jvmargs", value: "-Xmx4096m -XX:MaxMetaspaceSize=1024m", replace: true },
|
|
105
119
|
// boat-large has 8 cores. Replace Expo's lower default.
|
|
106
120
|
{ key: "org.gradle.workers.max", value: "8", replace: true },
|
|
@@ -109,6 +123,19 @@ export const DEFAULT_GRADLE_PROPERTY_EDITS = [
|
|
|
109
123
|
// the cache, and native modules may still be incompatible on release tasks.
|
|
110
124
|
{ key: "android.lint.checkReleaseBuilds", value: "false", replace: false },
|
|
111
125
|
];
|
|
126
|
+
/** The edits the release build makes to `gradle.properties`, in order. */
|
|
127
|
+
export function buildGradlePropertyEdits(reactNativeArchitectures) {
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
key: "reactNativeArchitectures",
|
|
131
|
+
value: resolveReactNativeArchitectures(reactNativeArchitectures),
|
|
132
|
+
replace: true,
|
|
133
|
+
},
|
|
134
|
+
...BASE_GRADLE_PROPERTY_EDITS,
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
/** The default edits (arm64-v8a only), in order. */
|
|
138
|
+
export const DEFAULT_GRADLE_PROPERTY_EDITS = buildGradlePropertyEdits();
|
|
112
139
|
function withTrailingNewline(contents) {
|
|
113
140
|
if (contents.length === 0)
|
|
114
141
|
return contents;
|
|
@@ -243,6 +270,30 @@ export function parseAndroidReleaseConfig(input) {
|
|
|
243
270
|
}
|
|
244
271
|
if (raw.gradleWrapperPin !== undefined)
|
|
245
272
|
config.gradleWrapperPin = parseWrapperPin(raw.gradleWrapperPin);
|
|
273
|
+
if (raw.reactNativeArchitectures !== undefined) {
|
|
274
|
+
if (typeof raw.reactNativeArchitectures !== "string") {
|
|
275
|
+
throw new Error('android-release config: "reactNativeArchitectures" must be a string.');
|
|
276
|
+
}
|
|
277
|
+
config.reactNativeArchitectures = raw.reactNativeArchitectures;
|
|
278
|
+
}
|
|
279
|
+
if (raw.abiSplits !== undefined) {
|
|
280
|
+
if (typeof raw.abiSplits !== "boolean")
|
|
281
|
+
throw new Error('android-release config: "abiSplits" must be a boolean.');
|
|
282
|
+
config.abiSplits = raw.abiSplits;
|
|
283
|
+
}
|
|
284
|
+
if (raw.publishArchitectures !== undefined) {
|
|
285
|
+
config.publishArchitectures = asStringArray(raw.publishArchitectures, "publishArchitectures");
|
|
286
|
+
}
|
|
287
|
+
if (config.abiSplits === true) {
|
|
288
|
+
const publish = config.publishArchitectures ?? [];
|
|
289
|
+
if (publish.length !== 1) {
|
|
290
|
+
throw new Error('android-release config: "abiSplits" needs "publishArchitectures" with exactly one ABI.');
|
|
291
|
+
}
|
|
292
|
+
const all = splitArchitectures(resolveReactNativeArchitectures(undefined, config.reactNativeArchitectures));
|
|
293
|
+
if (!all.includes(publish[0])) {
|
|
294
|
+
throw new Error('android-release config: "publishArchitectures" must be in "reactNativeArchitectures".');
|
|
295
|
+
}
|
|
296
|
+
}
|
|
246
297
|
if (raw.summary !== undefined)
|
|
247
298
|
config.summary = parseSummary(raw.summary);
|
|
248
299
|
return config;
|
|
@@ -354,3 +405,65 @@ export function syncPackageJsonVersion(packageJsonContents, versionName) {
|
|
|
354
405
|
export function gradleVersionNameOk(gradleText, versionName) {
|
|
355
406
|
return new RegExp(`^[\\t ]*versionName ["']${escapeRegExp(versionName)}["'][\\t ]*$`, "m").test(gradleText);
|
|
356
407
|
}
|
|
408
|
+
/** Splits a `reactNativeArchitectures` value such as `"arm64-v8a,x86_64"` into ABIs. */
|
|
409
|
+
export function splitArchitectures(value) {
|
|
410
|
+
return value
|
|
411
|
+
.split(",")
|
|
412
|
+
.map((abi) => abi.trim())
|
|
413
|
+
.filter((abi) => abi !== "");
|
|
414
|
+
}
|
|
415
|
+
/** Marker line that makes the ABI splits block idempotent. */
|
|
416
|
+
export const ABI_SPLITS_MARKER = "// vvedantb-android-release: abi splits";
|
|
417
|
+
/**
|
|
418
|
+
* The `android { splits { abi { ... } } }` block for `abis`. No universal APK,
|
|
419
|
+
* and no `versionCodeOverride`, so every ABI APK keeps the same versionCode.
|
|
420
|
+
*/
|
|
421
|
+
export function abiSplitsGradle(abis) {
|
|
422
|
+
const include = abis.map((abi) => `'${abi}'`).join(", ");
|
|
423
|
+
return [
|
|
424
|
+
ABI_SPLITS_MARKER,
|
|
425
|
+
"android {",
|
|
426
|
+
" splits {",
|
|
427
|
+
" abi {",
|
|
428
|
+
" enable true",
|
|
429
|
+
" reset()",
|
|
430
|
+
` include ${include}`,
|
|
431
|
+
" universalApk false",
|
|
432
|
+
" }",
|
|
433
|
+
" }",
|
|
434
|
+
"}",
|
|
435
|
+
ABI_SPLITS_MARKER + " (end)",
|
|
436
|
+
"",
|
|
437
|
+
].join("\n");
|
|
438
|
+
}
|
|
439
|
+
/** Adds the ABI splits block to `build.gradle` text, or replaces an earlier one. */
|
|
440
|
+
export function withAbiSplits(gradleText, abis) {
|
|
441
|
+
const start = gradleText.indexOf(ABI_SPLITS_MARKER);
|
|
442
|
+
const endMarker = ABI_SPLITS_MARKER + " (end)\n";
|
|
443
|
+
const end = gradleText.indexOf(endMarker);
|
|
444
|
+
const base = start >= 0 && end > start
|
|
445
|
+
? gradleText.slice(0, start) + gradleText.slice(end + endMarker.length)
|
|
446
|
+
: gradleText;
|
|
447
|
+
return withTrailingNewline(base) + abiSplitsGradle(abis);
|
|
448
|
+
}
|
|
449
|
+
/** The Gradle output name of an ABI split APK, such as `app-arm64-v8a-release.apk`. */
|
|
450
|
+
export function splitApkFileName(abi) {
|
|
451
|
+
return `app-${abi}-release.apk`;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Resolves the Gradle output file names. Without `abiSplits` it is
|
|
455
|
+
* `app-release.apk` and no start-up APK. With it, `publish` is the split for the
|
|
456
|
+
* publish ABI and `startup` the first other ABI in `architectures`, if any.
|
|
457
|
+
*/
|
|
458
|
+
export function resolveReleaseApkNames(options) {
|
|
459
|
+
if (options.abiSplits !== true)
|
|
460
|
+
return { publish: "app-release.apk" };
|
|
461
|
+
const publishAbi = options.publishArchitectures?.[0];
|
|
462
|
+
if (publishAbi === undefined)
|
|
463
|
+
throw new Error("abiSplits needs a publish ABI.");
|
|
464
|
+
const startupAbi = splitArchitectures(options.architectures).find((abi) => abi !== publishAbi);
|
|
465
|
+
return {
|
|
466
|
+
publish: splitApkFileName(publishAbi),
|
|
467
|
+
...(startupAbi === undefined ? {} : { startup: splitApkFileName(startupAbi) }),
|
|
468
|
+
};
|
|
469
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export { CHECK_IDS, checkCiReusableWorkflow, checkConfigVersion, checkNoEslint,
|
|
|
10
10
|
export { REACT_DEDUPE, defineWebViteConfig, defineWebVitestConfig, reactPlugins, srcAlias, vendorChunkBuild, type AliasOptions, type BabelReactCompiler, type PathOptions, type ReactSetup, type ResolveConfig, type RouterPluginOptions, type VendorChunk, type VendorChunkGroup, type VitePlugin, type VitePluginOption, type WebBuildConfig, type WebViteConfig, type WebViteOptions, type WebVitestConfig, type WebVitestOptions, } from "./vite.js";
|
|
11
11
|
export { defineExpoMetroConfig, expoBabelConfig, type BabelApi, type ExpoBabelConfig, type ExpoMetroOptions, type MetroConfigLike, type MetroResolveContext, type MetroResolveRequest, type NativeWindMetroOptions, } from "./expo.js";
|
|
12
12
|
export { DEFAULT_RELEASE_SIGNING_MARKER, appendReleaseSigning, releaseSigningGradle, withReleaseSigning, type AppBuildGradleMod, type ReleaseSigningOptions, type ReleaseSigningPropertyKeys, type WithAppBuildGradle, type WithReleaseSigningOptions, } from "./release-signing.js";
|
|
13
|
-
export { DEFAULT_GRADLE_PROPERTY_EDITS, apkFileName, easProfileEntries, formatGithubOutput, formatReleaseJson, gradlePropertiesEdits, parseAndroidReleaseConfig, parseBadging, publicEnvDefault, readExpoVersion, releaseJson, syncPackageJsonVersion, syncExpoVersion, validateVersionCode, validateVersionName, gradleVersionNameOk, type AndroidReleaseConfig, type BadgingFields, type GradlePropertyEdit, type PublicEnvSource, type ReadAppFile, type ReleaseJson, } from "./android-release.js";
|
|
13
|
+
export { ABI_SPLITS_MARKER, abiSplitsGradle, resolveReleaseApkNames, splitApkFileName, splitArchitectures, withAbiSplits, type ReleaseApkNames, DEFAULT_GRADLE_PROPERTY_EDITS, DEFAULT_REACT_NATIVE_ARCHITECTURES, buildGradlePropertyEdits, resolveReactNativeArchitectures, apkFileName, easProfileEntries, formatGithubOutput, formatReleaseJson, gradlePropertiesEdits, parseAndroidReleaseConfig, parseBadging, publicEnvDefault, readExpoVersion, releaseJson, syncPackageJsonVersion, syncExpoVersion, validateVersionCode, validateVersionName, gradleVersionNameOk, type AndroidReleaseConfig, type BadgingFields, type GradlePropertyEdit, type PublicEnvSource, type ReadAppFile, type ReleaseJson, } from "./android-release.js";
|
|
14
14
|
export { compareSemver, highestSemver, isSemver, pickAndroidReleaseVersion, publishedVersionNames, type AndroidReleaseVersion, type PickAndroidReleaseVersionInput, type PublishedReleases, type VersionNameSource, } from "./android-release-version.js";
|
package/dist/index.js
CHANGED
|
@@ -10,5 +10,5 @@ export { CHECK_IDS, checkCiReusableWorkflow, checkConfigVersion, checkNoEslint,
|
|
|
10
10
|
export { REACT_DEDUPE, defineWebViteConfig, defineWebVitestConfig, reactPlugins, srcAlias, vendorChunkBuild, } from "./vite.js";
|
|
11
11
|
export { defineExpoMetroConfig, expoBabelConfig, } from "./expo.js";
|
|
12
12
|
export { DEFAULT_RELEASE_SIGNING_MARKER, appendReleaseSigning, releaseSigningGradle, withReleaseSigning, } from "./release-signing.js";
|
|
13
|
-
export { DEFAULT_GRADLE_PROPERTY_EDITS, apkFileName, easProfileEntries, formatGithubOutput, formatReleaseJson, gradlePropertiesEdits, parseAndroidReleaseConfig, parseBadging, publicEnvDefault, readExpoVersion, releaseJson, syncPackageJsonVersion, syncExpoVersion, validateVersionCode, validateVersionName, gradleVersionNameOk, } from "./android-release.js";
|
|
13
|
+
export { ABI_SPLITS_MARKER, abiSplitsGradle, resolveReleaseApkNames, splitApkFileName, splitArchitectures, withAbiSplits, DEFAULT_GRADLE_PROPERTY_EDITS, DEFAULT_REACT_NATIVE_ARCHITECTURES, buildGradlePropertyEdits, resolveReactNativeArchitectures, apkFileName, easProfileEntries, formatGithubOutput, formatReleaseJson, gradlePropertiesEdits, parseAndroidReleaseConfig, parseBadging, publicEnvDefault, readExpoVersion, releaseJson, syncPackageJsonVersion, syncExpoVersion, validateVersionCode, validateVersionName, gradleVersionNameOk, } from "./android-release.js";
|
|
14
14
|
export { compareSemver, highestSemver, isSemver, pickAndroidReleaseVersion, publishedVersionNames, } from "./android-release-version.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/config",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared tsconfig bases, oxlint base, Vite, Vitest, Babel and Metro presets, a WXT preset and host-permission helper for Chrome extensions, pinned tool versions, a sync CLI for Claude commands, CLAUDE.md, Cursor environment and Convex tsconfig, a packaged Electron app.asar module check, a shared header and footer check, a no-source-text-in-tests check, shared oxlint JS plugins and a CLI that adds an extension to Clerk's allowed origins.",
|
|
6
6
|
"type": "module",
|