create-expo-updates-server 0.3.0 → 0.6.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 (191) hide show
  1. package/README.md +4 -2
  2. package/dist/template/Dockerfile +4 -6
  3. package/dist/template/README.md +5 -10
  4. package/dist/template/app/api/admin/device-favorites/route.test.ts +125 -0
  5. package/dist/template/app/api/admin/device-favorites/route.ts +91 -0
  6. package/dist/template/app/api/admin/distribution-history/restore/route.ts +39 -0
  7. package/dist/template/app/api/admin/distribution-history/route.test.ts +55 -0
  8. package/dist/template/app/api/admin/distribution-history/route.ts +24 -0
  9. package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +2 -1
  10. package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +2 -1
  11. package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +2 -1
  12. package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +2 -1
  13. package/dist/template/app/api/admin/updates/route.test.ts +21 -0
  14. package/dist/template/app/api/admin/updates/route.ts +12 -1
  15. package/dist/template/app/globals.css +65 -68
  16. package/dist/template/app/login/page.tsx +66 -42
  17. package/dist/template/app/updates/[encodedKey]/page.tsx +382 -248
  18. package/dist/template/app/updates/devices/page.tsx +187 -145
  19. package/dist/template/app/updates/embedded/page.tsx +80 -34
  20. package/dist/template/app/updates/emergency-redirects/page.tsx +138 -71
  21. package/dist/template/app/updates/layout.tsx +2 -1
  22. package/dist/template/app/updates/page.tsx +385 -274
  23. package/dist/template/app/updates/releases.test.tsx +156 -0
  24. package/dist/template/components/admin/admin-role.ts +5 -0
  25. package/dist/template/components/admin/admin-shell.tsx +166 -95
  26. package/dist/template/components/admin/confirm-action.tsx +123 -0
  27. package/dist/template/components/admin/language-switcher.tsx +27 -16
  28. package/dist/template/components/admin/release-badges.test.tsx +50 -0
  29. package/dist/template/components/admin/release-badges.tsx +101 -0
  30. package/dist/template/components/ui/alert.tsx +10 -3
  31. package/dist/template/components/ui/avatar.tsx +108 -0
  32. package/dist/template/components/ui/badge.tsx +2 -2
  33. package/dist/template/components/ui/breadcrumb.tsx +108 -0
  34. package/dist/template/components/ui/button.tsx +5 -5
  35. package/dist/template/components/ui/card.tsx +2 -2
  36. package/dist/template/components/ui/chart.tsx +1 -1
  37. package/dist/template/components/ui/collapsible.tsx +7 -0
  38. package/dist/template/components/ui/dialog.tsx +13 -4
  39. package/dist/template/components/ui/empty.tsx +103 -0
  40. package/dist/template/components/ui/field.tsx +248 -0
  41. package/dist/template/components/ui/input-group.tsx +170 -0
  42. package/dist/template/components/ui/input.tsx +1 -1
  43. package/dist/template/components/ui/native-select.tsx +1 -1
  44. package/dist/template/components/ui/radio-group.tsx +41 -0
  45. package/dist/template/components/ui/sheet.tsx +6 -2
  46. package/dist/template/components/ui/sidebar.tsx +62 -17
  47. package/dist/template/components/ui/status-tones.ts +15 -0
  48. package/dist/template/components/ui/table.tsx +1 -1
  49. package/dist/template/components/ui/textarea.tsx +1 -1
  50. package/dist/template/docs/admin-ui.md +22 -24
  51. package/dist/template/docs/device-targeting.md +6 -12
  52. package/dist/template/docs/doctor.md +2 -2
  53. package/dist/template/docs/expo-app-setup.md +9 -27
  54. package/dist/template/docs/getting-started.md +3 -4
  55. package/dist/template/docs/getting-started.ru.md +11 -544
  56. package/dist/template/docs/index.md +1 -1
  57. package/dist/template/docs/installation-telemetry.md +6 -12
  58. package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
  59. package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
  60. package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
  61. package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
  62. package/dist/template/docs/migrations/schema.sql +349 -0
  63. package/dist/template/docs/npm-installer.md +3 -3
  64. package/dist/template/docs/operations-guide.md +9 -7
  65. package/dist/template/docs/ota-client-lifecycle.md +30 -68
  66. package/dist/template/docs/ota-emergency-recovery.md +34 -57
  67. package/dist/template/docs/ota-update-policy.md +9 -20
  68. package/dist/template/docs/ru/admin-ui.md +33 -0
  69. package/dist/template/docs/ru/device-targeting.md +59 -0
  70. package/dist/template/docs/ru/doctor.md +98 -0
  71. package/dist/template/docs/ru/expo-app-setup.md +497 -0
  72. package/dist/template/docs/ru/getting-started.md +391 -0
  73. package/dist/template/docs/ru/index.md +50 -0
  74. package/dist/template/docs/ru/installation-telemetry.md +125 -0
  75. package/dist/template/docs/ru/npm-installer.md +71 -0
  76. package/dist/template/docs/ru/operations-guide.md +322 -0
  77. package/dist/template/docs/ru/ota-client-lifecycle.md +162 -0
  78. package/dist/template/docs/ru/ota-emergency-recovery.md +108 -0
  79. package/dist/template/docs/ru/ota-update-policy.md +69 -0
  80. package/dist/template/docs/ru/publishing-npm-installer.md +49 -0
  81. package/dist/template/docs/ru/supabase-setup.md +120 -0
  82. package/dist/template/docs/uk/admin-ui.md +33 -0
  83. package/dist/template/docs/uk/device-targeting.md +59 -0
  84. package/dist/template/docs/uk/doctor.md +98 -0
  85. package/dist/template/docs/uk/expo-app-setup.md +497 -0
  86. package/dist/template/docs/uk/getting-started.md +391 -0
  87. package/dist/template/docs/uk/index.md +50 -0
  88. package/dist/template/docs/uk/installation-telemetry.md +125 -0
  89. package/dist/template/docs/uk/npm-installer.md +71 -0
  90. package/dist/template/docs/uk/operations-guide.md +322 -0
  91. package/dist/template/docs/uk/ota-client-lifecycle.md +162 -0
  92. package/dist/template/docs/uk/ota-emergency-recovery.md +108 -0
  93. package/dist/template/docs/uk/ota-update-policy.md +69 -0
  94. package/dist/template/docs/uk/publishing-npm-installer.md +49 -0
  95. package/dist/template/docs/uk/supabase-setup.md +120 -0
  96. package/dist/template/lib/audience-ids.ts +4 -0
  97. package/dist/template/package-lock.json +46 -0
  98. package/dist/template/package.json +4 -1
  99. package/dist/template/scripts/configure-expo-app.mjs +3 -3
  100. package/dist/template/scripts/create-access-token.mjs +1 -1
  101. package/dist/template/scripts/lib/doctor.mjs +10 -7
  102. package/dist/template/scripts/lib/doctor.test.mjs +7 -5
  103. package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
  104. package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
  105. package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
  106. package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
  107. package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
  108. package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
  109. package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
  110. package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
  111. package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
  112. package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
  113. package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
  114. package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
  115. package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
  116. package/dist/template/scripts/tests/e2e/console.mjs +86 -0
  117. package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
  118. package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
  119. package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
  120. package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
  121. package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
  122. package/dist/template/scripts/tests/e2e/release-matrix.mjs +307 -0
  123. package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
  124. package/dist/template/scripts/tests/e2e/run.mjs +224 -0
  125. package/dist/template/scripts/tests/manifest-identity.sql +7 -5
  126. package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
  127. package/dist/template/src/client/admin-api.ts +45 -10
  128. package/dist/template/src/client/admin-types.ts +35 -1
  129. package/dist/template/src/client/devices/analytics.tsx +169 -219
  130. package/dist/template/src/client/devices/cohorts.tsx +181 -0
  131. package/dist/template/src/client/devices/device-name.tsx +37 -21
  132. package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
  133. package/dist/template/src/client/devices/registry.tsx +265 -233
  134. package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
  135. package/dist/template/src/client/devices/use-devices-report.ts +53 -82
  136. package/dist/template/src/client/devices/version-adoption-chart.tsx +48 -38
  137. package/dist/template/src/client/distribution-control.tsx +98 -53
  138. package/dist/template/src/client/distribution-history.tsx +353 -0
  139. package/dist/template/src/client/guard-action-catalog.tsx +183 -0
  140. package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
  141. package/dist/template/src/client/guard-action-combobox.tsx +134 -234
  142. package/dist/template/src/client/guard-action-options.ts +4 -6
  143. package/dist/template/src/client/i18n/en.json +335 -2
  144. package/dist/template/src/client/i18n/language-switching.test.tsx +233 -0
  145. package/dist/template/src/client/i18n/messages.test.ts +102 -19
  146. package/dist/template/src/client/i18n/messages.ts +31 -16
  147. package/dist/template/src/client/i18n/provider.tsx +6 -3
  148. package/dist/template/src/client/i18n/ru.json +619 -0
  149. package/dist/template/src/client/i18n/uk.json +619 -0
  150. package/dist/template/src/client/i18n/use-formatters.ts +5 -0
  151. package/dist/template/src/client/logout-button.tsx +3 -3
  152. package/dist/template/src/client/policy-draft.ts +138 -0
  153. package/dist/template/src/client/update-audience-editor.tsx +597 -199
  154. package/dist/template/src/client/update-policy-editor.test.ts +101 -29
  155. package/dist/template/src/client/update-policy-editor.tsx +466 -307
  156. package/dist/template/src/client/use-filtered-results.ts +55 -0
  157. package/dist/template/src/server/controllers/manifest.test.ts +23 -3
  158. package/dist/template/src/server/controllers/manifest.ts +15 -1
  159. package/dist/template/src/server/devices/audience.ts +9 -5
  160. package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
  161. package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
  162. package/dist/template/src/server/lib/admin-updates.ts +160 -534
  163. package/dist/template/src/server/lib/distribution-history.ts +97 -0
  164. package/dist/template/src/server/lib/supabase.js +24 -0
  165. package/dist/template/src/server/lib/supabase.test.ts +38 -1
  166. package/dist/template/src/server/lib/update-policy.test.ts +20 -0
  167. package/dist/template/src/server/lib/update-policy.ts +23 -10
  168. package/dist/template/src/server/manifest/manifest-repository.ts +11 -3
  169. package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
  170. package/dist/template/src/server/manifest/manifest-values.ts +21 -13
  171. package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
  172. package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
  173. package/dist/template/tsconfig.json +2 -2
  174. package/dist/template-manifest.json +571 -271
  175. package/package.json +1 -1
  176. package/dist/template/scripts/lib/device-identity.test.ts +0 -29
  177. package/dist/template/scripts/lib/ota-client.test.ts +0 -55
  178. package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
  179. package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
  180. package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
  181. package/dist/template/templates/expo-app/ota-client/README.md +0 -73
  182. package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
  183. package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
  184. package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
  185. package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
  186. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
  187. package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
  188. package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
  189. package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
  190. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
  191. package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process";
2
2
  import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
- import { pathToFileURL } from "node:url";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import vm from "node:vm";
7
7
  import { afterEach, describe, expect, it } from "vitest";
8
8
 
@@ -27,12 +27,15 @@ function createIosRegistrarFixture() {
27
27
  const iosRegistrar = path.join(registrarDirectory, "register-ios.sh");
28
28
  const jsRegistrar = path.join(registrarDirectory, "index.mjs");
29
29
  fs.mkdirSync(registrarDirectory, { recursive: true });
30
- fs.copyFileSync(
31
- path.resolve(
32
- "templates/expo-app/scripts/ota-register-embedded/register-ios.sh",
33
- ),
34
- iosRegistrar,
30
+ // Confine the Xcode/Homebrew fallback paths to this simulated build host.
31
+ const registrar = fs.readFileSync(
32
+ path.resolve("templates/expo-app/scripts/ota-register-embedded/register-ios.sh"),
33
+ "utf8",
35
34
  );
35
+ fs.writeFileSync(iosRegistrar, registrar.replace(
36
+ /"(\/(?:opt\/homebrew|usr\/local)\/bin\/node)"/g,
37
+ (_, absolutePath) => JSON.stringify(projectRoot + absolutePath),
38
+ ));
36
39
  fs.writeFileSync(jsRegistrar, "// Fake registrar; fake Node must run this.\n");
37
40
 
38
41
  const targetBuildDirectory = path.join(projectRoot, "build");
@@ -61,7 +64,9 @@ fi
61
64
  );
62
65
  fs.chmodSync(fakeNode, 0o755);
63
66
 
64
- const pathWithoutNode = "/usr/bin:/bin";
67
+ const pathWithoutNode = path.join(projectRoot, "bin");
68
+ fs.mkdirSync(pathWithoutNode);
69
+ fs.symlinkSync("/usr/bin/dirname", path.join(pathWithoutNode, "dirname"));
65
70
  const env = {
66
71
  ...process.env,
67
72
  PATH: pathWithoutNode,
@@ -442,3 +447,13 @@ describe("embedded update registrar", () => {
442
447
  );
443
448
  });
444
449
  });
450
+
451
+ it("executes the embedded registrar when Xcode invokes a symlinked path", () => {
452
+ const scratch = fs.mkdtempSync(path.join(os.tmpdir(), "ota-cli-link-"));
453
+ temporaryDirectories.push(scratch);
454
+ const entry = path.join(scratch, "register.mjs");
455
+ fs.symlinkSync(fileURLToPath(registrarUrl), entry);
456
+ const result = spawnSync(process.execPath, [entry, "--platform", "ios"], { encoding: "utf8" });
457
+ expect(result.status).toBe(1);
458
+ expect(result.stderr).toContain("Embedded update registration failed");
459
+ });
@@ -1,4 +1,5 @@
1
- import { planOtaClient } from './ota-client-configurator.mjs';
1
+ import { planOtaClient } from "./ota-client-configurator.mjs";
2
+ import { clientPackage, clientVersion, nativeClientDependencies } from "./ota-client-package.mjs";
2
3
  import { execFileSync } from "node:child_process";
3
4
  import crypto from "node:crypto";
4
5
  import fs from "node:fs";
@@ -7,7 +8,9 @@ import { fileURLToPath } from "node:url";
7
8
 
8
9
  const CHANNEL_PATTERN = /^[a-z0-9][a-z0-9._-]{0,63}$/;
9
10
  const LEGACY_GENERATED_FILE_SHA256 = {
11
+ publisherDatabaseClient: "79fd8aea1fa626485f83c1b3bf5b234317c5bcadd64dac7c6c9faddc490cbe62",
10
12
  embeddedRegistrars: [
13
+ "6d2201f51851d9af41449f8da3653a4792cddb30d411d59e3c161adbc5cf76ff",
11
14
  "29c48288d4804c072129da0ef60a12ad0892809eb8d57a14be94d039d990d6d7",
12
15
  "89997ef11a939ce00e65159bd8e04845f16b184d5192f8fb56b1bc4204b07bca",
13
16
  ],
@@ -137,6 +140,7 @@ function detectPackageManager(appRoot) {
137
140
  }
138
141
 
139
142
  function getPackageCommands(packageManager, platform) {
143
+ const clientInstallArgs = ["expo", "install", ...nativeClientDependencies, `${clientPackage}@${clientVersion}`];
140
144
  const prebuildArgs = ["expo", "prebuild"];
141
145
  if (platform !== "all") {
142
146
  prebuildArgs.push("--platform", platform);
@@ -144,7 +148,7 @@ function getPackageCommands(packageManager, platform) {
144
148
 
145
149
  if (packageManager === "pnpm") {
146
150
  return {
147
- installExpoUpdates: ["pnpm", ["exec", "expo", "install", "expo-updates", "expo-application", "expo-crypto", "expo-secure-store", "@react-native-async-storage/async-storage"]],
151
+ installExpoUpdates: ["pnpm", ["exec", ...clientInstallArgs]],
148
152
  installPublisherDependencies: [
149
153
  "pnpm",
150
154
  ["add", "--save-dev", ...PUBLISHER_DEPENDENCIES],
@@ -155,7 +159,7 @@ function getPackageCommands(packageManager, platform) {
155
159
 
156
160
  if (packageManager === "yarn") {
157
161
  return {
158
- installExpoUpdates: ["yarn", ["expo", "install", "expo-updates", "expo-application", "expo-crypto", "expo-secure-store", "@react-native-async-storage/async-storage"]],
162
+ installExpoUpdates: ["yarn", clientInstallArgs],
159
163
  installPublisherDependencies: [
160
164
  "yarn",
161
165
  ["add", "--dev", ...PUBLISHER_DEPENDENCIES],
@@ -166,7 +170,7 @@ function getPackageCommands(packageManager, platform) {
166
170
 
167
171
  if (packageManager === "bun") {
168
172
  return {
169
- installExpoUpdates: ["bunx", ["expo", "install", "expo-updates", "expo-application", "expo-crypto", "expo-secure-store", "@react-native-async-storage/async-storage"]],
173
+ installExpoUpdates: ["bunx", clientInstallArgs],
170
174
  installPublisherDependencies: [
171
175
  "bun",
172
176
  ["add", "--dev", ...PUBLISHER_DEPENDENCIES],
@@ -176,7 +180,7 @@ function getPackageCommands(packageManager, platform) {
176
180
  }
177
181
 
178
182
  return {
179
- installExpoUpdates: ["npx", ["expo", "install", "expo-updates", "expo-application", "expo-crypto", "expo-secure-store", "@react-native-async-storage/async-storage"]],
183
+ installExpoUpdates: ["npx", clientInstallArgs],
180
184
  installPublisherDependencies: [
181
185
  "npm",
182
186
  ["install", "--save-dev", ...PUBLISHER_DEPENDENCIES],
@@ -461,15 +465,6 @@ function patchPackageJson(packageJson, platform) {
461
465
  return packageJson;
462
466
  }
463
467
 
464
- function patchPublisherEnvExample(filePath, channel) {
465
- const current = fs.readFileSync(filePath, "utf8");
466
- const next = current.replace(
467
- /^EXPO_UPDATE_CHANNEL=.*$/m,
468
- `EXPO_UPDATE_CHANNEL=${channel}`,
469
- );
470
- fs.writeFileSync(filePath, next, "utf8");
471
- }
472
-
473
468
  function validateProject(appRoot) {
474
469
  const packagePath = path.join(appRoot, "package.json");
475
470
  const appJsonPath = path.join(appRoot, "app.json");
@@ -561,7 +556,7 @@ export function configureExpoApp(
561
556
  validateCertificate(certificatePath);
562
557
  const manifestUrl = resolveManifestUrl(rawOptions.serverUrl);
563
558
  const project = validateProject(appRoot);
564
- const clientPlan = planOtaClient({ appRoot, templateRoot, packageJson: project.packageJson, manifestUrl, channel, force });
559
+ const clientPlan = planOtaClient({ appRoot, packageJson: project.packageJson, manifestUrl, channel, force });
565
560
  const packageManager = detectPackageManager(appRoot);
566
561
  const commands = getPackageCommands(packageManager, platform);
567
562
  const certificateDestination = path.join(
@@ -714,9 +709,18 @@ export function configureExpoApp(
714
709
  exportCommandDestination,
715
710
  force,
716
711
  );
717
- assertCopyAllowed(envExampleSource, envExampleDestination, force);
712
+ const envExample = fs.readFileSync(envExampleSource, "utf8").replace(
713
+ /^EXPO_UPDATE_CHANNEL=.*$/m,
714
+ `EXPO_UPDATE_CHANNEL=${channel}`,
715
+ );
716
+ if (fs.existsSync(envExampleDestination) && fs.readFileSync(envExampleDestination, "utf8") !== envExample) {
717
+ assertCopyAllowed(envExampleSource, envExampleDestination, force);
718
+ }
718
719
  for (const file of publisherFiles) {
719
- assertCopyAllowed(file.source, file.destination, force);
720
+ const knownVersions = file.source === path.join(publisherTemplateRoot, "api", "database-client.mjs")
721
+ ? [LEGACY_GENERATED_FILE_SHA256.publisherDatabaseClient]
722
+ : [];
723
+ assertGeneratedCopyAllowed(file.source, file.destination, force, knownVersions);
720
724
  }
721
725
  assertGeneratedCopyAllowed(
722
726
  registrarSource,
@@ -760,9 +764,11 @@ export function configureExpoApp(
760
764
  );
761
765
  }
762
766
 
767
+ commandRunner(...commands.installExpoUpdates, appRoot);
768
+
763
769
  writeJson(
764
770
  project.appJsonPath,
765
- patchAppJson(project.appJson, {
771
+ patchAppJson(readJson(project.appJsonPath), {
766
772
  channel,
767
773
  runtimeVersion,
768
774
  manifestUrl,
@@ -774,7 +780,7 @@ export function configureExpoApp(
774
780
  copyFile(certificatePath, certificateDestination);
775
781
  copyFile(publisherSource, publisherDestination);
776
782
  copyFile(exportCommandSource, exportCommandDestination);
777
- copyFile(envExampleSource, envExampleDestination);
783
+ fs.writeFileSync(envExampleDestination, envExample);
778
784
  for (const file of publisherFiles) {
779
785
  copyFile(file.source, file.destination);
780
786
  }
@@ -782,7 +788,6 @@ export function configureExpoApp(
782
788
  copyFile(androidRegistrarSource, androidRegistrarDestination);
783
789
  fs.chmodSync(androidRegistrarDestination, 0o755);
784
790
  copyFile(iosPluginSource, iosPluginDestination);
785
- patchPublisherEnvExample(envExampleDestination, channel);
786
791
  if (localPublisherEnv) {
787
792
  fs.writeFileSync(
788
793
  publisherEnvDestination,
@@ -792,8 +797,6 @@ export function configureExpoApp(
792
797
  }
793
798
  appendGitignore(appRoot);
794
799
 
795
- commandRunner(...commands.installExpoUpdates, appRoot);
796
-
797
800
  const installedPackageJson = readJson(project.packagePath);
798
801
  writeJson(
799
802
  project.packagePath,
@@ -193,6 +193,10 @@ function readCurrentRegistrar() {
193
193
 
194
194
  function createManifestOnlyRegistrar() {
195
195
  const manifestOnly = readCurrentRegistrar()
196
+ .replace(
197
+ /if \(process\.argv\[1\] && fs\.existsSync[\s\S]*?fileURLToPath\(import\.meta\.url\)\)\) \{/,
198
+ "if (process.argv[1] === fileURLToPath(import.meta.url)) {",
199
+ )
196
200
  .replace(
197
201
  `
198
202
  export function readExpoAppVersion(appRoot, readFile = fs.readFileSync) {
@@ -408,6 +412,7 @@ function createRunner() {
408
412
  const packagePath = path.join(cwd, "package.json");
409
413
  const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf8"));
410
414
  packageJson.dependencies["expo-updates"] = "~56.0.0";
415
+ packageJson.dependencies["expo-updates-server-client"] = "^0.1.0";
411
416
  fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
412
417
  }
413
418
  };
@@ -476,6 +481,7 @@ describe("configureExpoApp", () => {
476
481
  "./plugins/with-ota-embedded-registration",
477
482
  );
478
483
  expect(packageJson.dependencies["expo-updates"]).toBe("~56.0.0");
484
+ expect(packageJson.dependencies["expo-updates-server-client"]).toBe("0.1.0");
479
485
  expect(packageJson.scripts["ota:publish"]).toBe(
480
486
  "node scripts/ota-publish/index.mjs",
481
487
  );
@@ -587,7 +593,7 @@ describe("configureExpoApp", () => {
587
593
  expect(calls).toEqual([
588
594
  {
589
595
  command: "npx",
590
- args: ["expo", "install", "expo-updates", "expo-application", "expo-crypto", "expo-secure-store", "@react-native-async-storage/async-storage"],
596
+ args: ["expo", "install", "expo-updates", "expo-application", "expo-crypto", "expo-secure-store", "@react-native-async-storage/async-storage", "expo-updates-server-client@0.1.0"],
591
597
  cwd: appRoot,
592
598
  },
593
599
  {
@@ -609,6 +615,35 @@ describe("configureExpoApp", () => {
609
615
  ]);
610
616
  });
611
617
 
618
+ it.each([
619
+ ["pnpm-lock.yaml", "pnpm", ["exec", "expo", "install"]],
620
+ ["yarn.lock", "yarn", ["expo", "install"]],
621
+ ["bun.lock", "bunx", ["expo", "install"]],
622
+ ])("installs the SDK and Expo-compatible peers with %s", (lockfile, command, prefix) => {
623
+ const { appRoot, certificatePath, templateRoot } = createFixture();
624
+ fs.writeFileSync(path.join(appRoot, lockfile as string), "");
625
+ const { calls, commandRunner } = createRunner();
626
+ configureExpoApp({
627
+ app: appRoot, certificate: certificatePath, serverUrl: "https://updates.example.com",
628
+ channel: "production", runtimeVersion: "1.0", platform: "android",
629
+ }, { commandRunner, templateRoot });
630
+ expect(calls[0]).toEqual({ command, cwd: appRoot, args: [
631
+ ...prefix, "expo-updates", "expo-application", "expo-crypto", "expo-secure-store",
632
+ "@react-native-async-storage/async-storage", "expo-updates-server-client@0.1.0",
633
+ ] });
634
+ });
635
+
636
+ it("keeps app wiring intact when installing the SDK fails", () => {
637
+ const { appRoot, certificatePath, templateRoot } = createFixture();
638
+ const original = fs.readFileSync(path.join(appRoot, "App.tsx"), "utf8");
639
+ expect(() => configureExpoApp({
640
+ app: appRoot, certificate: certificatePath, serverUrl: "https://updates.example.com",
641
+ channel: "production", runtimeVersion: "1.0", platform: "android",
642
+ }, { commandRunner: () => { throw new Error("registry unavailable"); }, templateRoot })).toThrow("registry unavailable");
643
+ expect(fs.readFileSync(path.join(appRoot, "App.tsx"), "utf8")).toBe(original);
644
+ expect(fs.existsSync(path.join(appRoot, "ota-entry.js"))).toBe(false);
645
+ });
646
+
612
647
  it("creates publisher credentials from local Docker settings", () => {
613
648
  const { appRoot, certificatePath, templateRoot } = createFixture();
614
649
  const serverRoot = path.dirname(appRoot);
@@ -882,7 +917,7 @@ describe("configureExpoApp", () => {
882
917
  app: appRoot,
883
918
  certificate: certificatePath,
884
919
  serverUrl: "https://updates.example.com",
885
- channel: "production",
920
+ channel: "qa-preview",
886
921
  runtimeVersion: "1.0.0",
887
922
  };
888
923
  fs.mkdirSync(path.dirname(registrarPath), { recursive: true });
@@ -1,8 +1,87 @@
1
+ import { createHash } from "node:crypto";
1
2
  import fs from "node:fs";
2
3
  import path from "node:path";
3
4
  import { planOtaRootHook } from "./ota-root-hook-patcher.mjs";
5
+ import {
6
+ bootstrapCode,
7
+ clientPackage,
8
+ clientVersion,
9
+ originalEntryCode,
10
+ } from "./ota-client-package.mjs";
11
+
4
12
  const ENTRY = "ota-entry.js";
5
13
  const META = "ota-client-entry.json";
14
+ // SHA-256 of the generated JavaScript and TypeScript clients shipped before the SDK.
15
+ const legacyClientFiles = {
16
+ "README.md": [
17
+ "63ba1e4caad176611ba3b005ce0f22a26bdf475a0ba9ecdffbf13c417987477a",
18
+ "94de27962827a474e3348a8619d2f0d5a5a28db986350d87337843c55427754e",
19
+ ],
20
+ "controller.js": [
21
+ "071d8964015f6569df552ad137be92dc2319b6c9c99cd965fed04b72cd330b0e",
22
+ ],
23
+ "controller.ts": [
24
+ "857b872021aafe85dcefa16c5926084adeba356049534f5b5beeeddd8d69e997",
25
+ ],
26
+ "device-identity.js": [
27
+ "3df8f2161a969fb913a4fc25e4e2a4e45b77b276c8aa494f482c4a63fc28a7d0",
28
+ ],
29
+ "device-identity.ts": [
30
+ "175e6420b2af63d554b6873f85cdb5367a07deaa5ab2aa9843b35be38846a874",
31
+ ],
32
+ "docs/update-lifecycle.md": [
33
+ "2cb7ced11ee8c1a2952644e0ae9d1e883476d3967e990a25bec69f2b3b814446",
34
+ "45a8e9f52076d39ef9afce51afe311ed7d4a6d38d44680ecfbe223118dd61b7e",
35
+ "5b2c18bdbd481d65af2e2777e8299e7385a4d2aa8aec156c9da807ee4cf4e095",
36
+ "f16381c3884675c0278968a5980c869af909b89ba61dfcaf8cdc3febe97604b4",
37
+ ],
38
+ "index.d.ts": [
39
+ "4dda51592f0baf0f665df266fbc6de7e4fd003302c9a8d4df8e6b29521c50c9b",
40
+ ],
41
+ "index.js": [
42
+ "04398d73c08b9c25c251cca3bbd9484306b76b82e37c55dc01904a678b756281",
43
+ ],
44
+ "index.ts": [
45
+ "43229cadbeffcc544704c70e506a89c6bde7b44666f4ff44b64a768eade200b3",
46
+ ],
47
+ "model/hooks/useOtaUpdates.js": [
48
+ "10c611ec2a22852efaa8642a267cd0e15def919f272921b1f519d37a6eeda7a0",
49
+ ],
50
+ "model/hooks/useOtaUpdates.ts": [
51
+ "01aec47eb8197039beb8895ce3b25e726518bd31c18838656967deb55b025eae",
52
+ "59b9777a0d097df62a0d65bc86c8a272672c62322cdda89f49aafeeabfb6e801",
53
+ ],
54
+ "model/update-controller.js": [
55
+ "7efcedf3fc730294ff58be0b2151f6a29ae449228ed85c341c7536d11f696fe1",
56
+ ],
57
+ "model/update-controller.ts": [
58
+ "130bcfa37864383143b0f1fb2b0789e94e5f3e2b7f4fe3d22e168a55643b7e03",
59
+ "60ebb33895cbe7d7b12c0c8d9f443669e4955de1f9d0c528f3d7578e2c9f1349",
60
+ "9a1020c1de7211273929b5da7b4a85f0abe076b24f470c4be9151245f5ba6716",
61
+ ],
62
+ "runtime.js": [
63
+ "8d6a5d6c4bc39b1035f5e1f300a5dfe7c7f20390478f2e022d23e9825b980690",
64
+ ],
65
+ "runtime.ts": [
66
+ "8eb1548b060125ddd93dd05a31ee9197777da30bb7d052ebc3e647c9360e1f4c",
67
+ ],
68
+ "types.ts": [
69
+ "29c4894ed1f7cbd61f59f2f62319748f3555f9e2d883d858e3b64100d8940c64",
70
+ "a892b2989e61dbbcf83d271f88fce57226d2aa13401393e14b9c67c75638c566",
71
+ "dedae48ece515569c4a4509fbcfde5f88ee20adc949484f03cff869f22572679",
72
+ ],
73
+ "ui/ota-update-gate.js": [
74
+ "a3c430656849ec960ab1dbaf555c6bc6414c0cf31a74982be8b3024cd5dfb5ed",
75
+ ],
76
+ "ui/ota-update-gate.tsx": [
77
+ "26f34d88605950df11597a01204710c606203baee87a9df9de29be33860d5678",
78
+ ],
79
+ "ui/ota-updates.tsx": [
80
+ "839fa62ee9583ee41983e003492cdd76c03ecbff7e9cf7d038743389e3a9f21d",
81
+ "83c8c4f4e7a62a5d793e4ed519c7c6b4692c902208ecfcb1340ca655631df88d",
82
+ "e2a710f41e9ab2f33fbd8b7948f25c43a601324703b7f714bf34f4fdc9099f2c",
83
+ ],
84
+ };
6
85
  const extensions = ["tsx", "ts", "jsx", "js", "mjs", "cjs"];
7
86
  function hasEntry(root, entry, platform) {
8
87
  const suffixes = platform === "web" ? ["web", ""] : [platform, "native", ""];
@@ -18,7 +97,6 @@ function hasEntry(root, entry, platform) {
18
97
  // Preflight every generated file before the main configurator changes the project.
19
98
  export function planOtaClient({
20
99
  appRoot,
21
- templateRoot,
22
100
  packageJson,
23
101
  manifestUrl,
24
102
  channel,
@@ -71,81 +149,100 @@ export function planOtaClient({
71
149
  ]);
72
150
  }
73
151
  }
74
- const original =
75
- entry === "__platform_default__"
76
- ? "require('./ota-original-entry');"
77
- : entry === "__app_fallback__"
78
- ? "require('expo').registerRootComponent(require('./App').default);"
79
- : `require(${JSON.stringify(entry)});`;
152
+ const header = `// Generated by configure-app. Original entry is preserved in ${META}.\n`;
153
+ const oldEntries = ["./ota-client", "./ota-client/runtime"].map(
154
+ (module) => `${header}require('${module}').start();\n${originalEntryCode(entry)}\n`,
155
+ );
80
156
  const rootHookPlan = planOtaRootHook({ appRoot, originalEntry: entry });
81
157
  const files = [
82
158
  ...defaultEntries,
83
- [
84
- ENTRY,
85
- `// Generated by configure-app. Original entry is preserved in ${META}.\nrequire('./ota-client/runtime').start();\n${original}\n`,
86
- ],
159
+ [ENTRY, `${header}${bootstrapCode(entry)}\n`],
87
160
  [META, `${JSON.stringify({ originalEntry: entry }, null, 2)}\n`],
88
161
  [
89
162
  "ota-client/config.json",
90
- `${JSON.stringify({ channel, heartbeatUrl: heartbeatUrl.toString(), identityNamespace }, null, 2)}\n`,
163
+ `${JSON.stringify({ ...existingConfig, channel, heartbeatUrl: heartbeatUrl.toString(), identityNamespace }, null, 2)}\n`,
91
164
  ],
92
- ...[
93
- "index.ts",
94
- "types.ts",
95
- "runtime.ts",
96
- "controller.ts",
97
- "device-identity.ts",
98
- "model/update-controller.ts",
99
- "model/hooks/useOtaUpdates.ts",
100
- "ui/ota-updates.tsx",
101
- "ui/ota-update-gate.tsx",
102
- "docs/update-lifecycle.md",
103
- "README.md",
104
- ].map((name) => [
105
- `ota-client/${name}`,
106
- fs.readFileSync(path.join(templateRoot, "ota-client", name), "utf8"),
107
- ]),
108
165
  ];
109
- const obsolete = [
110
- "index.js",
111
- "index.d.ts",
112
- "runtime.js",
113
- "controller.js",
114
- "device-identity.js",
115
- "model/update-controller.js",
116
- "model/hooks/useOtaUpdates.js",
117
- "ui/ota-update-gate.js",
118
- ]
119
- .map((name) => path.join(appRoot, "ota-client", name))
120
- .filter((file) => fs.existsSync(file));
121
- if (obsolete.length && !force)
122
- throw new Error(
123
- "Refusing to replace the existing JavaScript OTA client. Review your customizations and rerun with --force to migrate to TypeScript.",
124
- );
125
- for (const [name, content] of files) {
126
- const destination = path.join(appRoot, name);
166
+ const warnings = [...rootHookPlan.warnings];
167
+ const backups = [];
168
+ const forwarders = [];
169
+ const obsoleteDocs = [];
170
+
171
+ function preserveCustomizedFile(relative) {
172
+ const file = path.join(appRoot, relative);
173
+ if (!force)
174
+ throw new Error(
175
+ `Refusing to replace customized ${file}. Migrate your changes or rerun with --force to save a backup and switch to the SDK.`,
176
+ );
177
+ const backup = `${file}.pre-sdk.bak`;
127
178
  if (
128
- fs.existsSync(destination) &&
129
- fs.readFileSync(destination, "utf8") !== content &&
130
- !force
131
- ) {
179
+ fs.existsSync(backup) &&
180
+ !fs.readFileSync(file).equals(fs.readFileSync(backup))
181
+ )
132
182
  throw new Error(
133
- `Refusing to overwrite ${destination}. Re-run with --force.`,
183
+ `Refusing to overwrite ${backup}. Move the existing backup before rerunning.`,
134
184
  );
185
+ backups.push([file, backup]);
186
+ warnings.push(
187
+ `Review customized ${relative} saved in ${relative}.pre-sdk.bak and reapply any needed changes.`,
188
+ );
189
+ }
190
+
191
+ // Preserve the old module paths for application code outside the root we patch.
192
+ // Both the new entry and all compatibility imports resolve to one SDK instance.
193
+ for (const [name, hashes] of Object.entries(legacyClientFiles)) {
194
+ const relative = `ota-client/${name}`;
195
+ const file = path.join(appRoot, relative);
196
+ if (!fs.existsSync(file)) continue;
197
+ const current = fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n");
198
+ const generated = hashes.includes(
199
+ createHash("sha256").update(current).digest("hex"),
200
+ );
201
+ if (name.endsWith(".md")) {
202
+ if (generated) obsoleteDocs.push(file);
203
+ continue;
135
204
  }
205
+ const subpath = name.replace(/(?:\.d)?\.[jt]sx?$/, "");
206
+ const target = subpath === "index" ? clientPackage : `${clientPackage}/${subpath}`;
207
+ const forwarder = `export * from "${target}";\n`;
208
+ if (current === forwarder) continue;
209
+ if (!generated) preserveCustomizedFile(relative);
210
+ forwarders.push([relative, forwarder]);
211
+ }
212
+
213
+ for (const [name, content] of files) {
214
+ const destination = path.join(appRoot, name);
215
+ if (!fs.existsSync(destination)) continue;
216
+ const current = fs.readFileSync(destination, "utf8").replace(/\r\n/g, "\n");
217
+ if (current === content || (name === ENTRY && oldEntries.includes(current)))
218
+ continue;
219
+ if (name.endsWith(".js")) preserveCustomizedFile(name);
220
+ else if (!force)
221
+ throw new Error(`Refusing to overwrite ${destination}. Re-run with --force.`);
136
222
  }
137
223
  return {
138
- warnings: rootHookPlan.warnings,
224
+ warnings,
139
225
  apply() {
140
- for (const file of obsolete) fs.rmSync(file);
141
- for (const [name, content] of [...files, ...rootHookPlan.files]) {
226
+ for (const [file, backup] of backups)
227
+ if (!fs.existsSync(backup))
228
+ fs.copyFileSync(file, backup, fs.constants.COPYFILE_EXCL);
229
+ for (const file of obsoleteDocs) fs.rmSync(file, { force: true });
230
+ for (const [name, content] of [
231
+ ...files,
232
+ ...forwarders,
233
+ ...rootHookPlan.files,
234
+ ]) {
142
235
  const destination = path.join(appRoot, name);
143
236
  fs.mkdirSync(path.dirname(destination), { recursive: true });
144
237
  fs.writeFileSync(destination, content);
145
238
  }
146
239
  },
147
240
  patchPackage(packageJson) {
148
- return { ...packageJson, main: ENTRY };
241
+ return {
242
+ ...packageJson,
243
+ main: ENTRY,
244
+ dependencies: { ...packageJson.dependencies, [clientPackage]: clientVersion },
245
+ };
149
246
  },
150
247
  };
151
248
  }
@@ -13,7 +13,6 @@ function setup(main?: string) {
13
13
  roots.push(appRoot);
14
14
  const options = {
15
15
  appRoot,
16
- templateRoot: path.resolve("templates/expo-app"),
17
16
  packageJson: main ? { main } : {},
18
17
  manifestUrl: "https://example.org/prefix/api/manifest",
19
18
  channel: "test",
@@ -25,7 +24,7 @@ function setup(main?: string) {
25
24
  };
26
25
  }
27
26
  describe("configure-only bootstrap", () => {
28
- it("migrates legacy JavaScript modules without leaving files that shadow TypeScript", () => {
27
+ it("backs up customized JavaScript modules on forced migration and preserves old import paths", () => {
29
28
  const f = setup("expo-router/entry");
30
29
  const legacy = [
31
30
  "index.js",
@@ -58,13 +57,11 @@ export default function Layout() {
58
57
  fs.existsSync(path.join(f.options.appRoot, "ota-client/index.js")),
59
58
  ).toBe(true);
60
59
  planOtaClient({ ...f.options, force: true }).apply();
61
- for (const name of legacy)
62
- expect(
63
- fs.existsSync(path.join(f.options.appRoot, "ota-client", name)),
64
- ).toBe(false);
65
- expect(
66
- fs.existsSync(path.join(f.options.appRoot, "ota-client/index.ts")),
67
- ).toBe(true);
60
+ for (const name of legacy) {
61
+ const file = path.join(f.options.appRoot, "ota-client", name);
62
+ expect(fs.readFileSync(file, "utf8")).toMatch(/^export \* from "expo-updates-server-client/);
63
+ expect(fs.readFileSync(`${file}.pre-sdk.bak`, "utf8")).toBe("// old customized client");
64
+ }
68
65
  const migrated = fs.readFileSync(layout, "utf8");
69
66
  expect(migrated).toContain("<OtaUpdates");
70
67
  expect(migrated).toContain("autoUpdate: true");
@@ -75,6 +72,44 @@ export default function Layout() {
75
72
  }).apply();
76
73
  expect(fs.readFileSync(layout, "utf8")).toBe(migrated);
77
74
  });
75
+ it.each([
76
+ ["index.js", "./ota-client", "export { start, getInstallationId, getDeviceId, checkForUpdateAsync, fetchUpdateAsync } from './runtime';\nexport { useOtaUpdates } from './model/hooks/useOtaUpdates';\nexport { OtaUpdateGate } from './ui/ota-update-gate';\n"],
77
+ ["index.ts", "./ota-client/runtime", `export {
78
+ start,
79
+ getInstallationId,
80
+ getDeviceId,
81
+ checkForUpdateAsync,
82
+ fetchUpdateAsync,
83
+ } from "./runtime";
84
+ export { useOtaUpdates } from "./model/hooks/useOtaUpdates";
85
+ export { OtaUpdateGate } from "./ui/ota-update-gate";
86
+ export { OtaUpdates } from "./ui/ota-updates";
87
+ export type {
88
+ OtaOptions,
89
+ OtaController,
90
+ OtaUpdatesProps,
91
+ OtaPolicy,
92
+ } from "./types";
93
+ `],
94
+ ])("migrates a shipped %s client and bootstrap without force", (name, oldImport, contents) => {
95
+ const f = setup("ota-entry.js");
96
+ const dir = f.options.appRoot;
97
+ const originalEntry = "expo-router/entry";
98
+ fs.mkdirSync(path.join(dir, "ota-client"));
99
+ fs.writeFileSync(path.join(dir, "ota-client", name), contents.replaceAll("\n", "\r\n"));
100
+ fs.writeFileSync(path.join(dir, "ota-client/README.md"), "Custom notes");
101
+ fs.writeFileSync(path.join(dir, "ota-client-entry.json"), JSON.stringify({ originalEntry }, null, 2) + "\n");
102
+ fs.writeFileSync(path.join(dir, "ota-entry.js"), `// Generated by configure-app. Original entry is preserved in ota-client-entry.json.\nrequire('${oldImport}').start();\nrequire("expo-router/entry");\n`);
103
+ const config = { channel: "test", heartbeatUrl: "https://example.org/prefix/api/device-heartbeat", identityNamespace: "stable-device-namespace", custom: true };
104
+ fs.writeFileSync(path.join(dir, "ota-client/config.json"), JSON.stringify(config, null, 2) + "\n");
105
+ planOtaClient(f.options).apply();
106
+ expect(f.entry()).toContain("otaClient.initializeOtaClient");
107
+ expect(fs.readFileSync(path.join(dir, "ota-client", name), "utf8")).toBe('export * from "expo-updates-server-client";\n');
108
+ expect(fs.readFileSync(path.join(dir, "ota-client/README.md"), "utf8")).toBe("Custom notes");
109
+ expect(JSON.parse(fs.readFileSync(path.join(dir, "ota-client/config.json"), "utf8"))).toEqual(config);
110
+ planOtaClient(f.options).apply();
111
+ expect(fs.readdirSync(path.join(dir, "ota-client")).sort()).toEqual(["README.md", "config.json", name]);
112
+ });
78
113
  it("preserves Router entry across repeated configurations and keeps URL prefix", () => {
79
114
  const f = setup("expo-router/entry");
80
115
  const plan = planOtaClient(f.options);
@@ -144,17 +179,22 @@ export default function Layout() {
144
179
  planOtaClient({ ...f.options, packageJson: { main: "ota-entry.js" } }),
145
180
  ).toThrow("Refusing");
146
181
  });
147
- it("automatically starts the client, preserves namespace when URL/channel changes, and copies identity model", () => {
182
+ it("initializes and starts the SDK before the original entry and preserves namespace when URL/channel changes", () => {
148
183
  const f = setup("expo-router/entry");
149
184
  planOtaClient(f.options).apply();
150
- expect(
151
- f.entry().indexOf("require('./ota-client/runtime').start()"),
152
- ).toBeLessThan(f.entry().indexOf('require("expo-router/entry")'));
153
- expect(
154
- fs.existsSync(
155
- path.join(f.options.appRoot, "ota-client/device-identity.ts"),
156
- ),
157
- ).toBe(true);
185
+ const calls: string[] = [];
186
+ const config = JSON.parse(fs.readFileSync(path.join(f.options.appRoot, "ota-client/config.json"), "utf8"));
187
+ const requireModule = (name: string) => {
188
+ calls.push(name);
189
+ if (name.endsWith("config.json")) return config;
190
+ if (name === "expo-updates-server-client") return {
191
+ initializeOtaClient: (value: unknown) => { expect(value).toBe(config); calls.push("initialize"); },
192
+ start: () => calls.push("start"),
193
+ };
194
+ };
195
+ Function("require", f.entry())(requireModule);
196
+ expect(calls).toEqual(["expo-updates-server-client", "./ota-client/config.json", "initialize", "start", "expo-router/entry"]);
197
+ expect(fs.readdirSync(path.join(f.options.appRoot, "ota-client"))).toEqual(["config.json"]);
158
198
  planOtaClient({
159
199
  ...f.options,
160
200
  packageJson: { main: "ota-entry.js" },
@@ -188,7 +228,7 @@ export default function Layout() {
188
228
  fs.existsSync(
189
229
  path.join(f.options.appRoot, "ota-client/model/hooks/useOtaUpdates.ts"),
190
230
  ),
191
- ).toBe(true);
231
+ ).toBe(false);
192
232
  const customized = fs
193
233
  .readFileSync(layout, "utf8")
194
234
  .replace("autoUpdate={false}", "autoUpdate={true}");
@@ -224,7 +264,7 @@ export default function Layout() {
224
264
  fs.mkdirSync(path.dirname(layout), { recursive: true });
225
265
  fs.writeFileSync(layout, original);
226
266
  expect(() => planOtaClient(f.options)).toThrow(
227
- "use a relative import to ota-client",
267
+ "use an import from expo-updates-server-client",
228
268
  );
229
269
  expect(fs.readFileSync(layout, "utf8")).toBe(original);
230
270
  expect(fs.existsSync(path.join(f.options.appRoot, "ota-entry.js"))).toBe(