create-expo-updates-server 0.1.3 → 0.1.4

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 (29) hide show
  1. package/dist/template/README.md +12 -7
  2. package/dist/template/app/api/admin/embedded-updates/route.test.ts +36 -1
  3. package/dist/template/app/api/admin/updates/route.test.ts +29 -1
  4. package/dist/template/app/updates/embedded/page.tsx +6 -2
  5. package/dist/template/app/updates/page.tsx +6 -2
  6. package/dist/template/docs/expo-app-setup.md +14 -3
  7. package/dist/template/docs/getting-started.md +12 -7
  8. package/dist/template/docs/getting-started.ru.md +13 -6
  9. package/dist/template/docs/migrations/2026-09-01-app-version-columns.sql +23 -0
  10. package/dist/template/docs/migrations/schema.sql +22 -0
  11. package/dist/template/package-lock.json +2 -2
  12. package/dist/template/package.json +1 -1
  13. package/dist/template/scripts/configure-expo-app.mjs +6 -0
  14. package/dist/template/scripts/lib/embedded-update-registrar.test.ts +383 -3
  15. package/dist/template/scripts/lib/expo-app-configurator.mjs +165 -9
  16. package/dist/template/scripts/lib/expo-app-configurator.test.ts +658 -9
  17. package/dist/template/src/client/admin-types.ts +2 -0
  18. package/dist/template/src/server/lib/admin-embedded-updates.test.ts +57 -0
  19. package/dist/template/src/server/lib/admin-embedded-updates.ts +42 -25
  20. package/dist/template/src/server/lib/admin-updates.test.ts +61 -0
  21. package/dist/template/src/server/lib/admin-updates.ts +23 -3
  22. package/dist/template/templates/expo-app/ci_scripts/ci_post_xcodebuild.sh +23 -1
  23. package/dist/template/templates/expo-app/plugins/with-ota-embedded-registration.js +13 -4
  24. package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +53 -7
  25. package/dist/template/templates/expo-app/scripts/ota-register-embedded/register-ios.sh +87 -0
  26. package/dist/template-manifest.json +65 -50
  27. package/package.json +1 -1
  28. package/dist/template/templates/expo-app/ci_scripts/register-embedded-update.sh +0 -36
  29. /package/dist/template/templates/expo-app/scripts/ota-register-embedded/{android-register-embedded-update.sh → register-android.sh} +0 -0
@@ -372,9 +372,14 @@ npm run ota:build:android:apk
372
372
  ```
373
373
 
374
374
  Use `npm run ota:build:android:aab` for an App Bundle. After Gradle succeeds,
375
- the generated script finds `app.manifest` and registers the embedded update.
376
- For iOS, the configurator adds an Xcode Build Phase, so a Release/Archive build
377
- in Xcode performs registration automatically.
375
+ `scripts/ota-register-embedded/register-android.sh` finds `app.manifest` and
376
+ registers the embedded update. For iOS, the configurator adds an Xcode Build
377
+ Phase that invokes `scripts/ota-register-embedded/register-ios.sh`, so a
378
+ Release/Archive build in Xcode performs registration automatically.
379
+ The registrar uses an app version from the embedded manifest when available;
380
+ otherwise it falls back to the normalized `expo.version` in the project's
381
+ static `app.json`. A missing or invalid fallback remains `null` and does not
382
+ fail an otherwise valid registration.
378
383
 
379
384
  For remote CI or Xcode Cloud, do not provide PostgreSQL credentials. Create a
380
385
  dedicated token:
@@ -391,10 +396,10 @@ OTA_SERVER_URL=https://updates.example.com
391
396
  OTA_ACCESS_TOKEN=ota_...
392
397
  ```
393
398
 
394
- The configurator also creates `ci_scripts/ci_post_xcodebuild.sh`, which Xcode
395
- Cloud runs after a build. The token is shown only once and must never be
396
- committed or included in the mobile binary. Verify registered binaries at
397
- `/updates/embedded`.
399
+ The configurator also creates `ci_scripts/ci_post_xcodebuild.sh`, a thin Xcode
400
+ Cloud lifecycle adapter that invokes the same `register-ios.sh`. The token is
401
+ shown only once and must never be committed or included in the mobile binary.
402
+ Verify registered binaries at `/updates/embedded`.
398
403
 
399
404
  ## Step 1. Install Expo Updates
400
405
 
@@ -2,6 +2,9 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
2
2
  import { NextRequest } from "next/server";
3
3
 
4
4
  const requireAdminAccess = vi.hoisted(() => vi.fn());
5
+ const listEmbeddedUpdates = vi.hoisted(() =>
6
+ vi.fn(async (): Promise<Array<Record<string, unknown>>> => []),
7
+ );
5
8
  const registerEmbeddedUpdate = vi.hoisted(() =>
6
9
  vi.fn(async (input) => ({
7
10
  ...input,
@@ -22,7 +25,7 @@ vi.mock("@/src/server/lib/admin-embedded-updates", async (importOriginal) => {
22
25
  >();
23
26
  return {
24
27
  ...original,
25
- listEmbeddedUpdates: vi.fn(async () => []),
28
+ listEmbeddedUpdates,
26
29
  registerEmbeddedUpdate,
27
30
  };
28
31
  });
@@ -51,6 +54,7 @@ describe("POST /api/admin/embedded-updates", () => {
51
54
  },
52
55
  body: JSON.stringify({
53
56
  id: "55555555-5555-4555-8555-555555555555",
57
+ appVersion: " 2.4.1 ",
54
58
  createdAt: "2026-01-01T00:00:00Z",
55
59
  channel: "Production",
56
60
  platform: "ios",
@@ -66,12 +70,43 @@ describe("POST /api/admin/embedded-updates", () => {
66
70
  );
67
71
  expect(registerEmbeddedUpdate).toHaveBeenCalledWith({
68
72
  embeddedUpdateId: "55555555-5555-4555-8555-555555555555",
73
+ appVersion: "2.4.1",
69
74
  createdAt: "2026-01-01T00:00:00.000Z",
70
75
  channel: "production",
71
76
  platform: "ios",
72
77
  });
73
78
  });
74
79
 
80
+ it("lists appVersion as a nullable per-update value", async () => {
81
+ requireAdminAccess.mockResolvedValue({
82
+ type: "access-token",
83
+ id: "token-id",
84
+ name: "admin",
85
+ scopes: ["updates:read"],
86
+ });
87
+ listEmbeddedUpdates.mockResolvedValueOnce([
88
+ {
89
+ embeddedUpdateId: "55555555-5555-4555-8555-555555555555",
90
+ appVersion: null,
91
+ createdAt: "2026-01-01T00:00:00.000Z",
92
+ channel: "production",
93
+ platform: "ios",
94
+ isEmbedded: true,
95
+ insertedAt: "2026-01-01T00:00:00.000Z",
96
+ modifiedAt: "2026-01-01T00:00:00.000Z",
97
+ },
98
+ ]);
99
+ const { GET } = await import("./route");
100
+ const response = await GET(
101
+ new NextRequest(
102
+ "https://updates.example.com/api/admin/embedded-updates",
103
+ ),
104
+ );
105
+
106
+ expect(response.status).toBe(200);
107
+ expect((await response.json()).items[0].appVersion).toBeNull();
108
+ });
109
+
75
110
  it("rejects invalid registration payloads", async () => {
76
111
  requireAdminAccess.mockResolvedValue({
77
112
  type: "access-token",
@@ -22,7 +22,14 @@ const sessionAuth = vi.hoisted(() => ({
22
22
  }));
23
23
 
24
24
  const getUpdatesPage = vi.hoisted(() =>
25
- vi.fn(async () => ({
25
+ vi.fn(async (): Promise<{
26
+ items: Array<Record<string, unknown>>;
27
+ total: number;
28
+ page: number;
29
+ pageSize: number;
30
+ totalPages: number;
31
+ rollbackLockByScope: Array<Record<string, unknown>>;
32
+ }> => ({
26
33
  items: [],
27
34
  total: 0,
28
35
  page: 1,
@@ -89,6 +96,27 @@ describe("GET /api/admin/updates authorization", () => {
89
96
  expect(getUpdatesPage).toHaveBeenCalledOnce();
90
97
  });
91
98
 
99
+ it("returns the app version associated with each update", async () => {
100
+ tokenAuth.result = {
101
+ id: "token-id",
102
+ name: "CI",
103
+ scopes: ["updates:read"],
104
+ };
105
+ getUpdatesPage.mockResolvedValueOnce({
106
+ items: [{ updateId: "update-id", appVersion: "2.4.1" }],
107
+ total: 1,
108
+ page: 1,
109
+ pageSize: 20,
110
+ totalPages: 1,
111
+ rollbackLockByScope: [],
112
+ });
113
+ const { GET } = await import("./route");
114
+ const response = await GET(makeRequest("ota_test_token"));
115
+
116
+ expect(response.status).toBe(200);
117
+ expect((await response.json()).items[0].appVersion).toBe("2.4.1");
118
+ });
119
+
92
120
  it("rejects a bearer token without updates:read scope", async () => {
93
121
  tokenAuth.result = {
94
122
  id: "token-id",
@@ -102,6 +102,7 @@ export default function EmbeddedUpdatesPage() {
102
102
  <thead className="bg-zinc-100 dark:bg-zinc-800">
103
103
  <tr>
104
104
  <th className="px-4 py-4 text-left">Created At</th>
105
+ <th className="px-4 py-4 text-left">App version</th>
105
106
  <th className="px-4 py-4 text-left">Platform</th>
106
107
  <th className="px-4 py-4 text-left">Channel</th>
107
108
  <th className="px-4 py-4 text-left">Embedded ID</th>
@@ -111,7 +112,7 @@ export default function EmbeddedUpdatesPage() {
111
112
  <tbody>
112
113
  {loading ? (
113
114
  <tr>
114
- <td className="px-3 py-4 text-zinc-500" colSpan={5}>
115
+ <td className="px-3 py-4 text-zinc-500" colSpan={6}>
115
116
  Загрузка...
116
117
  </td>
117
118
  </tr>
@@ -119,7 +120,7 @@ export default function EmbeddedUpdatesPage() {
119
120
 
120
121
  {!loading && items.length === 0 ? (
121
122
  <tr>
122
- <td className="px-3 py-4 text-zinc-500" colSpan={5}>
123
+ <td className="px-3 py-4 text-zinc-500" colSpan={6}>
123
124
  Embedded записи не найдены
124
125
  </td>
125
126
  </tr>
@@ -134,6 +135,9 @@ export default function EmbeddedUpdatesPage() {
134
135
  <td className="px-4 py-4">
135
136
  {new Date(item.createdAt).toLocaleString("uk-UA")}
136
137
  </td>
138
+ <td className="px-4 py-4">
139
+ {item.appVersion || "—"}
140
+ </td>
137
141
  <td className="px-4 py-4">{item.platform}</td>
138
142
  <td className="px-4 py-4">{item.channel}</td>
139
143
  <td className="px-4 py-4 font-mono text-xs">
@@ -160,6 +160,7 @@ export default function UpdatesPage() {
160
160
  <tr>
161
161
  <th className="px-4 py-4 text-left">Дата</th>
162
162
  <th className="px-4 py-4 text-left">Runtime</th>
163
+ <th className="px-4 py-4 text-left">App version</th>
163
164
  <th className="px-4 py-4 text-left">Платформа</th>
164
165
  <th className="px-4 py-4 text-left">Канал</th>
165
166
  <th className="px-4 py-4 text-left">Комментарий</th>
@@ -174,7 +175,7 @@ export default function UpdatesPage() {
174
175
  <tbody>
175
176
  {loading ? (
176
177
  <tr>
177
- <td className="px-3 py-4 text-zinc-500" colSpan={11}>
178
+ <td className="px-3 py-4 text-zinc-500" colSpan={12}>
178
179
  Загрузка...
179
180
  </td>
180
181
  </tr>
@@ -182,7 +183,7 @@ export default function UpdatesPage() {
182
183
 
183
184
  {!loading && items.length === 0 ? (
184
185
  <tr>
185
- <td className="px-3 py-4 text-zinc-500" colSpan={11}>
186
+ <td className="px-3 py-4 text-zinc-500" colSpan={12}>
186
187
  Апдейты не найдены
187
188
  </td>
188
189
  </tr>
@@ -203,6 +204,9 @@ export default function UpdatesPage() {
203
204
  item.createdAtPath}
204
205
  </td>
205
206
  <td className="px-4 py-4">{item.runtimeVersion}</td>
207
+ <td className="px-4 py-4">
208
+ {item.appVersion || "—"}
209
+ </td>
206
210
  <td className="px-4 py-4">{item.platform}</td>
207
211
  <td className="px-4 py-4">{item.channel}</td>
208
212
  <td className="px-4 py-4">
@@ -372,6 +372,7 @@ native binary registers its embedded update:
372
372
 
373
373
  ```text
374
374
  embedded_update_id
375
+ app_version
375
376
  created_at
376
377
  channel
377
378
  platform
@@ -383,6 +384,12 @@ Register the value after each iOS and Android release build in
383
384
  generated Expo embedded manifest, not from a random value created before the
384
385
  build.
385
386
 
387
+ For `app_version`, the registrar keeps a version found in the embedded
388
+ manifest as the highest-priority value. Expo SDKs that omit it there fall back
389
+ to the trimmed string `expo.version` from the project's static `app.json`.
390
+ Missing, blank, malformed or unreadable fallback configuration leaves
391
+ `app_version` null without blocking an otherwise valid registration.
392
+
386
393
  The MIEX application contains a reference implementation:
387
394
 
388
395
  ```text
@@ -457,9 +464,13 @@ Create a dedicated access token with `npm run create-access-token` (or
457
464
 
458
465
  The app configurator installs:
459
466
 
460
- - Android APK/AAB build commands that register `app.manifest` after Gradle;
461
- - an iOS Xcode Build Phase for local Release/Archive builds;
462
- - `ci_scripts/ci_post_xcodebuild.sh` for Xcode Cloud.
467
+ - Android APK/AAB build commands that invoke
468
+ `scripts/ota-register-embedded/register-android.sh` after Gradle;
469
+ - an iOS Xcode Build Phase that invokes
470
+ `scripts/ota-register-embedded/register-ios.sh` for local Release/Archive
471
+ builds;
472
+ - `ci_scripts/ci_post_xcodebuild.sh`, a thin Xcode Cloud adapter that invokes
473
+ the same `register-ios.sh`.
463
474
 
464
475
  Registered binaries are visible at `/updates/embedded`.
465
476
 
@@ -372,9 +372,14 @@ npm run ota:build:android:apk
372
372
  ```
373
373
 
374
374
  Use `npm run ota:build:android:aab` for an App Bundle. After Gradle succeeds,
375
- the generated script finds `app.manifest` and registers the embedded update.
376
- For iOS, the configurator adds an Xcode Build Phase, so a Release/Archive build
377
- in Xcode performs registration automatically.
375
+ `scripts/ota-register-embedded/register-android.sh` finds `app.manifest` and
376
+ registers the embedded update. For iOS, the configurator adds an Xcode Build
377
+ Phase that invokes `scripts/ota-register-embedded/register-ios.sh`, so a
378
+ Release/Archive build in Xcode performs registration automatically.
379
+ The registrar uses an app version from the embedded manifest when available;
380
+ otherwise it falls back to the normalized `expo.version` in the project's
381
+ static `app.json`. A missing or invalid fallback remains `null` and does not
382
+ fail an otherwise valid registration.
378
383
 
379
384
  For remote CI or Xcode Cloud, do not provide PostgreSQL credentials. Create a
380
385
  dedicated token:
@@ -391,10 +396,10 @@ OTA_SERVER_URL=https://updates.example.com
391
396
  OTA_ACCESS_TOKEN=ota_...
392
397
  ```
393
398
 
394
- The configurator also creates `ci_scripts/ci_post_xcodebuild.sh`, which Xcode
395
- Cloud runs after a build. The token is shown only once and must never be
396
- committed or included in the mobile binary. Verify registered binaries at
397
- `/updates/embedded`.
399
+ The configurator also creates `ci_scripts/ci_post_xcodebuild.sh`, a thin Xcode
400
+ Cloud lifecycle adapter that invokes the same `register-ios.sh`. The token is
401
+ shown only once and must never be committed or included in the mobile binary.
402
+ Verify registered binaries at `/updates/embedded`.
398
403
 
399
404
  ## Step 1. Install Expo Updates
400
405
 
@@ -474,9 +474,15 @@ npm run ota:build:android:apk
474
474
  npm run ota:build:android:aab
475
475
  ```
476
476
 
477
- После успешной Gradle-сборки script найдёт `app.manifest` и зарегистрирует
478
- embedded update. Для iOS CLI добавляет Xcode Build Phase, поэтому достаточно
479
- собрать Release/Archive в Xcode.
477
+ После успешной Gradle-сборки
478
+ `scripts/ota-register-embedded/register-android.sh` найдёт `app.manifest` и
479
+ зарегистрирует embedded update. Для iOS CLI добавляет Xcode Build Phase,
480
+ который вызывает `scripts/ota-register-embedded/register-ios.sh`, поэтому
481
+ достаточно собрать Release/Archive в Xcode.
482
+ Версия приложения сначала берётся из embedded manifest, а при её отсутствии —
483
+ из нормализованного `expo.version` в статическом `app.json` проекта. Если
484
+ fallback отсутствует или некорректен, `app_version` остаётся `null`, но
485
+ корректная в остальном регистрация не прерывается.
480
486
 
481
487
  Для удалённого CI или Xcode Cloud не передавайте пароль PostgreSQL. Создайте
482
488
  отдельный access token:
@@ -493,9 +499,10 @@ OTA_SERVER_URL=https://updates.example.com
493
499
  OTA_ACCESS_TOKEN=ota_...
494
500
  ```
495
501
 
496
- CLI также создаёт `ci_scripts/ci_post_xcodebuild.sh`. Xcode Cloud автоматически
497
- запустит его после сборки. Token показывается только один раз и не должен
498
- попадать в Git или в mobile binary.
502
+ CLI также создаёт `ci_scripts/ci_post_xcodebuild.sh` — тонкий lifecycle-адаптер
503
+ Xcode Cloud, который вызывает тот же `register-ios.sh`. Xcode Cloud
504
+ автоматически запустит его после сборки. Token показывается только один раз и
505
+ не должен попадать в Git или в mobile binary.
499
506
 
500
507
  Зарегистрированные binary можно проверить в админ-панели на странице
501
508
  `/updates/embedded`.
@@ -0,0 +1,23 @@
1
+ alter table public.ota_embedded_updates
2
+ add column if not exists app_version text null;
3
+
4
+ create or replace function public.preserve_embedded_update_app_version()
5
+ returns trigger
6
+ language plpgsql
7
+ as $$
8
+ begin
9
+ if tg_op = 'UPDATE' and nullif(btrim(new.app_version), '') is null then
10
+ new.app_version := old.app_version;
11
+ else
12
+ new.app_version := nullif(btrim(new.app_version), '');
13
+ end if;
14
+
15
+ return new;
16
+ end;
17
+ $$;
18
+
19
+ drop trigger if exists trg_ota_embedded_updates_preserve_app_version
20
+ on public.ota_embedded_updates;
21
+ create trigger trg_ota_embedded_updates_preserve_app_version
22
+ before insert or update on public.ota_embedded_updates
23
+ for each row execute function public.preserve_embedded_update_app_version();
@@ -179,6 +179,7 @@ execute function public.ota_channels_validate_scope_pointers();
179
179
  create table if not exists public.ota_embedded_updates (
180
180
  id uuid primary key default gen_random_uuid(),
181
181
  embedded_update_id uuid not null unique,
182
+ app_version text null,
182
183
  created_at timestamptz not null,
183
184
  channel text not null,
184
185
  platform text not null check (platform in ('ios', 'android')),
@@ -196,6 +197,27 @@ create trigger trg_ota_embedded_updates_modified_at
196
197
  before update on public.ota_embedded_updates
197
198
  for each row execute function public.set_modified_at();
198
199
 
200
+ create or replace function public.preserve_embedded_update_app_version()
201
+ returns trigger
202
+ language plpgsql
203
+ as $$
204
+ begin
205
+ if tg_op = 'UPDATE' and nullif(btrim(new.app_version), '') is null then
206
+ new.app_version := old.app_version;
207
+ else
208
+ new.app_version := nullif(btrim(new.app_version), '');
209
+ end if;
210
+
211
+ return new;
212
+ end;
213
+ $$;
214
+
215
+ drop trigger if exists trg_ota_embedded_updates_preserve_app_version
216
+ on public.ota_embedded_updates;
217
+ create trigger trg_ota_embedded_updates_preserve_app_version
218
+ before insert or update on public.ota_embedded_updates
219
+ for each row execute function public.preserve_embedded_update_app_version();
220
+
199
221
  create table if not exists public.ota_served_manifest_log (
200
222
  served_manifest_id uuid primary key,
201
223
  update_id uuid not null
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "expo-updates-server",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "expo-updates-server",
9
- "version": "0.1.2",
9
+ "version": "0.1.4",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-s3": "^3.888.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-updates-server",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -124,6 +124,12 @@ try {
124
124
  : "fill .env.ota.example manually"
125
125
  }`,
126
126
  );
127
+ if (result.migrationWarnings.length > 0) {
128
+ console.warn("\nMigration warnings:");
129
+ for (const warning of result.migrationWarnings) {
130
+ console.warn(`- ${warning}`);
131
+ }
132
+ }
127
133
  console.log("\nNext:");
128
134
  if (!result.publisherEnvConfigured) {
129
135
  console.log(