Skip to content

feat: add optional binary patch metadata - #153

Draft
floyd-soomgo wants to merge 3 commits into
feature/binary-patch-cli-artifactsfrom
feature/binary-patch-metadata
Draft

feat: add optional binary patch metadata#153
floyd-soomgo wants to merge 3 commits into
feature/binary-patch-cli-artifactsfrom
feature/binary-patch-metadata

Conversation

@floyd-soomgo

Copy link
Copy Markdown
Member

Summary

Third PR of the binary differential OTA series (stacked on feat(cli): generate platform binary patch artifacts).

PR 2 uploads the patch archive but discards its URL after logging it. This PR carries that URL end-to-end as optional metadata: the CLI stores it in the release history JSON, and the JS runtime passes it from the fetched history through to the object handed to native downloadUpdate. Native does not consume the field yet — the Android/iOS appliers (next PRs) will download and apply the patch, with a one-time fallback to the full archive.

Compatibility is the point of the design:

  • Old library versions ignore the unknown JSON field and keep using downloadUrl — nothing to coordinate.
  • A history without the field behaves exactly as today (pinned byte-identical in tests, key order included).
  • Removing the field from a history JSON and re-uploading is the emergency kill switch: clients silently return to full-only updates.

Changes

  • TypingsReleaseInfo.binaryPatchDownloadUrl?, RemotePackage.binaryPatchDownloadUrl?, and binary_patch_download_url? on the deprecated UpdateCheckResponse. Additive only.
  • CLIaddToReleaseHistory records the patch URL in the same platform entry when (and only when) the patch archive was uploaded. No patch, or a patch skipped by --on-oversized-patch, leaves the entry without the key.
  • JS runtime (src/CodePush.js) — the field flows through the two mapping points between the fetched history and the remote package. The absent case is handled with a conditional spread on purpose: package-mixins copies the remote package with Object.assign into the native call, so a plain binaryPatchDownloadUrl: undefined assignment would have shipped the key to native. Tests assert absence with toHaveProperty (not toEqual, which ignores undefined-valued keys). package-mixins itself is unchanged, and the TurboModule spec (UnsafeObject) passes the field through as-is.
  • Test infrastructuresrc/CodePush.js contains JSX and the repo's Babel config has no JSX transform, so no jest test could load this module before. Added a root jest.config.js with a small transformer that compiles just that file using TypeScript (already a devDependency — no new packages). The new src/CodePush.test.js drives the real code path: real history JSON fixtures, the real package-mixins, only the native bridge mocked, asserting the actual downloadUpdate argument. Maintainer note: if you'd rather add @babel/preset-react, both jest files can be deleted with no test changes.
  • Docs — the release-history field documented in docs/api-js.md and both CLI READMEs.

Test plan

npm run jest        # root suites (now includes src/CodePush.test.js) + cli suites
npm run typecheck

The Babel config of this repository has no JSX transform - an app bundling
the library transforms it with the React Native preset - so a test cannot
load src/CodePush.js. Compile that one file with TypeScript instead, which
turns the JSX of the decorator into React.createElement calls and leaves the
rest of the module to the same downlevelling Babel would have applied.
A release published with --binary-bundle-path uploads a patch archive whose
URL was logged and then dropped. Record it in the release history entry of
that release, and carry it from the fetched history through the update check
to the metadata the native module is handed when it downloads the update.

A release without a patch says nothing about one: the field is absent from
the history entry and from the update, so a release history written before
binary patches existed keeps behaving exactly as it did.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant