create-expo-updates-server 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/template/README.md +12 -7
- package/dist/template/app/api/admin/embedded-updates/route.test.ts +36 -1
- package/dist/template/app/api/admin/updates/route.test.ts +29 -1
- package/dist/template/app/updates/embedded/page.tsx +6 -2
- package/dist/template/app/updates/page.tsx +6 -2
- package/dist/template/docs/expo-app-setup.md +14 -3
- package/dist/template/docs/getting-started.md +12 -7
- package/dist/template/docs/getting-started.ru.md +13 -6
- package/dist/template/docs/migrations/2026-09-01-app-version-columns.sql +23 -0
- package/dist/template/docs/migrations/schema.sql +22 -0
- 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-types.ts +2 -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-updates.test.ts +61 -0
- package/dist/template/src/server/lib/admin-updates.ts +23 -3
- 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-manifest.json +65 -50
- 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,6 +1,7 @@
|
|
|
1
1
|
export type UpdateItem = {
|
|
2
2
|
key: string;
|
|
3
3
|
encodedKey: string;
|
|
4
|
+
appVersion: string | null;
|
|
4
5
|
comment: string | null;
|
|
5
6
|
runtimeVersion: string;
|
|
6
7
|
platform: "ios" | "android";
|
|
@@ -48,6 +49,7 @@ export type UpdateDetail = UpdateItem & {
|
|
|
48
49
|
|
|
49
50
|
export type EmbeddedUpdateItem = {
|
|
50
51
|
embeddedUpdateId: string;
|
|
52
|
+
appVersion: string | null;
|
|
51
53
|
createdAt: string;
|
|
52
54
|
channel: string;
|
|
53
55
|
platform: "ios" | "android";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
buildEmbeddedUpdateUpsertRow,
|
|
4
|
+
mapEmbeddedUpdateRow,
|
|
5
|
+
parseRegisterEmbeddedUpdateInput,
|
|
6
|
+
} from "./admin-embedded-updates";
|
|
7
|
+
|
|
8
|
+
const baseInput = {
|
|
9
|
+
embeddedUpdateId: "55555555-5555-4555-8555-555555555555",
|
|
10
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
11
|
+
channel: "production",
|
|
12
|
+
platform: "ios" as const,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe("embedded update app versions", () => {
|
|
16
|
+
it("normalizes an incoming appVersion and remains compatible when absent", () => {
|
|
17
|
+
expect(
|
|
18
|
+
parseRegisterEmbeddedUpdateInput({
|
|
19
|
+
...baseInput,
|
|
20
|
+
appVersion: " 2.4.1 ",
|
|
21
|
+
}).appVersion,
|
|
22
|
+
).toBe("2.4.1");
|
|
23
|
+
expect(parseRegisterEmbeddedUpdateInput(baseInput).appVersion).toBeNull();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("does not include a missing appVersion in an upsert", () => {
|
|
27
|
+
const row = buildEmbeddedUpdateUpsertRow({
|
|
28
|
+
...baseInput,
|
|
29
|
+
appVersion: null,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
expect(row).not.toHaveProperty("app_version");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("includes a new non-empty appVersion so an upsert can update it", () => {
|
|
36
|
+
const row = buildEmbeddedUpdateUpsertRow({
|
|
37
|
+
...baseInput,
|
|
38
|
+
appVersion: "2.4.1",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
expect(row).toHaveProperty("app_version", "2.4.1");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("maps missing legacy values to null", () => {
|
|
45
|
+
const item = mapEmbeddedUpdateRow({
|
|
46
|
+
embedded_update_id: baseInput.embeddedUpdateId,
|
|
47
|
+
created_at: baseInput.createdAt,
|
|
48
|
+
channel: baseInput.channel,
|
|
49
|
+
platform: baseInput.platform,
|
|
50
|
+
is_embedded: true,
|
|
51
|
+
inserted_at: baseInput.createdAt,
|
|
52
|
+
modified_at: baseInput.createdAt,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(item.appVersion).toBeNull();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { supabase } from "./supabase.js";
|
|
2
2
|
|
|
3
|
-
type EmbeddedUpdateRow = {
|
|
3
|
+
export type EmbeddedUpdateRow = {
|
|
4
4
|
embedded_update_id: string;
|
|
5
|
+
app_version?: string | null;
|
|
5
6
|
created_at: string;
|
|
6
7
|
channel: string;
|
|
7
8
|
platform: "ios" | "android";
|
|
@@ -12,6 +13,7 @@ type EmbeddedUpdateRow = {
|
|
|
12
13
|
|
|
13
14
|
export type EmbeddedUpdateRecord = {
|
|
14
15
|
embeddedUpdateId: string;
|
|
16
|
+
appVersion: string | null;
|
|
15
17
|
createdAt: string;
|
|
16
18
|
channel: string;
|
|
17
19
|
platform: "ios" | "android";
|
|
@@ -22,6 +24,7 @@ export type EmbeddedUpdateRecord = {
|
|
|
22
24
|
|
|
23
25
|
export type RegisterEmbeddedUpdateInput = {
|
|
24
26
|
embeddedUpdateId: string;
|
|
27
|
+
appVersion: string | null;
|
|
25
28
|
createdAt: string;
|
|
26
29
|
channel: string;
|
|
27
30
|
platform: "ios" | "android";
|
|
@@ -47,6 +50,10 @@ export function parseRegisterEmbeddedUpdateInput(
|
|
|
47
50
|
const createdAt = String(input.createdAt || "").trim();
|
|
48
51
|
const channel = String(input.channel || "").trim().toLowerCase();
|
|
49
52
|
const platform = String(input.platform || "").trim().toLowerCase();
|
|
53
|
+
const appVersion =
|
|
54
|
+
typeof input.appVersion === "string" && input.appVersion.trim()
|
|
55
|
+
? input.appVersion.trim()
|
|
56
|
+
: null;
|
|
50
57
|
|
|
51
58
|
if (!UUID_PATTERN.test(embeddedUpdateId)) {
|
|
52
59
|
throw new EmbeddedUpdateValidationError(
|
|
@@ -71,27 +78,53 @@ export function parseRegisterEmbeddedUpdateInput(
|
|
|
71
78
|
|
|
72
79
|
return {
|
|
73
80
|
embeddedUpdateId,
|
|
81
|
+
appVersion,
|
|
74
82
|
createdAt: new Date(createdAt).toISOString(),
|
|
75
83
|
channel,
|
|
76
84
|
platform,
|
|
77
85
|
};
|
|
78
86
|
}
|
|
79
87
|
|
|
80
|
-
export
|
|
88
|
+
export function mapEmbeddedUpdateRow(
|
|
89
|
+
row: EmbeddedUpdateRow,
|
|
90
|
+
): EmbeddedUpdateRecord {
|
|
91
|
+
return {
|
|
92
|
+
embeddedUpdateId: row.embedded_update_id,
|
|
93
|
+
appVersion: row.app_version || null,
|
|
94
|
+
createdAt: row.created_at,
|
|
95
|
+
channel: row.channel,
|
|
96
|
+
platform: row.platform,
|
|
97
|
+
isEmbedded: row.is_embedded,
|
|
98
|
+
insertedAt: row.inserted_at,
|
|
99
|
+
modifiedAt: row.modified_at,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function buildEmbeddedUpdateUpsertRow(
|
|
81
104
|
input: RegisterEmbeddedUpdateInput,
|
|
82
|
-
)
|
|
83
|
-
|
|
105
|
+
) {
|
|
106
|
+
return {
|
|
84
107
|
embedded_update_id: input.embeddedUpdateId,
|
|
85
108
|
created_at: input.createdAt,
|
|
86
109
|
channel: input.channel,
|
|
87
110
|
platform: input.platform,
|
|
88
111
|
is_embedded: true,
|
|
112
|
+
...(input.appVersion ? { app_version: input.appVersion } : {}),
|
|
89
113
|
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function registerEmbeddedUpdate(
|
|
117
|
+
input: RegisterEmbeddedUpdateInput,
|
|
118
|
+
): Promise<EmbeddedUpdateRecord> {
|
|
119
|
+
const row = buildEmbeddedUpdateUpsertRow(input);
|
|
90
120
|
const { data, error } = await supabase
|
|
91
121
|
.from("ota_embedded_updates")
|
|
92
|
-
.upsert(row, {
|
|
122
|
+
.upsert(row, {
|
|
123
|
+
onConflict: "embedded_update_id",
|
|
124
|
+
defaultToNull: false,
|
|
125
|
+
})
|
|
93
126
|
.select(
|
|
94
|
-
"embedded_update_id,created_at,channel,platform,is_embedded,inserted_at,modified_at",
|
|
127
|
+
"embedded_update_id,app_version,created_at,channel,platform,is_embedded,inserted_at,modified_at",
|
|
95
128
|
)
|
|
96
129
|
.single();
|
|
97
130
|
|
|
@@ -100,22 +133,14 @@ export async function registerEmbeddedUpdate(
|
|
|
100
133
|
}
|
|
101
134
|
|
|
102
135
|
const saved = data as EmbeddedUpdateRow;
|
|
103
|
-
return
|
|
104
|
-
embeddedUpdateId: saved.embedded_update_id,
|
|
105
|
-
createdAt: saved.created_at,
|
|
106
|
-
channel: saved.channel,
|
|
107
|
-
platform: saved.platform,
|
|
108
|
-
isEmbedded: saved.is_embedded,
|
|
109
|
-
insertedAt: saved.inserted_at,
|
|
110
|
-
modifiedAt: saved.modified_at,
|
|
111
|
-
};
|
|
136
|
+
return mapEmbeddedUpdateRow(saved);
|
|
112
137
|
}
|
|
113
138
|
|
|
114
139
|
export async function listEmbeddedUpdates(): Promise<EmbeddedUpdateRecord[]> {
|
|
115
140
|
const { data, error } = await supabase
|
|
116
141
|
.from("ota_embedded_updates")
|
|
117
142
|
.select(
|
|
118
|
-
"embedded_update_id,created_at,channel,platform,is_embedded,inserted_at,modified_at",
|
|
143
|
+
"embedded_update_id,app_version,created_at,channel,platform,is_embedded,inserted_at,modified_at",
|
|
119
144
|
)
|
|
120
145
|
.order("created_at", { ascending: false })
|
|
121
146
|
.execute();
|
|
@@ -124,15 +149,7 @@ export async function listEmbeddedUpdates(): Promise<EmbeddedUpdateRecord[]> {
|
|
|
124
149
|
throw new Error(`Failed to fetch embedded updates: ${error.message}`);
|
|
125
150
|
}
|
|
126
151
|
|
|
127
|
-
return ((data || []) as EmbeddedUpdateRow[]).map(
|
|
128
|
-
embeddedUpdateId: row.embedded_update_id,
|
|
129
|
-
createdAt: row.created_at,
|
|
130
|
-
channel: row.channel,
|
|
131
|
-
platform: row.platform,
|
|
132
|
-
isEmbedded: row.is_embedded,
|
|
133
|
-
insertedAt: row.inserted_at,
|
|
134
|
-
modifiedAt: row.modified_at,
|
|
135
|
-
}));
|
|
152
|
+
return ((data || []) as EmbeddedUpdateRow[]).map(mapEmbeddedUpdateRow);
|
|
136
153
|
}
|
|
137
154
|
|
|
138
155
|
export async function deleteEmbeddedUpdateById(embeddedUpdateId: string) {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
mapRowToRecord,
|
|
4
|
+
OtaUpdateRow,
|
|
5
|
+
} from "./admin-updates";
|
|
6
|
+
|
|
7
|
+
function makeRow(manifest: Record<string, unknown> = {}): OtaUpdateRow {
|
|
8
|
+
return {
|
|
9
|
+
id: "11111111-1111-4111-8111-111111111111",
|
|
10
|
+
update_id: "22222222-2222-4222-8222-222222222222",
|
|
11
|
+
build_id: "33333333-3333-4333-8333-333333333333",
|
|
12
|
+
comment: null,
|
|
13
|
+
runtime_version: "runtime-1",
|
|
14
|
+
channel: "production",
|
|
15
|
+
platform: "ios",
|
|
16
|
+
created_at: "2026-01-01T00:00:00.000Z",
|
|
17
|
+
created_at_path: "2026/01/01/000000",
|
|
18
|
+
storage_bucket: "updates",
|
|
19
|
+
storage_base_path: "runtime-1/ios/update",
|
|
20
|
+
is_active: true,
|
|
21
|
+
updated_at: null,
|
|
22
|
+
disabled_at: null,
|
|
23
|
+
assets_count: 2,
|
|
24
|
+
launch_asset_path: "bundle.js",
|
|
25
|
+
rolled_back_from_update_id: null,
|
|
26
|
+
manifest,
|
|
27
|
+
inserted_at: "2026-01-01T00:00:00.000Z",
|
|
28
|
+
modified_at: "2026-01-01T00:00:00.000Z",
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe("OTA admin update mapping", () => {
|
|
33
|
+
it("maps expoClient.version from the stored manifest", () => {
|
|
34
|
+
const item = mapRowToRecord(
|
|
35
|
+
makeRow({ expoClient: { version: "2.4.1" } }),
|
|
36
|
+
null,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
expect(item.appVersion).toBe("2.4.1");
|
|
40
|
+
expect(item.runtimeVersion).toBe("runtime-1");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("normalizes a non-empty manifest app version", () => {
|
|
44
|
+
const item = mapRowToRecord(
|
|
45
|
+
makeRow({ expoClient: { version: " 2.4.1 " } }),
|
|
46
|
+
null,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
expect(item.appVersion).toBe("2.4.1");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it.each([
|
|
53
|
+
["missing expoClient", {}],
|
|
54
|
+
["missing version", { expoClient: {} }],
|
|
55
|
+
["blank version", { expoClient: { version: " \t " } }],
|
|
56
|
+
["non-string version", { expoClient: { version: 241 } }],
|
|
57
|
+
["malformed expoClient", { expoClient: "invalid" }],
|
|
58
|
+
])("maps %s to null", (_case, manifest) => {
|
|
59
|
+
expect(mapRowToRecord(makeRow(manifest), null).appVersion).toBeNull();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -89,7 +89,7 @@ type UpdateMetaState = {
|
|
|
89
89
|
disabledAt: string | null;
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
type OtaUpdateRow = {
|
|
92
|
+
export type OtaUpdateRow = {
|
|
93
93
|
id: string;
|
|
94
94
|
update_id: string;
|
|
95
95
|
build_id: string;
|
|
@@ -112,7 +112,7 @@ type OtaUpdateRow = {
|
|
|
112
112
|
modified_at: string;
|
|
113
113
|
};
|
|
114
114
|
|
|
115
|
-
type OtaChannelRow = {
|
|
115
|
+
export type OtaChannelRow = {
|
|
116
116
|
id: number;
|
|
117
117
|
runtime_version: string;
|
|
118
118
|
channel: string;
|
|
@@ -131,6 +131,7 @@ type OtaChannelRow = {
|
|
|
131
131
|
export type UpdateRecord = {
|
|
132
132
|
key: string;
|
|
133
133
|
encodedKey: string;
|
|
134
|
+
appVersion: string | null;
|
|
134
135
|
comment: string | null;
|
|
135
136
|
runtimeVersion: string;
|
|
136
137
|
platform: "ios" | "android";
|
|
@@ -228,6 +229,24 @@ function mapUpdateMeta(row: OtaUpdateRow): UpdateMetaState {
|
|
|
228
229
|
};
|
|
229
230
|
}
|
|
230
231
|
|
|
232
|
+
function getManifestAppVersion(
|
|
233
|
+
manifest: Record<string, unknown>,
|
|
234
|
+
): string | null {
|
|
235
|
+
const expoClient = manifest.expoClient;
|
|
236
|
+
if (
|
|
237
|
+
!expoClient ||
|
|
238
|
+
typeof expoClient !== "object" ||
|
|
239
|
+
Array.isArray(expoClient)
|
|
240
|
+
) {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const version = (expoClient as Record<string, unknown>).version;
|
|
245
|
+
return typeof version === "string" && version.trim()
|
|
246
|
+
? version.trim()
|
|
247
|
+
: null;
|
|
248
|
+
}
|
|
249
|
+
|
|
231
250
|
function channelLatestToJson(
|
|
232
251
|
channel: OtaChannelRow | null,
|
|
233
252
|
newestUpdateId?: string | null,
|
|
@@ -273,7 +292,7 @@ async function getNewestUpdateByScope(
|
|
|
273
292
|
return (data as OtaUpdateRow | null) || null;
|
|
274
293
|
}
|
|
275
294
|
|
|
276
|
-
function mapRowToRecord(
|
|
295
|
+
export function mapRowToRecord(
|
|
277
296
|
row: OtaUpdateRow,
|
|
278
297
|
channel: OtaChannelRow | null,
|
|
279
298
|
): UpdateRecord {
|
|
@@ -292,6 +311,7 @@ function mapRowToRecord(
|
|
|
292
311
|
return {
|
|
293
312
|
key,
|
|
294
313
|
encodedKey: encodeUpdateKey(row.update_id),
|
|
314
|
+
appVersion: getManifestAppVersion(row.manifest),
|
|
295
315
|
comment: row.comment,
|
|
296
316
|
runtimeVersion: row.runtime_version,
|
|
297
317
|
platform: row.platform,
|
|
@@ -2,5 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
set -eu
|
|
4
4
|
|
|
5
|
+
if [ -n "${CI_PRIMARY_REPOSITORY_PATH:-}" ]; then
|
|
6
|
+
if ! PROJECT_ROOT="$(CDPATH= cd -- "$CI_PRIMARY_REPOSITORY_PATH" && pwd)"; then
|
|
7
|
+
echo "Embedded update registration failed: CI_PRIMARY_REPOSITORY_PATH is unavailable: $CI_PRIMARY_REPOSITORY_PATH" >&2
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
else
|
|
11
|
+
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname "$0")" && pwd)" || {
|
|
12
|
+
echo "Embedded update registration failed: unable to resolve the Xcode Cloud script directory." >&2
|
|
13
|
+
exit 1
|
|
14
|
+
}
|
|
15
|
+
PROJECT_ROOT="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)" || {
|
|
16
|
+
echo "Embedded update registration failed: unable to resolve the Expo project root." >&2
|
|
17
|
+
exit 1
|
|
18
|
+
}
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
REGISTER_SCRIPT="$PROJECT_ROOT/scripts/ota-register-embedded/register-ios.sh"
|
|
22
|
+
if [ ! -f "$REGISTER_SCRIPT" ]; then
|
|
23
|
+
echo "Embedded update registration failed: iOS registrar was not found at $REGISTER_SCRIPT." >&2
|
|
24
|
+
exit 1
|
|
25
|
+
fi
|
|
26
|
+
|
|
5
27
|
export OTA_EMBEDDED_REGISTER_STRICT="${OTA_EMBEDDED_REGISTER_STRICT:-true}"
|
|
6
|
-
sh "$
|
|
28
|
+
exec sh "$REGISTER_SCRIPT"
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
1
2
|
const { withXcodeProject } = require("expo/config-plugins");
|
|
2
3
|
|
|
3
4
|
const PHASE_NAME = "Register Expo embedded update";
|
|
5
|
+
const SHELL_SCRIPT =
|
|
6
|
+
'OTA_EMBEDDED_REGISTER_STRICT=true sh "$PROJECT_DIR/../scripts/ota-register-embedded/register-ios.sh"';
|
|
7
|
+
const SERIALIZED_SHELL_SCRIPT = `"${SHELL_SCRIPT.replaceAll(
|
|
8
|
+
"\\",
|
|
9
|
+
"\\\\",
|
|
10
|
+
).replaceAll('"', '\\"')}"`;
|
|
4
11
|
|
|
5
12
|
module.exports = function withOtaEmbeddedRegistration(config) {
|
|
6
13
|
return withXcodeProject(config, (projectConfig) => {
|
|
7
14
|
const project = projectConfig.modResults;
|
|
8
15
|
const phases =
|
|
9
16
|
project.hash.project.objects.PBXShellScriptBuildPhase || {};
|
|
10
|
-
const
|
|
17
|
+
const existingPhase = Object.values(phases).find(
|
|
11
18
|
(phase) =>
|
|
12
19
|
phase &&
|
|
13
20
|
typeof phase === "object" &&
|
|
14
21
|
phase.name === `"${PHASE_NAME}"`,
|
|
15
22
|
);
|
|
16
23
|
|
|
17
|
-
if (
|
|
24
|
+
if (existingPhase) {
|
|
25
|
+
existingPhase.shellPath = "/bin/sh";
|
|
26
|
+
existingPhase.shellScript = SERIALIZED_SHELL_SCRIPT;
|
|
27
|
+
} else {
|
|
18
28
|
project.addBuildPhase(
|
|
19
29
|
[],
|
|
20
30
|
"PBXShellScriptBuildPhase",
|
|
@@ -22,8 +32,7 @@ module.exports = function withOtaEmbeddedRegistration(config) {
|
|
|
22
32
|
project.getFirstTarget().uuid,
|
|
23
33
|
{
|
|
24
34
|
shellPath: "/bin/sh",
|
|
25
|
-
shellScript:
|
|
26
|
-
'OTA_EMBEDDED_REGISTER_STRICT=true sh "$PROJECT_DIR/../ci_scripts/register-embedded-update.sh"',
|
|
35
|
+
shellScript: SHELL_SCRIPT,
|
|
27
36
|
},
|
|
28
37
|
);
|
|
29
38
|
}
|
|
@@ -108,6 +108,17 @@ export function parseEmbeddedManifest(content, fallbackDate = new Date()) {
|
|
|
108
108
|
["metadata", "createdAt"],
|
|
109
109
|
["extra", "expoClient", "createdAt"],
|
|
110
110
|
]);
|
|
111
|
+
const appVersion =
|
|
112
|
+
readPath(manifest, [
|
|
113
|
+
["extra", "expoClient", "version"],
|
|
114
|
+
["expoClient", "version"],
|
|
115
|
+
["version"],
|
|
116
|
+
]) ||
|
|
117
|
+
readPath(root, [
|
|
118
|
+
["extra", "expoClient", "version"],
|
|
119
|
+
["expoClient", "version"],
|
|
120
|
+
["version"],
|
|
121
|
+
]);
|
|
111
122
|
const fallbackId = crypto
|
|
112
123
|
.createHash("sha256")
|
|
113
124
|
.update(content)
|
|
@@ -118,10 +129,38 @@ export function parseEmbeddedManifest(content, fallbackDate = new Date()) {
|
|
|
118
129
|
embeddedUpdateId:
|
|
119
130
|
embeddedUpdateId ||
|
|
120
131
|
`${fallbackId.slice(0, 8)}-${fallbackId.slice(8, 12)}-4${fallbackId.slice(13, 16)}-a${fallbackId.slice(17, 20)}-${fallbackId.slice(20)}`,
|
|
132
|
+
appVersion: typeof appVersion === "string" ? appVersion : null,
|
|
121
133
|
createdAt: normalizeDate(createdAt, fallbackDate),
|
|
122
134
|
};
|
|
123
135
|
}
|
|
124
136
|
|
|
137
|
+
export function readExpoAppVersion(appRoot, readFile = fs.readFileSync) {
|
|
138
|
+
try {
|
|
139
|
+
const appJson = JSON.parse(
|
|
140
|
+
readFile(path.join(appRoot, "app.json"), "utf8"),
|
|
141
|
+
);
|
|
142
|
+
const appVersion = appJson?.expo?.version;
|
|
143
|
+
return typeof appVersion === "string" && appVersion.trim()
|
|
144
|
+
? appVersion.trim()
|
|
145
|
+
: null;
|
|
146
|
+
} catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function parseEmbeddedManifestForProject(
|
|
152
|
+
content,
|
|
153
|
+
appRoot,
|
|
154
|
+
fallbackDate = new Date(),
|
|
155
|
+
readFile = fs.readFileSync,
|
|
156
|
+
) {
|
|
157
|
+
const fields = parseEmbeddedManifest(content, fallbackDate);
|
|
158
|
+
return {
|
|
159
|
+
...fields,
|
|
160
|
+
appVersion: fields.appVersion || readExpoAppVersion(appRoot, readFile),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
125
164
|
function parseArgs(argv) {
|
|
126
165
|
const args = {};
|
|
127
166
|
for (let index = 0; index < argv.length; index += 1) {
|
|
@@ -135,16 +174,17 @@ function parseArgs(argv) {
|
|
|
135
174
|
}
|
|
136
175
|
|
|
137
176
|
function readChannel(appRoot, explicitChannel) {
|
|
138
|
-
|
|
139
|
-
|
|
177
|
+
const configuredChannel =
|
|
178
|
+
explicitChannel || process.env.EXPO_UPDATE_CHANNEL;
|
|
179
|
+
if (configuredChannel) {
|
|
180
|
+
return configuredChannel.trim().toLowerCase();
|
|
140
181
|
}
|
|
141
182
|
|
|
142
183
|
const appJson = JSON.parse(
|
|
143
184
|
fs.readFileSync(path.join(appRoot, "app.json"), "utf8"),
|
|
144
185
|
);
|
|
145
186
|
return String(
|
|
146
|
-
|
|
147
|
-
appJson.expo?.updates?.requestHeaders?.["expo-channel-name"] ||
|
|
187
|
+
appJson.expo?.updates?.requestHeaders?.["expo-channel-name"] ||
|
|
148
188
|
appJson.expo?.extra?.updateChannel ||
|
|
149
189
|
"production",
|
|
150
190
|
)
|
|
@@ -210,9 +250,13 @@ async function registerWithDatabase(input) {
|
|
|
210
250
|
try {
|
|
211
251
|
await client.query(
|
|
212
252
|
`INSERT INTO ota_embedded_updates (
|
|
213
|
-
embedded_update_id, created_at, channel, platform, is_embedded
|
|
214
|
-
) VALUES ($1, $2, $3, $4, true)
|
|
253
|
+
embedded_update_id, app_version, created_at, channel, platform, is_embedded
|
|
254
|
+
) VALUES ($1, $2, $3, $4, $5, true)
|
|
215
255
|
ON CONFLICT (embedded_update_id) DO UPDATE SET
|
|
256
|
+
app_version = COALESCE(
|
|
257
|
+
NULLIF(BTRIM(EXCLUDED.app_version), ''),
|
|
258
|
+
ota_embedded_updates.app_version
|
|
259
|
+
),
|
|
216
260
|
created_at = EXCLUDED.created_at,
|
|
217
261
|
channel = EXCLUDED.channel,
|
|
218
262
|
platform = EXCLUDED.platform,
|
|
@@ -220,6 +264,7 @@ async function registerWithDatabase(input) {
|
|
|
220
264
|
modified_at = now()`,
|
|
221
265
|
[
|
|
222
266
|
input.embeddedUpdateId,
|
|
267
|
+
input.appVersion || null,
|
|
223
268
|
input.createdAt,
|
|
224
269
|
input.channel,
|
|
225
270
|
input.platform,
|
|
@@ -251,8 +296,9 @@ async function main() {
|
|
|
251
296
|
|
|
252
297
|
const manifestPath = path.resolve(args.manifest);
|
|
253
298
|
const channel = readChannel(ROOT_DIR, args.channel);
|
|
254
|
-
const fields =
|
|
299
|
+
const fields = parseEmbeddedManifestForProject(
|
|
255
300
|
fs.readFileSync(manifestPath, "utf8"),
|
|
301
|
+
ROOT_DIR,
|
|
256
302
|
fs.statSync(manifestPath).mtime,
|
|
257
303
|
);
|
|
258
304
|
const input = {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -eu
|
|
4
|
+
|
|
5
|
+
if [ "${CONFIGURATION:-Release}" = "Debug" ]; then
|
|
6
|
+
exit 0
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
fail_registration() {
|
|
10
|
+
echo "Embedded update registration failed: $1" >&2
|
|
11
|
+
if [ "${OTA_EMBEDDED_REGISTER_STRICT:-false}" = "true" ]; then
|
|
12
|
+
exit 1
|
|
13
|
+
fi
|
|
14
|
+
exit 0
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname "$0")" && pwd)" ||
|
|
18
|
+
fail_registration "unable to resolve the registration script directory."
|
|
19
|
+
PROJECT_ROOT="$(CDPATH= cd -- "$SCRIPT_DIR/../.." && pwd)" ||
|
|
20
|
+
fail_registration "unable to resolve the Expo project root."
|
|
21
|
+
REGISTRAR_PATH="$PROJECT_ROOT/scripts/ota-register-embedded/index.mjs"
|
|
22
|
+
MANIFEST_PATH=""
|
|
23
|
+
NODE_EXECUTABLE=""
|
|
24
|
+
|
|
25
|
+
if [ -f "$PROJECT_ROOT/ios/.xcode.env" ]; then
|
|
26
|
+
set +u
|
|
27
|
+
. "$PROJECT_ROOT/ios/.xcode.env"
|
|
28
|
+
set -u
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
if [ -f "$PROJECT_ROOT/ios/.xcode.env.local" ]; then
|
|
32
|
+
set +u
|
|
33
|
+
. "$PROJECT_ROOT/ios/.xcode.env.local"
|
|
34
|
+
set -u
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
if [ -n "${NODE_BINARY:-}" ] && [ -x "$NODE_BINARY" ]; then
|
|
38
|
+
NODE_EXECUTABLE="$NODE_BINARY"
|
|
39
|
+
else
|
|
40
|
+
NODE_FROM_PATH="$(command -v node 2>/dev/null || true)"
|
|
41
|
+
if [ -n "$NODE_FROM_PATH" ] && [ -x "$NODE_FROM_PATH" ]; then
|
|
42
|
+
NODE_EXECUTABLE="$NODE_FROM_PATH"
|
|
43
|
+
elif [ -x "/opt/homebrew/bin/node" ]; then
|
|
44
|
+
NODE_EXECUTABLE="/opt/homebrew/bin/node"
|
|
45
|
+
elif [ -x "/usr/local/bin/node" ]; then
|
|
46
|
+
NODE_EXECUTABLE="/usr/local/bin/node"
|
|
47
|
+
fi
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
if [ -z "$NODE_EXECUTABLE" ]; then
|
|
51
|
+
fail_registration "Node.js executable was not found. Set NODE_BINARY to an absolute executable path in $PROJECT_ROOT/ios/.xcode.env.local (for example: export NODE_BINARY=/absolute/path/to/node)."
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
if [ ! -f "$REGISTRAR_PATH" ]; then
|
|
55
|
+
fail_registration "registrar was not found at $REGISTRAR_PATH."
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
if [ -n "${TARGET_BUILD_DIR:-}" ] &&
|
|
59
|
+
[ -n "${UNLOCALIZED_RESOURCES_FOLDER_PATH:-}" ] &&
|
|
60
|
+
[ -f "$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/app.manifest" ]; then
|
|
61
|
+
MANIFEST_PATH="$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/app.manifest"
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
if [ -z "$MANIFEST_PATH" ] && [ -n "${CI_ARCHIVE_PATH:-}" ]; then
|
|
65
|
+
for candidate in "$CI_ARCHIVE_PATH"/Products/Applications/*.app/app.manifest; do
|
|
66
|
+
if [ -f "$candidate" ]; then
|
|
67
|
+
MANIFEST_PATH="$candidate"
|
|
68
|
+
break
|
|
69
|
+
fi
|
|
70
|
+
done
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
if [ -z "$MANIFEST_PATH" ] && [ -n "${TARGET_BUILD_DIR:-}" ]; then
|
|
74
|
+
MANIFEST_PATH="$(find "$TARGET_BUILD_DIR" -type f -name app.manifest 2>/dev/null | head -n 1 || true)"
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
if [ -z "$MANIFEST_PATH" ]; then
|
|
78
|
+
fail_registration "iOS app.manifest was not found."
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
if ! "$NODE_EXECUTABLE" "$REGISTRAR_PATH" \
|
|
82
|
+
--manifest "$MANIFEST_PATH" \
|
|
83
|
+
--platform ios; then
|
|
84
|
+
if [ "${OTA_EMBEDDED_REGISTER_STRICT:-false}" = "true" ]; then
|
|
85
|
+
exit 1
|
|
86
|
+
fi
|
|
87
|
+
fi
|