create-expo-updates-server 0.2.1 → 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.
Files changed (41) hide show
  1. package/dist/template/docs/expo-app-setup.md +8 -12
  2. package/dist/template/docs/getting-started.md +5 -5
  3. package/dist/template/docs/getting-started.ru.md +5 -5
  4. package/dist/template/docs/ota-client-lifecycle.md +46 -42
  5. package/dist/template/package-lock.json +589 -0
  6. package/dist/template/package.json +1 -0
  7. package/dist/template/scripts/lib/device-identity.test.ts +2 -2
  8. package/dist/template/scripts/lib/doctor.mjs +3 -3
  9. package/dist/template/scripts/lib/doctor.test.mjs +1 -1
  10. package/dist/template/scripts/lib/ota-client-configurator.mjs +116 -34
  11. package/dist/template/scripts/lib/ota-client-configurator.test.ts +210 -61
  12. package/dist/template/scripts/lib/ota-client.test.ts +1 -1
  13. package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +435 -118
  14. package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +243 -86
  15. package/dist/template/scripts/lib/ota-update-controller.test.ts +10 -9
  16. package/dist/template/scripts/lib/ota-updates-ui.test.tsx +154 -0
  17. package/dist/template/scripts/tests/fixtures/react-native-ui.tsx +34 -0
  18. package/dist/template/scripts/tests/ota-client-types.mjs +69 -0
  19. package/dist/template/templates/expo-app/ota-client/README.md +16 -2
  20. package/dist/template/templates/expo-app/ota-client/controller.ts +107 -0
  21. package/dist/template/templates/expo-app/ota-client/device-identity.ts +48 -0
  22. package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +18 -9
  23. package/dist/template/templates/expo-app/ota-client/index.ts +16 -0
  24. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +97 -0
  25. package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +293 -0
  26. package/dist/template/templates/expo-app/ota-client/runtime.ts +153 -0
  27. package/dist/template/templates/expo-app/ota-client/types.ts +85 -0
  28. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +25 -0
  29. package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +196 -0
  30. package/dist/template/tsconfig.json +3 -1
  31. package/dist/template/vitest.config.mts +3 -0
  32. package/dist/template-manifest.json +85 -65
  33. package/package.json +1 -1
  34. package/dist/template/templates/expo-app/ota-client/controller.js +0 -60
  35. package/dist/template/templates/expo-app/ota-client/device-identity.js +0 -26
  36. package/dist/template/templates/expo-app/ota-client/index.d.ts +0 -47
  37. package/dist/template/templates/expo-app/ota-client/index.js +0 -3
  38. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.js +0 -48
  39. package/dist/template/templates/expo-app/ota-client/model/update-controller.js +0 -182
  40. package/dist/template/templates/expo-app/ota-client/runtime.js +0 -112
  41. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.js +0 -56
@@ -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 inserts `useOtaUpdates` into `src/app/_layout` (or `app/_layout`)
38
- and wraps the root's rendered content with `OtaUpdateGate`. Standard `App`
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 initial hook
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
- hook/gate or replace the stored original entry. Change a hook option in the root
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
- Use the generated `useOtaUpdates` controller with `OtaUpdateGate` in the root
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
- const ota = useOtaUpdates({
464
- autoCheck: true,
465
- autoUpdate: false,
466
- autoReload: false,
467
- });
463
+ <OtaUpdates autoCheck autoUpdate={false} autoReload={false} />
468
464
  ```
469
465
 
470
- Screens use `useOtaUpdates()` and its `check()`, `download()` and `reload()` methods.
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"`.
@@ -351,7 +351,7 @@ npm run configure-app
351
351
 
352
352
  Select the app directory, certificate, public URL, channel, runtime and platform.
353
353
  The CLI installs dependencies, configures native updates, generates the identity
354
- and telemetry client, inserts the root hook/gate, installs publisher/registration
354
+ and telemetry client, inserts the standalone root component, installs publisher/registration
355
355
  scripts and runs prebuild. Review its summary before applying changes.
356
356
 
357
357
  For flags, supported root components and reruns, see
@@ -384,10 +384,10 @@ a server running directly with npm. See [embedded registration](./expo-app-setup
384
384
 
385
385
  Before building, choose how the app will download and apply updates.
386
386
 
387
- The generated root checks automatically, but defaults to manual download/restart.
388
- Add the [manual controls example](./ota-client-lifecycle.md#_3-add-manual-update-controls)
389
- to a test screen, or explicitly configure automation using the [hook options](./ota-client-lifecycle.md).
390
- The generator does not add test buttons to your application's UI.
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).
391
391
 
392
392
  From the **application directory**, with the Android toolchain installed:
393
393
 
@@ -458,12 +458,12 @@ credentials; административный access token их не замен
458
458
 
459
459
  До сборки выберите, как приложение будет скачивать и применять обновления.
460
460
 
461
- Созданный root-хук проверяет обновления автоматически, но скачивание и перезапуск
462
- по умолчанию ручные. Добавьте на тестовый экран [пример кнопок](./ota-client-lifecycle.md#_3-add-manual-update-controls)
463
- или явно включите автоматизацию через [параметры хука](./ota-client-lifecycle.md).
464
- Генератор не добавляет тестовые кнопки в интерфейс приложения.
461
+ Созданный `<OtaUpdates />` проверяет обновления автоматически и показывает кнопки
462
+ скачивания, перезапуска и откладывания. Для автоматического скачивания включите
463
+ `autoUpdate`, для автоматического перезапуска — `autoReload`. Дополнительные кнопки
464
+ в экранах приложения не обязательны. См. [режимы обновления](./ota-client-lifecycle.md).
465
465
 
466
- Из **папки приложения**, с установленным Android toolchain:
466
+ Из **папки приложения** с установленным Android toolchain:
467
467
 
468
468
  ```bash
469
469
  npm run ota:build:android:apk
@@ -1,11 +1,20 @@
1
1
  # Generated OTA client lifecycle
2
2
 
3
- `configure-app` inserts `useOtaUpdates({ autoCheck: true, autoUpdate: false,
4
- autoReload: false })` in the root layout/App and wraps its content in `OtaUpdateGate`.
5
- All screens can call `useOtaUpdates()` to observe the same state and use `check()`,
6
- `download()` and `reload()`. No provider is needed. Configure automation in one root;
7
- additional consumers default to observation/manual actions. Multiple configured roots
8
- combine boolean options with OR. Guard handlers should be stable references.
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 | Check exposes candidate; caller downloads and reloads |
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
- It is customizable with `renderBlocked`. Keep the gate mounted around
33
- the application; a hook alone exposes `blocked` but cannot prevent interaction with
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 hook/gate in
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
- const ota = useOtaUpdates({
68
- autoCheck: true,
69
- autoUpdate: false,
70
- autoReload: false,
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 the existing
82
- `--force` flow when replacing generated files. Native dependencies need a new binary;
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.js`, `ota-client/index.d.ts` and `ota-client/config.json` already
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, add the hook to the existing `src/app/_layout.tsx`. This minimal
142
- example shows the integration; preserve your current navigation, providers, fonts,
143
- splash-screen handling and other layout code inside the gate:
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 { OtaUpdateGate, useOtaUpdates } from '../../ota-client';
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
- <OtaUpdateGate controller={ota}>
164
+ <>
165
+ <OtaUpdates autoCheck autoUpdate={false} autoReload={false} />
158
166
  <Stack />
159
- </OtaUpdateGate>
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, call the hook in your existing function `App` and
173
- wrap its existing returned content with the same gate. A class component can stay
174
- inside a function wrapper that owns the hook. Call the hook unconditionally, before
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
- The gate is required for the default force-update UI. Using the hook without it
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 above checks automatically but leaves ordinary manual-policy updates for
195
- the user to download and apply. A separate screen can subscribe without enabling
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';