create-expo-updates-server 0.1.3 → 0.1.5
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.
- package/dist/template/.env.docker.example +1 -0
- package/dist/template/.env.example +2 -0
- package/dist/template/README.md +16 -8
- package/dist/template/app/api/admin/distribution-control/route.test.ts +153 -0
- package/dist/template/app/api/admin/distribution-control/route.ts +111 -0
- package/dist/template/app/api/admin/embedded-updates/route.test.ts +36 -1
- package/dist/template/app/api/admin/guard-actions/[id]/route.test.ts +60 -0
- package/dist/template/app/api/admin/guard-actions/[id]/route.ts +32 -0
- package/dist/template/app/api/admin/guard-actions/route.test.ts +123 -0
- package/dist/template/app/api/admin/guard-actions/route.ts +66 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +4 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/policy/route.test.ts +171 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/policy/route.ts +75 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +4 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +4 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +4 -1
- package/dist/template/app/api/admin/updates/route.test.ts +29 -1
- package/dist/template/app/updates/[encodedKey]/page.tsx +74 -6
- package/dist/template/app/updates/embedded/page.tsx +6 -2
- package/dist/template/app/updates/page.tsx +28 -3
- package/dist/template/docs/expo-app-setup.md +14 -3
- package/dist/template/docs/getting-started.md +13 -7
- package/dist/template/docs/getting-started.ru.md +15 -7
- package/dist/template/docs/migrations/2026-09-01-app-version-columns.sql +23 -0
- package/dist/template/docs/migrations/2026-09-01-ota-update-policy.sql +108 -0
- package/dist/template/docs/migrations/2026-09-01-p1-guard-actions.sql +19 -0
- package/dist/template/docs/migrations/2026-09-01-p2-simplify-ota-guard-policy.sql +69 -0
- package/dist/template/docs/migrations/2026-09-01-policy-publication-correction.sql +44 -0
- package/dist/template/docs/migrations/2026-09-02-ota-distribution-control.sql +377 -0
- package/dist/template/docs/migrations/schema.sql +561 -2
- package/dist/template/docs/operations-guide.md +52 -1
- package/dist/template/docs/ota-emergency-recovery.md +22 -0
- package/dist/template/docs/ota-update-policy.md +89 -0
- package/dist/template/docs/supabase-setup.md +2 -1
- package/dist/template/package-lock.json +2 -2
- package/dist/template/package.json +1 -1
- package/dist/template/scripts/configure-expo-app.mjs +6 -0
- package/dist/template/scripts/lib/embedded-update-registrar.test.ts +383 -3
- package/dist/template/scripts/lib/expo-app-configurator.mjs +165 -9
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +658 -9
- package/dist/template/src/client/admin-api.ts +80 -1
- package/dist/template/src/client/admin-types.ts +52 -2
- package/dist/template/src/client/distribution-control.tsx +231 -0
- package/dist/template/src/client/guard-action-combobox.test.ts +26 -0
- package/dist/template/src/client/guard-action-combobox.tsx +267 -0
- package/dist/template/src/client/guard-action-options.test.ts +62 -0
- package/dist/template/src/client/guard-action-options.ts +70 -0
- package/dist/template/src/client/update-policy-editor.test.ts +36 -0
- package/dist/template/src/client/update-policy-editor.tsx +436 -0
- package/dist/template/src/server/controllers/assets.test.ts +87 -0
- package/dist/template/src/server/controllers/assets.ts +26 -0
- package/dist/template/src/server/controllers/manifest.test.ts +413 -2
- package/dist/template/src/server/controllers/manifest.ts +103 -38
- package/dist/template/src/server/lib/admin-distribution-guard.test.ts +61 -0
- package/dist/template/src/server/lib/admin-embedded-updates.test.ts +57 -0
- package/dist/template/src/server/lib/admin-embedded-updates.ts +42 -25
- package/dist/template/src/server/lib/admin-update-policy.test.ts +176 -0
- package/dist/template/src/server/lib/admin-updates.test.ts +133 -0
- package/dist/template/src/server/lib/admin-updates.ts +174 -9
- package/dist/template/src/server/lib/distribution-control-migration.test.ts +94 -0
- package/dist/template/src/server/lib/distribution-control.test.ts +160 -0
- package/dist/template/src/server/lib/distribution-control.ts +250 -0
- package/dist/template/src/server/lib/guard-actions-migration.test.ts +56 -0
- package/dist/template/src/server/lib/guard-actions.test.ts +142 -0
- package/dist/template/src/server/lib/guard-actions.ts +106 -0
- package/dist/template/src/server/lib/ota-policy-migrations.test.ts +64 -0
- package/dist/template/src/server/lib/simple-policy-migration.test.ts +97 -0
- package/dist/template/src/server/lib/supabase.js +95 -8
- package/dist/template/src/server/lib/supabase.test.ts +194 -0
- package/dist/template/src/server/lib/update-policy.test.ts +98 -0
- package/dist/template/src/server/lib/update-policy.ts +171 -0
- package/dist/template/src/server/manifest/manifest-repository.ts +10 -1
- package/dist/template/src/server/manifest/manifest-response.ts +0 -16
- package/dist/template/src/server/manifest/manifest-values.test.ts +54 -0
- package/dist/template/src/server/manifest/manifest-values.ts +145 -0
- package/dist/template/templates/expo-app/ci_scripts/ci_post_xcodebuild.sh +23 -1
- package/dist/template/templates/expo-app/plugins/with-ota-embedded-registration.js +13 -4
- package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +53 -7
- package/dist/template/templates/expo-app/scripts/ota-register-embedded/register-ios.sh +87 -0
- package/dist/template/tsconfig.json +4 -1
- package/dist/template-manifest.json +283 -88
- package/package.json +1 -1
- package/dist/template/templates/expo-app/ci_scripts/register-embedded-update.sh +0 -36
- /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
|
-
|
|
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
|
-
|
|
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
|
-
"
|
|
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
|
-
"
|
|
530
|
-
"register-embedded
|
|
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
|
-
|
|
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
|
-
|
|
728
|
+
assertGeneratedCopyAllowed(
|
|
729
|
+
iosPluginSource,
|
|
730
|
+
iosPluginDestination,
|
|
731
|
+
force,
|
|
732
|
+
[LEGACY_GENERATED_FILE_SHA256.iosPlugin],
|
|
733
|
+
);
|
|
588
734
|
if (platform !== "android") {
|
|
589
|
-
|
|
590
|
-
|
|
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
|
}
|