create-expo-updates-server 0.4.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.
- package/README.md +4 -2
- package/dist/template/Dockerfile +4 -6
- package/dist/template/README.md +4 -9
- package/dist/template/app/api/admin/device-favorites/route.test.ts +125 -0
- package/dist/template/app/api/admin/device-favorites/route.ts +91 -0
- package/dist/template/app/api/admin/distribution-history/restore/route.ts +39 -0
- package/dist/template/app/api/admin/distribution-history/route.test.ts +55 -0
- package/dist/template/app/api/admin/distribution-history/route.ts +24 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +2 -1
- package/dist/template/app/api/admin/updates/route.test.ts +21 -0
- package/dist/template/app/api/admin/updates/route.ts +12 -1
- package/dist/template/app/globals.css +65 -68
- package/dist/template/app/login/page.tsx +66 -42
- package/dist/template/app/updates/[encodedKey]/page.tsx +375 -263
- package/dist/template/app/updates/devices/page.tsx +188 -152
- package/dist/template/app/updates/embedded/page.tsx +63 -29
- package/dist/template/app/updates/emergency-redirects/page.tsx +93 -58
- package/dist/template/app/updates/layout.tsx +2 -1
- package/dist/template/app/updates/page.tsx +381 -283
- package/dist/template/app/updates/releases.test.tsx +156 -0
- package/dist/template/components/admin/admin-role.ts +5 -0
- package/dist/template/components/admin/admin-shell.tsx +166 -101
- package/dist/template/components/admin/confirm-action.tsx +123 -0
- package/dist/template/components/admin/language-switcher.tsx +25 -17
- package/dist/template/components/admin/release-badges.test.tsx +50 -0
- package/dist/template/components/admin/release-badges.tsx +101 -0
- package/dist/template/components/ui/alert.tsx +10 -3
- package/dist/template/components/ui/avatar.tsx +108 -0
- package/dist/template/components/ui/badge.tsx +2 -2
- package/dist/template/components/ui/breadcrumb.tsx +108 -0
- package/dist/template/components/ui/button.tsx +5 -5
- package/dist/template/components/ui/card.tsx +2 -2
- package/dist/template/components/ui/chart.tsx +1 -1
- package/dist/template/components/ui/collapsible.tsx +7 -0
- package/dist/template/components/ui/empty.tsx +103 -0
- package/dist/template/components/ui/field.tsx +248 -0
- package/dist/template/components/ui/input-group.tsx +170 -0
- package/dist/template/components/ui/input.tsx +1 -1
- package/dist/template/components/ui/native-select.tsx +1 -1
- package/dist/template/components/ui/radio-group.tsx +41 -0
- package/dist/template/components/ui/status-tones.ts +15 -0
- package/dist/template/components/ui/table.tsx +1 -1
- package/dist/template/components/ui/textarea.tsx +1 -1
- package/dist/template/docs/admin-ui.md +7 -3
- package/dist/template/docs/device-targeting.md +2 -7
- package/dist/template/docs/doctor.md +2 -2
- package/dist/template/docs/expo-app-setup.md +9 -27
- package/dist/template/docs/getting-started.md +3 -4
- package/dist/template/docs/installation-telemetry.md +2 -8
- package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
- package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
- package/dist/template/docs/migrations/schema.sql +349 -0
- package/dist/template/docs/npm-installer.md +3 -3
- package/dist/template/docs/operations-guide.md +8 -6
- package/dist/template/docs/ota-client-lifecycle.md +30 -68
- package/dist/template/docs/ota-update-policy.md +9 -20
- package/dist/template/docs/ru/admin-ui.md +7 -3
- package/dist/template/docs/ru/device-targeting.md +2 -2
- package/dist/template/docs/ru/doctor.md +2 -2
- package/dist/template/docs/ru/expo-app-setup.md +9 -9
- package/dist/template/docs/ru/getting-started.md +3 -3
- package/dist/template/docs/ru/installation-telemetry.md +2 -2
- package/dist/template/docs/ru/npm-installer.md +3 -3
- package/dist/template/docs/ru/operations-guide.md +8 -3
- package/dist/template/docs/ru/ota-client-lifecycle.md +30 -35
- package/dist/template/docs/ru/ota-update-policy.md +9 -7
- package/dist/template/docs/ru/publishing-npm-installer.md +2 -2
- package/dist/template/docs/uk/admin-ui.md +7 -3
- package/dist/template/docs/uk/device-targeting.md +2 -2
- package/dist/template/docs/uk/doctor.md +2 -2
- package/dist/template/docs/uk/expo-app-setup.md +9 -9
- package/dist/template/docs/uk/getting-started.md +3 -3
- package/dist/template/docs/uk/installation-telemetry.md +2 -2
- package/dist/template/docs/uk/npm-installer.md +3 -3
- package/dist/template/docs/uk/operations-guide.md +8 -3
- package/dist/template/docs/uk/ota-client-lifecycle.md +30 -35
- package/dist/template/docs/uk/ota-update-policy.md +9 -7
- package/dist/template/docs/uk/publishing-npm-installer.md +2 -2
- package/dist/template/lib/audience-ids.ts +4 -0
- package/dist/template/package-lock.json +46 -0
- package/dist/template/package.json +3 -1
- package/dist/template/scripts/configure-expo-app.mjs +3 -3
- package/dist/template/scripts/create-access-token.mjs +1 -1
- package/dist/template/scripts/lib/doctor.mjs +10 -7
- package/dist/template/scripts/lib/doctor.test.mjs +7 -5
- package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
- package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
- package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
- package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
- package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
- package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
- package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
- package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
- package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
- package/dist/template/scripts/tests/e2e/console.mjs +86 -0
- package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
- package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
- package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
- package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
- package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
- package/dist/template/scripts/tests/e2e/release-matrix.mjs +307 -0
- package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
- package/dist/template/scripts/tests/e2e/run.mjs +224 -0
- package/dist/template/scripts/tests/manifest-identity.sql +7 -5
- package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
- package/dist/template/src/client/admin-api.ts +45 -10
- package/dist/template/src/client/admin-types.ts +35 -1
- package/dist/template/src/client/devices/analytics.tsx +168 -231
- package/dist/template/src/client/devices/cohorts.tsx +181 -0
- package/dist/template/src/client/devices/device-name.tsx +37 -23
- package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
- package/dist/template/src/client/devices/registry.tsx +258 -245
- package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
- package/dist/template/src/client/devices/use-devices-report.ts +53 -82
- package/dist/template/src/client/devices/version-adoption-chart.tsx +47 -49
- package/dist/template/src/client/distribution-control.tsx +89 -57
- package/dist/template/src/client/distribution-history.tsx +353 -0
- package/dist/template/src/client/guard-action-catalog.tsx +183 -0
- package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
- package/dist/template/src/client/guard-action-combobox.tsx +133 -239
- package/dist/template/src/client/guard-action-options.ts +4 -6
- package/dist/template/src/client/i18n/en.json +133 -2
- package/dist/template/src/client/i18n/language-switching.test.tsx +12 -3
- package/dist/template/src/client/i18n/ru.json +133 -2
- package/dist/template/src/client/i18n/uk.json +133 -2
- package/dist/template/src/client/logout-button.tsx +3 -3
- package/dist/template/src/client/policy-draft.ts +138 -0
- package/dist/template/src/client/update-audience-editor.tsx +597 -206
- package/dist/template/src/client/update-policy-editor.test.ts +101 -29
- package/dist/template/src/client/update-policy-editor.tsx +454 -320
- package/dist/template/src/client/use-filtered-results.ts +55 -0
- package/dist/template/src/server/controllers/manifest.test.ts +23 -3
- package/dist/template/src/server/controllers/manifest.ts +15 -1
- package/dist/template/src/server/devices/audience.ts +9 -5
- package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
- package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
- package/dist/template/src/server/lib/admin-updates.ts +160 -534
- package/dist/template/src/server/lib/distribution-history.ts +97 -0
- package/dist/template/src/server/lib/supabase.js +24 -0
- package/dist/template/src/server/lib/supabase.test.ts +38 -1
- package/dist/template/src/server/lib/update-policy.test.ts +20 -0
- package/dist/template/src/server/lib/update-policy.ts +23 -10
- package/dist/template/src/server/manifest/manifest-repository.ts +11 -3
- package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
- package/dist/template/src/server/manifest/manifest-values.ts +21 -13
- package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
- package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
- package/dist/template/tsconfig.json +2 -2
- package/dist/template-manifest.json +446 -301
- package/package.json +1 -1
- package/dist/template/scripts/lib/device-identity.test.ts +0 -29
- package/dist/template/scripts/lib/ota-client.test.ts +0 -55
- package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
- package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
- package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
- package/dist/template/templates/expo-app/ota-client/README.md +0 -73
- package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
- package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
- package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
- package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
- package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
- package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
- package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
|
@@ -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
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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(
|
|
129
|
-
fs.readFileSync(
|
|
130
|
-
|
|
131
|
-
) {
|
|
179
|
+
fs.existsSync(backup) &&
|
|
180
|
+
!fs.readFileSync(file).equals(fs.readFileSync(backup))
|
|
181
|
+
)
|
|
132
182
|
throw new Error(
|
|
133
|
-
`Refusing to overwrite ${
|
|
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
|
|
224
|
+
warnings,
|
|
139
225
|
apply() {
|
|
140
|
-
for (const file of
|
|
141
|
-
|
|
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 {
|
|
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("
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
).toBe(
|
|
65
|
-
|
|
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("
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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(
|
|
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
|
|
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(
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const clientPackage = "expo-updates-server-client";
|
|
2
|
+
export const clientVersion = "0.1.0";
|
|
3
|
+
export const nativeClientDependencies = [
|
|
4
|
+
"expo-updates",
|
|
5
|
+
"expo-application",
|
|
6
|
+
"expo-crypto",
|
|
7
|
+
"expo-secure-store",
|
|
8
|
+
"@react-native-async-storage/async-storage",
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
export function originalEntryCode(entry) {
|
|
12
|
+
if (entry === "__platform_default__") return "require('./ota-original-entry');";
|
|
13
|
+
if (entry === "__app_fallback__")
|
|
14
|
+
return "require('expo').registerRootComponent(require('./App').default);";
|
|
15
|
+
return `require(${JSON.stringify(entry)});`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function bootstrapCode(entry) {
|
|
19
|
+
return [
|
|
20
|
+
`const otaClient = require('${clientPackage}');`,
|
|
21
|
+
"otaClient.initializeOtaClient(require('./ota-client/config.json'));",
|
|
22
|
+
"otaClient.start();",
|
|
23
|
+
originalEntryCode(entry),
|
|
24
|
+
].join("\n");
|
|
25
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import ts from "typescript";
|
|
4
|
+
import { clientPackage } from "./ota-client-package.mjs";
|
|
4
5
|
|
|
5
6
|
const extensions = ["tsx", "jsx", "ts", "js"];
|
|
6
7
|
const suffixes = ["", ".android", ".ios", ".native", ".web"];
|
|
@@ -84,16 +85,16 @@ export function patchOtaRootHook(text, filename, appRoot) {
|
|
|
84
85
|
const newline = text.includes("\r\n") ? "\r\n" : "\n";
|
|
85
86
|
const clientPath = path.join(appRoot, "ota-client");
|
|
86
87
|
const imports = source.statements.filter(ts.isImportDeclaration);
|
|
87
|
-
const clientImports = imports.filter(
|
|
88
|
-
(node)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
);
|
|
88
|
+
const clientImports = imports.filter((node) => {
|
|
89
|
+
if (!ts.isStringLiteral(node.moduleSpecifier)) return false;
|
|
90
|
+
const specifier = node.moduleSpecifier.text;
|
|
91
|
+
if (specifier === clientPackage) return true;
|
|
92
|
+
if (!specifier.startsWith(".")) return false;
|
|
93
|
+
const resolved = path.resolve(path.dirname(filename), specifier);
|
|
94
|
+
return ["", "/index", "/index.js", "/index.ts"].some(
|
|
95
|
+
(suffix) => resolved === clientPath + suffix,
|
|
96
|
+
);
|
|
97
|
+
});
|
|
97
98
|
const binding = (nodes, name) =>
|
|
98
99
|
nodes
|
|
99
100
|
.flatMap((node) =>
|
|
@@ -116,15 +117,26 @@ export function patchOtaRootHook(text, filename, appRoot) {
|
|
|
116
117
|
)
|
|
117
118
|
)
|
|
118
119
|
fail(
|
|
119
|
-
"use
|
|
120
|
+
"use an import from expo-updates-server-client or the relative ota-client path so existing configuration can be preserved",
|
|
120
121
|
);
|
|
121
|
-
const
|
|
122
|
-
|
|
122
|
+
const namespaces = clientImports.flatMap(({ importClause }) =>
|
|
123
|
+
!importClause?.isTypeOnly && importClause?.namedBindings &&
|
|
124
|
+
ts.isNamespaceImport(importClause.namedBindings)
|
|
125
|
+
? [importClause.namedBindings.name.text]
|
|
126
|
+
: [],
|
|
127
|
+
);
|
|
128
|
+
const otaBindings = (member) => new Set([
|
|
129
|
+
...clientImports.map((node) => binding([node], member)).filter(Boolean),
|
|
130
|
+
...namespaces.map((name) => `${name}.${member}`),
|
|
131
|
+
]);
|
|
132
|
+
const hookNames = otaBindings("useOtaUpdates");
|
|
133
|
+
const gateNames = otaBindings("OtaUpdateGate");
|
|
123
134
|
const createName = binding(
|
|
124
135
|
imports.filter((node) => node.moduleSpecifier.text === "react"),
|
|
125
136
|
"createElement",
|
|
126
137
|
);
|
|
127
|
-
const
|
|
138
|
+
const componentNames = otaBindings("OtaUpdates");
|
|
139
|
+
const existingName = componentNames.values().next().value;
|
|
128
140
|
const identifiers = new Set();
|
|
129
141
|
const gather = (node) => {
|
|
130
142
|
if (ts.isIdentifier(node)) identifiers.add(node.text);
|
|
@@ -135,7 +147,7 @@ export function patchOtaRootHook(text, filename, appRoot) {
|
|
|
135
147
|
if (!existingName)
|
|
136
148
|
for (let i = 2; identifiers.has(name); i++) name = `OtaUpdates${i}`;
|
|
137
149
|
const watched = new Set(
|
|
138
|
-
[
|
|
150
|
+
[...namespaces, ...hookNames, ...gateNames, ...componentNames, createName].filter(Boolean),
|
|
139
151
|
);
|
|
140
152
|
const checkBinding = (node) => {
|
|
141
153
|
if (!node) return;
|
|
@@ -159,8 +171,7 @@ export function patchOtaRootHook(text, filename, appRoot) {
|
|
|
159
171
|
if (ts.isReturnStatement(node)) returns.push(node);
|
|
160
172
|
if (
|
|
161
173
|
ts.isCallExpression(node) &&
|
|
162
|
-
|
|
163
|
-
node.expression.text === hookName
|
|
174
|
+
hookNames.has(node.expression.getText(source))
|
|
164
175
|
) {
|
|
165
176
|
if (hook) fail("multiple update hooks in the root");
|
|
166
177
|
hook = node;
|
|
@@ -225,7 +236,7 @@ export function patchOtaRootHook(text, filename, appRoot) {
|
|
|
225
236
|
if (!node) return false;
|
|
226
237
|
if (
|
|
227
238
|
(ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) &&
|
|
228
|
-
tagName(node)
|
|
239
|
+
componentNames.has(tagName(node))
|
|
229
240
|
)
|
|
230
241
|
return true;
|
|
231
242
|
if (ts.isJsxElement(node) || ts.isJsxFragment(node))
|
|
@@ -237,12 +248,12 @@ export function patchOtaRootHook(text, filename, appRoot) {
|
|
|
237
248
|
if (!node) return false;
|
|
238
249
|
if (
|
|
239
250
|
(ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) &&
|
|
240
|
-
tagName(node)
|
|
251
|
+
componentNames.has(tagName(node))
|
|
241
252
|
)
|
|
242
253
|
return true;
|
|
243
254
|
return ts.forEachChild(node, containsComponent) || false;
|
|
244
255
|
};
|
|
245
|
-
const obsolete = new Set([
|
|
256
|
+
const obsolete = new Set([...hookNames, ...gateNames, createName].filter(Boolean));
|
|
246
257
|
const expressions = ts.isBlock(component.body)
|
|
247
258
|
? returns.map((node) => ({ node, expression: node.expression }))
|
|
248
259
|
: [{ expression: component.body }];
|
|
@@ -266,7 +277,7 @@ export function patchOtaRootHook(text, filename, appRoot) {
|
|
|
266
277
|
ts.isCallExpression(child) &&
|
|
267
278
|
ts.isIdentifier(child.expression) &&
|
|
268
279
|
child.expression.text === createName &&
|
|
269
|
-
child.arguments[0]?.getText(source)
|
|
280
|
+
gateNames.has(child.arguments[0]?.getText(source))
|
|
270
281
|
) {
|
|
271
282
|
const settings = child.arguments[1];
|
|
272
283
|
if (
|
|
@@ -285,7 +296,7 @@ export function patchOtaRootHook(text, filename, appRoot) {
|
|
|
285
296
|
} else if (
|
|
286
297
|
child &&
|
|
287
298
|
(ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child)) &&
|
|
288
|
-
tagName(child)
|
|
299
|
+
gateNames.has(tagName(child))
|
|
289
300
|
) {
|
|
290
301
|
const opening = child.openingElement || child;
|
|
291
302
|
const attrs = opening.attributes.properties;
|
|
@@ -335,24 +346,20 @@ export function patchOtaRootHook(text, filename, appRoot) {
|
|
|
335
346
|
};
|
|
336
347
|
inspectReferences(component.body);
|
|
337
348
|
}
|
|
349
|
+
const migrateImportsOnly = !edits.length;
|
|
338
350
|
for (const node of clientImports) {
|
|
339
|
-
if (node.moduleSpecifier.text
|
|
351
|
+
if (node.moduleSpecifier.text !== clientPackage) {
|
|
340
352
|
const specifier = node.moduleSpecifier;
|
|
341
353
|
const quote = text[specifier.getStart(source)];
|
|
342
354
|
edits.push({
|
|
343
355
|
start: specifier.getStart(source),
|
|
344
356
|
end: specifier.end,
|
|
345
|
-
content: `${quote}${
|
|
357
|
+
content: `${quote}${clientPackage}${quote}`,
|
|
346
358
|
});
|
|
347
359
|
}
|
|
348
360
|
}
|
|
349
361
|
if (!edits.length) return text;
|
|
350
362
|
if (!existingName) {
|
|
351
|
-
let relative = path
|
|
352
|
-
.relative(path.dirname(filename), clientPath)
|
|
353
|
-
.split(path.sep)
|
|
354
|
-
.join("/");
|
|
355
|
-
if (!relative.startsWith(".")) relative = `./${relative}`;
|
|
356
363
|
let at =
|
|
357
364
|
imports.at(-1)?.end ??
|
|
358
365
|
source.statements[0]?.getStart(source) ??
|
|
@@ -366,11 +373,12 @@ export function patchOtaRootHook(text, filename, appRoot) {
|
|
|
366
373
|
edits.push({
|
|
367
374
|
start: at,
|
|
368
375
|
end: at,
|
|
369
|
-
content: `${newline}import { ${specifier} } from '${
|
|
376
|
+
content: `${newline}import { ${specifier} } from '${clientPackage}';${newline}`,
|
|
370
377
|
});
|
|
371
378
|
}
|
|
372
379
|
for (const edit of edits.sort((a, b) => b.start - a.start))
|
|
373
380
|
text = text.slice(0, edit.start) + edit.content + text.slice(edit.end);
|
|
381
|
+
if (migrateImportsOnly) return text;
|
|
374
382
|
// Drop only obsolete imports which no longer have references after migration.
|
|
375
383
|
const updated = ts.createSourceFile(
|
|
376
384
|
filename,
|
|
@@ -443,6 +451,44 @@ function formatRoot(text, filename, newline) {
|
|
|
443
451
|
}
|
|
444
452
|
}
|
|
445
453
|
|
|
454
|
+
// Expo's blank template imports App and registers it directly in index.js.
|
|
455
|
+
function registersDefaultApp(filename) {
|
|
456
|
+
const source = ts.createSourceFile(
|
|
457
|
+
filename,
|
|
458
|
+
fs.readFileSync(filename, "utf8"),
|
|
459
|
+
ts.ScriptTarget.Latest,
|
|
460
|
+
true,
|
|
461
|
+
);
|
|
462
|
+
if (source.parseDiagnostics.length || source.statements.length !== 3)
|
|
463
|
+
return false;
|
|
464
|
+
const imports = source.statements.filter(ts.isImportDeclaration);
|
|
465
|
+
const registration = imports.find(
|
|
466
|
+
(node) => node.moduleSpecifier.text === "expo",
|
|
467
|
+
)?.importClause?.namedBindings;
|
|
468
|
+
const app = imports.find((node) => node.moduleSpecifier.text === "./App")
|
|
469
|
+
?.importClause?.name;
|
|
470
|
+
if (!app || !registration || !ts.isNamedImports(registration)) return false;
|
|
471
|
+
const register = registration.elements.find(
|
|
472
|
+
(element) =>
|
|
473
|
+
(element.propertyName ?? element.name).text === "registerRootComponent",
|
|
474
|
+
);
|
|
475
|
+
const last = source.statements[2];
|
|
476
|
+
if (
|
|
477
|
+
!register ||
|
|
478
|
+
!ts.isExpressionStatement(last) ||
|
|
479
|
+
!ts.isCallExpression(last.expression)
|
|
480
|
+
)
|
|
481
|
+
return false;
|
|
482
|
+
const call = last.expression;
|
|
483
|
+
return (
|
|
484
|
+
ts.isIdentifier(call.expression) &&
|
|
485
|
+
call.expression.text === register.name.text &&
|
|
486
|
+
call.arguments.length === 1 &&
|
|
487
|
+
ts.isIdentifier(call.arguments[0]) &&
|
|
488
|
+
call.arguments[0].text === app.text
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
|
|
446
492
|
export function planOtaRootHook({ appRoot, originalEntry }) {
|
|
447
493
|
const candidates = (base) =>
|
|
448
494
|
suffixes
|
|
@@ -458,9 +504,21 @@ export function planOtaRootHook({ appRoot, originalEntry }) {
|
|
|
458
504
|
? "src/app/_layout"
|
|
459
505
|
: "app/_layout",
|
|
460
506
|
);
|
|
507
|
+
} else if (
|
|
508
|
+
/^(?:\.\/)?index(?:\.[jt]sx?)?$/.test(originalEntry) ||
|
|
509
|
+
originalEntry === "__platform_default__"
|
|
510
|
+
) {
|
|
511
|
+
const entries = candidates("index");
|
|
512
|
+
if (
|
|
513
|
+
entries.length &&
|
|
514
|
+
entries.every((entry) => registersDefaultApp(path.join(appRoot, entry)))
|
|
515
|
+
) {
|
|
516
|
+
roots = candidates("App");
|
|
517
|
+
} else if (!entries.length && originalEntry === "__platform_default__") {
|
|
518
|
+
roots = candidates("App");
|
|
519
|
+
}
|
|
461
520
|
} else if (
|
|
462
521
|
[
|
|
463
|
-
"__platform_default__",
|
|
464
522
|
"__app_fallback__",
|
|
465
523
|
"node_modules/expo/AppEntry.js",
|
|
466
524
|
"expo/AppEntry",
|
|
@@ -474,7 +532,7 @@ export function planOtaRootHook({ appRoot, originalEntry }) {
|
|
|
474
532
|
return {
|
|
475
533
|
files: [],
|
|
476
534
|
warnings: [
|
|
477
|
-
"The OTA identity/telemetry bootstrap is configured, but no safely identifiable root component was found. Render <OtaUpdates /> from
|
|
535
|
+
"The OTA identity/telemetry bootstrap is configured, but no safely identifiable root component was found. Render <OtaUpdates /> from expo-updates-server-client beside navigation in your main layout to enable update orchestration.",
|
|
478
536
|
],
|
|
479
537
|
};
|
|
480
538
|
return {
|