@vvedantb/config 0.10.1 → 0.12.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.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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.
8
+
9
+ - 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.
10
+ - `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.
11
+ - 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`.
12
+ - The bin now also checks `versionName` in `android/app/build.gradle` after prebuild, not only `versionCode`.
13
+
14
+ ## 0.11.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [#300](https://github.com/vvedantb/packages/pull/300) [`45a64a3`](https://github.com/vvedantb/packages/commit/45a64a3ff5140e29218302865b2fdbaeac0e5cb3) Thanks [@vvedantb](https://github.com/vvedantb)! - The oxlint base now loads the 9 rules of `eslint-plugin-react-you-might-not-need-an-effect` 1.0.2 as the `no-effect` JS plugin and sets them to `error`. A repo that extends `oxlint/base.json` gets the rules with no change of its own. The plugin is bundled into `@vvedantb/config/oxlint/no-effect.mjs`, so the package adds no dependency and no app installs ESLint. A repo that does not extend the base can name that file as its `jsPlugins` specifier.
19
+
3
20
  ## 0.10.1
4
21
 
5
22
  ### Patch Changes
package/README.md CHANGED
@@ -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/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";
@@ -0,0 +1,37 @@
1
+ Licences for the code bundled in no-effect.mjs
2
+
3
+ == eslint-plugin-react-you-might-not-need-an-effect 1.0.2 ==
4
+
5
+ MIT License
6
+
7
+ Copyright (c) 2025 Nick van Dyke
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the “Software”), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+ == globals 16.5.0 ==
28
+
29
+ MIT License
30
+
31
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
34
+
35
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/oxlint/base.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json",
3
3
  "plugins": ["typescript", "import", "unicorn", "react"],
4
+ "jsPlugins": [{ "name": "no-effect", "specifier": "./no-effect.mjs" }],
4
5
  "categories": {
5
6
  "suspicious": "error"
6
7
  },
@@ -25,6 +26,15 @@
25
26
  "import/no-cycle": "error",
26
27
  "react/rules-of-hooks": "error",
27
28
  "react/exhaustive-deps": "error",
29
+ "no-effect/no-derived-state": "error",
30
+ "no-effect/no-chain-state-updates": "error",
31
+ "no-effect/no-event-handler": "error",
32
+ "no-effect/no-adjust-state-on-prop-change": "error",
33
+ "no-effect/no-reset-all-state-on-prop-change": "error",
34
+ "no-effect/no-pass-live-state-to-parent": "error",
35
+ "no-effect/no-pass-data-to-parent": "error",
36
+ "no-effect/no-external-store-subscription": "error",
37
+ "no-effect/no-initialize-state": "error",
28
38
  "no-console": ["error", { "allow": ["warn", "error", "info"] }],
29
39
  "no-unused-vars": [
30
40
  "error",
@@ -0,0 +1,2 @@
1
+ declare const plugin: { rules: Record<string, object> };
2
+ export default plugin;