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,5 +1,27 @@
|
|
|
1
1
|
# Аварийное восстановление OTA
|
|
2
2
|
|
|
3
|
+
## Глобальная аварийная остановка
|
|
4
|
+
|
|
5
|
+
Если необходимо немедленно прекратить **любую** OTA-раздачу, используйте
|
|
6
|
+
глобальный переключатель `ACTIVE/BLOCKED` на `/updates`. Он имеет приоритет над
|
|
7
|
+
всеми emergency redirects: manifest вернёт `noUpdateAvailable`, а уже выданные
|
|
8
|
+
ссылки `/api/assets` перестанут отдавать bytes и ответят `503 no-store`.
|
|
9
|
+
|
|
10
|
+
Укажите причину/номер инцидента, подтвердите включение и проверьте manifest и
|
|
11
|
+
asset URL. После исправления проверьте pointers каналов, подтвердите выключение
|
|
12
|
+
блокировки и повторите проверки для iOS и Android.
|
|
13
|
+
|
|
14
|
+
RPC переключателя и DB-триггеры mutations используют одну transaction advisory
|
|
15
|
+
lock. Поэтому конкурентная activation/channel mutation либо завершится до
|
|
16
|
+
включения `BLOCKED`, либо дождётся его и будет отклонена PostgreSQL с SQLSTATE
|
|
17
|
+
`P0OTA` и сообщением `OTA_DISTRIBUTION_BLOCKED`. Deactivation, inactive draft
|
|
18
|
+
insert и безопасные metadata edits остаются доступны. Не отключайте guard
|
|
19
|
+
triggers во время инцидента.
|
|
20
|
+
|
|
21
|
+
Новые manifest используют gated server-proxy URL `/api/assets`. Уже выданные
|
|
22
|
+
старыми версиями сервера immutable storage/CDN URL отозвать этим switch
|
|
23
|
+
невозможно; это ограничение legacy URL должно учитываться в incident response.
|
|
24
|
+
|
|
3
25
|
Emergency redirect используется, когда опубликованный binary build запрашивает
|
|
4
26
|
неправильный нативный Expo channel. JavaScript OTA не может изменить channel,
|
|
5
27
|
записанный в Android Manifest или iOS Expo.plist, поэтому сервер точечно
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# OTA update policy client contract
|
|
2
|
+
|
|
3
|
+
Every served update manifest includes `extra.updatePolicy`:
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"schemaVersion": 1,
|
|
8
|
+
"policyVersion": 2,
|
|
9
|
+
"delivery": "background",
|
|
10
|
+
"guard": {
|
|
11
|
+
"action": "require-confirmation",
|
|
12
|
+
"payload": { "message": "Restart when ready" }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The `guard` property is omitted when no Guard is configured. A configured
|
|
18
|
+
Guard is unconditional: it is included for every client to which the existing
|
|
19
|
+
runtime, channel, platform, and update selection logic serves that OTA.
|
|
20
|
+
Catalog membership is advisory and is not required to save or serve an action.
|
|
21
|
+
|
|
22
|
+
- `Updates.checkForUpdateAsync()` returns the policy on the **candidate**
|
|
23
|
+
manifest in the check result.
|
|
24
|
+
- `Updates.manifest` contains the policy of the update that is **currently
|
|
25
|
+
running**. Do not use it as the candidate policy before downloading.
|
|
26
|
+
- `manual` is the default and leaves fetch/reload behavior to the application.
|
|
27
|
+
- `background` means fetch the candidate silently, do not reload immediately,
|
|
28
|
+
and apply it on the next cold start.
|
|
29
|
+
- Legacy clients safely ignore the additional `extra` value.
|
|
30
|
+
|
|
31
|
+
An inactive upload is a draft, even though its initial `disabled_at` value is
|
|
32
|
+
equal to `created_at`. Its delivery mode and simple Guard remain editable until
|
|
33
|
+
activation. `disabled_at` by itself is not evidence that an update was
|
|
34
|
+
published.
|
|
35
|
+
|
|
36
|
+
`ota_update_channels.latest_update_id` identifies the newest upload and may
|
|
37
|
+
therefore point to an inactive draft. That pointer is not publication evidence;
|
|
38
|
+
manifest selection falls back to the latest active update. An
|
|
39
|
+
`active_update_id` rollback pointer or an `ota_served_manifest_log` row is
|
|
40
|
+
publication evidence.
|
|
41
|
+
|
|
42
|
+
Activation is the publication event. Once activated, promoted, used as a
|
|
43
|
+
rollback target, or demonstrably served, a policy remains immutable even if the
|
|
44
|
+
update is later disabled. Publish a new update ID when policy needs to change.
|
|
45
|
+
|
|
46
|
+
## Production upgrade order
|
|
47
|
+
|
|
48
|
+
Back up the database. Existing installations should apply these idempotent
|
|
49
|
+
migrations in order:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
psql "$DATABASE_URL" -f docs/migrations/2026-09-01-p1-guard-actions.sql
|
|
53
|
+
psql "$DATABASE_URL" -f docs/migrations/2026-09-01-p2-simplify-ota-guard-policy.sql
|
|
54
|
+
psql "$DATABASE_URL" -f docs/migrations/2026-09-01-policy-publication-correction.sql
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The simplification migration deliberately drops `guard_rules` without
|
|
58
|
+
converting old rules. It adds nullable `guard_action` and `guard_payload`
|
|
59
|
+
columns and recreates the policy immutability trigger for the simple model.
|
|
60
|
+
The final corrective migration only clears incorrectly inferred publication
|
|
61
|
+
markers for conservative, inactive, never-served default policies. It does not
|
|
62
|
+
unlock active, rollback, or served updates.
|
|
63
|
+
|
|
64
|
+
Environments that already successfully ran
|
|
65
|
+
`2026-09-01-policy-publication-correction.sql` and verified that no drafts
|
|
66
|
+
remain falsely marked as published may skip the third step. Otherwise, the
|
|
67
|
+
correction must run third because it references the `guard_action` and
|
|
68
|
+
`guard_payload` columns created by the simplification migration.
|
|
69
|
+
|
|
70
|
+
Supabase users can run the same files in SQL Editor in the listed order. Fresh
|
|
71
|
+
installations should apply only the canonical
|
|
72
|
+
`docs/migrations/schema.sql`, which contains the simple model.
|
|
73
|
+
|
|
74
|
+
## Guard action catalog
|
|
75
|
+
|
|
76
|
+
The policy editor loads reusable action names from `ota_guard_actions`. New
|
|
77
|
+
installations receive the `ota-force-store-update` action. Operators can create
|
|
78
|
+
an action by typing it in the action combobox or through the catalog-only form,
|
|
79
|
+
which remains available while viewing an immutable policy and never changes
|
|
80
|
+
that policy.
|
|
81
|
+
|
|
82
|
+
Persisted catalog entries can be removed with the trash control. Catalog
|
|
83
|
+
deletion does not modify an existing policy. Its action remains visible as a
|
|
84
|
+
synthetic option until deliberately changed, and synthetic options have no
|
|
85
|
+
delete control.
|
|
86
|
+
|
|
87
|
+
Catalog action keys are trimmed when created, contain 1–100 characters, and
|
|
88
|
+
cannot contain control characters. Viewers can list catalog entries but cannot
|
|
89
|
+
create or delete them.
|
|
@@ -42,6 +42,7 @@ creates:
|
|
|
42
42
|
| `ota_admin_users` | Admin users and roles |
|
|
43
43
|
| `ota_admin_sessions` | Revocable browser sessions |
|
|
44
44
|
| `ota_access_tokens` | Hashed automation tokens |
|
|
45
|
+
| `ota_guard_actions` | Reusable Guard action catalog |
|
|
45
46
|
| `ota_emergency_redirects` | Emergency channel rules |
|
|
46
47
|
|
|
47
48
|
Do not run a pgAdmin schema dump as the installation script. Dumps contain
|
|
@@ -123,7 +124,7 @@ Then sign in at:
|
|
|
123
124
|
https://updates.example.com/login
|
|
124
125
|
```
|
|
125
126
|
|
|
126
|
-
The **Table Editor** should show all
|
|
127
|
+
The **Table Editor** should show all eleven OTA tables listed above.
|
|
127
128
|
|
|
128
129
|
## 7. Upgrades
|
|
129
130
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-updates-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "expo-updates-server",
|
|
9
|
-
"version": "0.1.
|
|
9
|
+
"version": "0.1.5",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-s3": "^3.888.0",
|
|
@@ -124,6 +124,12 @@ try {
|
|
|
124
124
|
: "fill .env.ota.example manually"
|
|
125
125
|
}`,
|
|
126
126
|
);
|
|
127
|
+
if (result.migrationWarnings.length > 0) {
|
|
128
|
+
console.warn("\nMigration warnings:");
|
|
129
|
+
for (const warning of result.migrationWarnings) {
|
|
130
|
+
console.warn(`- ${warning}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
127
133
|
console.log("\nNext:");
|
|
128
134
|
if (!result.publisherEnvConfigured) {
|
|
129
135
|
console.log(
|
|
@@ -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
|
|
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/
|
|
54
|
-
"
|
|
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
|
});
|