create-expo-updates-server 0.1.6 → 0.2.1

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.
Files changed (143) hide show
  1. package/dist/template/.dockerignore +16 -0
  2. package/dist/template/Dockerfile +5 -0
  3. package/dist/template/README.md +51 -660
  4. package/dist/template/app/api/admin/device-targets/route.test.ts +43 -0
  5. package/dist/template/app/api/admin/device-targets/route.ts +91 -0
  6. package/dist/template/app/api/admin/devices/route.test.ts +41 -0
  7. package/dist/template/app/api/admin/devices/route.ts +15 -0
  8. package/dist/template/app/api/admin/updates/[encodedKey]/audience/route.ts +75 -0
  9. package/dist/template/app/api/device-heartbeat/route.ts +2 -0
  10. package/dist/template/app/globals.css +114 -15
  11. package/dist/template/app/layout.tsx +12 -4
  12. package/dist/template/app/login/page.tsx +22 -18
  13. package/dist/template/app/updates/[encodedKey]/page.tsx +112 -88
  14. package/dist/template/app/updates/devices/page.tsx +264 -0
  15. package/dist/template/app/updates/embedded/page.tsx +102 -68
  16. package/dist/template/app/updates/emergency-redirects/page.tsx +144 -111
  17. package/dist/template/app/updates/layout.tsx +6 -1
  18. package/dist/template/app/updates/page.tsx +262 -212
  19. package/dist/template/components/admin/admin-shell.tsx +196 -0
  20. package/dist/template/components/admin/language-switcher.tsx +25 -0
  21. package/dist/template/components/admin/theme-provider.tsx +15 -0
  22. package/dist/template/components/ui/alert.tsx +65 -0
  23. package/dist/template/components/ui/badge.tsx +47 -0
  24. package/dist/template/components/ui/button.tsx +63 -0
  25. package/dist/template/components/ui/card.tsx +91 -0
  26. package/dist/template/components/ui/chart.tsx +373 -0
  27. package/dist/template/components/ui/checkbox.tsx +31 -0
  28. package/dist/template/components/ui/dialog.tsx +158 -0
  29. package/dist/template/components/ui/dropdown-menu.tsx +256 -0
  30. package/dist/template/components/ui/input.tsx +20 -0
  31. package/dist/template/components/ui/label.tsx +23 -0
  32. package/dist/template/components/ui/native-select.tsx +61 -0
  33. package/dist/template/components/ui/popover.tsx +88 -0
  34. package/dist/template/components/ui/scroll-area.tsx +57 -0
  35. package/dist/template/components/ui/select.tsx +189 -0
  36. package/dist/template/components/ui/separator.tsx +27 -0
  37. package/dist/template/components/ui/sheet.tsx +142 -0
  38. package/dist/template/components/ui/sidebar.tsx +736 -0
  39. package/dist/template/components/ui/skeleton.tsx +13 -0
  40. package/dist/template/components/ui/switch.tsx +34 -0
  41. package/dist/template/components/ui/table.tsx +115 -0
  42. package/dist/template/components/ui/tabs.tsx +90 -0
  43. package/dist/template/components/ui/textarea.tsx +17 -0
  44. package/dist/template/components/ui/tooltip.tsx +56 -0
  45. package/dist/template/components.json +22 -0
  46. package/dist/template/docker/minio.Dockerfile +11 -0
  47. package/dist/template/docker-compose.yml +7 -9
  48. package/dist/template/docs/admin-ui.md +35 -0
  49. package/dist/template/docs/device-targeting.md +129 -0
  50. package/dist/template/docs/doctor.md +137 -0
  51. package/dist/template/docs/expo-app-setup.md +174 -47
  52. package/dist/template/docs/getting-started.md +109 -146
  53. package/dist/template/docs/getting-started.ru.md +110 -193
  54. package/dist/template/docs/index.md +14 -33
  55. package/dist/template/docs/installation-telemetry.md +233 -0
  56. package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +89 -0
  57. package/dist/template/docs/migrations/2026-10-19-device-heartbeat.sql +131 -0
  58. package/dist/template/docs/migrations/2026-10-22-device-analytics.sql +264 -0
  59. package/dist/template/docs/migrations/2026-10-22-device-targeting-activation.sql +108 -0
  60. package/dist/template/docs/migrations/2026-10-22-device-targeting.sql +130 -0
  61. package/dist/template/docs/migrations/2026-10-22-device-version-metadata.sql +154 -0
  62. package/dist/template/docs/migrations/schema.sql +868 -6
  63. package/dist/template/docs/npm-installer.md +15 -30
  64. package/dist/template/docs/operations-guide.md +87 -0
  65. package/dist/template/docs/ota-client-lifecycle.md +263 -0
  66. package/dist/template/docs/ota-update-policy.md +36 -2
  67. package/dist/template/docs/supabase-setup.md +4 -0
  68. package/dist/template/hooks/use-mobile.ts +21 -0
  69. package/dist/template/lib/utils.ts +6 -0
  70. package/dist/template/package-lock.json +2325 -101
  71. package/dist/template/package.json +13 -3
  72. package/dist/template/scripts/configure-expo-app.mjs +11 -15
  73. package/dist/template/scripts/doctor.mjs +51 -0
  74. package/dist/template/scripts/ensure-storage-bucket.mjs +25 -0
  75. package/dist/template/scripts/ensure-test-bucket.mjs +21 -0
  76. package/dist/template/scripts/lib/device-identity.test.ts +29 -0
  77. package/dist/template/scripts/lib/doctor-probes.mjs +139 -0
  78. package/dist/template/scripts/lib/doctor.mjs +208 -0
  79. package/dist/template/scripts/lib/doctor.test.mjs +262 -0
  80. package/dist/template/scripts/lib/expo-app-configurator.mjs +14 -9
  81. package/dist/template/scripts/lib/expo-app-configurator.test.ts +3 -2
  82. package/dist/template/scripts/lib/ota-client-configurator.mjs +69 -0
  83. package/dist/template/scripts/lib/ota-client-configurator.test.ts +88 -0
  84. package/dist/template/scripts/lib/ota-client.test.ts +55 -0
  85. package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +173 -0
  86. package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +123 -0
  87. package/dist/template/scripts/lib/ota-update-controller.test.ts +231 -0
  88. package/dist/template/scripts/tests/device-analytics-migrations.mjs +80 -0
  89. package/dist/template/scripts/tests/device-analytics.mjs +126 -0
  90. package/dist/template/scripts/tests/device-heartbeat.mjs +86 -0
  91. package/dist/template/scripts/tests/device-targeting-activation.mjs +111 -0
  92. package/dist/template/scripts/tests/device-targeting.mjs +39 -0
  93. package/dist/template/scripts/tests/device-version-metadata.mjs +31 -0
  94. package/dist/template/scripts/tests/manifest-identity-concurrency.mjs +106 -0
  95. package/dist/template/scripts/tests/manifest-identity.sql +204 -0
  96. package/dist/template/src/client/admin-types.ts +1 -0
  97. package/dist/template/src/client/devices/analytics.tsx +429 -0
  98. package/dist/template/src/client/devices/device-name.tsx +82 -0
  99. package/dist/template/src/client/devices/registry.tsx +399 -0
  100. package/dist/template/src/client/devices/use-devices-report.ts +108 -0
  101. package/dist/template/src/client/devices/version-adoption-chart.tsx +269 -0
  102. package/dist/template/src/client/devices/version-groups.test.ts +57 -0
  103. package/dist/template/src/client/devices/version-groups.ts +101 -0
  104. package/dist/template/src/client/distribution-control.tsx +135 -81
  105. package/dist/template/src/client/guard-action-combobox.tsx +13 -24
  106. package/dist/template/src/client/i18n/en.json +286 -0
  107. package/dist/template/src/client/i18n/messages.test.ts +42 -0
  108. package/dist/template/src/client/i18n/messages.ts +31 -0
  109. package/dist/template/src/client/i18n/provider.tsx +55 -0
  110. package/dist/template/src/client/i18n/use-formatters.ts +38 -0
  111. package/dist/template/src/client/logout-button.tsx +3 -1
  112. package/dist/template/src/client/update-audience-editor.tsx +285 -0
  113. package/dist/template/src/client/update-policy-editor.tsx +53 -41
  114. package/dist/template/src/server/controllers/manifest.test.ts +250 -7
  115. package/dist/template/src/server/controllers/manifest.ts +39 -31
  116. package/dist/template/src/server/devices/audience.test.ts +48 -0
  117. package/dist/template/src/server/devices/audience.ts +86 -0
  118. package/dist/template/src/server/devices/heartbeat.test.ts +39 -0
  119. package/dist/template/src/server/devices/heartbeat.ts +75 -0
  120. package/dist/template/src/server/devices/report-types.ts +114 -0
  121. package/dist/template/src/server/devices/report.test.ts +29 -0
  122. package/dist/template/src/server/devices/report.ts +27 -0
  123. package/dist/template/src/server/lib/admin-audience-activation.test.ts +94 -0
  124. package/dist/template/src/server/lib/admin-updates.ts +32 -168
  125. package/dist/template/src/server/lib/supabase.js +10 -10
  126. package/dist/template/src/server/lib/supabase.test.ts +11 -0
  127. package/dist/template/src/server/manifest/manifest-identity.test.ts +30 -0
  128. package/dist/template/src/server/manifest/manifest-identity.ts +24 -0
  129. package/dist/template/src/server/manifest/manifest-repository.ts +31 -102
  130. package/dist/template/src/server/manifest/manifest-response.ts +1 -1
  131. package/dist/template/templates/expo-app/ota-client/README.md +59 -0
  132. package/dist/template/templates/expo-app/ota-client/controller.js +60 -0
  133. package/dist/template/templates/expo-app/ota-client/device-identity.js +26 -0
  134. package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +52 -0
  135. package/dist/template/templates/expo-app/ota-client/index.d.ts +47 -0
  136. package/dist/template/templates/expo-app/ota-client/index.js +3 -0
  137. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.js +48 -0
  138. package/dist/template/templates/expo-app/ota-client/model/update-controller.js +182 -0
  139. package/dist/template/templates/expo-app/ota-client/runtime.js +112 -0
  140. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.js +56 -0
  141. package/dist/template-manifest.json +592 -77
  142. package/lib/cli.mjs +4 -6
  143. package/package.json +1 -1
@@ -0,0 +1,137 @@
1
+ # Diagnose setup with doctor
2
+
3
+ Run `doctor` from the **server directory**. It checks the server and optionally an
4
+ Expo app without changing files, starting containers, applying migrations, uploading
5
+ assets or activating updates. Node.js 24 is recommended; the env parser requires
6
+ Node.js 20.12+. Certificate usage checks also need the OpenSSL executable.
7
+
8
+ ```bash
9
+ npm ci
10
+ npm run doctor -- --app ../my-expo-app
11
+ ```
12
+
13
+ The default is **Docker mode**, with `.env` and `docker-compose.yml`. The `app`
14
+ service must be running. Database, bucket and signing-key probes execute inside
15
+ that container as its normal user, so they test actual container access rather
16
+ than the host's permission to read a bind-mounted key.
17
+
18
+ To check only server files before startup:
19
+
20
+ ```bash
21
+ npm run doctor -- --offline --certificate ./local-certificates/code-signing-certificate.pem
22
+ ```
23
+
24
+ Offline Docker checks use the standard template's env mapping and host key location
25
+ `secrets/code-signing-private-key.pem`. They do not evaluate custom Compose overrides
26
+ or prove that the container can read the key.
27
+
28
+ ## Remote or npm deployment
29
+
30
+ Choose remote mode explicitly. It reads **only** the selected env file, without
31
+ merging shell credentials or loading another `.env.local` implicitly:
32
+
33
+ ```bash
34
+ npm run doctor -- \
35
+ --mode remote \
36
+ --server-env ./server.env \
37
+ --app ../my-expo-app
38
+ ```
39
+
40
+ This mode supports PostgreSQL/S3 and Supabase configurations. Run it where the env
41
+ file, private key, database and storage are accessible. Relative private-key paths
42
+ resolve from the server directory. No SSH connection or remote filesystem access
43
+ is inferred from a hostname. Env variable interpolation is not evaluated in remote
44
+ mode; use explicit values. PostgreSQL URLs must include user/password and database;
45
+ only `sslmode` is supported in URL query parameters. The default port is explicitly
46
+ 5432, so ambient `PG*` credentials/ports cannot silently select another connection.
47
+
48
+ ## Custom Docker project
49
+
50
+ Pass the same project and Compose files used to start the stack, in the same order:
51
+
52
+ ```bash
53
+ npm run doctor -- \
54
+ --server-env .env.ota-test \
55
+ --project ota-test \
56
+ --compose-file docker-compose.yml \
57
+ --compose-file docker-compose.ota-test.yml \
58
+ --app ../rn-app-ota-test
59
+ ```
60
+
61
+ `--compose-file` is repeatable. These example test files belong to a local test
62
+ stand; use your own files for a generated project. Docker connection/context
63
+ settings are forwarded, but arbitrary shell application env overrides are not.
64
+ The online probe reads the running app's environment and reports a public URL
65
+ mismatch with the selected env file.
66
+
67
+ ## What is checked
68
+
69
+ | Area | Checks |
70
+ | --- | --- |
71
+ | Runtime | Node env parser and server dependencies |
72
+ | Environment | Explicit env file, placeholder values, Docker escaping caveats |
73
+ | Signing | Readable RSA key, at least 2048 bits, current non-CA public certificate, Digital Signature / Code Signing usage, matching public keys |
74
+ | Server URL | Valid public URL, host access to `/api/health`, loopback/HTTP caveat |
75
+ | PostgreSQL | Connection, read access to core OTA/telemetry/targeting columns, required table/function signatures and enabled audience-activation trigger |
76
+ | Supabase | Read access to core REST tables/columns and storage bucket; SQL function bodies are not inspected |
77
+ | Storage | Existing accessible bucket via S3 HEAD or Supabase bucket GET; no writes |
78
+ | Expo app | Static config, installed client dependencies, implementation files, URL/channel/runtime, native check mode, identity namespace and telemetry URL |
79
+ | Root | Recognized root hook/gate wiring and generated bootstrap metadata; custom roots need manual verification |
80
+ | Publisher/registrar | Presence and basic shape of `.env.ota` credentials, publisher command, channel and registration URL consistency |
81
+
82
+ Without `--app`, app checks are skipped. Without an app certificate or an explicit
83
+ `--certificate`, key-pair comparison is skipped. An explicit certificate takes
84
+ precedence over the app's certificate and produces a warning if it is a different
85
+ file. Doctor never evaluates `app.config.*`; those projects report the current
86
+ static-config limitation.
87
+
88
+ Each check reports `pass`, `fail`, `warn` or `skip`, plus an actionable remedy where
89
+ needed. Raw exceptions, credentials, private keys and connection strings are not
90
+ included in the output.
91
+
92
+ ## CI and timeouts
93
+
94
+ ```bash
95
+ npm run --silent doctor -- --mode remote --server-env ./server.env --json
96
+ ```
97
+
98
+ Use `--silent` so npm's command banner does not precede the JSON document.
99
+ Output has a versioned shape:
100
+
101
+ ```json
102
+ {
103
+ "version": 1,
104
+ "mode": "remote",
105
+ "offline": false,
106
+ "status": "fail",
107
+ "checks": [
108
+ {
109
+ "id": "signing.key",
110
+ "status": "fail",
111
+ "message": "Signing key is missing, unreadable or invalid.",
112
+ "remedy": "Check the signing key configuration and read permissions."
113
+ }
114
+ ]
115
+ }
116
+ ```
117
+
118
+ Exit codes: `0` means no detected blockers (warnings/skips may remain), `1` means
119
+ failed checks, and `2` means invalid arguments or an unexpected diagnostic failure.
120
+ Use `--timeout 10000` to allow 10 seconds per network operation; supported values
121
+ are 500–30000 ms. Several probes run sequentially, so the total duration can exceed
122
+ one timeout. Docker execution also has an overall bound.
123
+
124
+ ## What a pass does not prove
125
+
126
+ Doctor does not validate native SDK toolchains, execute builds, compare every
127
+ migration definition or exercise write permissions. A token's presence does not
128
+ prove its scope. App credentials may differ from server credentials; publisher and
129
+ registrar authorization still need the real build/publish flow. Container settings
130
+ other than the public URL are checked as currently running, not compared exhaustively
131
+ with pending Compose changes.
132
+
133
+ The host reaching a URL does not prove that a phone can reach it. Source configuration
134
+ also cannot prove which URL/runtime/certificate is installed in a native binary.
135
+ After fixing configuration, follow the [Quick Start](./getting-started.md) or
136
+ [fresh app verification](./expo-app-setup.md#verify-generation-in-a-fresh-application)
137
+ for the final build → install → publish → activate → download → restart check.
@@ -6,9 +6,11 @@ receiving and publishing updates.
6
6
  ## Automatic configuration
7
7
 
8
8
  Applications using a static `app.json` can be configured from the OTA server
9
- repository:
9
+ repository. Install the server dependencies on the host first, including when
10
+ the server itself runs in Docker:
10
11
 
11
12
  ```bash
13
+ npm ci
12
14
  npm run configure-app
13
15
  ```
14
16
 
@@ -27,26 +29,145 @@ npm run configure-app -- \
27
29
  ```
28
30
 
29
31
  The command patches `app.json` and `package.json`, copies the public
30
- certificate, installs `expo-updates`, adds the portable publisher and runs
32
+ certificate, installs `expo-updates` and the identity/telemetry dependencies, adds the portable publisher and runs
31
33
  `expo prebuild`. It supports npm, pnpm, Yarn and Bun lockfiles.
32
34
 
35
+ It also generates `ota-client/` and starts identity/installation telemetry from
36
+ `ota-entry.js`, preserving the original application entry. For Expo Router,
37
+ the configurator inserts `useOtaUpdates` into `src/app/_layout` (or `app/_layout`)
38
+ and wraps the root's rendered content with `OtaUpdateGate`. Standard `App`
39
+ entry components are supported too, including platform variants. No manual
40
+ Installation ID, Device ID, or heartbeat wiring is needed. The initial hook
41
+ options are `{ autoCheck: true, autoUpdate: false, autoReload: false }`;
42
+ customized options are preserved on later configurations. See the generated
43
+ [OTA client lifecycle](./ota-client-lifecycle.md) for update modes and the hook API.
44
+ If generation is unavailable, follow [manual hook integration](./ota-client-lifecycle.md#manual-integration).
45
+
46
+ The source patch uses syntax-tree locations and keeps existing imports, comments,
47
+ directives, component code and nested callbacks. Unsupported root exports
48
+ (such as a class, asynchronous function, HOC or re-export) stop configuration
49
+ before any application writes. Export a synchronous root function or a local
50
+ function identifier to make the patch possible. A custom entry whose root
51
+ cannot be identified keeps its existing startup behavior and prints a warning
52
+ that update orchestration still needs integration in its root component;
53
+ identity and telemetry remain connected through the generated bootstrap.
54
+ An existing `useOtaUpdates` import must use a relative path to `ota-client`.
55
+ Unresolved aliases such as `@/ota-client` stop the patch before writing, so a
56
+ second hook cannot silently override an existing automation configuration.
57
+
33
58
  Options:
34
59
 
35
60
  ```text
36
61
  --platform all|ios|android
37
62
  --force
63
+ --server-env /full/path/to/server.env
38
64
  ```
39
65
 
40
66
  The CLI intentionally refuses dynamic `app.config.*` projects and refuses to
41
67
  replace generated files unless `--force` is provided. The sections below
42
- document the equivalent manual configuration.
68
+ document native configuration; [manual hook integration](./ota-client-lifecycle.md#manual-integration)
69
+ covers client files, dependencies, root wiring and controls. `--force` permits generated
70
+ file replacement; it does not bypass unsupported dynamic configs or root shapes.
71
+ `--server-env` selects the local server environment used to prepare publisher settings.
72
+ For an isolated test stand, explicitly pass its `.env.ota-test`.
73
+
74
+ ## Verify generation in a fresh application
75
+
76
+ Use a separate app to check first-time generation, and retain an existing app to
77
+ check upgrades/reruns. Do not reuse another app's runtime just to make a test OTA
78
+ appear: the new app has its own native compatibility boundary.
79
+
80
+ Create a sibling Expo Router application using the SDK 58 template used for this
81
+ client's integration checks:
82
+
83
+ ```bash
84
+ npx create-expo-app@latest ota-smoke-app --template default@sdk-58
85
+ ```
86
+
87
+ The explicit template pins the SDK family; see the official
88
+ [create-expo-app reference](https://docs.expo.dev/more/create-expo/). For another SDK,
89
+ use its compatible packages and repeat the release-device checks below.
90
+
91
+ Prepare a reachable HTTPS OTA server and its matching public signing certificate.
92
+ Then run from the **server repository**, adjusting the application/certificate paths:
93
+
94
+ ```bash
95
+ npm run configure-app -- \
96
+ --app /full/path/to/ota-smoke-app \
97
+ --certificate /full/path/code-signing-certificate.pem \
98
+ --server-url https://updates.example.com \
99
+ --channel hook-smoke \
100
+ --runtime-version hook-smoke-sdk58-v1 \
101
+ --platform android
102
+ ```
103
+
104
+ For the isolated local stand, add `--server-env .env.ota-test` and use the public
105
+ tunnel URL for `--server-url`. Configure the same public base on the server so
106
+ asset downloads also work from the phone. Use a distinct Android package/iOS bundle
107
+ identifier when installing this app alongside an existing test app.
108
+
109
+ Inspect the resulting diff before building:
43
110
 
44
- ## 1. Install Expo Updates
111
+ | File/change | Expected result |
112
+ | --- | --- |
113
+ | `app.json` | Correct HTTPS URL, certificate, runtime, channel; native automatic checks disabled |
114
+ | `package.json` | Client dependencies, `main: "ota-entry.js"`, publisher and selected platform build scripts |
115
+ | `ota-client-entry.json` | Original application entry retained |
116
+ | `ota-client/` | Public API, nested model/UI files and public `config.json` |
117
+ | Root `_layout` / `App` | One unconditional hook and a gate; existing navigation/providers retained |
118
+ | `.env.ota` | Local publisher/build credentials; ignored by Git, never imported by app code |
45
119
 
46
- Install the Expo-compatible version of `expo-updates`:
120
+ Before building, add the
121
+ [manual controls example](./ota-client-lifecycle.md#_3-add-manual-update-controls)
122
+ to a test screen, or explicitly enable download/reload automation through the hook
123
+ options. The default root only checks; a stock Expo template has no OTA test buttons.
124
+ These controls/options must be in the binary you install so it can receive the first OTA.
125
+
126
+ From the **application directory**, run:
47
127
 
48
128
  ```bash
49
- npx expo install expo-updates
129
+ npx expo lint
130
+ npx tsc --noEmit
131
+ npm run ota:build:android:apk
132
+ ```
133
+
134
+ The Android command requires a working local Java/Android toolchain. Before running
135
+ it, configure embedded registration in `.env.ota`: local Docker can use the generated
136
+ `OTA_DATABASE_URL`; HTTP registration requires `OTA_SERVER_URL` and an
137
+ `OTA_ACCESS_TOKEN` with `updates:write`. The generated script treats registration
138
+ failure as a build failure. See [embedded registration](#_6-register-embedded-updates).
139
+ For iOS, configure with `--platform ios`/`all` and build a signed Release/Archive.
140
+
141
+ Install the release APK from `android/app/build/outputs/apk/release/app-release.apk`.
142
+ After its first launch, verify the installation in `/updates/devices`.
143
+
144
+ Make a visible JS change and update `expo.version` for a distinct chart label,
145
+ keeping the compatible runtime unchanged. Publish **after the native build**:
146
+
147
+ ```bash
148
+ npm run ota:publish -- --platform android --message "Fresh app hook smoke test"
149
+ ```
150
+
151
+ The release appears inactive in `/updates`. Select the intended device audience,
152
+ activate it, then check/download/restart. A check or download alone must not move
153
+ the installation to the new running version in analytics; the next launch heartbeat
154
+ should. Confirm the Installation ID stays unchanged across the OTA restart.
155
+
156
+ Finally, rerun the same configurator command. Check that it does not duplicate the
157
+ hook/gate or replace the stored original entry. Change a hook option in the root
158
+ and rerun to verify that the option survives. Use `--force` only when intentionally
159
+ replacing changed generated files; it does not bypass unsupported root shapes.
160
+ For the manual fallback test, use a separate clean copy and follow
161
+ [manual integration](./ota-client-lifecycle.md#manual-integration) without running
162
+ the generator. Keep these as separate checks so generated leftovers cannot hide
163
+ missing manual setup steps.
164
+
165
+ ## 1. Install client dependencies
166
+
167
+ For manual setup, install Expo-compatible versions of all client dependencies:
168
+
169
+ ```bash
170
+ npx expo install expo-updates expo-application expo-crypto expo-secure-store @react-native-async-storage/async-storage
50
171
  ```
51
172
 
52
173
  The application does not send an admin access token when checking for an
@@ -112,8 +233,10 @@ an unknown key.
112
233
 
113
234
  ## 3. Configure the Expo application
114
235
 
115
- Use a dynamic Expo config so the channel cannot accidentally remain
116
- `development` in a production binary.
236
+ The automatic path updates static `app.json`. For manual setup, the dynamic config
237
+ below requires an explicit channel and runtime for each build. The current configurator
238
+ and stock publisher read static `app.json`; they do not evaluate dynamic config.
239
+ Do not use the stock publisher with conflicting static and resolved dynamic values.
117
240
 
118
241
  Example `app.config.ts`:
119
242
 
@@ -187,8 +310,10 @@ Each native binary requests an update using three selection keys:
187
310
  runtimeVersion + channel + platform
188
311
  ```
189
312
 
190
- The server looks up only the latest active update inside that exact scope.
191
- Updates do not cross runtime versions, channels, or platforms.
313
+ Within that scope, the server applies activation/rollback rules and the device
314
+ audience before selecting an eligible update. Ordinary delivery does not cross
315
+ runtime versions, channels or platforms; explicit emergency redirects are a separate
316
+ [recovery mechanism](./ota-emergency-recovery.md).
192
317
 
193
318
  ```mermaid
194
319
  flowchart TD
@@ -327,32 +452,28 @@ expected URL, runtime, channel and certificate.
327
452
 
328
453
  ## 5. Check and install updates in the application
329
454
 
330
- With `checkAutomatically: "NEVER"`, the application controls the user
331
- experience:
332
-
333
- ```ts
334
- import * as Updates from "expo-updates";
455
+ Use the generated `useOtaUpdates` controller with `OtaUpdateGate` in the root
456
+ layout. `configure-app` inserts this integration automatically. If the files or root
457
+ patch are missing, follow [manual integration](./ota-client-lifecycle.md#manual-integration),
458
+ including the complete Router example and manual controls.
335
459
 
336
- export async function checkForOtaUpdate() {
337
- if (__DEV__) {
338
- return { available: false };
339
- }
340
-
341
- const result = await Updates.checkForUpdateAsync();
342
- return { available: result.isAvailable };
343
- }
344
-
345
- export async function installOtaUpdate() {
346
- const result = await Updates.fetchUpdateAsync();
347
-
348
- if (!result.isNew) {
349
- return;
350
- }
460
+ The root defaults to automatic checks and manual download/restart:
351
461
 
352
- await Updates.reloadAsync();
353
- }
462
+ ```tsx
463
+ const ota = useOtaUpdates({
464
+ autoCheck: true,
465
+ autoUpdate: false,
466
+ autoReload: false,
467
+ });
354
468
  ```
355
469
 
470
+ Screens use `useOtaUpdates()` and its `check()`, `download()` and `reload()` methods.
471
+ Identity setup, telemetry and update policies share one controller. Do not replace
472
+ these actions with direct `Updates.checkForUpdateAsync()`/`fetchUpdateAsync()` calls:
473
+ those bypass hook orchestration. Keep native `checkAutomatically: "NEVER"`.
474
+ See [the lifecycle reference](./ota-client-lifecycle.md) for force/store/background
475
+ behavior, errors and custom guard handlers.
476
+
356
477
  Expo Updates automatically sends the runtime headers used by the server,
357
478
  including:
358
479
 
@@ -390,13 +511,18 @@ to the trimmed string `expo.version` from the project's static `app.json`.
390
511
  Missing, blank, malformed or unreadable fallback configuration leaves
391
512
  `app_version` null without blocking an otherwise valid registration.
392
513
 
393
- The MIEX application contains a reference implementation:
514
+ The configurator installs the implementation from `templates/expo-app/`:
394
515
 
395
516
  ```text
396
- scripts/build-update/register-embedded-update.mjs
397
- android/ci_scripts/register_embedded_update_android.sh
517
+ scripts/ota-register-embedded/register-android.sh
518
+ scripts/ota-register-embedded/register-ios.sh
519
+ plugins/with-ota-embedded-registration.js
398
520
  ```
399
521
 
522
+ If configuring entirely by hand, integrate these registrar scripts with your build
523
+ pipeline and configure their server URL/access token; copying the client hook alone
524
+ does not register native builds.
525
+
400
526
  Registration should be a required CI step for production builds. If it fails,
401
527
  the binary should not be distributed.
402
528
 
@@ -419,32 +545,33 @@ A publisher performs these steps:
419
545
  8. Leave the update inactive when manual activation is required.
420
546
  9. Activate or roll back from the admin panel after validation.
421
547
 
422
- The MIEX application already implements this workflow under:
548
+ The configurator installs the portable publisher under `scripts/ota-publish/`
549
+ and adds `ota:publish` to the application's `package.json`. It uses static `app.json`
550
+ for runtime/channel metadata. Configure the application's ignored `.env.ota` using
551
+ `.env.ota.example`; local Docker values can be prepared with `--server-env`.
423
552
 
424
- ```text
425
- scripts/build-update/
553
+ Run from the **application** directory:
554
+
555
+ ```bash
556
+ npm run ota:publish -- --platform android --message "Fix checkout validation"
426
557
  ```
427
558
 
428
- Its relevant environment is:
559
+ Use `--platform ios` or `--platform all` as needed. This command exports and uploads
560
+ the OTA and creates an inactive release in the admin panel; activation is separate.
561
+ Do not use EAS Update to publish to this self-hosted server.
562
+
563
+ Required publisher settings include:
429
564
 
430
565
  ```env
431
566
  EXPO_UPDATE_CHANNEL=production
432
567
  OTA_DATABASE_URL=postgresql://...
433
568
  OTA_DATABASE_SSL=true
434
- OTA_SYNC_UPDATES_DB=true
435
-
436
569
  R2_ENDPOINT=https://...
437
570
  R2_ACCESS_KEY_ID=...
438
571
  R2_SECRET_ACCESS_KEY=...
439
572
  R2_BUCKET=expo-updates
440
573
  ```
441
574
 
442
- Example publish command in that application:
443
-
444
- ```bash
445
- npm run local-update:production -- -m "Fix checkout validation"
446
- ```
447
-
448
575
  The application's configured channel, exported runtime, uploaded storage path
449
576
  and database records must all use the same values. Publishing JavaScript for a
450
577
  different `runtimeVersion` is safe but the binary will not select it.