create-expo-updates-server 0.2.0 → 0.3.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/dist/template/Dockerfile +5 -0
- package/dist/template/docker/minio.Dockerfile +11 -0
- package/dist/template/docker-compose.yml +7 -9
- package/dist/template/docs/expo-app-setup.md +8 -12
- package/dist/template/docs/getting-started.md +9 -5
- package/dist/template/docs/getting-started.ru.md +9 -7
- package/dist/template/docs/ota-client-lifecycle.md +46 -42
- package/dist/template/package-lock.json +589 -0
- package/dist/template/package.json +1 -0
- package/dist/template/scripts/ensure-storage-bucket.mjs +25 -0
- package/dist/template/scripts/lib/device-identity.test.ts +2 -2
- package/dist/template/scripts/lib/doctor.mjs +3 -3
- package/dist/template/scripts/lib/doctor.test.mjs +1 -1
- package/dist/template/scripts/lib/ota-client-configurator.mjs +116 -34
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +210 -61
- package/dist/template/scripts/lib/ota-client.test.ts +1 -1
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +435 -118
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +243 -86
- package/dist/template/scripts/lib/ota-update-controller.test.ts +10 -9
- package/dist/template/scripts/lib/ota-updates-ui.test.tsx +154 -0
- package/dist/template/scripts/tests/fixtures/react-native-ui.tsx +34 -0
- package/dist/template/scripts/tests/ota-client-types.mjs +69 -0
- package/dist/template/templates/expo-app/ota-client/README.md +16 -2
- package/dist/template/templates/expo-app/ota-client/controller.ts +107 -0
- package/dist/template/templates/expo-app/ota-client/device-identity.ts +48 -0
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +18 -9
- package/dist/template/templates/expo-app/ota-client/index.ts +16 -0
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +97 -0
- package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +293 -0
- package/dist/template/templates/expo-app/ota-client/runtime.ts +153 -0
- package/dist/template/templates/expo-app/ota-client/types.ts +85 -0
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +25 -0
- package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +196 -0
- package/dist/template/tsconfig.json +3 -1
- package/dist/template/vitest.config.mts +3 -0
- package/dist/template-manifest.json +99 -69
- package/package.json +1 -1
- package/dist/template/templates/expo-app/ota-client/controller.js +0 -60
- package/dist/template/templates/expo-app/ota-client/device-identity.js +0 -26
- package/dist/template/templates/expo-app/ota-client/index.d.ts +0 -47
- package/dist/template/templates/expo-app/ota-client/index.js +0 -3
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.js +0 -48
- package/dist/template/templates/expo-app/ota-client/model/update-controller.js +0 -182
- package/dist/template/templates/expo-app/ota-client/runtime.js +0 -112
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.js +0 -56
package/dist/template/Dockerfile
CHANGED
|
@@ -10,6 +10,11 @@ WORKDIR /app
|
|
|
10
10
|
COPY package.json package-lock.json ./
|
|
11
11
|
RUN npm ci --omit=dev
|
|
12
12
|
|
|
13
|
+
FROM production-dependencies AS storage-init
|
|
14
|
+
COPY scripts/ensure-storage-bucket.mjs ./scripts/ensure-storage-bucket.mjs
|
|
15
|
+
USER node
|
|
16
|
+
ENTRYPOINT ["node", "/app/scripts/ensure-storage-bucket.mjs"]
|
|
17
|
+
|
|
13
18
|
FROM node:24-alpine AS builder
|
|
14
19
|
|
|
15
20
|
WORKDIR /app
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Community images are no longer published on Docker Hub. Build a pinned release.
|
|
2
|
+
FROM golang:1.24.8-alpine AS builder
|
|
3
|
+
RUN apk add --no-cache git ca-certificates
|
|
4
|
+
ENV CGO_ENABLED=0 GOMAXPROCS=2
|
|
5
|
+
RUN go install -p 2 github.com/minio/minio@RELEASE.2025-10-15T17-29-55Z \
|
|
6
|
+
&& go clean -cache -modcache
|
|
7
|
+
|
|
8
|
+
FROM alpine:3.22
|
|
9
|
+
RUN apk add --no-cache ca-certificates curl
|
|
10
|
+
COPY --from=builder /go/bin/minio /usr/local/bin/minio
|
|
11
|
+
ENTRYPOINT ["minio"]
|
|
@@ -22,7 +22,9 @@ services:
|
|
|
22
22
|
retries: 20
|
|
23
23
|
|
|
24
24
|
minio:
|
|
25
|
-
|
|
25
|
+
build:
|
|
26
|
+
context: .
|
|
27
|
+
dockerfile: docker/minio.Dockerfile
|
|
26
28
|
restart: unless-stopped
|
|
27
29
|
command: server /data --console-address ":9001"
|
|
28
30
|
environment:
|
|
@@ -40,17 +42,13 @@ services:
|
|
|
40
42
|
retries: 20
|
|
41
43
|
|
|
42
44
|
minio-init:
|
|
43
|
-
|
|
45
|
+
build:
|
|
46
|
+
context: .
|
|
47
|
+
dockerfile: Dockerfile
|
|
48
|
+
target: storage-init
|
|
44
49
|
depends_on:
|
|
45
50
|
minio:
|
|
46
51
|
condition: service_healthy
|
|
47
|
-
entrypoint:
|
|
48
|
-
- /bin/sh
|
|
49
|
-
- -c
|
|
50
|
-
- >
|
|
51
|
-
mc alias set local http://minio:9000
|
|
52
|
-
"$${MINIO_ROOT_USER}" "$${MINIO_ROOT_PASSWORD}" &&
|
|
53
|
-
mc mb --ignore-existing "local/$${OTA_STORAGE_BUCKET}"
|
|
54
52
|
environment:
|
|
55
53
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-expo_updates}
|
|
56
54
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-expo_updates_local}
|
|
@@ -34,11 +34,11 @@ certificate, installs `expo-updates` and the identity/telemetry dependencies, ad
|
|
|
34
34
|
|
|
35
35
|
It also generates `ota-client/` and starts identity/installation telemetry from
|
|
36
36
|
`ota-entry.js`, preserving the original application entry. For Expo Router,
|
|
37
|
-
the configurator
|
|
38
|
-
|
|
37
|
+
the configurator renders `<OtaUpdates />` beside navigation in `src/app/_layout`
|
|
38
|
+
(or `app/_layout`). The generated TypeScript component owns the hook internally;
|
|
39
|
+
it does not wrap the application or require context. Standard `App`
|
|
39
40
|
entry components are supported too, including platform variants. No manual
|
|
40
|
-
Installation ID, Device ID, or heartbeat wiring is needed. The
|
|
41
|
-
options are `{ autoCheck: true, autoUpdate: false, autoReload: false }`;
|
|
41
|
+
Installation ID, Device ID, or heartbeat wiring is needed. The component starts with automatic checks and manual download/restart prompts;
|
|
42
42
|
customized options are preserved on later configurations. See the generated
|
|
43
43
|
[OTA client lifecycle](./ota-client-lifecycle.md) for update modes and the hook API.
|
|
44
44
|
If generation is unavailable, follow [manual hook integration](./ota-client-lifecycle.md#manual-integration).
|
|
@@ -154,7 +154,7 @@ the installation to the new running version in analytics; the next launch heartb
|
|
|
154
154
|
should. Confirm the Installation ID stays unchanged across the OTA restart.
|
|
155
155
|
|
|
156
156
|
Finally, rerun the same configurator command. Check that it does not duplicate the
|
|
157
|
-
|
|
157
|
+
OTA component or replace the stored original entry. Change a component prop in the root
|
|
158
158
|
and rerun to verify that the option survives. Use `--force` only when intentionally
|
|
159
159
|
replacing changed generated files; it does not bypass unsupported root shapes.
|
|
160
160
|
For the manual fallback test, use a separate clean copy and follow
|
|
@@ -452,7 +452,7 @@ expected URL, runtime, channel and certificate.
|
|
|
452
452
|
|
|
453
453
|
## 5. Check and install updates in the application
|
|
454
454
|
|
|
455
|
-
|
|
455
|
+
Render the generated `<OtaUpdates />` component beside navigation in the root
|
|
456
456
|
layout. `configure-app` inserts this integration automatically. If the files or root
|
|
457
457
|
patch are missing, follow [manual integration](./ota-client-lifecycle.md#manual-integration),
|
|
458
458
|
including the complete Router example and manual controls.
|
|
@@ -460,14 +460,10 @@ including the complete Router example and manual controls.
|
|
|
460
460
|
The root defaults to automatic checks and manual download/restart:
|
|
461
461
|
|
|
462
462
|
```tsx
|
|
463
|
-
|
|
464
|
-
autoCheck: true,
|
|
465
|
-
autoUpdate: false,
|
|
466
|
-
autoReload: false,
|
|
467
|
-
});
|
|
463
|
+
<OtaUpdates autoCheck autoUpdate={false} autoReload={false} />
|
|
468
464
|
```
|
|
469
465
|
|
|
470
|
-
|
|
466
|
+
Optional custom screens can use `useOtaUpdates()` and its `check()`, `download()` and `reload()` methods.
|
|
471
467
|
Identity setup, telemetry and update policies share one controller. Do not replace
|
|
472
468
|
these actions with direct `Updates.checkForUpdateAsync()`/`fetchUpdateAsync()` calls:
|
|
473
469
|
those bypass hook orchestration. Keep native `checkAutomatically: "NEVER"`.
|
|
@@ -125,6 +125,10 @@ docker compose up -d --build
|
|
|
125
125
|
docker compose ps
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
+
The first build compiles a pinned MinIO release from source and may take several
|
|
129
|
+
minutes. Go runs inside Docker; no host installation is needed. Subsequent starts
|
|
130
|
+
reuse the built image. Bucket creation is automatic; no `minio/mc` image is needed.
|
|
131
|
+
|
|
128
132
|
Wait until `postgres`, `minio` and `app` are `healthy`. `/api/health` currently
|
|
129
133
|
checks the database only. Verify that the app can also read a valid signing key:
|
|
130
134
|
|
|
@@ -347,7 +351,7 @@ npm run configure-app
|
|
|
347
351
|
|
|
348
352
|
Select the app directory, certificate, public URL, channel, runtime and platform.
|
|
349
353
|
The CLI installs dependencies, configures native updates, generates the identity
|
|
350
|
-
and telemetry client, inserts the root
|
|
354
|
+
and telemetry client, inserts the standalone root component, installs publisher/registration
|
|
351
355
|
scripts and runs prebuild. Review its summary before applying changes.
|
|
352
356
|
|
|
353
357
|
For flags, supported root components and reruns, see
|
|
@@ -380,10 +384,10 @@ a server running directly with npm. See [embedded registration](./expo-app-setup
|
|
|
380
384
|
|
|
381
385
|
Before building, choose how the app will download and apply updates.
|
|
382
386
|
|
|
383
|
-
The generated
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
+
The generated `<OtaUpdates />` component checks automatically and offers download,
|
|
388
|
+
restart and Later actions. To download ordinary updates automatically, set
|
|
389
|
+
`autoUpdate` on the component; use `autoReload` only if automatic restarts suit the app.
|
|
390
|
+
Custom screen controls are optional. See [hook options](./ota-client-lifecycle.md).
|
|
387
391
|
|
|
388
392
|
From the **application directory**, with the Android toolchain installed:
|
|
389
393
|
|
|
@@ -142,8 +142,10 @@ chmod 600 secrets/code-signing-private-key.pem
|
|
|
142
142
|
docker compose up -d --build
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
Первый запуск может занять несколько минут. Docker скачивает PostgreSQL,
|
|
146
|
-
и собирает OTA-сервер.
|
|
145
|
+
Первый запуск может занять несколько минут. Docker скачивает PostgreSQL,
|
|
146
|
+
компилирует закреплённую версию MinIO из исходников и собирает OTA-сервер.
|
|
147
|
+
Устанавливать Go на компьютер не нужно. Следующие запуски используют собранный
|
|
148
|
+
образ. Bucket создаётся автоматически, образ `minio/mc` больше не нужен.
|
|
147
149
|
|
|
148
150
|
Проверьте состояние:
|
|
149
151
|
|
|
@@ -456,12 +458,12 @@ credentials; административный access token их не замен
|
|
|
456
458
|
|
|
457
459
|
До сборки выберите, как приложение будет скачивать и применять обновления.
|
|
458
460
|
|
|
459
|
-
Созданный
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
Созданный `<OtaUpdates />` проверяет обновления автоматически и показывает кнопки
|
|
462
|
+
скачивания, перезапуска и откладывания. Для автоматического скачивания включите
|
|
463
|
+
`autoUpdate`, для автоматического перезапуска — `autoReload`. Дополнительные кнопки
|
|
464
|
+
в экранах приложения не обязательны. См. [режимы обновления](./ota-client-lifecycle.md).
|
|
463
465
|
|
|
464
|
-
Из **папки
|
|
466
|
+
Из **папки приложения** с установленным Android toolchain:
|
|
465
467
|
|
|
466
468
|
```bash
|
|
467
469
|
npm run ota:build:android:apk
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
# Generated OTA client lifecycle
|
|
2
2
|
|
|
3
|
-
`configure-app`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
`configure-app` generates a formatted TypeScript client and renders `<OtaUpdates />`
|
|
4
|
+
beside navigation in the root layout/App. The component calls `useOtaUpdates`
|
|
5
|
+
internally; it does not wrap the app or provide React context. Mount it once in a
|
|
6
|
+
persistent root, including loading/early-return paths.
|
|
7
|
+
|
|
8
|
+
By default it checks automatically and shows **Download / Later** for an ordinary
|
|
9
|
+
update, then **Restart / Later** when downloaded. `autoUpdate={false}` disables
|
|
10
|
+
automatic downloading, not the prompt. A dismissed candidate stays hidden until the
|
|
11
|
+
component remounts, a different candidate arrives, or its download state changes.
|
|
12
|
+
Background updates remain silent; required updates cannot be dismissed.
|
|
13
|
+
|
|
14
|
+
The lower-level `useOtaUpdates()` is still available for optional custom screens.
|
|
15
|
+
It shares state/actions but defaults to no automation and renders no UI. Configure
|
|
16
|
+
automation in one root; multiple configured consumers combine booleans with OR.
|
|
17
|
+
Keep custom guard handlers stable.
|
|
9
18
|
|
|
10
19
|
Identity is persisted and installed in Expo request parameters before any check/download.
|
|
11
20
|
Launch/foreground heartbeats report only the **running** bundle, never a downloaded
|
|
@@ -14,7 +23,7 @@ Expo Go, web and disabled-updates builds leave automation off.
|
|
|
14
23
|
|
|
15
24
|
| Policy/options | Behavior |
|
|
16
25
|
| --- | --- |
|
|
17
|
-
| manual, default options |
|
|
26
|
+
| manual, default options | OtaUpdates offers download/restart; the hook alone exposes state |
|
|
18
27
|
| autoCheck | Check on mount and foreground, minimum interval 60 seconds |
|
|
19
28
|
| autoUpdate | Also download eligible manual candidates |
|
|
20
29
|
| autoReload | Reload a pending non-background bundle while app is active |
|
|
@@ -29,8 +38,8 @@ https, market and itms-apps URLs are accepted. Native upgrades still require a s
|
|
|
29
38
|
release; OTA cannot add native modules or change the installed runtime.
|
|
30
39
|
|
|
31
40
|
The built-in gate is a non-dismissable modal that preserves mounted navigation and providers.
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
Customize required UI with `renderBlocked`, and optional UI with `renderAvailable`.
|
|
42
|
+
Keep `OtaUpdates` mounted beside navigation; a hook alone exposes `blocked` but cannot prevent interaction with
|
|
34
43
|
your own screens. Unknown guards fail closed. Required checks are online policy,
|
|
35
44
|
not authentication or a tamper-proof access restriction. Offline check failure keeps
|
|
36
45
|
the running app usable unless a required candidate was already discovered or the running bundle requires a store/custom guard.
|
|
@@ -54,7 +63,7 @@ No database/admin credentials are shipped: the server persists public heartbeat
|
|
|
54
63
|
## Integration and customization
|
|
55
64
|
|
|
56
65
|
Use the stock `npm run configure-app -- ...` command from the server project. It
|
|
57
|
-
preserves the original app entry, generates the client and inserts the
|
|
66
|
+
preserves the original app entry, generates the client and inserts the standalone component in
|
|
58
67
|
supported root components. For Expo Router this is `src/app/_layout` (preferred when
|
|
59
68
|
`src/app` exists) or `app/_layout`, including platform variants. For the default entry
|
|
60
69
|
it is `App`, provided no custom `index` registers a different root. Synchronous function
|
|
@@ -64,13 +73,12 @@ automatic identity/telemetry setup and emits a warning to connect the lifecycle
|
|
|
64
73
|
The generated integration starts with:
|
|
65
74
|
|
|
66
75
|
```tsx
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return <OtaUpdateGate controller={ota}>{/* app content */}</OtaUpdateGate>;
|
|
76
|
+
return (
|
|
77
|
+
<>
|
|
78
|
+
<OtaUpdates autoCheck autoUpdate={false} autoReload={false} />
|
|
79
|
+
<AppTabs />
|
|
80
|
+
</>
|
|
81
|
+
);
|
|
74
82
|
```
|
|
75
83
|
|
|
76
84
|
Adjust these options in the root component. Use `useOtaUpdates()` in other screens for
|
|
@@ -78,8 +86,12 @@ manual controls and shared state. The configurator selects the appropriate impor
|
|
|
78
86
|
no database or admin credentials belong in the application. Generated source includes
|
|
79
87
|
`ota-client/docs/update-lifecycle.md` with this contract for application developers.
|
|
80
88
|
|
|
81
|
-
For an already configured project, review generated-file changes and rerun
|
|
82
|
-
`--force
|
|
89
|
+
For an already configured project, review generated-file changes and rerun with
|
|
90
|
+
`--force`. This replaces the legacy JavaScript files with TypeScript, removes stale
|
|
91
|
+
`.js`/`.d.ts` copies that could shadow the new modules, and migrates the stock root
|
|
92
|
+
hook/gate while preserving its options. Custom code that uses the old root controller
|
|
93
|
+
or a custom gate must be migrated manually; the preflight stops before any writes.
|
|
94
|
+
Use `.tsx` for TypeScript JSX roots. Existing `OtaUpdateGate` consumers remain supported. Native dependencies need a new binary;
|
|
83
95
|
use a new runtime when older installed binaries lack those modules. Publishing remains
|
|
84
96
|
the generated `npm run ota:publish` workflow. See [device targeting](./device-targeting.md)
|
|
85
97
|
for selecting a smoke-test audience and [installation telemetry](./installation-telemetry.md)
|
|
@@ -94,7 +106,7 @@ it from `expo-updates`.
|
|
|
94
106
|
|
|
95
107
|
### 1. Prepare the client and native configuration
|
|
96
108
|
|
|
97
|
-
If `ota-client/index.
|
|
109
|
+
If `ota-client/index.ts`, `ota-client/types.ts` and `ota-client/config.json` already
|
|
98
110
|
exist after configuration, keep them and continue with step 2. A warning about an
|
|
99
111
|
unidentified custom root means the bootstrap/client were installed; an unsupported
|
|
100
112
|
root error stops configuration before writes, so check which files actually exist.
|
|
@@ -138,25 +150,21 @@ A dynamic config must resolve the same channel used in `ota-client/config.json`.
|
|
|
138
150
|
|
|
139
151
|
### 2. Connect the root layout or App
|
|
140
152
|
|
|
141
|
-
For Expo Router,
|
|
142
|
-
|
|
143
|
-
|
|
153
|
+
For Expo Router, render the component beside navigation in the existing
|
|
154
|
+
`src/app/_layout.tsx`. Preserve your providers, fonts, splash-screen handling and
|
|
155
|
+
other layout code. Keep the component outside navigator-only child collections
|
|
156
|
+
such as `Stack.Screen`/`Tabs.Screen`.
|
|
144
157
|
|
|
145
158
|
```tsx
|
|
146
159
|
import { Stack } from 'expo-router';
|
|
147
|
-
import {
|
|
160
|
+
import { OtaUpdates } from '../../ota-client';
|
|
148
161
|
|
|
149
162
|
export default function RootLayout() {
|
|
150
|
-
const ota = useOtaUpdates({
|
|
151
|
-
autoCheck: true,
|
|
152
|
-
autoUpdate: false,
|
|
153
|
-
autoReload: false,
|
|
154
|
-
});
|
|
155
|
-
|
|
156
163
|
return (
|
|
157
|
-
|
|
164
|
+
<>
|
|
165
|
+
<OtaUpdates autoCheck autoUpdate={false} autoReload={false} />
|
|
158
166
|
<Stack />
|
|
159
|
-
|
|
167
|
+
</>
|
|
160
168
|
);
|
|
161
169
|
}
|
|
162
170
|
```
|
|
@@ -169,12 +177,9 @@ Adjust the relative import to the file location:
|
|
|
169
177
|
| `app/_layout.tsx` | `../ota-client` |
|
|
170
178
|
| `App.tsx` at the application root | `./ota-client` |
|
|
171
179
|
|
|
172
|
-
For a non-Router application,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
early returns, keep the gate on loading/early-return paths as well, and configure
|
|
176
|
-
automation in one persistent root. A custom entry
|
|
177
|
-
must still register that root using its existing registration mechanism.
|
|
180
|
+
For a non-Router application, render the same component beside the existing app
|
|
181
|
+
content. It can be a sibling of a class component too. Mount one instance, including
|
|
182
|
+
loading/early-return paths. A custom entry still registers the original root.
|
|
178
183
|
|
|
179
184
|
Keep an existing generated `ota-entry.js` and its `package.json.main` setting.
|
|
180
185
|
When integrating entirely by hand, changing the entry is **not required**: the
|
|
@@ -185,15 +190,14 @@ initialization. For an app that needs registration before its root mounts, the
|
|
|
185
190
|
public `start()` can also be called in its existing entry without replacing the
|
|
186
191
|
original registration code.
|
|
187
192
|
|
|
188
|
-
|
|
193
|
+
`OtaUpdates` supplies the default force-update UI. Using the hook without it
|
|
189
194
|
requires your own UI to enforce `blocked`. A custom gate view is supported through
|
|
190
195
|
`renderBlocked`; this does not change the controller's guard decision.
|
|
191
196
|
|
|
192
197
|
### 3. Add manual update controls
|
|
193
198
|
|
|
194
|
-
The root
|
|
195
|
-
|
|
196
|
-
another automatic workflow. For example, `src/components/ota-controls.tsx`:
|
|
199
|
+
The root already provides download/restart controls. A separate settings screen is
|
|
200
|
+
optional and can subscribe without enabling another automatic workflow. For example, `src/components/ota-controls.tsx`:
|
|
197
201
|
|
|
198
202
|
```tsx
|
|
199
203
|
import { useState } from 'react';
|