create-expo-updates-server 0.1.0 → 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 (33) hide show
  1. package/README.md +19 -4
  2. package/dist/template/README.md +24 -10
  3. package/dist/template/app/api/admin/embedded-updates/route.test.ts +36 -1
  4. package/dist/template/app/api/admin/updates/route.test.ts +29 -1
  5. package/dist/template/app/updates/embedded/page.tsx +6 -2
  6. package/dist/template/app/updates/page.tsx +6 -2
  7. package/dist/template/docs/expo-app-setup.md +14 -3
  8. package/dist/template/docs/getting-started.md +12 -7
  9. package/dist/template/docs/getting-started.ru.md +13 -6
  10. package/dist/template/docs/index.md +22 -3
  11. package/dist/template/docs/migrations/2026-09-01-app-version-columns.sql +23 -0
  12. package/dist/template/docs/migrations/schema.sql +22 -0
  13. package/dist/template/docs/npm-installer.md +68 -18
  14. package/dist/template/package-lock.json +2 -67
  15. package/dist/template/package.json +1 -1
  16. package/dist/template/scripts/configure-expo-app.mjs +6 -0
  17. package/dist/template/scripts/lib/embedded-update-registrar.test.ts +383 -3
  18. package/dist/template/scripts/lib/expo-app-configurator.mjs +165 -9
  19. package/dist/template/scripts/lib/expo-app-configurator.test.ts +658 -9
  20. package/dist/template/src/client/admin-types.ts +2 -0
  21. package/dist/template/src/server/lib/admin-embedded-updates.test.ts +57 -0
  22. package/dist/template/src/server/lib/admin-embedded-updates.ts +42 -25
  23. package/dist/template/src/server/lib/admin-updates.test.ts +61 -0
  24. package/dist/template/src/server/lib/admin-updates.ts +23 -3
  25. package/dist/template/templates/expo-app/ci_scripts/ci_post_xcodebuild.sh +23 -1
  26. package/dist/template/templates/expo-app/plugins/with-ota-embedded-registration.js +13 -4
  27. package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +53 -7
  28. package/dist/template/templates/expo-app/scripts/ota-register-embedded/register-ios.sh +87 -0
  29. package/dist/template-manifest.json +70 -55
  30. package/lib/cli.mjs +252 -23
  31. package/package.json +1 -1
  32. package/dist/template/templates/expo-app/ci_scripts/register-embedded-update.sh +0 -36
  33. /package/dist/template/templates/expo-app/scripts/ota-register-embedded/{android-register-embedded-update.sh → register-android.sh} +0 -0
package/README.md CHANGED
@@ -8,11 +8,26 @@ npx create-expo-updates-server@latest my-server
8
8
  cd my-server
9
9
  ```
10
10
 
11
+ To scaffold into an empty current directory instead:
12
+
13
+ ```bash
14
+ mkdir my-server
15
+ cd my-server
16
+ npx create-expo-updates-server@latest .
17
+ ```
18
+
11
19
  The initializer performs no network requests, dependency installation, Git
12
- initialization, or secret generation while scaffolding. The target path must
13
- remain absent while the command runs; the initializer never merges with an
14
- existing path. If scaffolding fails after staging starts, the error reports the
15
- private staging directory left for manual inspection or removal.
20
+ initialization, or secret generation while scaffolding. A named target must
21
+ remain absent while the command runs. The special `.` target is accepted only
22
+ when it resolves to the current directory and that directory starts empty.
23
+ The initializer verifies a private sibling staging snapshot before installing
24
+ it and never merges with an existing entry. If installation into `.` stops
25
+ after creating files, it reports the partial output for manual review rather
26
+ than recursively deleting the current directory.
27
+
28
+ Successful output provides numbered Docker and npm paths. When `.` is used,
29
+ those steps start directly with configuration or installation instead of
30
+ asking you to change into the directory again.
16
31
 
17
32
  See the
18
33
  [installer documentation](https://github.com/tonichiga/expo-updates-server/blob/main/docs/npm-installer.md)
@@ -1,5 +1,7 @@
1
1
  # Expo Updates Server
2
2
 
3
+ ## Install with NPX
4
+
3
5
  The easiest way to create a standalone server project is the npm initializer:
4
6
 
5
7
  ```bash
@@ -7,9 +9,16 @@ npx create-expo-updates-server@latest my-server
7
9
  cd my-server
8
10
  ```
9
11
 
12
+ To install into the current empty directory:
13
+
14
+ ```bash
15
+ npx create-expo-updates-server@latest .
16
+ ```
17
+
10
18
  The downloaded initializer uses its bundled, checksum-verified template. It
11
19
  does not fetch source code, install project dependencies, initialize Git, or
12
- create secrets while scaffolding. The target path must not already exist.
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.
13
22
  Continue with either Docker:
14
23
 
15
24
  ```bash
@@ -25,8 +34,8 @@ cp .env.example .env.local
25
34
  npm run dev
26
35
  ```
27
36
 
28
- See the [npm initializer guide](docs/npm-installer.md) for safety behavior and
29
- complete next steps. Cloning the
37
+ See the [npm initializer guide](docs/npm-installer.md) for supported commands,
38
+ safety behavior, and complete next steps. Cloning the
30
39
  [GitHub repository](https://github.com/tonichiga/expo-updates-server) remains
31
40
  supported for contributors and manual installations.
32
41
 
@@ -363,9 +372,14 @@ npm run ota:build:android:apk
363
372
  ```
364
373
 
365
374
  Use `npm run ota:build:android:aab` for an App Bundle. After Gradle succeeds,
366
- the generated script finds `app.manifest` and registers the embedded update.
367
- For iOS, the configurator adds an Xcode Build Phase, so a Release/Archive build
368
- 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.
369
383
 
370
384
  For remote CI or Xcode Cloud, do not provide PostgreSQL credentials. Create a
371
385
  dedicated token:
@@ -382,10 +396,10 @@ OTA_SERVER_URL=https://updates.example.com
382
396
  OTA_ACCESS_TOKEN=ota_...
383
397
  ```
384
398
 
385
- The configurator also creates `ci_scripts/ci_post_xcodebuild.sh`, which Xcode
386
- Cloud runs after a build. The token is shown only once and must never be
387
- committed or included in the mobile binary. Verify registered binaries at
388
- `/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`.
389
403
 
390
404
  ## Step 1. Install Expo Updates
391
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`.
@@ -7,11 +7,11 @@ hero:
7
7
  tagline: Self-host signed updates, promote releases deliberately, roll back safely, and recover misconfigured native builds.
8
8
  actions:
9
9
  - theme: brand
10
+ text: Install with NPX
11
+ link: /npm-installer
12
+ - theme: alt
10
13
  text: Quick Start
11
14
  link: /getting-started
12
- - theme: alt
13
- text: Быстрый старт
14
- link: /getting-started.ru
15
15
  - theme: alt
16
16
  text: View on GitHub
17
17
  link: https://github.com/tonichiga/expo-updates-server
@@ -37,6 +37,25 @@ features:
37
37
  details: Manage role-based access, scoped automation tokens, embedded builds, and release history from the admin panel.
38
38
  ---
39
39
 
40
+ ## Install in seconds
41
+
42
+ Create a new project directory:
43
+
44
+ ```bash
45
+ npx create-expo-updates-server@latest my-server
46
+ cd my-server
47
+ ```
48
+
49
+ Or initialize the current empty directory:
50
+
51
+ ```bash
52
+ npx create-expo-updates-server@latest .
53
+ ```
54
+
55
+ The initializer bundles and verifies the complete server template. Continue
56
+ with the [npm initializer guide](/npm-installer) for Docker and local npm
57
+ startup commands.
58
+
40
59
  ## Choose your path
41
60
 
42
61
  Create a standalone project with the
@@ -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
@@ -8,36 +8,86 @@ npx create-expo-updates-server@latest my-server
8
8
  cd my-server
9
9
  ```
10
10
 
11
+ You can also initialize an empty current directory:
12
+
13
+ ```bash
14
+ mkdir my-server
15
+ cd my-server
16
+ npx create-expo-updates-server@latest .
17
+ ```
18
+
11
19
  `npx` downloads the published initializer package from npm. After it starts,
12
20
  the initializer makes no network requests: the server template and its
13
21
  SHA-256 manifest are bundled in the package.
14
22
 
23
+ For a named target, successful plain-text output looks like this (interactive
24
+ terminals add color):
25
+
26
+ ```text
27
+ ✓ Expo Updates Server is ready
28
+ Project: /path/to/my-server
29
+
30
+ Next steps (Docker):
31
+ 1. cd -- 'my-server'
32
+ 2. cp .env.docker.example .env
33
+ 3. docker compose up -d --build
34
+ 4. docker compose exec app npm run create-admin
35
+
36
+ Next steps (npm):
37
+ 1. cd -- 'my-server'
38
+ 2. npm ci
39
+ 3. cp .env.example .env.local
40
+ 4. npm run dev
41
+ ```
42
+
43
+ With `.`, the redundant `cd` step is omitted. Color is disabled when output is
44
+ not a TTY or the `NO_COLOR` environment variable is present.
45
+
15
46
  ## Safety behavior
16
47
 
17
48
  The initializer:
18
49
 
19
50
  - accepts exactly one destination directory;
20
- - requires the destination path not to exist and refuses existing empty or
21
- non-empty directories, files, and symbolic links;
51
+ - requires a named destination path not to exist and refuses existing empty
52
+ or non-empty directories, files, and symbolic links;
53
+ - accepts an existing destination only when it resolves exactly to the current
54
+ directory and that directory has no visible or hidden entries;
22
55
  - creates a unique sibling staging directory with mode `0700`;
23
56
  - builds the complete project in staging and verifies its full path set, file
24
57
  types, sizes, and SHA-256 digests before installation;
25
- - checks the destination again immediately before one final rename, so normal
26
- installation exposes either the complete verified project or no project;
27
- - never merges files, incrementally copies into the destination, or
28
- recursively deletes the destination;
29
- - leaves the unique staging directory in place after any failure and reports
30
- its exact path for manual inspection or removal.
31
-
32
- The destination must remain absent for the entire command. If another process
33
- creates a file, symbolic link, or non-empty directory before the final rename,
34
- the initializer fails and leaves it unchanged. Portable filesystem APIs do not
35
- provide a cross-platform, atomic no-clobber directory rename. In the narrow
36
- race where another process creates an empty destination directory after the
37
- last absence check, the rename may replace that empty directory.
38
-
39
- Staging contains only public template files. On success, the final rename
40
- consumes it, so no staging directory remains.
58
+ - installs an absent named destination with the existing staging-directory
59
+ rename flow;
60
+ - checks the current directory's device, inode, and emptiness again immediately
61
+ before installing `.`, creates directories exclusively, copies files with
62
+ no-clobber semantics, and verifies the final full path set, sizes, and
63
+ SHA-256 digests;
64
+ - never overwrites an entry encountered while installing `.` and never
65
+ recursively deletes the current directory;
66
+ - once staging has started, leaves the unique staging directory in place after
67
+ a failure and reports its exact path for manual inspection or removal; if `.`
68
+ contains partial installer output, that is also reported for manual review.
69
+
70
+ An absent named destination must remain absent for the entire command. If
71
+ another process creates a file, symbolic link, or non-empty directory before
72
+ the final rename, the initializer fails and leaves it unchanged. Portable
73
+ filesystem APIs do not provide a cross-platform, atomic no-clobber directory
74
+ rename. In the narrow race where another process creates an empty named
75
+ destination directory after the last absence check, the rename may replace
76
+ that empty directory.
77
+
78
+ Installing into `.` necessarily transfers entries rather than replacing the
79
+ current directory itself. Exclusive operations prevent the initializer from
80
+ overwriting an entry that appears at a destination path during normal
81
+ concurrent use. If installation fails after creating some entries, those
82
+ entries are deliberately not removed because they can no longer be safely
83
+ distinguished from user changes. Review the reported current directory and
84
+ staging snapshot manually. These checks are safety measures for normal
85
+ filesystem races, not a security boundary against another process running as
86
+ the same user.
87
+
88
+ Staging contains only public template files. On success, it is consumed by the
89
+ named-target rename or removed after the verified `.` transfer, so no staging
90
+ directory remains.
41
91
 
42
92
  It deliberately does not install dependencies, initialize a Git repository,
43
93
  write `.env` files, or generate signing keys and other secrets. There is no