fix(ota): emit expo-compatible update identifiers
This commit is contained in:
@@ -110,6 +110,9 @@ export async function buildOtaMetadata(input) {
|
||||
|
||||
return {
|
||||
schemaVersion: 1,
|
||||
updateId: createDeterministicUuid(
|
||||
`${input.product}:${input.channel}:${input.releaseVersion}:${input.runtimeVersion}:${input.gitTag}:${input.gitCommit}`,
|
||||
),
|
||||
product: input.product,
|
||||
channel: input.channel,
|
||||
releaseVersion: input.releaseVersion,
|
||||
@@ -125,6 +128,23 @@ export async function buildOtaMetadata(input) {
|
||||
}
|
||||
}
|
||||
|
||||
function createDeterministicUuid(seed) {
|
||||
const digest = createHash("sha1").update(seed).digest()
|
||||
const bytes = Buffer.from(digest.subarray(0, 16))
|
||||
|
||||
bytes[6] = (bytes[6] & 0x0f) | 0x50
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80
|
||||
|
||||
const hex = bytes.toString("hex")
|
||||
return [
|
||||
hex.slice(0, 8),
|
||||
hex.slice(8, 12),
|
||||
hex.slice(12, 16),
|
||||
hex.slice(16, 20),
|
||||
hex.slice(20, 32),
|
||||
].join("-")
|
||||
}
|
||||
|
||||
export async function buildReleaseAssets(options = {}) {
|
||||
const projectDir = resolveMobileProjectDir(options.projectDir)
|
||||
const distDir = join(projectDir, "dist")
|
||||
|
||||
@@ -54,6 +54,9 @@ describe("buildOtaMetadata", () => {
|
||||
expect(result.releaseVersion).toBe("0.4.2")
|
||||
expect(result.runtimeVersion).toBe("0.4.1")
|
||||
expect(result.git.tag).toBe("mobile/v0.4.2")
|
||||
expect(result.updateId).toMatch(
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,
|
||||
)
|
||||
})
|
||||
|
||||
it("uses asset ext metadata when exported asset paths have no suffix", async () => {
|
||||
|
||||
Reference in New Issue
Block a user