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.
- package/dist/template/.dockerignore +16 -0
- package/dist/template/Dockerfile +5 -0
- package/dist/template/README.md +51 -660
- package/dist/template/app/api/admin/device-targets/route.test.ts +43 -0
- package/dist/template/app/api/admin/device-targets/route.ts +91 -0
- package/dist/template/app/api/admin/devices/route.test.ts +41 -0
- package/dist/template/app/api/admin/devices/route.ts +15 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/audience/route.ts +75 -0
- package/dist/template/app/api/device-heartbeat/route.ts +2 -0
- package/dist/template/app/globals.css +114 -15
- package/dist/template/app/layout.tsx +12 -4
- package/dist/template/app/login/page.tsx +22 -18
- package/dist/template/app/updates/[encodedKey]/page.tsx +112 -88
- package/dist/template/app/updates/devices/page.tsx +264 -0
- package/dist/template/app/updates/embedded/page.tsx +102 -68
- package/dist/template/app/updates/emergency-redirects/page.tsx +144 -111
- package/dist/template/app/updates/layout.tsx +6 -1
- package/dist/template/app/updates/page.tsx +262 -212
- package/dist/template/components/admin/admin-shell.tsx +196 -0
- package/dist/template/components/admin/language-switcher.tsx +25 -0
- package/dist/template/components/admin/theme-provider.tsx +15 -0
- package/dist/template/components/ui/alert.tsx +65 -0
- package/dist/template/components/ui/badge.tsx +47 -0
- package/dist/template/components/ui/button.tsx +63 -0
- package/dist/template/components/ui/card.tsx +91 -0
- package/dist/template/components/ui/chart.tsx +373 -0
- package/dist/template/components/ui/checkbox.tsx +31 -0
- package/dist/template/components/ui/dialog.tsx +158 -0
- package/dist/template/components/ui/dropdown-menu.tsx +256 -0
- package/dist/template/components/ui/input.tsx +20 -0
- package/dist/template/components/ui/label.tsx +23 -0
- package/dist/template/components/ui/native-select.tsx +61 -0
- package/dist/template/components/ui/popover.tsx +88 -0
- package/dist/template/components/ui/scroll-area.tsx +57 -0
- package/dist/template/components/ui/select.tsx +189 -0
- package/dist/template/components/ui/separator.tsx +27 -0
- package/dist/template/components/ui/sheet.tsx +142 -0
- package/dist/template/components/ui/sidebar.tsx +736 -0
- package/dist/template/components/ui/skeleton.tsx +13 -0
- package/dist/template/components/ui/switch.tsx +34 -0
- package/dist/template/components/ui/table.tsx +115 -0
- package/dist/template/components/ui/tabs.tsx +90 -0
- package/dist/template/components/ui/textarea.tsx +17 -0
- package/dist/template/components/ui/tooltip.tsx +56 -0
- package/dist/template/components.json +22 -0
- package/dist/template/docker/minio.Dockerfile +11 -0
- package/dist/template/docker-compose.yml +7 -9
- package/dist/template/docs/admin-ui.md +35 -0
- package/dist/template/docs/device-targeting.md +129 -0
- package/dist/template/docs/doctor.md +137 -0
- package/dist/template/docs/expo-app-setup.md +174 -47
- package/dist/template/docs/getting-started.md +109 -146
- package/dist/template/docs/getting-started.ru.md +110 -193
- package/dist/template/docs/index.md +14 -33
- package/dist/template/docs/installation-telemetry.md +233 -0
- package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +89 -0
- package/dist/template/docs/migrations/2026-10-19-device-heartbeat.sql +131 -0
- package/dist/template/docs/migrations/2026-10-22-device-analytics.sql +264 -0
- package/dist/template/docs/migrations/2026-10-22-device-targeting-activation.sql +108 -0
- package/dist/template/docs/migrations/2026-10-22-device-targeting.sql +130 -0
- package/dist/template/docs/migrations/2026-10-22-device-version-metadata.sql +154 -0
- package/dist/template/docs/migrations/schema.sql +868 -6
- package/dist/template/docs/npm-installer.md +15 -30
- package/dist/template/docs/operations-guide.md +87 -0
- package/dist/template/docs/ota-client-lifecycle.md +263 -0
- package/dist/template/docs/ota-update-policy.md +36 -2
- package/dist/template/docs/supabase-setup.md +4 -0
- package/dist/template/hooks/use-mobile.ts +21 -0
- package/dist/template/lib/utils.ts +6 -0
- package/dist/template/package-lock.json +2325 -101
- package/dist/template/package.json +13 -3
- package/dist/template/scripts/configure-expo-app.mjs +11 -15
- package/dist/template/scripts/doctor.mjs +51 -0
- package/dist/template/scripts/ensure-storage-bucket.mjs +25 -0
- package/dist/template/scripts/ensure-test-bucket.mjs +21 -0
- package/dist/template/scripts/lib/device-identity.test.ts +29 -0
- package/dist/template/scripts/lib/doctor-probes.mjs +139 -0
- package/dist/template/scripts/lib/doctor.mjs +208 -0
- package/dist/template/scripts/lib/doctor.test.mjs +262 -0
- package/dist/template/scripts/lib/expo-app-configurator.mjs +14 -9
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +3 -2
- package/dist/template/scripts/lib/ota-client-configurator.mjs +69 -0
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +88 -0
- package/dist/template/scripts/lib/ota-client.test.ts +55 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +173 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +123 -0
- package/dist/template/scripts/lib/ota-update-controller.test.ts +231 -0
- package/dist/template/scripts/tests/device-analytics-migrations.mjs +80 -0
- package/dist/template/scripts/tests/device-analytics.mjs +126 -0
- package/dist/template/scripts/tests/device-heartbeat.mjs +86 -0
- package/dist/template/scripts/tests/device-targeting-activation.mjs +111 -0
- package/dist/template/scripts/tests/device-targeting.mjs +39 -0
- package/dist/template/scripts/tests/device-version-metadata.mjs +31 -0
- package/dist/template/scripts/tests/manifest-identity-concurrency.mjs +106 -0
- package/dist/template/scripts/tests/manifest-identity.sql +204 -0
- package/dist/template/src/client/admin-types.ts +1 -0
- package/dist/template/src/client/devices/analytics.tsx +429 -0
- package/dist/template/src/client/devices/device-name.tsx +82 -0
- package/dist/template/src/client/devices/registry.tsx +399 -0
- package/dist/template/src/client/devices/use-devices-report.ts +108 -0
- package/dist/template/src/client/devices/version-adoption-chart.tsx +269 -0
- package/dist/template/src/client/devices/version-groups.test.ts +57 -0
- package/dist/template/src/client/devices/version-groups.ts +101 -0
- package/dist/template/src/client/distribution-control.tsx +135 -81
- package/dist/template/src/client/guard-action-combobox.tsx +13 -24
- package/dist/template/src/client/i18n/en.json +286 -0
- package/dist/template/src/client/i18n/messages.test.ts +42 -0
- package/dist/template/src/client/i18n/messages.ts +31 -0
- package/dist/template/src/client/i18n/provider.tsx +55 -0
- package/dist/template/src/client/i18n/use-formatters.ts +38 -0
- package/dist/template/src/client/logout-button.tsx +3 -1
- package/dist/template/src/client/update-audience-editor.tsx +285 -0
- package/dist/template/src/client/update-policy-editor.tsx +53 -41
- package/dist/template/src/server/controllers/manifest.test.ts +250 -7
- package/dist/template/src/server/controllers/manifest.ts +39 -31
- package/dist/template/src/server/devices/audience.test.ts +48 -0
- package/dist/template/src/server/devices/audience.ts +86 -0
- package/dist/template/src/server/devices/heartbeat.test.ts +39 -0
- package/dist/template/src/server/devices/heartbeat.ts +75 -0
- package/dist/template/src/server/devices/report-types.ts +114 -0
- package/dist/template/src/server/devices/report.test.ts +29 -0
- package/dist/template/src/server/devices/report.ts +27 -0
- package/dist/template/src/server/lib/admin-audience-activation.test.ts +94 -0
- package/dist/template/src/server/lib/admin-updates.ts +32 -168
- package/dist/template/src/server/lib/supabase.js +10 -10
- package/dist/template/src/server/lib/supabase.test.ts +11 -0
- package/dist/template/src/server/manifest/manifest-identity.test.ts +30 -0
- package/dist/template/src/server/manifest/manifest-identity.ts +24 -0
- package/dist/template/src/server/manifest/manifest-repository.ts +31 -102
- package/dist/template/src/server/manifest/manifest-response.ts +1 -1
- package/dist/template/templates/expo-app/ota-client/README.md +59 -0
- package/dist/template/templates/expo-app/ota-client/controller.js +60 -0
- package/dist/template/templates/expo-app/ota-client/device-identity.js +26 -0
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +52 -0
- package/dist/template/templates/expo-app/ota-client/index.d.ts +47 -0
- package/dist/template/templates/expo-app/ota-client/index.js +3 -0
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.js +48 -0
- package/dist/template/templates/expo-app/ota-client/model/update-controller.js +182 -0
- package/dist/template/templates/expo-app/ota-client/runtime.js +112 -0
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.js +56 -0
- package/dist/template-manifest.json +592 -77
- package/lib/cli.mjs +4 -6
- package/package.json +1 -1
package/dist/template/README.md
CHANGED
|
@@ -1,682 +1,73 @@
|
|
|
1
1
|
# Expo Updates Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Self-hosted OTA delivery for Expo applications, with signed manifests, an admin
|
|
4
|
+
panel, device targeting and installation analytics.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
- Publish inactive updates, review their audience, then activate them.
|
|
7
|
+
- Track running app versions by runtime, channel and platform.
|
|
8
|
+
- Test a release on selected devices before making it available to everyone.
|
|
9
|
+
- Integrate identity, telemetry and manual/automatic updates through a generated
|
|
10
|
+
`useOtaUpdates` hook, including background delivery and required-update policies.
|
|
11
|
+
- Run PostgreSQL and S3-compatible storage locally with Docker, or use Supabase.
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
npx create-expo-updates-server@latest my-server
|
|
9
|
-
cd my-server
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
To install into the current empty directory:
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
npx create-expo-updates-server@latest .
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
The downloaded initializer uses its bundled, checksum-verified template. It
|
|
19
|
-
does not fetch source code, install project dependencies, initialize Git, or
|
|
20
|
-
create secrets while scaffolding. A named target path must not already exist;
|
|
21
|
-
`.` is supported only when it resolves to the empty current directory.
|
|
22
|
-
Continue with either Docker:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
cp .env.docker.example .env
|
|
26
|
-
docker compose up -d --build
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
or a local npm setup:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm ci
|
|
33
|
-
cp .env.example .env.local
|
|
34
|
-
npm run dev
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
See the [npm initializer guide](docs/npm-installer.md) for supported commands,
|
|
38
|
-
safety behavior, and complete next steps. Cloning the
|
|
39
|
-
[GitHub repository](https://github.com/tonichiga/expo-updates-server) remains
|
|
40
|
-
supported for contributors and manual installations.
|
|
41
|
-
|
|
42
|
-
# Beginner Quick Start
|
|
43
|
-
|
|
44
|
-
This guide takes you from an empty machine to a working OTA server and a
|
|
45
|
-
connected Expo application. Deep Docker, PostgreSQL or Supabase knowledge is
|
|
46
|
-
not required.
|
|
47
|
-
|
|
48
|
-
## What you will have
|
|
49
|
-
|
|
50
|
-
At the end you can:
|
|
51
|
-
|
|
52
|
-
1. open the OTA admin panel;
|
|
53
|
-
2. sign in as an administrator;
|
|
54
|
-
3. connect an Expo application;
|
|
55
|
-
4. publish updates;
|
|
56
|
-
5. activate an update manually;
|
|
57
|
-
6. roll back or configure an emergency redirect.
|
|
58
|
-
|
|
59
|
-
## Choose one installation path
|
|
60
|
-
|
|
61
|
-
- **NPX** creates a clean standalone copy without cloning the repository.
|
|
62
|
-
- **Docker** runs the server, PostgreSQL and MinIO together.
|
|
63
|
-
- **Supabase** hosts the database and storage; the OTA server is deployed
|
|
64
|
-
separately.
|
|
65
|
-
|
|
66
|
-
Use Docker for the quickest local test.
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
# Option A: Docker
|
|
71
|
-
|
|
72
|
-
## Step 1. Install and start Docker Desktop
|
|
73
|
-
|
|
74
|
-
Download Docker Desktop from:
|
|
75
|
-
|
|
76
|
-
```text
|
|
77
|
-
https://www.docker.com/products/docker-desktop/
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Open it and wait until Docker Engine is running.
|
|
81
|
-
|
|
82
|
-
## Step 2. Open the project folder
|
|
83
|
-
|
|
84
|
-
In Terminal:
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
cd /path/to/expo-updates-server
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Step 3. Create the settings file
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
cp .env.docker.example .env
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Open `.env` and replace:
|
|
97
|
-
|
|
98
|
-
```env
|
|
99
|
-
POSTGRES_PASSWORD=choose-a-long-random-password
|
|
100
|
-
MINIO_ROOT_PASSWORD=choose-another-long-random-password
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Do not publish `.env` to GitHub.
|
|
104
|
-
|
|
105
|
-
If port `3000` is busy:
|
|
106
|
-
|
|
107
|
-
```env
|
|
108
|
-
OTA_HTTP_PORT=3100
|
|
109
|
-
OTA_PUBLIC_BASE_URL=http://localhost:3100
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
If another project already uses PostgreSQL port `5432`, set:
|
|
113
|
-
|
|
114
|
-
```env
|
|
115
|
-
POSTGRES_PORT=5433
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## Step 4. Create the signing key pair
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
mkdir -p secrets local-certificates
|
|
122
|
-
|
|
123
|
-
openssl req \
|
|
124
|
-
-x509 \
|
|
125
|
-
-newkey rsa:2048 \
|
|
126
|
-
-nodes \
|
|
127
|
-
-sha256 \
|
|
128
|
-
-days 3650 \
|
|
129
|
-
-subj "/CN=expo-updates" \
|
|
130
|
-
-addext "basicConstraints=critical,CA:FALSE" \
|
|
131
|
-
-addext "keyUsage=critical,digitalSignature" \
|
|
132
|
-
-addext "extendedKeyUsage=codeSigning" \
|
|
133
|
-
-keyout secrets/code-signing-private-key.pem \
|
|
134
|
-
-out local-certificates/code-signing-certificate.pem
|
|
135
|
-
|
|
136
|
-
chmod 600 secrets/code-signing-private-key.pem
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Keep `secrets/code-signing-private-key.pem` on the server. Copy
|
|
140
|
-
`local-certificates/code-signing-certificate.pem` to the Expo application.
|
|
141
|
-
The two files must remain a matching pair.
|
|
142
|
-
|
|
143
|
-
## Step 5. Start everything
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
docker compose up -d --build
|
|
147
|
-
docker compose ps
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
Wait until `postgres`, `minio` and `app` are `healthy`.
|
|
151
|
-
|
|
152
|
-
## Step 6. Database setup is automatic
|
|
153
|
-
|
|
154
|
-
Docker automatically applies:
|
|
155
|
-
|
|
156
|
-
```text
|
|
157
|
-
docs/migrations/schema.sql
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
You do not need pgAdmin or manual SQL commands for a new Docker installation.
|
|
161
|
-
|
|
162
|
-
## Step 7. Create the first administrator
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
docker compose exec app npm run create-admin
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
Enter a username, a password of at least 12 characters and choose `admin`.
|
|
169
|
-
|
|
170
|
-
## Step 8. Open the admin panel
|
|
171
|
-
|
|
172
|
-
```text
|
|
173
|
-
http://localhost:3000/login
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
Use `3100` if you changed `OTA_HTTP_PORT`.
|
|
177
|
-
|
|
178
|
-
## Step 9. Local publisher settings
|
|
179
|
-
|
|
180
|
-
The Expo publisher can reach Docker services through loopback-only ports:
|
|
181
|
-
|
|
182
|
-
```env
|
|
183
|
-
OTA_DATABASE_URL=postgresql://expo_updates:YOUR_POSTGRES_PASSWORD@localhost:YOUR_POSTGRES_PORT/expo_updates
|
|
184
|
-
OTA_DATABASE_SSL=false
|
|
185
|
-
|
|
186
|
-
R2_ENDPOINT=http://localhost:9000
|
|
187
|
-
R2_ACCESS_KEY_ID=expo_updates
|
|
188
|
-
R2_SECRET_ACCESS_KEY=YOUR_MINIO_ROOT_PASSWORD
|
|
189
|
-
R2_BUCKET=expo-updates
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
Use `5432` when `POSTGRES_PORT` was not changed. If `.env` contains
|
|
193
|
-
`POSTGRES_PORT=5433`, use `5433` in `OTA_DATABASE_URL` as well.
|
|
194
|
-
|
|
195
|
-
MinIO Console is available at `http://localhost:9001`.
|
|
196
|
-
|
|
197
|
-
---
|
|
198
|
-
|
|
199
|
-
# Option B: Supabase
|
|
200
|
-
|
|
201
|
-
Supabase replaces PostgreSQL and MinIO. It does not run the OTA web server.
|
|
202
|
-
|
|
203
|
-
## Step 1. Create a project
|
|
204
|
-
|
|
205
|
-
1. Open `https://supabase.com`.
|
|
206
|
-
2. Select **New project**.
|
|
207
|
-
3. Enter a project name.
|
|
208
|
-
4. Create and save a strong database password.
|
|
209
|
-
5. Select a nearby region.
|
|
210
|
-
6. Wait until the project is ready.
|
|
211
|
-
|
|
212
|
-
## Step 2. Install the schema
|
|
213
|
-
|
|
214
|
-
1. Open **SQL Editor** in the left sidebar.
|
|
215
|
-
2. Select **New query**.
|
|
216
|
-
3. Open `docs/migrations/schema.sql` on your computer.
|
|
217
|
-
4. Copy the entire file.
|
|
218
|
-
5. Paste it into Supabase SQL Editor.
|
|
219
|
-
6. Select **Run**.
|
|
220
|
-
7. Wait for the success message.
|
|
221
|
-
|
|
222
|
-
No other migration files are required.
|
|
223
|
-
|
|
224
|
-
## Step 3. Confirm the tables
|
|
225
|
-
|
|
226
|
-
Open **Table Editor**. You should see:
|
|
227
|
-
|
|
228
|
-
```text
|
|
229
|
-
ota_access_tokens
|
|
230
|
-
ota_admin_sessions
|
|
231
|
-
ota_admin_users
|
|
232
|
-
ota_device_state
|
|
233
|
-
ota_device_transitions
|
|
234
|
-
ota_embedded_updates
|
|
235
|
-
ota_emergency_redirects
|
|
236
|
-
ota_guard_actions
|
|
237
|
-
ota_served_manifest_log
|
|
238
|
-
ota_update_channels
|
|
239
|
-
ota_updates
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
## Step 4. Create storage
|
|
243
|
-
|
|
244
|
-
1. Open **Storage**.
|
|
245
|
-
2. Select **New bucket**.
|
|
246
|
-
3. Name it `expo-updates`.
|
|
247
|
-
4. Keep the bucket private.
|
|
248
|
-
5. Select **Create bucket**.
|
|
249
|
-
|
|
250
|
-
## Step 5. Get server credentials
|
|
251
|
-
|
|
252
|
-
Find the project URL and `service_role` key in project settings. The service
|
|
253
|
-
role key is a backend secret. Never place it in the Expo application.
|
|
254
|
-
|
|
255
|
-
## Step 6. Configure the OTA server
|
|
256
|
-
|
|
257
|
-
Create `.env.local`:
|
|
258
|
-
|
|
259
|
-
```env
|
|
260
|
-
DATABASE_PROVIDER=supabase
|
|
261
|
-
SUPABASE_PROJECT_URL=https://YOUR-PROJECT.supabase.co
|
|
262
|
-
SUPABASE_SERVICE_ROLE_KEY=YOUR_SERVICE_ROLE_KEY
|
|
263
|
-
SUPABASE_UPDATES_BUCKET=expo-updates
|
|
264
|
-
|
|
265
|
-
OTA_PUBLIC_BASE_URL=https://updates.example.com
|
|
266
|
-
CODE_SIGNING_PRIVATE_KEY_PATH=/full/path/code-signing-private-key.pem
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
## Step 7. Start and check the server
|
|
270
|
-
|
|
271
|
-
```bash
|
|
272
|
-
npm ci
|
|
273
|
-
npm run build
|
|
274
|
-
npm run start
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
Open `http://localhost:3000/api/health`. A response containing
|
|
278
|
-
`"status":"ok"` means the database connection works.
|
|
279
|
-
|
|
280
|
-
## Step 8. Create the administrator
|
|
281
|
-
|
|
282
|
-
```bash
|
|
283
|
-
npm run create-admin
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
Choose the `admin` role for the first user.
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
# Connect the Expo application
|
|
291
|
-
|
|
292
|
-
These steps are the same for Docker and Supabase.
|
|
293
|
-
|
|
294
|
-
## Automatic CLI configuration
|
|
295
|
-
|
|
296
|
-
For an Expo application with a static `app.json`, run this command from the OTA
|
|
297
|
-
server repository:
|
|
298
|
-
|
|
299
|
-
```bash
|
|
300
|
-
npm run configure-app
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
The CLI asks for the application path, public certificate, server URL, channel,
|
|
304
|
-
runtime, platform and overwrite preference. It displays a summary and requires
|
|
305
|
-
confirmation before changing files or running `expo prebuild`.
|
|
13
|
+
## Start here
|
|
306
14
|
|
|
307
|
-
|
|
15
|
+
Create a server project:
|
|
308
16
|
|
|
309
17
|
```bash
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
--certificate /full/path/code-signing-certificate.pem \
|
|
313
|
-
--server-url https://updates.example.com \
|
|
314
|
-
--channel production \
|
|
315
|
-
--runtime-version 1.0.0
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
The CLI:
|
|
319
|
-
|
|
320
|
-
1. validates the Expo project;
|
|
321
|
-
2. installs the Expo-compatible `expo-updates` version;
|
|
322
|
-
3. configures URL, channel, runtime and code signing in `app.json`;
|
|
323
|
-
4. copies the public certificate;
|
|
324
|
-
5. installs a portable publish script;
|
|
325
|
-
6. creates `.env.ota.example`;
|
|
326
|
-
7. adds `npm run ota:publish`;
|
|
327
|
-
8. installs publisher dependencies;
|
|
328
|
-
9. installs Android, Xcode and Xcode Cloud embedded registration hooks;
|
|
329
|
-
10. runs `expo prebuild` to synchronize native projects.
|
|
330
|
-
|
|
331
|
-
Use `--platform ios` or `--platform android` to prebuild one platform. The
|
|
332
|
-
default is both platforms.
|
|
333
|
-
|
|
334
|
-
Existing generated publisher or certificate files are not overwritten. Add
|
|
335
|
-
`--force` only when replacement is intentional.
|
|
336
|
-
|
|
337
|
-
The CLI stops when `app.config.ts`, `app.config.js`, `app.config.mjs` or
|
|
338
|
-
`app.config.cjs` exists because dynamic Expo config overrides `app.json`.
|
|
339
|
-
|
|
340
|
-
After configuration:
|
|
341
|
-
|
|
342
|
-
```bash
|
|
343
|
-
cd /full/path/to/expo-application
|
|
344
|
-
cp .env.ota.example .env.ota
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
Fill in the publisher credentials, then run:
|
|
348
|
-
|
|
349
|
-
```bash
|
|
350
|
-
npm run ota:publish -- --message "Describe the change"
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
For local Docker with a `localhost` server URL, the CLI creates the ignored
|
|
354
|
-
`.env.ota` automatically from the OTA server `.env`. Manual configuration is
|
|
355
|
-
only required for a remote server, Supabase or another storage provider.
|
|
356
|
-
Microsoft Dev Tunnel URLs (`*.devtunnels.ms`) are also recognized as local
|
|
357
|
-
Docker exposure: the public tunnel is used for `OTA_SERVER_URL`, while the
|
|
358
|
-
publisher connects directly to MinIO at `http://127.0.0.1:9000`.
|
|
359
|
-
|
|
360
|
-
The update is uploaded as inactive. Activate it in the admin panel after
|
|
361
|
-
review. The following sections describe the equivalent manual setup.
|
|
362
|
-
|
|
363
|
-
## Register the update embedded in a binary
|
|
364
|
-
|
|
365
|
-
Every release binary contains an embedded update. The server needs its ID for
|
|
366
|
-
reliable rollback and emergency redirects. The configurator installs this flow
|
|
367
|
-
automatically.
|
|
368
|
-
|
|
369
|
-
For local Docker, build Android with:
|
|
370
|
-
|
|
371
|
-
```bash
|
|
372
|
-
npm run ota:build:android:apk
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
Use `npm run ota:build:android:aab` for an App Bundle. After Gradle succeeds,
|
|
376
|
-
`scripts/ota-register-embedded/register-android.sh` finds `app.manifest` and
|
|
377
|
-
registers the embedded update. For iOS, the configurator adds an Xcode Build
|
|
378
|
-
Phase that invokes `scripts/ota-register-embedded/register-ios.sh`, so a
|
|
379
|
-
Release/Archive build in Xcode performs registration automatically.
|
|
380
|
-
The registrar uses an app version from the embedded manifest when available;
|
|
381
|
-
otherwise it falls back to the normalized `expo.version` in the project's
|
|
382
|
-
static `app.json`. A missing or invalid fallback remains `null` and does not
|
|
383
|
-
fail an otherwise valid registration.
|
|
384
|
-
|
|
385
|
-
For remote CI or Xcode Cloud, do not provide PostgreSQL credentials. Create a
|
|
386
|
-
dedicated token:
|
|
387
|
-
|
|
388
|
-
```bash
|
|
389
|
-
docker compose exec app npm run create-access-token
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
Keep the default `updates:write` scope and add the displayed token to CI
|
|
393
|
-
secrets:
|
|
394
|
-
|
|
395
|
-
```env
|
|
396
|
-
OTA_SERVER_URL=https://updates.example.com
|
|
397
|
-
OTA_ACCESS_TOKEN=ota_...
|
|
398
|
-
```
|
|
399
|
-
|
|
400
|
-
The configurator also creates `ci_scripts/ci_post_xcodebuild.sh`, a thin Xcode
|
|
401
|
-
Cloud lifecycle adapter that invokes the same `register-ios.sh`. The token is
|
|
402
|
-
shown only once and must never be committed or included in the mobile binary.
|
|
403
|
-
Verify registered binaries at `/updates/embedded`.
|
|
404
|
-
|
|
405
|
-
## Step 1. Install Expo Updates
|
|
406
|
-
|
|
407
|
-
```bash
|
|
408
|
-
npx expo install expo-updates
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
## Step 2. Copy the public certificate
|
|
412
|
-
|
|
413
|
-
Copy `code-signing-certificate.pem` into a `certificates` directory in the Expo
|
|
414
|
-
application. Never copy the private key into the mobile project.
|
|
415
|
-
|
|
416
|
-
## Step 3. Configure Expo
|
|
417
|
-
|
|
418
|
-
Use the `app.config.ts` example in
|
|
419
|
-
[`docs/expo-app-setup.md`](docs/expo-app-setup.md). Set:
|
|
420
|
-
|
|
421
|
-
- `EXPO_OTA_SERVER_URL`;
|
|
422
|
-
- `EXPO_UPDATE_CHANNEL`;
|
|
423
|
-
- `EXPO_RUNTIME_VERSION`.
|
|
424
|
-
|
|
425
|
-
A physical device cannot reach the computer through `localhost`. Production
|
|
426
|
-
requires a public HTTPS URL.
|
|
427
|
-
|
|
428
|
-
## Step 4. Build a new native binary
|
|
429
|
-
|
|
430
|
-
The OTA URL, channel, runtime and certificate are native settings. Build the
|
|
431
|
-
iOS or Android application again after changing them.
|
|
432
|
-
|
|
433
|
-
## Step 5. Publish an update
|
|
434
|
-
|
|
435
|
-
After automatic configuration, use:
|
|
436
|
-
|
|
437
|
-
```bash
|
|
438
|
-
npm run ota:publish -- --message "Describe the change"
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
The publisher exports JavaScript, uploads assets and inserts database records.
|
|
442
|
-
The new update remains inactive until you approve it.
|
|
443
|
-
|
|
444
|
-
## Step 6. Activate the update
|
|
445
|
-
|
|
446
|
-
1. Open `/updates` in the admin panel.
|
|
447
|
-
2. Find the new update.
|
|
448
|
-
3. Confirm its channel, runtime and platform.
|
|
449
|
-
4. Activate it manually.
|
|
450
|
-
|
|
451
|
-
## Step 7. Test on a device
|
|
452
|
-
|
|
453
|
-
Use a release build, run the update check, download the update and reload the
|
|
454
|
-
application. Expo Go is not suitable for this test.
|
|
455
|
-
|
|
456
|
-
## Troubleshooting
|
|
457
|
-
|
|
458
|
-
- Server failure: `docker compose logs app`.
|
|
459
|
-
- Container state: `docker compose ps`.
|
|
460
|
-
- Port conflict: change the matching `*_PORT` in `.env`.
|
|
461
|
-
- `password authentication failed for user "expo_updates"` after editing
|
|
462
|
-
`.env`: the existing PostgreSQL volume still has its original password. Run:
|
|
463
|
-
|
|
464
|
-
```bash
|
|
465
|
-
npm run docker:sync-db-password
|
|
466
|
-
docker compose restart app
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
- Missing Supabase tables: run the complete `schema.sql` again.
|
|
470
|
-
- Missing update: compare platform, runtime and channel.
|
|
471
|
-
- Signature error: the server private key does not match the app certificate.
|
|
472
|
-
- `SignatureDoesNotMatch`: `.env.ota` storage credentials do not match MinIO
|
|
473
|
-
or R2. For local Docker, run `npm run configure-app` again and allow generated
|
|
474
|
-
files to be replaced so `.env.ota` is synchronized from the server `.env`.
|
|
475
|
-
If the OTA server uses a Dev Tunnel, put the tunnel URL in `OTA_SERVER_URL`
|
|
476
|
-
but keep `R2_ENDPOINT=http://127.0.0.1:9000` for a local publisher. Sending
|
|
477
|
-
signed S3 requests through a
|
|
478
|
-
generic HTTP tunnel can change the host and
|
|
479
|
-
invalidate the AWS signature.
|
|
480
|
-
- `unknown or unexpected option: --platform`: the publisher was generated by
|
|
481
|
-
an older CLI version. Run `npm run configure-app` again and allow generated
|
|
482
|
-
files to be replaced.
|
|
483
|
-
- Missing embedded update: confirm that a Release configuration was built and
|
|
484
|
-
CI has `OTA_SERVER_URL` plus an `OTA_ACCESS_TOKEN` with `updates:write`.
|
|
485
|
-
|
|
486
|
-
Technical reference:
|
|
487
|
-
|
|
488
|
-
- [`docs/operations-guide.md`](docs/operations-guide.md);
|
|
489
|
-
- [`docs/supabase-setup.md`](docs/supabase-setup.md);
|
|
490
|
-
- [`docs/expo-app-setup.md`](docs/expo-app-setup.md).
|
|
491
|
-
|
|
492
|
-
<!-- ## OTA Update Admin Panel
|
|
493
|
-
|
|
494
|
-
Админ-панель для управления `expo-updates` в PostgreSQL + S3-совместимом bucket (Cloudflare R2).
|
|
495
|
-
|
|
496
|
-
Аварийное восстановление ошибочного OTA-канала описано в
|
|
497
|
-
[`docs/ota-emergency-recovery.md`](docs/ota-emergency-recovery.md).
|
|
498
|
-
|
|
499
|
-
Установка, Docker, резервное копирование и безопасное обновление описаны в
|
|
500
|
-
[`docs/operations-guide.md`](docs/operations-guide.md).
|
|
501
|
-
|
|
502
|
-
Пошаговая инструкция для начинающих:
|
|
503
|
-
[`Русский`](docs/getting-started.ru.md) |
|
|
504
|
-
[`English`](docs/getting-started.md).
|
|
505
|
-
|
|
506
|
-
Быстрый запуск через Supabase SQL Editor описан в
|
|
507
|
-
[`docs/supabase-setup.md`](docs/supabase-setup.md).
|
|
508
|
-
|
|
509
|
-
Настройка Expo-приложения, code signing, получение и публикация OTA описаны в
|
|
510
|
-
[`docs/expo-app-setup.md`](docs/expo-app-setup.md).
|
|
511
|
-
|
|
512
|
-
Автоматическая настройка Expo-приложения со статическим `app.json`:
|
|
513
|
-
|
|
514
|
-
```bash
|
|
515
|
-
npm run configure-app
|
|
516
|
-
```
|
|
517
|
-
|
|
518
|
-
CLI задаст вопросы и покажет итоговые настройки перед изменением приложения.
|
|
519
|
-
Для CI также поддерживаются flags:
|
|
520
|
-
|
|
521
|
-
```bash
|
|
522
|
-
npm run configure-app -- \
|
|
523
|
-
--app /path/to/expo-app \
|
|
524
|
-
--certificate /path/to/code-signing-certificate.pem \
|
|
525
|
-
--server-url https://updates.example.com \
|
|
526
|
-
--channel production \
|
|
527
|
-
--runtime-version 1.0.0
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
### Основные возможности
|
|
531
|
-
|
|
532
|
-
- Логин по сессионной cookie (без регистрации)
|
|
533
|
-
- Список апдейтов с сортировкой и пагинацией
|
|
534
|
-
- Детальная страница апдейта
|
|
535
|
-
- Удаление апдейта из bucket
|
|
536
|
-
- Редактирование JSON-файлов (`update-info.json`, `metadata.json`, `channels/*/latest.json`)
|
|
537
|
-
- Rollback через перезапись `latest.json`
|
|
538
|
-
- Деактивация/активация апдейта
|
|
539
|
-
|
|
540
|
-
### Переменные окружения
|
|
541
|
-
|
|
542
|
-
Обязательные:
|
|
543
|
-
|
|
544
|
-
- `DATABASE_PROVIDER` - провайдер БД: `pg` или `supabase` (по умолчанию `pg`)
|
|
545
|
-
- `DATABASE_URL` - строка подключения к PostgreSQL
|
|
546
|
-
- `R2_ENDPOINT` - S3 endpoint для Cloudflare R2
|
|
547
|
-
- `R2_ACCESS_KEY_ID` - access key для R2
|
|
548
|
-
- `R2_SECRET_ACCESS_KEY` - secret key для R2
|
|
549
|
-
- `R2_BUCKET` (или `OTA_STORAGE_BUCKET`) - bucket с OTA ассетами
|
|
550
|
-
|
|
551
|
-
Для `DATABASE_PROVIDER=supabase`:
|
|
552
|
-
|
|
553
|
-
- `SUPABASE_PROJECT_URL` (или `SUPABASE_URL`)
|
|
554
|
-
- `SUPABASE_SERVICE_ROLE_KEY` (или `SUPABASE_PUBLISHED_KEY`)
|
|
555
|
-
|
|
556
|
-
### Пользователи админки
|
|
557
|
-
|
|
558
|
-
Пользователи, password hashes, роли и активные сессии хранятся в PostgreSQL.
|
|
559
|
-
Environment credentials не используются.
|
|
560
|
-
|
|
561
|
-
Примените единую схему и создайте первого администратора:
|
|
562
|
-
|
|
563
|
-
```bash
|
|
564
|
-
psql "$DATABASE_URL" -f docs/migrations/schema.sql
|
|
565
|
-
npm run create-admin
|
|
566
|
-
```
|
|
567
|
-
|
|
568
|
-
Доступны роли:
|
|
569
|
-
|
|
570
|
-
- `admin` — полный доступ, включая управление access tokens;
|
|
571
|
-
- `operator` — управление updates и emergency redirects;
|
|
572
|
-
- `viewer` — только просмотр updates и redirects.
|
|
573
|
-
|
|
574
|
-
Опционально:
|
|
575
|
-
|
|
576
|
-
- `OTA_PUBLIC_BASE_URL` - публичный URL OTA сервера (для `/api/manifest` и `/api/assets`)
|
|
577
|
-
- `OTA_CDN_BASE_URL` - устаревшая совместимая настройка; новые manifest
|
|
578
|
-
намеренно игнорируют её и выдают gated `/api/assets` URL, чтобы глобальный
|
|
579
|
-
аварийный выключатель нельзя было обойти прямой загрузкой из CDN
|
|
580
|
-
- `OTA_SIGNED_URL_TTL` - TTL signed URL в секундах (по умолчанию `3600`)
|
|
581
|
-
- `R2_REGION` - регион для S3 клиента (по умолчанию `auto`)
|
|
582
|
-
|
|
583
|
-
### Маршруты
|
|
584
|
-
|
|
585
|
-
- `/login` — страница входа
|
|
586
|
-
- `/updates` — список апдейтов
|
|
587
|
-
- `/updates/[id]` — страница конкретного апдейта
|
|
588
|
-
|
|
589
|
-
### Access tokens
|
|
590
|
-
|
|
591
|
-
Admin API поддерживает cookie-сессию и Bearer tokens. Перед первым
|
|
592
|
-
использованием примените миграцию:
|
|
593
|
-
|
|
594
|
-
```bash
|
|
595
|
-
psql "$DATABASE_URL" -f docs/migrations/schema.sql
|
|
596
|
-
```
|
|
597
|
-
|
|
598
|
-
Создание токена доступно только через cookie-сессию администратора:
|
|
599
|
-
|
|
600
|
-
```http
|
|
601
|
-
POST /api/admin/access-tokens
|
|
602
|
-
Content-Type: application/json
|
|
603
|
-
|
|
604
|
-
{
|
|
605
|
-
"name": "Deployment CI",
|
|
606
|
-
"scopes": ["updates:read", "updates:write"],
|
|
607
|
-
"expiresAt": "2027-01-01T00:00:00.000Z"
|
|
608
|
-
}
|
|
609
|
-
```
|
|
610
|
-
|
|
611
|
-
Raw token возвращается только при создании. В базе хранится SHA-256 hash.
|
|
612
|
-
Поддерживаемые scopes: `updates:read`, `updates:write`, `redirects:read`,
|
|
613
|
-
`redirects:write`.
|
|
614
|
-
|
|
615
|
-
Использование:
|
|
616
|
-
|
|
617
|
-
```bash
|
|
618
|
-
curl -H "Authorization: Bearer $OTA_ACCESS_TOKEN" \
|
|
619
|
-
https://updates.example.com/api/admin/updates
|
|
620
|
-
```
|
|
621
|
-
|
|
622
|
-
### Emergency redirects
|
|
623
|
-
|
|
624
|
-
Правила хранятся в таблице `ota_emergency_redirects` и управляются на странице
|
|
625
|
-
`/updates/emergency-redirects`.
|
|
626
|
-
|
|
627
|
-
Перед deploy примените миграцию:
|
|
628
|
-
|
|
629
|
-
```bash
|
|
630
|
-
psql "$DATABASE_URL" -f docs/migrations/schema.sql
|
|
631
|
-
```
|
|
632
|
-
|
|
633
|
-
Если раньше использовался JSON-конфиг, импортируйте его до deploy новой версии:
|
|
634
|
-
|
|
635
|
-
```bash
|
|
636
|
-
npm run emergency:import
|
|
18
|
+
npx create-expo-updates-server@latest my-server
|
|
19
|
+
cd my-server
|
|
637
20
|
```
|
|
638
21
|
|
|
639
|
-
|
|
22
|
+
The initializer creates files; it does **not** start services, install dependencies
|
|
23
|
+
or generate credentials/signing keys. It contains the template from its published
|
|
24
|
+
version, not unpublished changes on GitHub or in a local checkout.
|
|
640
25
|
|
|
641
|
-
|
|
26
|
+
Continue with the **[Quick Start](docs/getting-started.md)**
|
|
27
|
+
([Русский](docs/getting-started.ru.md)). It covers one complete path:
|
|
642
28
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
docker compose exec app npm run create-admin
|
|
649
|
-
```
|
|
29
|
+
1. Prepare Docker, server settings and a signing key pair.
|
|
30
|
+
2. Start the server and create an administrator.
|
|
31
|
+
3. Give the phone a reachable HTTPS endpoint.
|
|
32
|
+
4. Run `configure-app`, then build and install a native release.
|
|
33
|
+
5. Make a JS change, publish an OTA and activate it for the intended audience.
|
|
650
34
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
npm
|
|
655
|
-
# or
|
|
656
|
-
yarn dev
|
|
657
|
-
# or
|
|
658
|
-
pnpm dev
|
|
659
|
-
# or
|
|
660
|
-
bun dev
|
|
661
|
-
```
|
|
35
|
+
Use [Supabase setup](docs/supabase-setup.md) for hosted infrastructure.
|
|
36
|
+
Cloning this repository is also supported; use the same quick start from the
|
|
37
|
+
checkout. For initializer options and filesystem behavior, see
|
|
38
|
+
[the npm initializer guide](docs/npm-installer.md).
|
|
662
39
|
|
|
663
|
-
|
|
40
|
+
## Application integration
|
|
664
41
|
|
|
665
|
-
|
|
42
|
+
Run `npm ci` in the **server directory** before `npm run configure-app`.
|
|
43
|
+
The configurator supports static `app.json` projects and installs the client,
|
|
44
|
+
root hook, publisher and embedded-build registration scripts. See
|
|
45
|
+
[Expo application setup](docs/expo-app-setup.md) for supported roots and flags.
|
|
666
46
|
|
|
667
|
-
|
|
47
|
+
If generation cannot be used, follow [manual client integration](docs/ota-client-lifecycle.md#manual-integration).
|
|
48
|
+
This fallback wires the client; publisher/build registration still require
|
|
49
|
+
separate setup. Expo Go cannot validate the release OTA lifecycle.
|
|
668
50
|
|
|
669
|
-
##
|
|
51
|
+
## Check your setup
|
|
670
52
|
|
|
671
|
-
|
|
53
|
+
From the server directory, run `npm run doctor -- --app ../my-expo-app`.
|
|
54
|
+
Use `--offline` before starting Docker or `--mode remote --server-env ./server.env`
|
|
55
|
+
for hosted infrastructure. [Doctor](docs/doctor.md) explains failures without
|
|
56
|
+
changing your configuration; `--json` supports CI.
|
|
672
57
|
|
|
673
|
-
|
|
674
|
-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
58
|
+
## Documentation
|
|
675
59
|
|
|
676
|
-
|
|
60
|
+
- [Client hook and update modes](docs/ota-client-lifecycle.md)
|
|
61
|
+
- [Device targeting](docs/device-targeting.md) and [installation analytics](docs/installation-telemetry.md)
|
|
62
|
+
- [Update policy](docs/ota-update-policy.md) and [emergency recovery](docs/ota-emergency-recovery.md)
|
|
63
|
+
- [Deployment, backups and operations](docs/operations-guide.md)
|
|
677
64
|
|
|
678
|
-
##
|
|
65
|
+
## Contributing
|
|
679
66
|
|
|
680
|
-
|
|
67
|
+
From a source checkout, run `npm ci`, then `npm test` and `npm run lint`.
|
|
68
|
+
Run `npm run docs:dev` to preview the VitePress documentation.
|
|
69
|
+
See [publishing the initializer](https://github.com/tonichiga/expo-updates-server/blob/main/docs/publishing-npm-installer.md)
|
|
70
|
+
for the commit, package smoke test and release workflow. A merge alone does not
|
|
71
|
+
update the package used by `npx`.
|
|
681
72
|
|
|
682
|
-
|
|
73
|
+
Released under the [MIT License](LICENSE).
|