create-expo-updates-server 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/template/README.md +12 -7
  2. package/dist/template/app/api/admin/embedded-updates/route.test.ts +36 -1
  3. package/dist/template/app/api/admin/updates/route.test.ts +29 -1
  4. package/dist/template/app/updates/embedded/page.tsx +6 -2
  5. package/dist/template/app/updates/page.tsx +6 -2
  6. package/dist/template/docs/expo-app-setup.md +14 -3
  7. package/dist/template/docs/getting-started.md +12 -7
  8. package/dist/template/docs/getting-started.ru.md +13 -6
  9. package/dist/template/docs/migrations/2026-09-01-app-version-columns.sql +23 -0
  10. package/dist/template/docs/migrations/schema.sql +22 -0
  11. package/dist/template/package-lock.json +2 -2
  12. package/dist/template/package.json +1 -1
  13. package/dist/template/scripts/configure-expo-app.mjs +6 -0
  14. package/dist/template/scripts/lib/embedded-update-registrar.test.ts +383 -3
  15. package/dist/template/scripts/lib/expo-app-configurator.mjs +165 -9
  16. package/dist/template/scripts/lib/expo-app-configurator.test.ts +658 -9
  17. package/dist/template/src/client/admin-types.ts +2 -0
  18. package/dist/template/src/server/lib/admin-embedded-updates.test.ts +57 -0
  19. package/dist/template/src/server/lib/admin-embedded-updates.ts +42 -25
  20. package/dist/template/src/server/lib/admin-updates.test.ts +61 -0
  21. package/dist/template/src/server/lib/admin-updates.ts +23 -3
  22. package/dist/template/templates/expo-app/ci_scripts/ci_post_xcodebuild.sh +23 -1
  23. package/dist/template/templates/expo-app/plugins/with-ota-embedded-registration.js +13 -4
  24. package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +53 -7
  25. package/dist/template/templates/expo-app/scripts/ota-register-embedded/register-ios.sh +87 -0
  26. package/dist/template-manifest.json +65 -50
  27. package/package.json +1 -1
  28. package/dist/template/templates/expo-app/ci_scripts/register-embedded-update.sh +0 -36
  29. /package/dist/template/templates/expo-app/scripts/ota-register-embedded/{android-register-embedded-update.sh → register-android.sh} +0 -0
@@ -1,13 +1,86 @@
1
+ import { spawnSync } from "node:child_process";
1
2
  import fs from "node:fs";
3
+ import os from "node:os";
2
4
  import path from "node:path";
3
5
  import { pathToFileURL } from "node:url";
4
- import { describe, expect, it } from "vitest";
6
+ import vm from "node:vm";
7
+ import { afterEach, describe, expect, it } from "vitest";
5
8
 
6
9
  const registrarUrl = pathToFileURL(
7
10
  path.resolve(
8
11
  "templates/expo-app/scripts/ota-register-embedded/index.mjs",
9
12
  ),
10
13
  ).href;
14
+ const temporaryDirectories: string[] = [];
15
+
16
+ function createIosRegistrarFixture() {
17
+ const projectRoot = fs.mkdtempSync(
18
+ path.join(os.tmpdir(), "ota-ios-registrar-"),
19
+ );
20
+ temporaryDirectories.push(projectRoot);
21
+
22
+ const registrarDirectory = path.join(
23
+ projectRoot,
24
+ "scripts",
25
+ "ota-register-embedded",
26
+ );
27
+ const iosRegistrar = path.join(registrarDirectory, "register-ios.sh");
28
+ const jsRegistrar = path.join(registrarDirectory, "index.mjs");
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,
35
+ );
36
+ fs.writeFileSync(jsRegistrar, "// Fake registrar; fake Node must run this.\n");
37
+
38
+ const targetBuildDirectory = path.join(projectRoot, "build");
39
+ const resourcesFolder = "Fixture.app";
40
+ const manifestPath = path.join(
41
+ targetBuildDirectory,
42
+ resourcesFolder,
43
+ "app.manifest",
44
+ );
45
+ fs.mkdirSync(path.dirname(manifestPath), { recursive: true });
46
+ fs.writeFileSync(manifestPath, "{}\n");
47
+
48
+ const fakeNode = path.join(projectRoot, "fake-node");
49
+ fs.writeFileSync(
50
+ fakeNode,
51
+ `#!/bin/sh
52
+ if [ "$1" != "${jsRegistrar}" ] ||
53
+ [ "$2" != "--manifest" ] ||
54
+ [ "$3" != "${manifestPath}" ] ||
55
+ [ "$4" != "--platform" ] ||
56
+ [ "$5" != "ios" ]; then
57
+ echo "Unexpected fake Node arguments: $*" >&2
58
+ exit 64
59
+ fi
60
+ `,
61
+ );
62
+ fs.chmodSync(fakeNode, 0o755);
63
+
64
+ const pathWithoutNode = "/usr/bin:/bin";
65
+ const env = {
66
+ ...process.env,
67
+ PATH: pathWithoutNode,
68
+ NODE_BINARY: "",
69
+ CONFIGURATION: "Release",
70
+ OTA_EMBEDDED_REGISTER_STRICT: "true",
71
+ TARGET_BUILD_DIR: targetBuildDirectory,
72
+ UNLOCALIZED_RESOURCES_FOLDER_PATH: resourcesFolder,
73
+ CI_ARCHIVE_PATH: "",
74
+ };
75
+
76
+ return { env, fakeNode, iosRegistrar, projectRoot };
77
+ }
78
+
79
+ afterEach(() => {
80
+ for (const directory of temporaryDirectories.splice(0)) {
81
+ fs.rmSync(directory, { recursive: true, force: true });
82
+ }
83
+ });
11
84
 
12
85
  describe("embedded update registrar", () => {
13
86
  it("extracts Expo update fields from a nested manifest", async () => {
@@ -17,12 +90,18 @@ describe("embedded update registrar", () => {
17
90
  manifest: JSON.stringify({
18
91
  id: "55555555-5555-4555-8555-555555555555",
19
92
  createdAt: "2026-01-01T00:00:00Z",
93
+ extra: {
94
+ expoClient: {
95
+ version: "2.4.1",
96
+ },
97
+ },
20
98
  }),
21
99
  }),
22
100
  );
23
101
 
24
102
  expect(result).toEqual({
25
103
  embeddedUpdateId: "55555555-5555-4555-8555-555555555555",
104
+ appVersion: "2.4.1",
26
105
  createdAt: "2026-01-01T00:00:00.000Z",
27
106
  });
28
107
  });
@@ -43,15 +122,101 @@ describe("embedded update registrar", () => {
43
122
  expect(first.embeddedUpdateId).toMatch(
44
123
  /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-a[0-9a-f]{3}-[0-9a-f]{12}$/,
45
124
  );
125
+ expect(first.appVersion).toBeNull();
46
126
  expect(first.createdAt).toBe("2026-02-03T04:05:06.000Z");
47
127
  });
48
128
 
129
+ it("falls back from a real-shape Expo manifest to app.json version", async () => {
130
+ const {
131
+ parseEmbeddedManifest,
132
+ parseEmbeddedManifestForProject,
133
+ } = await import(registrarUrl);
134
+ const manifest = JSON.stringify({
135
+ id: "55555555-5555-4555-8555-555555555555",
136
+ commitTime: 1_767_225_600,
137
+ assets: [],
138
+ });
139
+ const fallbackDate = new Date("2026-02-03T04:05:06Z");
140
+ const readAppJson = (filePath: string, encoding: string) => {
141
+ expect(filePath).toBe(path.join("/expo-project", "app.json"));
142
+ expect(encoding).toBe("utf8");
143
+ return JSON.stringify({ expo: { version: " 1.7.11 " } });
144
+ };
145
+
146
+ expect(parseEmbeddedManifest(manifest, fallbackDate).appVersion).toBeNull();
147
+ expect(
148
+ parseEmbeddedManifestForProject(
149
+ manifest,
150
+ "/expo-project",
151
+ fallbackDate,
152
+ readAppJson,
153
+ ),
154
+ ).toEqual({
155
+ embeddedUpdateId: "55555555-5555-4555-8555-555555555555",
156
+ appVersion: "1.7.11",
157
+ createdAt: "2026-01-01T00:00:00.000Z",
158
+ });
159
+ });
160
+
161
+ it("keeps manifest app version ahead of the app.json fallback", async () => {
162
+ const { parseEmbeddedManifestForProject } = await import(registrarUrl);
163
+ let appJsonRead = false;
164
+ const result = parseEmbeddedManifestForProject(
165
+ JSON.stringify({
166
+ id: "55555555-5555-4555-8555-555555555555",
167
+ commitTime: "2026-01-01T00:00:00Z",
168
+ assets: [],
169
+ extra: { expoClient: { version: "2.4.1" } },
170
+ }),
171
+ "/expo-project",
172
+ new Date("2026-02-03T04:05:06Z"),
173
+ () => {
174
+ appJsonRead = true;
175
+ return JSON.stringify({ expo: { version: "1.7.11" } });
176
+ },
177
+ );
178
+
179
+ expect(result.appVersion).toBe("2.4.1");
180
+ expect(appJsonRead).toBe(false);
181
+ });
182
+
183
+ it.each([
184
+ ["missing", () => {
185
+ throw new Error("ENOENT");
186
+ }],
187
+ ["blank", () => JSON.stringify({ expo: { version: " " } })],
188
+ ["malformed JSON", () => "{not-json"],
189
+ ["malformed version", () =>
190
+ JSON.stringify({ expo: { version: { major: 1 } } })],
191
+ ])(
192
+ "keeps registration fields valid when app.json version is %s",
193
+ async (_case, readAppJson) => {
194
+ const { parseEmbeddedManifestForProject } = await import(registrarUrl);
195
+ const result = parseEmbeddedManifestForProject(
196
+ JSON.stringify({
197
+ id: "55555555-5555-4555-8555-555555555555",
198
+ commitTime: "2026-01-01T00:00:00Z",
199
+ assets: [],
200
+ }),
201
+ "/expo-project",
202
+ new Date("2026-02-03T04:05:06Z"),
203
+ readAppJson,
204
+ );
205
+
206
+ expect(result).toEqual({
207
+ embeddedUpdateId: "55555555-5555-4555-8555-555555555555",
208
+ appVersion: null,
209
+ createdAt: "2026-01-01T00:00:00.000Z",
210
+ });
211
+ },
212
+ );
213
+
49
214
  it("contains no application-specific paths or names", () => {
50
215
  const templateRoot = path.resolve("templates/expo-app");
51
216
  const files = [
52
217
  "scripts/ota-register-embedded/index.mjs",
53
- "scripts/ota-register-embedded/android-register-embedded-update.sh",
54
- "ci_scripts/register-embedded-update.sh",
218
+ "scripts/ota-register-embedded/register-android.sh",
219
+ "scripts/ota-register-embedded/register-ios.sh",
55
220
  "ci_scripts/ci_post_xcodebuild.sh",
56
221
  "plugins/with-ota-embedded-registration.js",
57
222
  ];
@@ -61,4 +226,219 @@ describe("embedded update registrar", () => {
61
226
 
62
227
  expect(content.toLowerCase()).not.toContain("miex");
63
228
  });
229
+
230
+ it("uses the canonical iOS registrar from local Xcode and Xcode Cloud", () => {
231
+ const templateRoot = path.resolve("templates/expo-app");
232
+ const iosRegistrar = fs.readFileSync(
233
+ path.join(
234
+ templateRoot,
235
+ "scripts/ota-register-embedded/register-ios.sh",
236
+ ),
237
+ "utf8",
238
+ );
239
+ const cloudAdapter = fs.readFileSync(
240
+ path.join(templateRoot, "ci_scripts/ci_post_xcodebuild.sh"),
241
+ "utf8",
242
+ );
243
+ const plugin = fs.readFileSync(
244
+ path.join(
245
+ templateRoot,
246
+ "plugins/with-ota-embedded-registration.js",
247
+ ),
248
+ "utf8",
249
+ );
250
+
251
+ expect(iosRegistrar).toContain(
252
+ '${TARGET_BUILD_DIR:-}',
253
+ );
254
+ expect(iosRegistrar).toContain('${CI_ARCHIVE_PATH:-}');
255
+ expect(iosRegistrar).toContain(
256
+ '${OTA_EMBEDDED_REGISTER_STRICT:-false}',
257
+ );
258
+ expect(iosRegistrar).toContain(
259
+ '[ "${CONFIGURATION:-Release}" = "Debug" ]',
260
+ );
261
+ expect(cloudAdapter).toContain(
262
+ "scripts/ota-register-embedded/register-ios.sh",
263
+ );
264
+ expect(cloudAdapter).toContain("CI_PRIMARY_REPOSITORY_PATH");
265
+ expect(plugin).toContain(
266
+ 'scripts/ota-register-embedded/register-ios.sh',
267
+ );
268
+ expect(plugin).not.toContain("ci_scripts/register-embedded-update.sh");
269
+ });
270
+
271
+ it("preserves iOS Debug skip and strict/non-strict behavior", () => {
272
+ const iosRegistrar = path.resolve(
273
+ "templates/expo-app/scripts/ota-register-embedded/register-ios.sh",
274
+ );
275
+ const baseEnv = {
276
+ ...process.env,
277
+ TARGET_BUILD_DIR: "",
278
+ UNLOCALIZED_RESOURCES_FOLDER_PATH: "",
279
+ CI_ARCHIVE_PATH: "",
280
+ };
281
+
282
+ const debug = spawnSync("sh", [iosRegistrar], {
283
+ encoding: "utf8",
284
+ env: {
285
+ ...baseEnv,
286
+ CONFIGURATION: "Debug",
287
+ OTA_EMBEDDED_REGISTER_STRICT: "true",
288
+ },
289
+ });
290
+ const nonStrict = spawnSync("sh", [iosRegistrar], {
291
+ encoding: "utf8",
292
+ env: {
293
+ ...baseEnv,
294
+ CONFIGURATION: "Release",
295
+ OTA_EMBEDDED_REGISTER_STRICT: "false",
296
+ },
297
+ });
298
+ const strict = spawnSync("sh", [iosRegistrar], {
299
+ encoding: "utf8",
300
+ env: {
301
+ ...baseEnv,
302
+ CONFIGURATION: "Release",
303
+ OTA_EMBEDDED_REGISTER_STRICT: "true",
304
+ },
305
+ });
306
+
307
+ expect(debug.status).toBe(0);
308
+ expect(debug.stderr).toBe("");
309
+ expect(nonStrict.status).toBe(0);
310
+ expect(nonStrict.stderr).toContain("iOS app.manifest was not found");
311
+ expect(strict.status).toBe(1);
312
+ expect(strict.stderr).toContain("iOS app.manifest was not found");
313
+ });
314
+
315
+ it("uses executable NODE_BINARY when PATH does not contain Node", () => {
316
+ const { env, fakeNode, iosRegistrar } = createIosRegistrarFixture();
317
+ const result = spawnSync("/bin/sh", [iosRegistrar], {
318
+ encoding: "utf8",
319
+ env: {
320
+ ...env,
321
+ NODE_BINARY: fakeNode,
322
+ },
323
+ });
324
+
325
+ expect(result.status).toBe(0);
326
+ expect(result.stderr).toBe("");
327
+ });
328
+
329
+ it("loads absolute NODE_BINARY from ios/.xcode.env.local", () => {
330
+ const { env, fakeNode, iosRegistrar, projectRoot } =
331
+ createIosRegistrarFixture();
332
+ const iosDirectory = path.join(projectRoot, "ios");
333
+ fs.mkdirSync(iosDirectory, { recursive: true });
334
+ fs.writeFileSync(
335
+ path.join(iosDirectory, ".xcode.env"),
336
+ [
337
+ 'export UNUSED_XCODE_VALUE="$INTENTIONALLY_UNSET_XCODE_VALUE"',
338
+ "export NODE_BINARY=/path/from/base/xcode-env",
339
+ "",
340
+ ].join("\n"),
341
+ );
342
+ fs.writeFileSync(
343
+ path.join(iosDirectory, ".xcode.env.local"),
344
+ `export NODE_BINARY="${fakeNode}"\n`,
345
+ );
346
+
347
+ const result = spawnSync("/bin/sh", [iosRegistrar], {
348
+ encoding: "utf8",
349
+ env,
350
+ });
351
+
352
+ expect(result.status).toBe(0);
353
+ expect(result.stderr).toBe("");
354
+ });
355
+
356
+ it("fails clearly in strict mode when Node cannot be resolved", () => {
357
+ const { env, iosRegistrar, projectRoot } = createIosRegistrarFixture();
358
+ const result = spawnSync("/bin/sh", [iosRegistrar], {
359
+ encoding: "utf8",
360
+ env,
361
+ });
362
+
363
+ expect(result.status).toBe(1);
364
+ expect(result.stderr).toContain("Node.js executable was not found");
365
+ expect(result.stderr).toContain(
366
+ `Set NODE_BINARY to an absolute executable path in ${projectRoot}/ios/.xcode.env.local`,
367
+ );
368
+ });
369
+
370
+ it("fails clearly when the Xcode Cloud project root is unavailable", () => {
371
+ const cloudAdapter = path.resolve(
372
+ "templates/expo-app/ci_scripts/ci_post_xcodebuild.sh",
373
+ );
374
+ const result = spawnSync("sh", [cloudAdapter], {
375
+ encoding: "utf8",
376
+ env: {
377
+ ...process.env,
378
+ CI_PRIMARY_REPOSITORY_PATH:
379
+ "/path-that-does-not-exist/expo-app",
380
+ },
381
+ });
382
+
383
+ expect(result.status).toBe(1);
384
+ expect(result.stderr).toContain(
385
+ "CI_PRIMARY_REPOSITORY_PATH is unavailable",
386
+ );
387
+ });
388
+
389
+ it("updates an existing Xcode registration phase to the canonical path", () => {
390
+ const pluginPath = path.resolve(
391
+ "templates/expo-app/plugins/with-ota-embedded-registration.js",
392
+ );
393
+ const pluginSource = fs.readFileSync(pluginPath, "utf8");
394
+ const pluginModule = { exports: {} as (config: unknown) => unknown };
395
+ const loadPlugin = vm.runInNewContext(
396
+ `(function (require, module, exports) { ${pluginSource}\n })`,
397
+ );
398
+ loadPlugin(
399
+ (specifier: string) => {
400
+ if (specifier !== "expo/config-plugins") {
401
+ throw new Error(`Unexpected module: ${specifier}`);
402
+ }
403
+ return {
404
+ withXcodeProject: (
405
+ config: unknown,
406
+ action: (value: unknown) => unknown,
407
+ ) => action(config),
408
+ };
409
+ },
410
+ pluginModule,
411
+ pluginModule.exports,
412
+ );
413
+
414
+ const phase = {
415
+ name: '"Register Expo embedded update"',
416
+ shellPath: "/bin/sh",
417
+ shellScript: '"legacy path"',
418
+ };
419
+ const projectConfig = {
420
+ modResults: {
421
+ hash: {
422
+ project: {
423
+ objects: {
424
+ PBXShellScriptBuildPhase: { phase },
425
+ },
426
+ },
427
+ },
428
+ addBuildPhase: () => {
429
+ throw new Error("Existing phase must be updated, not duplicated");
430
+ },
431
+ getFirstTarget: () => ({ uuid: "TARGET" }),
432
+ },
433
+ };
434
+
435
+ pluginModule.exports(projectConfig);
436
+
437
+ expect(phase.shellScript).toContain(
438
+ "scripts/ota-register-embedded/register-ios.sh",
439
+ );
440
+ expect(phase.shellScript).not.toContain(
441
+ "ci_scripts/register-embedded-update.sh",
442
+ );
443
+ });
64
444
  });
@@ -1,9 +1,31 @@
1
1
  import { execFileSync } from "node:child_process";
2
+ import crypto from "node:crypto";
2
3
  import fs from "node:fs";
3
4
  import path from "node:path";
4
5
  import { fileURLToPath } from "node:url";
5
6
 
6
7
  const CHANNEL_PATTERN = /^[a-z0-9][a-z0-9._-]{0,63}$/;
8
+ const LEGACY_GENERATED_FILE_SHA256 = {
9
+ embeddedRegistrars: [
10
+ "29c48288d4804c072129da0ef60a12ad0892809eb8d57a14be94d039d990d6d7",
11
+ "89997ef11a939ce00e65159bd8e04845f16b184d5192f8fb56b1bc4204b07bca",
12
+ ],
13
+ androidRegistrar:
14
+ "45a0fddd24600d109359e90ea1f347c70b411307ec232beba22dd71d8c369fe4",
15
+ iosRegistrar:
16
+ "21e4a557a49feb40bbc391db5d44c64962fdb7d9db86394c477379861e571116",
17
+ canonicalIosRegistrars: [
18
+ "37e0edac0397e5dc1d48d1641a8ed1f113495e3d24ce1d3c66c62e31c0ca7198",
19
+ ],
20
+ xcodeCloudHook:
21
+ "3dd1d92a782de37b8efd40662624dce21bc3d1b30442ee8dc1dd7d4c3a7b7823",
22
+ iosPlugin:
23
+ "9bd619449c3f2f6c91628bd0de885c60eab41fbecbae9420781d7929d83df844",
24
+ };
25
+ const ANDROID_REGISTER_SCRIPT =
26
+ "scripts/ota-register-embedded/register-android.sh";
27
+ const LEGACY_ANDROID_REGISTER_SCRIPT =
28
+ "scripts/ota-register-embedded/android-register-embedded-update.sh";
7
29
  const PUBLISHER_DEPENDENCIES = [
8
30
  "@aws-sdk/client-s3",
9
31
  "dotenv",
@@ -193,6 +215,73 @@ function assertCopyAllowed(source, destination, force) {
193
215
  }
194
216
  }
195
217
 
218
+ function getFileSha256(filePath) {
219
+ return crypto
220
+ .createHash("sha256")
221
+ .update(fs.readFileSync(filePath))
222
+ .digest("hex");
223
+ }
224
+
225
+ function assertGeneratedCopyAllowed(
226
+ source,
227
+ destination,
228
+ force,
229
+ recognizedSha256 = [],
230
+ ) {
231
+ if (!fs.existsSync(destination) || force) {
232
+ return;
233
+ }
234
+
235
+ const current = fs.readFileSync(destination);
236
+ const next = fs.readFileSync(source);
237
+ if (current.equals(next)) {
238
+ return;
239
+ }
240
+
241
+ if (recognizedSha256.includes(getFileSha256(destination))) {
242
+ return;
243
+ }
244
+
245
+ throw new Error(
246
+ `Refusing to overwrite ${destination}. Re-run with --force.`,
247
+ );
248
+ }
249
+
250
+ function planLegacyFileMigration(
251
+ filePath,
252
+ generatedSha256,
253
+ description,
254
+ warnings,
255
+ ) {
256
+ if (!fs.existsSync(filePath)) {
257
+ return null;
258
+ }
259
+
260
+ if (getFileSha256(filePath) === generatedSha256) {
261
+ return { filePath, generatedSha256, description };
262
+ }
263
+
264
+ warnings.push(
265
+ `Preserved customized legacy ${description} at ${filePath}. Remove it manually after verifying the canonical registration scripts.`,
266
+ );
267
+ return null;
268
+ }
269
+
270
+ function removeLegacyGeneratedFile(migration, warnings) {
271
+ if (!migration || !fs.existsSync(migration.filePath)) {
272
+ return;
273
+ }
274
+
275
+ if (getFileSha256(migration.filePath) !== migration.generatedSha256) {
276
+ warnings.push(
277
+ `Preserved ${migration.description} at ${migration.filePath} because it changed during configuration.`,
278
+ );
279
+ return;
280
+ }
281
+
282
+ fs.unlinkSync(migration.filePath);
283
+ }
284
+
196
285
  function copyFile(source, destination) {
197
286
  fs.mkdirSync(path.dirname(destination), { recursive: true });
198
287
  fs.copyFileSync(source, destination);
@@ -346,11 +435,26 @@ function patchPackageJson(packageJson, platform) {
346
435
  ...(packageJson.scripts || {}),
347
436
  "ota:publish": "node scripts/ota-publish/index.mjs",
348
437
  };
438
+ for (const scriptName of [
439
+ "ota:build:android:apk",
440
+ "ota:build:android:aab",
441
+ ]) {
442
+ if (
443
+ typeof packageJson.scripts[scriptName] === "string" &&
444
+ packageJson.scripts[scriptName].includes(
445
+ LEGACY_ANDROID_REGISTER_SCRIPT,
446
+ )
447
+ ) {
448
+ packageJson.scripts[scriptName] = packageJson.scripts[
449
+ scriptName
450
+ ].replace(LEGACY_ANDROID_REGISTER_SCRIPT, ANDROID_REGISTER_SCRIPT);
451
+ }
452
+ }
349
453
  if (platform !== "ios") {
350
454
  packageJson.scripts["ota:build:android:apk"] =
351
- "cd android && ./gradlew app:assembleRelease && cd .. && OTA_EMBEDDED_REGISTER_STRICT=true sh scripts/ota-register-embedded/android-register-embedded-update.sh";
455
+ `cd android && ./gradlew app:assembleRelease && cd .. && OTA_EMBEDDED_REGISTER_STRICT=true sh ${ANDROID_REGISTER_SCRIPT}`;
352
456
  packageJson.scripts["ota:build:android:aab"] =
353
- "cd android && ./gradlew app:bundleRelease && cd .. && OTA_EMBEDDED_REGISTER_STRICT=true sh scripts/ota-register-embedded/android-register-embedded-update.sh";
457
+ `cd android && ./gradlew app:bundleRelease && cd .. && OTA_EMBEDDED_REGISTER_STRICT=true sh ${ANDROID_REGISTER_SCRIPT}`;
354
458
  }
355
459
  return packageJson;
356
460
  }
@@ -506,9 +610,15 @@ export function configureExpoApp(
506
610
  templateRoot,
507
611
  "scripts",
508
612
  "ota-register-embedded",
509
- "android-register-embedded-update.sh",
613
+ "register-android.sh",
510
614
  );
511
615
  const androidRegistrarDestination = path.join(
616
+ appRoot,
617
+ "scripts",
618
+ "ota-register-embedded",
619
+ "register-android.sh",
620
+ );
621
+ const legacyAndroidRegistrarDestination = path.join(
512
622
  appRoot,
513
623
  "scripts",
514
624
  "ota-register-embedded",
@@ -526,10 +636,17 @@ export function configureExpoApp(
526
636
  );
527
637
  const iosRegisterSource = path.join(
528
638
  templateRoot,
529
- "ci_scripts",
530
- "register-embedded-update.sh",
639
+ "scripts",
640
+ "ota-register-embedded",
641
+ "register-ios.sh",
531
642
  );
532
643
  const iosRegisterDestination = path.join(
644
+ appRoot,
645
+ "scripts",
646
+ "ota-register-embedded",
647
+ "register-ios.sh",
648
+ );
649
+ const legacyIosRegisterDestination = path.join(
533
650
  appRoot,
534
651
  "ci_scripts",
535
652
  "register-embedded-update.sh",
@@ -566,6 +683,25 @@ export function configureExpoApp(
566
683
  ),
567
684
  }),
568
685
  );
686
+ const migrationWarnings = [];
687
+ const legacyFileMigrations = [
688
+ planLegacyFileMigration(
689
+ legacyAndroidRegistrarDestination,
690
+ LEGACY_GENERATED_FILE_SHA256.androidRegistrar,
691
+ "Android registrar",
692
+ migrationWarnings,
693
+ ),
694
+ ];
695
+ if (platform !== "android") {
696
+ legacyFileMigrations.push(
697
+ planLegacyFileMigration(
698
+ legacyIosRegisterDestination,
699
+ LEGACY_GENERATED_FILE_SHA256.iosRegistrar,
700
+ "iOS registrar",
701
+ migrationWarnings,
702
+ ),
703
+ );
704
+ }
569
705
 
570
706
  assertCopyAllowed(certificatePath, certificateDestination, force);
571
707
  assertCopyAllowed(publisherSource, publisherDestination, force);
@@ -578,19 +714,35 @@ export function configureExpoApp(
578
714
  for (const file of publisherFiles) {
579
715
  assertCopyAllowed(file.source, file.destination, force);
580
716
  }
581
- assertCopyAllowed(registrarSource, registrarDestination, force);
717
+ assertGeneratedCopyAllowed(
718
+ registrarSource,
719
+ registrarDestination,
720
+ force,
721
+ LEGACY_GENERATED_FILE_SHA256.embeddedRegistrars,
722
+ );
582
723
  assertCopyAllowed(
583
724
  androidRegistrarSource,
584
725
  androidRegistrarDestination,
585
726
  force,
586
727
  );
587
- assertCopyAllowed(iosPluginSource, iosPluginDestination, force);
728
+ assertGeneratedCopyAllowed(
729
+ iosPluginSource,
730
+ iosPluginDestination,
731
+ force,
732
+ [LEGACY_GENERATED_FILE_SHA256.iosPlugin],
733
+ );
588
734
  if (platform !== "android") {
589
- assertCopyAllowed(iosRegisterSource, iosRegisterDestination, force);
590
- assertCopyAllowed(
735
+ assertGeneratedCopyAllowed(
736
+ iosRegisterSource,
737
+ iosRegisterDestination,
738
+ force,
739
+ LEGACY_GENERATED_FILE_SHA256.canonicalIosRegistrars,
740
+ );
741
+ assertGeneratedCopyAllowed(
591
742
  xcodeCloudHookSource,
592
743
  xcodeCloudHookDestination,
593
744
  force,
745
+ [LEGACY_GENERATED_FILE_SHA256.xcodeCloudHook],
594
746
  );
595
747
  }
596
748
  if (
@@ -652,6 +804,9 @@ export function configureExpoApp(
652
804
  fs.chmodSync(iosRegisterDestination, 0o755);
653
805
  fs.chmodSync(xcodeCloudHookDestination, 0o755);
654
806
  }
807
+ for (const migration of legacyFileMigrations) {
808
+ removeLegacyGeneratedFile(migration, migrationWarnings);
809
+ }
655
810
 
656
811
  return {
657
812
  appRoot,
@@ -662,5 +817,6 @@ export function configureExpoApp(
662
817
  platform,
663
818
  packageManager,
664
819
  publisherEnvConfigured: Boolean(localPublisherEnv),
820
+ migrationWarnings,
665
821
  };
666
822
  }