feat: add optional binary patch metadata - #153
Draft
floyd-soomgo wants to merge 3 commits into
Draft
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
downloadUrl— nothing to coordinate.Changes
ReleaseInfo.binaryPatchDownloadUrl?,RemotePackage.binaryPatchDownloadUrl?, andbinary_patch_download_url?on the deprecatedUpdateCheckResponse. Additive only.addToReleaseHistoryrecords 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.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-mixinscopies the remote package withObject.assigninto the native call, so a plainbinaryPatchDownloadUrl: undefinedassignment would have shipped the key to native. Tests assert absence withtoHaveProperty(nottoEqual, which ignoresundefined-valued keys).package-mixinsitself is unchanged, and the TurboModule spec (UnsafeObject) passes the field through as-is.src/CodePush.jscontains JSX and the repo's Babel config has no JSX transform, so no jest test could load this module before. Added a rootjest.config.jswith a small transformer that compiles just that file using TypeScript (already a devDependency — no new packages). The newsrc/CodePush.test.jsdrives the real code path: real history JSON fixtures, the real package-mixins, only the native bridge mocked, asserting the actualdownloadUpdateargument. Maintainer note: if you'd rather add@babel/preset-react, both jest files can be deleted with no test changes.docs/api-js.mdand both CLI READMEs.Test plan
npm run jest # root suites (now includes src/CodePush.test.js) + cli suites npm run typecheck