Add support for changelogs and critical updates
diff --git a/src/deployments/expo.ts b/src/deployments/expo.ts
index 1a572db..36b30bb 100644
--- a/src/deployments/expo.ts
+++ b/src/deployments/expo.ts
@@ -43,19 +43,22 @@
perspective: "published"
});
- const manifestID = await client.fetch<string | null>(`*[_type == "release" && product->identity.current == $product && channel <= $channel && count(artifacts[_type == "expo" && platform == $platform && runtime == $runtime]) == 1] {
+ const updateData = await client.fetch<UpdateData | null>(`*[_type == "release" && product->identity.current == $product && channel <= $channel && count(artifacts[_type == "expo" && platform == $platform && runtime == $runtime]) == 1] {
"manifest": select(artifacts[_type == "expo" && platform == $platform && runtime == $runtime])[0].manifest,
- version
- } | order(version desc)[0].manifest`, {
+ version,
+ versionName,
+ "changelog": changelog[]{ summary, type },
+ critical
+ } | order(version desc)[0]`, {
product,
platform,
runtime,
channel: EXPO_CHANNEL_NAMES[channel as keyof typeof EXPO_CHANNEL_NAMES]
});
- if (!manifestID) return env.HTTP_STATUS_PAGES.fetch("https://http-status-pages.jottocraft.com/?status=404");
+ if (!updateData?.manifest) return env.HTTP_STATUS_PAGES.fetch("https://http-status-pages.jottocraft.com/?status=404");
- return serveExpoManifest(request, env, ctx, product, manifestID, channel);
+ return serveExpoManifest(request, env, ctx, product, updateData.manifest, channel, updateData);
}
async function serveExpoAsset(request: Request, env: Env, ctx: AeroCtx, product: string, filename: string) {
@@ -63,7 +66,7 @@
return serveR2(request, env, ctx, `${product}/expo/${filename}`, "public, max-age=31536000, immutable", mime.getType(filename.slice(filename.indexOf(".") + 1)) ?? "");
}
-async function serveExpoManifest(request: Request, env: Env, ctx: AeroCtx, product: string, manifestID: string, channel?: string) {
+async function serveExpoManifest(request: Request, env: Env, ctx: AeroCtx, product: string, manifestID: string, channel?: string, updateData?: UpdateData) {
if (!isSafe(manifestID)) return env.HTTP_STATUS_PAGES.fetch("https://http-status-pages.jottocraft.com/?status=400");
const object = await env.ARTIFACTS.get(`${product}/expo/${manifestID}.json`);
@@ -79,6 +82,12 @@
if (request.headers.get("Expo-Channel-Name")) buildManifest.extra.expoClient.updates.requestHeaders["Expo-Channel-Name"] = request.headers.get("Expo-Channel-Name");
if (request.headers.get("jottocraft-Native-App-Version")) buildManifest.extra.expoClient.updates.requestHeaders["jottocraft-Native-App-Version"] = request.headers.get("jottocraft-Native-App-Version");
+ // Add metadata
+ if (!buildManifest.metadata) buildManifest.metadata = {};
+ if (channel) buildManifest.metadata.channel = channel;
+ if (updateData) buildManifest.metadata.critical = updateData.critical;
+ if (updateData?.changelog) buildManifest.metadata.changelog = updateData.changelog;
+
const boundary = "jottocraft-Aero-Boundary-" + crypto.randomUUID();
let multipartBody = [];
diff --git a/src/globals.d.ts b/src/globals.d.ts
index 420c553..833c3b3 100644
--- a/src/globals.d.ts
+++ b/src/globals.d.ts
@@ -13,6 +13,14 @@
reg?: string;
};
+declare type UpdateData = {
+ manifest: string;
+ version: number;
+ versionName: string;
+ changelog: { summary: string; type: string; }[];
+ critical: boolean;
+};
+
declare type AeroCtx = ExecutionContext & {
headersPatch: HeadersRef;
};