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
@@ -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
  }