@vvedantb/config 0.14.1 → 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 CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 0.14.1
4
10
 
5
11
  ### Patch 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` 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). `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`, `buildGradlePropertyEdits`, `resolveReactNativeArchitectures`, `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, buildGradlePropertyEdits, gradlePropertiesEdits, resolveReactNativeArchitectures, 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,13 +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
- // Architectures precedence: REACT_NATIVE_ARCHITECTURES env, config field, arm64-v8a.
226
- writeFileSync(propsPath, gradlePropertiesEdits(propsText, buildGradlePropertyEdits(resolveReactNativeArchitectures(process.env.REACT_NATIVE_ARCHITECTURES, config.reactNativeArchitectures))));
239
+ writeFileSync(propsPath, gradlePropertiesEdits(propsText, buildGradlePropertyEdits(architectures)));
227
240
  writeFileSync(join(appDir, "android", "local.properties"), `sdk.dir=${sdkRoot}\n`);
228
241
  const outDir = join(appDir, "android", "app", "build", "outputs", "apk", "release");
229
- const apk = join(outDir, "app-release.apk");
242
+ const apk = join(outDir, apkNames.publish);
243
+ const startupApk = apkNames.startup === undefined ? undefined : join(outDir, apkNames.startup);
230
244
  // A failed run must not leave an older APK or release.json to publish.
231
245
  for (const stale of [apk, join(outDir, "release.json")]) {
232
246
  if (existsSync(stale))
@@ -234,7 +248,8 @@ for (const stale of [apk, join(outDir, "release.json")]) {
234
248
  }
235
249
  if (existsSync(outDir)) {
236
250
  for (const name of readdirSync(outDir)) {
237
- 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))) {
238
253
  rmSync(join(outDir, name));
239
254
  }
240
255
  }
@@ -258,6 +273,14 @@ if (badging.name !== config.packageId ||
258
273
  fail(`Built ${badging.name} ${badging.versionCode} ${badging.versionName} (package, versionCode, versionName); ` +
259
274
  `expected ${config.packageId} ${versionCode} ${versionName}.`);
260
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
+ }
261
284
  const certs = capture(join(buildTools, "apksigner"), ["verify", "--print-certs", apk], androidDir);
262
285
  if (certs.includes("CN=Android Debug")) {
263
286
  fail("The APK is signed with the debug key. Not writing release.json.");
@@ -277,6 +300,7 @@ console.info(`Wrote ${manifest}`);
277
300
  if (env.GITHUB_OUTPUT !== undefined && env.GITHUB_OUTPUT !== "") {
278
301
  appendFileSync(env.GITHUB_OUTPUT, formatGithubOutput({
279
302
  apk: named,
303
+ ...(startupApk === undefined ? {} : { startup_apk: startupApk }),
280
304
  release_json: manifest,
281
305
  version_name: versionName,
282
306
  version_code: String(versionCode),
@@ -142,6 +142,15 @@ export interface AndroidReleaseConfig {
142
142
  * Default `"arm64-v8a"`.
143
143
  */
144
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[];
145
154
  /** Label and env var for the final summary line, such as `{ label: "Convex", envVar: "EXPO_PUBLIC_CONVEX_URL" }`. */
146
155
  summary?: {
147
156
  label: string;
@@ -164,3 +173,33 @@ export declare function syncExpoVersion(appJsonContents: string, versionName: st
164
173
  export declare function syncPackageJsonVersion(packageJsonContents: string, versionName: string): string;
165
174
  /** True when the generated `android/app/build.gradle` sets `versionName "<versionName>"`. */
166
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;
@@ -276,6 +276,24 @@ export function parseAndroidReleaseConfig(input) {
276
276
  }
277
277
  config.reactNativeArchitectures = raw.reactNativeArchitectures;
278
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
+ }
279
297
  if (raw.summary !== undefined)
280
298
  config.summary = parseSummary(raw.summary);
281
299
  return config;
@@ -387,3 +405,65 @@ export function syncPackageJsonVersion(packageJsonContents, versionName) {
387
405
  export function gradleVersionNameOk(gradleText, versionName) {
388
406
  return new RegExp(`^[\\t ]*versionName ["']${escapeRegExp(versionName)}["'][\\t ]*$`, "m").test(gradleText);
389
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, 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";
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, 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";
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.1",
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",