@vvedantb/config 0.11.0 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#333](https://github.com/vvedantb/packages/pull/333) [`659811a`](https://github.com/vvedantb/packages/commit/659811aa48efa54b1a6f3c8f908d1fa78d34d16b) Thanks [@vvedantb](https://github.com/vvedantb)! - `ci-runner` now matches the new Boat runner policy. Check jobs use `boat` (or `boat-small`). `boat-large` is only for Android release builds: the `release-android-apk.yml` and `release-gallery-android.yml` workflows, or a workflow file with `android` in its name. A `boat-large` runner on a `ci-app.yml` job fails. An unknown `boat*` label such as `boat-medium` fails and the message lists the valid labels.
8
+
9
+ ## 0.12.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#318](https://github.com/vvedantb/packages/pull/318) [`5f7ce9d`](https://github.com/vvedantb/packages/commit/5f7ce9d342f04bfd979baacc17fd00930f34bb56) Thanks [@vvedantb](https://github.com/vvedantb)! - Speed up the shared Android APK release path.
14
+
15
+ - Add `pickAndroidReleaseVersion` and its helpers (`compareSemver`, `highestSemver`, `publishedVersionNames`). The tests own the version rules. The `release-android-apk.yml` version step now lists tags once, takes published versionNames from tag suffixes and downloads `release.json` only for the highest semver tag, instead of every release.
16
+ - `vvedantb-android-release` builds `arm64-v8a` only (no `x86_64`), sets `org.gradle.workers.max=8` (replacing Expo's lower default) and `org.gradle.parallel=true`. `org.gradle.configuration-cache` stays off: ephemeral CI runners never reuse the cache, so a cold release build only pays the store cost, and native modules can still be incompatible on release tasks.
17
+ - Add the config flags `syncAppVersion` (write the version to `app.json` and the root `package.json`) and `versionNameFromAppJson` (use `expo.version` when `VERSION_NAME` is unset) so v-store can use the shared bin. Both default to `false`.
18
+ - The bin now also checks `versionName` in `android/app/build.gradle` after prebuild, not only `versionCode`.
19
+
3
20
  ## 0.11.0
4
21
 
5
22
  ### Minor Changes
package/README.md CHANGED
@@ -202,7 +202,7 @@ Each check has a stable id:
202
202
  | `oxlint-script` | No `lint` script that runs `oxlint`. |
203
203
  | `config-version` | The `@vvedantb/config` range floor is an older minor than the running `vvedantb-doctor` version. |
204
204
  | `ci-reusable-workflow` | No workflow calls `vvedantb/packages/.github/workflows/ci-app.yml`. |
205
- | `ci-runner` | A workflow has `runs-on: boat` or `runs_on: boat`. Every boat.dev job runs on `boat-large`. GitHub-hosted labels pass. |
205
+ | `ci-runner` | A job uses a runner the Boat policy does not allow. `boat`, `boat-small` and `boat-xlarge` pass, as do GitHub-hosted labels and `${{ ... }}` expressions. `boat-large` is for Android release builds only: it passes as `runs_on` for `release-android-apk.yml` or `release-gallery-android.yml`, or in a workflow file with `android` in its name, and fails on check jobs such as `ci-app.yml`. An unknown `boat*` label such as `boat-medium` fails. |
206
206
  | `ci-commands` | A line in the `commands` input of the shared workflow is not `lint`, `typecheck` or `test` and has no written reason, or a reason names a command that CI does not run. |
207
207
 
208
208
  **CI commands.** The standard commands are `pnpm lint`, `pnpm typecheck` and `pnpm test` (`npm run` or `bun run` also pass, and so does `--filter <package>`). Every other line needs a reason, keyed by the exact command, in `.vvedantb-doctor.json` or under `vvedantbDoctor.ciCommands` in the root `package.json`:
@@ -495,6 +495,8 @@ The config (parsed by `parseAndroidReleaseConfig`) covers the differences betwee
495
495
  | `unsetEnv` | `[]` | Names removed from the build environment (before `extraEnv`). |
496
496
  | `preChecks` / `preBuildSteps` | — | bash steps run in the repo root / app dir before the build. |
497
497
  | `postPrebuildSteps` | `[]` | bash steps run in the app dir after prebuild, before Gradle. |
498
+ | `syncAppVersion` | `false` | After versionName resolves, write it to `<appDir>/app.json` (`expo.version`) and the root `package.json` (`version`) when they exist, before prebuild. |
499
+ | `versionNameFromAppJson` | `false` | Read `expo.version` from `<appDir>/app.json` when `VERSION_NAME` is unset. Otherwise `VERSION_NAME` is required. |
498
500
  | `gradleWrapperPin` | — | `{ ifContains, distributionUrl }` to pin the Gradle wrapper. |
499
501
  | `summary` | — | `{ label, envVar }` echoed at the end. |
500
502
 
@@ -553,9 +555,29 @@ Paths and filters are as read from each app's current script. Check them against
553
555
  "postPrebuildSteps": ["grep -q 'gradle-8.14.3-bin.zip' android/gradle/wrapper/gradle-wrapper.properties"] }
554
556
  ```
555
557
 
558
+ ```jsonc
559
+ // v-store (repo root is the app; VERSION_NAME may be omitted)
560
+ { "packageId": "com.projectvdotuk.vstore", "apkPrefix": "v-store",
561
+ "appDir": ".", "prebuildNoInstall": false,
562
+ "syncAppVersion": true, "versionNameFromAppJson": true,
563
+ "publicEnv": ["EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY"],
564
+ "optionalEnv": ["EXPO_PUBLIC_CONVEX_URL"],
565
+ "unsetEnv": ["EXPO_PUBLIC_LOCAL_APK_BASE", "APP_VARIANT"],
566
+ "summary": { "label": "Convex", "envVar": "EXPO_PUBLIC_CONVEX_URL" },
567
+ "gradleWrapperPin": { "ifContains": "gradle-9", "distributionUrl": "https://services.gradle.org/distributions/gradle-8.14.3-bin.zip" } }
568
+ ```
569
+
570
+ ### Gradle settings
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`.
573
+
574
+ ### Version pick
575
+
576
+ `pickAndroidReleaseVersion` (exported) holds the versionName, versionCode and tag rules of `release-android-apk.yml`; its tests own the algorithm. The workflow lists tags once, takes published versionNames from the tag suffixes and downloads `release.json` only for the highest semver tag, instead of every release. `versionCode` is `max(highest published + 1, version_code_floor)`, so it assumes the highest semver tag carries the highest versionCode.
577
+
556
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`).
557
579
 
558
- Pure helpers (`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`, `parseBadging`, `releaseJson`, `formatReleaseJson`, `formatGithubOutput`, `apkFileName`, `parseAndroidReleaseConfig`) are exported from the root and unit-tested. The full Android build was not exercised on Windows.
559
581
 
560
582
  ## Versions
561
583
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // `vvedantb-android-release`: build a signed, sideloadable Android release APK
3
- // (arm64-v8a + x86_64, embedded JS) with Gradle, then write release.json next to
3
+ // (arm64-v8a, embedded JS) with Gradle, then write release.json next to
4
4
  // it. No EAS. One bin for every app; per-app differences come from a JSON config:
5
5
  //
6
6
  // VERSION_NAME=1.0.1 VERSION_CODE=1000 \
@@ -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, parseAndroidReleaseConfig, parseBadging, publicEnvDefault, releaseJson, validateVersionCode, validateVersionName, } from "./android-release.js";
20
+ import { apkFileName, easProfileEntries, formatGithubOutput, formatReleaseJson, gradlePropertiesEdits, 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);
@@ -108,10 +108,27 @@ catch (error) {
108
108
  }
109
109
  const appDir = join(root, config.appDir);
110
110
  const env = { ...process.env };
111
- const versionName = validateVersionName(env.VERSION_NAME);
111
+ // VERSION_NAME is required, unless the config reads expo.version from app.json.
112
+ let rawVersionName = env.VERSION_NAME;
113
+ if ((rawVersionName === undefined || rawVersionName === "") && config.versionNameFromAppJson) {
114
+ const appJsonFile = join(appDir, "app.json");
115
+ rawVersionName = existsSync(appJsonFile) ? readExpoVersion(readFileSync(appJsonFile, "utf8")) : undefined;
116
+ }
117
+ const versionName = validateVersionName(rawVersionName);
112
118
  const versionCode = validateVersionCode(env.VERSION_CODE);
113
119
  env.VERSION_NAME = versionName;
114
120
  env.VERSION_CODE = String(versionCode);
121
+ // Keep app.json and the root package.json on the released version (v-store).
122
+ if (config.syncAppVersion) {
123
+ const appJsonFile = join(appDir, "app.json");
124
+ if (existsSync(appJsonFile)) {
125
+ writeFileSync(appJsonFile, syncExpoVersion(readFileSync(appJsonFile, "utf8"), versionName));
126
+ }
127
+ const packageJsonFile = join(root, "package.json");
128
+ if (existsSync(packageJsonFile)) {
129
+ writeFileSync(packageJsonFile, syncPackageJsonVersion(readFileSync(packageJsonFile, "utf8"), versionName));
130
+ }
131
+ }
115
132
  // Bake the production runtime config into the APK. Each value comes from the
116
133
  // environment, else a baked-in default named in the config. A release never
117
134
  // ships without them.
@@ -188,8 +205,9 @@ for (const step of config.postPrebuildSteps) {
188
205
  const appGradle = join(appDir, "android", "app", "build.gradle");
189
206
  const appGradleText = existsSync(appGradle) ? readFileSync(appGradle, "utf8") : "";
190
207
  const versionCodeOk = new RegExp(`^[\\t ]*versionCode ${versionCode}[\\t ]*$`, "m").test(appGradleText);
191
- if (!versionCodeOk || !appGradleText.includes("withReleaseSigning")) {
192
- fail("android/ is stale (versionCode or signing). Run again without SKIP_PREBUILD=1.");
208
+ const versionNameOk = gradleVersionNameOk(appGradleText, versionName);
209
+ if (!versionCodeOk || !versionNameOk || !appGradleText.includes("withReleaseSigning")) {
210
+ fail("android/ is stale (versionCode, versionName or signing). Run again without SKIP_PREBUILD=1.");
193
211
  }
194
212
  // Optionally pin the Gradle wrapper (one app ships an incompatible default).
195
213
  if (config.gradleWrapperPin !== undefined) {
@@ -0,0 +1,59 @@
1
+ /** Where the versionName floor comes from. */
2
+ export type VersionNameSource = "default_version_name" | "app_json";
3
+ /** What the workflow knows about the published releases for a tag prefix. */
4
+ export interface PublishedReleases {
5
+ /** Tags from `gh release list` that start with the tag prefix. */
6
+ tags: readonly string[];
7
+ /**
8
+ * versionCode from the release.json of the highest semver tag. `undefined`
9
+ * means that release has no release.json (a release from before this
10
+ * workflow), which counts as versionCode 1.
11
+ */
12
+ highestVersionCode?: number | undefined;
13
+ }
14
+ /** Inputs to {@link pickAndroidReleaseVersion}. */
15
+ export interface PickAndroidReleaseVersionInput {
16
+ /** Tag prefix, such as `"eva-v"`. */
17
+ tagPrefix: string;
18
+ /** `version_code_floor` input, such as `"1000"`. */
19
+ versionCodeFloor: string;
20
+ /** `version_name_source` input. */
21
+ versionNameSource: VersionNameSource;
22
+ /**
23
+ * The versionName floor: the `DEFAULT_VERSION_NAME` literal from
24
+ * app.config.ts (`default_version_name`) or `expo.version` from app.json
25
+ * (`app_json`). `undefined` when app.json has none.
26
+ */
27
+ appVersion?: string | undefined;
28
+ /** `version` input, empty or absent when not set. */
29
+ inputVersion?: string | undefined;
30
+ /** `version_code` input, empty or absent when not set. */
31
+ inputVersionCode?: string | undefined;
32
+ /** The pushed tag (`GITHUB_REF_NAME`) on a tag push, else absent. */
33
+ tagPush?: string | undefined;
34
+ /** Published releases for the tag prefix. */
35
+ published: PublishedReleases;
36
+ }
37
+ /** The decision. */
38
+ export interface AndroidReleaseVersion {
39
+ versionName: string;
40
+ versionCode: number;
41
+ /** The tag to release: the pushed tag, else `<tagPrefix><versionName>`. */
42
+ tag: string;
43
+ /** The tag with the highest published semver versionName, or `""`. */
44
+ previousTag: string;
45
+ }
46
+ /** True when `value` is `X.Y.Z`. */
47
+ export declare function isSemver(value: string): boolean;
48
+ /** Compares two `X.Y.Z` versions numerically. */
49
+ export declare function compareSemver(a: string, b: string): number;
50
+ /** The semver versionNames in `<tagPrefix><semver>` tags. Other tags are ignored. */
51
+ export declare function publishedVersionNames(tagPrefix: string, tags: readonly string[]): string[];
52
+ /** The highest of `names`, or `undefined` when empty. */
53
+ export declare function highestSemver(names: readonly string[]): string | undefined;
54
+ /**
55
+ * Chooses versionName, versionCode, tag and previous tag. Pure: the workflow's
56
+ * `gh` checks that the release and tag do not exist stay in the workflow.
57
+ * Throws with the workflow's error messages.
58
+ */
59
+ export declare function pickAndroidReleaseVersion(input: PickAndroidReleaseVersionInput): AndroidReleaseVersion;
@@ -0,0 +1,139 @@
1
+ // Version pick for the shared Android APK release workflow
2
+ // (.github/workflows/release-android-apk.yml). This module owns the algorithm and
3
+ // its tests. The workflow's "Choose versionName, versionCode and tag" step
4
+ // gathers the same inputs with one `gh release list` and one release.json
5
+ // download, and implements the same rules in bash. Change both together.
6
+ //
7
+ // The workflow does not read every release.json. Published versionNames come
8
+ // from tag suffixes (`<tagPrefix><semver>`). Only the highest semver tag needs
9
+ // its release.json, because the highest versionName carries the highest
10
+ // versionCode under the normal monotonic scheme.
11
+ const SEMVER_RE = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/;
12
+ const WHOLE_NUMBER_RE = /^[1-9][0-9]*$/;
13
+ const VERSION_CODE_FLOOR_RE = /^[1-9][0-9]{0,9}$/;
14
+ /** True when `value` is `X.Y.Z`. */
15
+ export function isSemver(value) {
16
+ return SEMVER_RE.test(value);
17
+ }
18
+ /** Compares two `X.Y.Z` versions numerically. */
19
+ export function compareSemver(a, b) {
20
+ const pa = a.split(".").map(Number);
21
+ const pb = b.split(".").map(Number);
22
+ for (let i = 0; i < 3; i++) {
23
+ const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
24
+ if (diff !== 0)
25
+ return diff;
26
+ }
27
+ return 0;
28
+ }
29
+ /** The semver versionNames in `<tagPrefix><semver>` tags. Other tags are ignored. */
30
+ export function publishedVersionNames(tagPrefix, tags) {
31
+ const names = [];
32
+ for (const tag of tags) {
33
+ if (!tag.startsWith(tagPrefix))
34
+ continue;
35
+ const name = tag.slice(tagPrefix.length);
36
+ if (isSemver(name))
37
+ names.push(name);
38
+ }
39
+ return names;
40
+ }
41
+ /** The highest of `names`, or `undefined` when empty. */
42
+ export function highestSemver(names) {
43
+ let highest;
44
+ for (const name of names) {
45
+ if (highest === undefined || compareSemver(name, highest) > 0)
46
+ highest = name;
47
+ }
48
+ return highest;
49
+ }
50
+ function bumpPatch(version) {
51
+ const [major, minor, patch] = version.split(".").map(Number);
52
+ return `${major}.${minor}.${(patch ?? 0) + 1}`;
53
+ }
54
+ /**
55
+ * Chooses versionName, versionCode, tag and previous tag. Pure: the workflow's
56
+ * `gh` checks that the release and tag do not exist stay in the workflow.
57
+ * Throws with the workflow's error messages.
58
+ */
59
+ export function pickAndroidReleaseVersion(input) {
60
+ const { tagPrefix, versionNameSource } = input;
61
+ const inputVersion = input.inputVersion ?? "";
62
+ const inputVersionCode = input.inputVersionCode ?? "";
63
+ if (!VERSION_CODE_FLOOR_RE.test(input.versionCodeFloor)) {
64
+ throw new Error("version_code_floor must be a whole number from 1.");
65
+ }
66
+ const floor = Number(input.versionCodeFloor);
67
+ let tagVersion = "";
68
+ if (input.tagPush !== undefined && input.tagPush !== "") {
69
+ if (!input.tagPush.startsWith(tagPrefix)) {
70
+ throw new Error(`Tag ${input.tagPush} does not start with ${tagPrefix}, so V Store's catalog sync would never pick it up.`);
71
+ }
72
+ tagVersion = input.tagPush.slice(tagPrefix.length);
73
+ if (!isSemver(tagVersion)) {
74
+ throw new Error(`Tag ${input.tagPush} must be ${tagPrefix} followed by a versionName like 1.0.1.`);
75
+ }
76
+ }
77
+ const appVersion = input.appVersion ?? "";
78
+ if (versionNameSource === "default_version_name" && !isSemver(appVersion)) {
79
+ throw new Error("Could not read the DEFAULT_VERSION_NAME literal from app.config.ts.");
80
+ }
81
+ const names = publishedVersionNames(tagPrefix, input.published.tags);
82
+ const highestPublished = highestSemver(names);
83
+ const highestTag = highestPublished === undefined ? "" : `${tagPrefix}${highestPublished}`;
84
+ const highestCode = highestPublished === undefined ? 0 : (input.published.highestVersionCode ?? 1);
85
+ let versionName;
86
+ if (versionNameSource === "app_json") {
87
+ // The version input; else the tag's version; else the highest published
88
+ // versionName with the patch bumped, or expo.version if that is higher or
89
+ // nothing is published yet.
90
+ if (inputVersion !== "") {
91
+ versionName = inputVersion;
92
+ }
93
+ else if (tagVersion !== "") {
94
+ versionName = tagVersion;
95
+ }
96
+ else {
97
+ versionName = appVersion;
98
+ if (highestPublished !== undefined) {
99
+ const bumped = bumpPatch(highestPublished);
100
+ if (!isSemver(versionName) || compareSemver(bumped, versionName) > 0)
101
+ versionName = bumped;
102
+ }
103
+ }
104
+ if (!isSemver(versionName)) {
105
+ throw new Error("versionName must be X.Y.Z, for example 1.0.1. Check the version input, or expo.version in app.json.");
106
+ }
107
+ }
108
+ else if (inputVersion !== "") {
109
+ versionName = inputVersion;
110
+ if (!isSemver(versionName))
111
+ throw new Error("version must look like 1.0.1.");
112
+ }
113
+ else if (tagVersion !== "") {
114
+ versionName = tagVersion;
115
+ }
116
+ else {
117
+ versionName = bumpPatch(highestSemver([appVersion, ...names]) ?? appVersion);
118
+ }
119
+ if (tagVersion !== "" && versionName !== tagVersion) {
120
+ throw new Error(`The version input (${versionName}) does not match the tag ${input.tagPush ?? ""}.`);
121
+ }
122
+ if (versionNameSource === "app_json" && highestPublished !== undefined) {
123
+ if (names.includes(versionName)) {
124
+ throw new Error(`versionName ${versionName} is already published in ${tagPrefix}${versionName}.`);
125
+ }
126
+ if (compareSemver(versionName, highestPublished) <= 0) {
127
+ throw new Error(`versionName ${versionName} must be higher than ${highestPublished}, the highest published release.json.`);
128
+ }
129
+ }
130
+ // Sideload versionCodes start at the floor. The version_code input can only
131
+ // raise that minimum.
132
+ const minCode = Math.max(highestCode + 1, floor);
133
+ const codeText = inputVersionCode === "" ? String(minCode) : inputVersionCode;
134
+ if (!WHOLE_NUMBER_RE.test(codeText) || Number(codeText) < minCode) {
135
+ throw new Error(`version_code '${codeText}' must be a whole number of at least ${minCode} (above ${highestCode}, the highest published release.json, and at least version_code_floor ${floor}).`);
136
+ }
137
+ const tag = tagVersion !== "" ? (input.tagPush ?? "") : `${tagPrefix}${versionName}`;
138
+ return { versionName, versionCode: Number(codeText), tag, previousTag: highestTag };
139
+ }
@@ -97,6 +97,14 @@ export interface AndroidReleaseConfig {
97
97
  publicEnvSources: readonly PublicEnvSource[];
98
98
  /** `pnpm install --filter` values, such as `["@vmem/mobile...", "{.}"]`. */
99
99
  pnpmFilters: readonly string[];
100
+ /**
101
+ * After versionName resolves, write it to `<appDir>/app.json` (`expo.version`)
102
+ * and the root `package.json` (`version`) when those files exist, before
103
+ * prebuild. Default `false`.
104
+ */
105
+ syncAppVersion: boolean;
106
+ /** Read `expo.version` from `<appDir>/app.json` when `VERSION_NAME` is unset. Default `false`. */
107
+ versionNameFromAppJson: boolean;
100
108
  /** Pass `--no-install` to `expo prebuild` (vibot installs during prebuild). */
101
109
  prebuildNoInstall: boolean;
102
110
  /** Extra environment set for the whole build, such as `{ APP_VARIANT: "production" }`. */
@@ -130,3 +138,11 @@ export interface AndroidReleaseConfig {
130
138
  export declare function parseAndroidReleaseConfig(input: unknown): AndroidReleaseConfig;
131
139
  /** The published APK file name for a version, such as `vmem-1.0.1-android.apk`. */
132
140
  export declare function apkFileName(apkPrefix: string, versionName: string): string;
141
+ /** `expo.version` from app.json contents, or `undefined` when absent or not a string. */
142
+ export declare function readExpoVersion(appJsonContents: string): string | undefined;
143
+ /** app.json contents with `expo.version` set. Throws when there is no `expo` object. */
144
+ export declare function syncExpoVersion(appJsonContents: string, versionName: string): string;
145
+ /** package.json contents with `version` set. */
146
+ export declare function syncPackageJsonVersion(packageJsonContents: string, versionName: string): string;
147
+ /** True when the generated `android/app/build.gradle` sets `versionName "<versionName>"`. */
148
+ export declare function gradleVersionNameOk(gradleText: string, versionName: string): boolean;
@@ -99,9 +99,14 @@ export function publicEnvDefault(name, options) {
99
99
  }
100
100
  /** The edits the release build makes to `gradle.properties`, in order. */
101
101
  export const DEFAULT_GRADLE_PROPERTY_EDITS = [
102
- { key: "reactNativeArchitectures", value: "arm64-v8a,x86_64", replace: true },
102
+ // arm64-v8a only: published APKs target phones. x86_64 is for emulators.
103
+ { key: "reactNativeArchitectures", value: "arm64-v8a", replace: true },
103
104
  { key: "org.gradle.jvmargs", value: "-Xmx4096m -XX:MaxMetaspaceSize=1024m", replace: true },
104
- { key: "org.gradle.workers.max", value: "2", replace: false },
105
+ // boat-large has 8 cores. Replace Expo's lower default.
106
+ { key: "org.gradle.workers.max", value: "8", replace: true },
107
+ { key: "org.gradle.parallel", value: "true", replace: true },
108
+ // org.gradle.configuration-cache stays off: ephemeral CI runners never reuse
109
+ // the cache, and native modules may still be incompatible on release tasks.
105
110
  { key: "android.lint.checkReleaseBuilds", value: "false", replace: false },
106
111
  ];
107
112
  function withTrailingNewline(contents) {
@@ -160,6 +165,8 @@ const DEFAULT_CONFIG = {
160
165
  publicEnvSources: [],
161
166
  pnpmFilters: ["{.}"],
162
167
  prebuildNoInstall: true,
168
+ syncAppVersion: false,
169
+ versionNameFromAppJson: false,
163
170
  extraEnv: {},
164
171
  unsetEnv: [],
165
172
  optionalEnv: [],
@@ -214,6 +221,13 @@ export function parseAndroidReleaseConfig(input) {
214
221
  }
215
222
  config.prebuildNoInstall = raw.prebuildNoInstall;
216
223
  }
224
+ for (const key of ["syncAppVersion", "versionNameFromAppJson"]) {
225
+ if (raw[key] === undefined)
226
+ continue;
227
+ if (typeof raw[key] !== "boolean")
228
+ throw new Error(`android-release config: "${key}" must be a boolean.`);
229
+ config[key] = raw[key];
230
+ }
217
231
  if (raw.extraEnv !== undefined)
218
232
  config.extraEnv = parseStringRecord(raw.extraEnv, "extraEnv");
219
233
  if (raw.unsetEnv !== undefined)
@@ -306,3 +320,37 @@ function parseSummary(input) {
306
320
  export function apkFileName(apkPrefix, versionName) {
307
321
  return `${apkPrefix}-${versionName}-android.apk`;
308
322
  }
323
+ /** `expo.version` from app.json contents, or `undefined` when absent or not a string. */
324
+ export function readExpoVersion(appJsonContents) {
325
+ const parsed = JSON.parse(appJsonContents);
326
+ if (typeof parsed !== "object" || parsed === null)
327
+ return undefined;
328
+ const expo = parsed.expo;
329
+ if (typeof expo !== "object" || expo === null)
330
+ return undefined;
331
+ const version = expo.version;
332
+ return typeof version === "string" && version !== "" ? version : undefined;
333
+ }
334
+ /** app.json contents with `expo.version` set. Throws when there is no `expo` object. */
335
+ export function syncExpoVersion(appJsonContents, versionName) {
336
+ const parsed = JSON.parse(appJsonContents);
337
+ const expo = typeof parsed === "object" && parsed !== null ? parsed.expo : undefined;
338
+ if (typeof expo !== "object" || expo === null) {
339
+ throw new Error('app.json has no "expo" object to set the version on.');
340
+ }
341
+ expo.version = versionName;
342
+ return JSON.stringify(parsed, null, 2) + "\n";
343
+ }
344
+ /** package.json contents with `version` set. */
345
+ export function syncPackageJsonVersion(packageJsonContents, versionName) {
346
+ const parsed = JSON.parse(packageJsonContents);
347
+ if (typeof parsed !== "object" || parsed === null) {
348
+ throw new Error("package.json is not a JSON object.");
349
+ }
350
+ parsed.version = versionName;
351
+ return JSON.stringify(parsed, null, 2) + "\n";
352
+ }
353
+ /** True when the generated `android/app/build.gradle` sets `versionName "<versionName>"`. */
354
+ export function gradleVersionNameOk(gradleText, versionName) {
355
+ return new RegExp(`^[\\t ]*versionName ["']${escapeRegExp(versionName)}["'][\\t ]*$`, "m").test(gradleText);
356
+ }
package/dist/doctor.d.ts CHANGED
@@ -62,8 +62,15 @@ export declare function isOlderMinor(range: string, running: string): boolean;
62
62
  export declare function checkConfigVersion(repo: RepoModel, runningVersion: string): CheckResult;
63
63
  export declare function checkCiReusableWorkflow(repo: RepoModel): CheckResult;
64
64
  /**
65
- * Fails on a job that names the small `boat` runner, as `runs-on: boat` or as the `runs_on: boat`
66
- * input of a reusable workflow. GitHub-hosted labels and `boat-large` pass.
65
+ * Checks the Boat runner policy on every `runs-on` line and every `runs_on` input of a reusable
66
+ * workflow.
67
+ *
68
+ * - `boat-small`, `boat` and `boat-xlarge` pass.
69
+ * - GitHub-hosted labels (any label not starting `boat`) and expressions (`${{ ... }}`) pass.
70
+ * - `boat-large` passes as the `runs_on` input of a job that calls `release-android-apk.yml` or
71
+ * `release-gallery-android.yml`, and on any job in a workflow file whose name contains `android`.
72
+ * It fails elsewhere, including on a job that calls the shared `ci-app.yml`.
73
+ * - An unknown `boat*` label (for example `boat-medium`) fails.
67
74
  */
68
75
  export declare function checkCiRunner(repo: RepoModel): CheckResult;
69
76
  /** The lines of every `commands: |` block in the workflows that call the shared ci-app.yml. */
package/dist/doctor.js CHANGED
@@ -341,29 +341,93 @@ function workflowFiles(root) {
341
341
  }
342
342
  return files;
343
343
  }
344
- /** The plain `boat` runner label. Every boat.dev job runs on `boat-large` (8 cores, 15 GB). */
345
- const SMALL_RUNNER = "boat";
344
+ const BOAT_LABELS = ["boat-small", "boat", "boat-large", "boat-xlarge"];
345
+ const BOAT_GUIDANCE = "check jobs use boat; boat-large is for Android release builds";
346
+ const ANDROID_RELEASE_WORKFLOW = /(?:^|\/)(?:release-android-apk|release-gallery-android)\.ya?ml(?:@|$)/;
347
+ const CI_APP_WORKFLOW = /(?:^|\/)ci-app\.ya?ml(?:@|$)/;
346
348
  /**
347
- * Fails on a job that names the small `boat` runner, as `runs-on: boat` or as the `runs_on: boat`
348
- * input of a reusable workflow. GitHub-hosted labels and `boat-large` pass.
349
+ * Scans a workflow for runner lines and for each job's own `uses:` value (the reusable workflow
350
+ * it calls). Jobs are the keys one level under `jobs:`. A `uses:` counts only at the job's own
351
+ * level, so a step's `uses: actions/checkout` is ignored.
349
352
  */
350
- export function checkCiRunner(repo) {
351
- const details = [];
352
- for (const file of workflowFiles(repo.root)) {
353
- file.text.split(/\r?\n/).forEach((line, index) => {
354
- const match = line.match(/^\s*(?:-\s+)?(runs[-_]on)\s*:\s*(.+?)\s*(?:#.*)?$/);
355
- if (!match?.[1] || match[2] === undefined)
353
+ function scanRunners(text) {
354
+ const runners = [];
355
+ const jobUses = [];
356
+ let inJobs = false;
357
+ let jobIndent = -1;
358
+ let childIndent = -1;
359
+ let job = -1;
360
+ text.split(/\r?\n/).forEach((line, index) => {
361
+ if (line.trim() === "" || line.trim().startsWith("#"))
362
+ return;
363
+ const indent = line.length - line.trimStart().length;
364
+ if (indent === 0)
365
+ inJobs = /^jobs\s*:/.test(line);
366
+ if (inJobs && indent > 0) {
367
+ if (jobIndent < 0)
368
+ jobIndent = indent;
369
+ if (indent === jobIndent && /^\s*[\w.-]+\s*:/.test(line)) {
370
+ job = jobUses.length;
371
+ jobUses.push(undefined);
372
+ childIndent = -1;
356
373
  return;
357
- const labels = match[2]
374
+ }
375
+ if (job >= 0 && childIndent < 0 && indent > jobIndent)
376
+ childIndent = indent;
377
+ const uses = line.match(/^\s*uses\s*:\s*(.+?)\s*(?:#.*)?$/);
378
+ if (uses?.[1] && job >= 0 && indent === childIndent)
379
+ jobUses[job] = stripQuotes(uses[1]);
380
+ }
381
+ const match = line.match(/^\s*(?:-\s+)?(runs[-_]on)\s*:\s*(.+?)\s*(?:#.*)?$/);
382
+ if (!match?.[1] || match[2] === undefined)
383
+ return;
384
+ const labels = match[2].includes("${{")
385
+ ? [match[2]]
386
+ : match[2]
358
387
  .replace(/^\[|\]$/g, "")
359
388
  .split(",")
360
389
  .map((label) => stripQuotes(label));
361
- if (labels.includes(SMALL_RUNNER)) {
362
- details.push(`.github/workflows/${file.name}:${index + 1} ${match[1]} is ${SMALL_RUNNER}; use boat-large`);
390
+ runners.push({ line: index + 1, key: match[1], labels, job: inJobs ? job : -1 });
391
+ });
392
+ return { runners, jobUses };
393
+ }
394
+ /**
395
+ * Checks the Boat runner policy on every `runs-on` line and every `runs_on` input of a reusable
396
+ * workflow.
397
+ *
398
+ * - `boat-small`, `boat` and `boat-xlarge` pass.
399
+ * - GitHub-hosted labels (any label not starting `boat`) and expressions (`${{ ... }}`) pass.
400
+ * - `boat-large` passes as the `runs_on` input of a job that calls `release-android-apk.yml` or
401
+ * `release-gallery-android.yml`, and on any job in a workflow file whose name contains `android`.
402
+ * It fails elsewhere, including on a job that calls the shared `ci-app.yml`.
403
+ * - An unknown `boat*` label (for example `boat-medium`) fails.
404
+ */
405
+ export function checkCiRunner(repo) {
406
+ const details = [];
407
+ for (const file of workflowFiles(repo.root)) {
408
+ const { runners, jobUses } = scanRunners(file.text);
409
+ const androidFile = /android/i.test(file.name);
410
+ for (const runner of runners) {
411
+ const uses = runner.job >= 0 ? jobUses[runner.job] : undefined;
412
+ const where = `.github/workflows/${file.name}:${runner.line} ${runner.key}`;
413
+ for (const label of runner.labels) {
414
+ if (label.includes("${{") || !label.startsWith("boat"))
415
+ continue;
416
+ if (label === "boat-large") {
417
+ if (androidFile)
418
+ continue;
419
+ if (runner.key === "runs_on" && uses !== undefined && ANDROID_RELEASE_WORKFLOW.test(uses))
420
+ continue;
421
+ const caller = uses !== undefined && CI_APP_WORKFLOW.test(uses) ? " on a ci-app.yml job" : "";
422
+ details.push(`${where} is boat-large${caller}; ${BOAT_GUIDANCE}`);
423
+ }
424
+ else if (!BOAT_LABELS.includes(label)) {
425
+ details.push(`${where} is ${label}, an unknown boat label; valid labels are ${BOAT_LABELS.join(", ")}`);
426
+ }
363
427
  }
364
- });
428
+ }
365
429
  }
366
- return result("ci-runner", "No job runs on the small boat runner", details);
430
+ return result("ci-runner", "Jobs use valid Boat runners and boat-large only for Android release builds", details);
367
431
  }
368
432
  /** The lines of every `commands: |` block in the workflows that call the shared ci-app.yml. */
369
433
  export function ciCommands(repo) {
package/dist/index.d.ts CHANGED
@@ -10,4 +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, releaseJson, validateVersionCode, validateVersionName, type AndroidReleaseConfig, type BadgingFields, type GradlePropertyEdit, type PublicEnvSource, type ReadAppFile, type ReleaseJson, } from "./android-release.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";
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,4 +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, releaseJson, validateVersionCode, validateVersionName, } from "./android-release.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";
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.11.0",
3
+ "version": "0.13.0",
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",