@bipopush/cli 0.3.0-beta.2 → 0.3.0-beta.3

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/pack.js +12 -20
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -46,7 +46,7 @@ Published iOS 1.0 v7 to production.
46
46
 
47
47
  - The signing key is saved at `~/.config/bipopush/keys/<appId>.pem`. Keep it private — whoever has it can ship code to your users.
48
48
  - In CI set `BIPOPUSH_TOKEN` (a CLI token) and `BIPOPUSH_SIGNING_KEY` (the PEM, or its base64).
49
- - `bsdiff-nodejs` is an optional native dependency; without it releases still work, just without patches.
49
+ - Patches are made by `bsdiff-wasm` (Debian's bsdiff 4.3 compiled to WebAssembly, BSDIFF40): nothing is compiled on install.
50
50
 
51
51
  ## Environment
52
52
 
package/dist/pack.js CHANGED
@@ -5,6 +5,7 @@ import { createRequire } from "node:module";
5
5
  import { tmpdir } from "node:os";
6
6
  import path from "node:path";
7
7
  import { brotliCompressSync, brotliDecompressSync, constants } from "node:zlib";
8
+ import { loadBsdiff } from "bsdiff-wasm";
8
9
  import { signDigest } from "./keys.js";
9
10
  /** A patch is only worth shipping when it is clearly smaller than the compressed full bundle. */
10
11
  export const PATCH_RATIO = 0.6;
@@ -45,22 +46,15 @@ export function compress(data) {
45
46
  export function decompress(data) {
46
47
  return brotliDecompressSync(data);
47
48
  }
48
- /** BSDIFF40 patch (old → new), or null when the optional native addon is unavailable. */
49
- export async function makePatch(oldData, newData, workDir) {
50
- let bsdiff;
51
- try {
52
- bsdiff = localRequire("bsdiff-nodejs");
53
- }
54
- catch {
55
- return null;
56
- }
57
- const oldFile = path.join(workDir, "base.hbc");
58
- const newFile = path.join(workDir, "new.hbc");
59
- const patchFile = path.join(workDir, "bundle.bspatch");
60
- writeFileSync(oldFile, oldData);
61
- writeFileSync(newFile, newData);
62
- await bsdiff.diff(oldFile, newFile, patchFile);
63
- return readFileSync(patchFile);
49
+ /** BSDIFF40 patch (old → new), the format the SDK's bspatch applies. WebAssembly: nothing to compile on install. */
50
+ export async function makePatch(oldData, newData) {
51
+ const bsdiff = await loadBsdiff();
52
+ bsdiff.FS.writeFile("/base.hbc", oldData);
53
+ bsdiff.FS.writeFile("/new.hbc", newData);
54
+ const code = bsdiff.callMain(["/base.hbc", "/new.hbc", "/bundle.bspatch"]);
55
+ if (code)
56
+ throw new Error(`bsdiff failed (exit ${code})`);
57
+ return Buffer.from(bsdiff.FS.readFile("/bundle.bspatch"));
64
58
  }
65
59
  /**
66
60
  * Canonical manifest digest (same in the API and the native SDK):
@@ -148,10 +142,8 @@ async function packIn(work, opts) {
148
142
  let patch = null;
149
143
  let patchNote = "no previous release for this channel and version";
150
144
  if (opts.base) {
151
- const data = await makePatch(opts.base.hbc, hbc, work);
152
- if (!data)
153
- patchNote = "bsdiff-nodejs not installed";
154
- else if (data.length >= full.length * PATCH_RATIO)
145
+ const data = await makePatch(opts.base.hbc, hbc);
146
+ if (data.length >= full.length * PATCH_RATIO)
155
147
  patchNote = `patch ${data.length} B is not smaller than ${PATCH_RATIO * 100}% of full`;
156
148
  else {
157
149
  patch = { baseArtifactId: opts.base.artifactId, data };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bipopush/cli",
3
- "version": "0.3.0-beta.2",
3
+ "version": "0.3.0-beta.3",
4
4
  "description": "BipoPush CLI — log in and publish releases",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,10 +40,10 @@
40
40
  "@types/node": "^26.6.3",
41
41
  "typescript": "^6.0.3"
42
42
  },
43
- "optionalDependencies": {
44
- "bsdiff-nodejs": "^2.2.0"
45
- },
46
43
  "publishConfig": {
47
44
  "access": "public"
45
+ },
46
+ "dependencies": {
47
+ "bsdiff-wasm": "0.1.4"
48
48
  }
49
49
  }