Skip to content

Commit 2f68d62

Browse files
sunnylqmclaude
andauthored
refactor: drop bytebuffer, fs-extra, node-fetch and form-data (#97)
- resources.arsc decoded with a small Buffer reader instead of bytebuffer (byte-identical output on real APKs, ~5x faster) - fix: UTF-16 resource string pools were decoded as UTF-8 - fs-extra replaced by node:fs plus src/utils/fs-helpers.ts - uploads stream over node:http(s) (src/utils/upload-request.ts) instead of node-fetch + form-data; wire format unchanged except User-Agent - review fixes: emptyDirSync only creates on ENOENT; a short upload body fails at once Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4704131 commit 2f68d62

34 files changed

Lines changed: 933 additions & 337 deletions

‎bun.lock‎

Lines changed: 1 addition & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,15 @@
6262
"homepage": "https://github.com/reactnativecn/react-native-update-cli",
6363
"dependencies": {
6464
"bplist-parser": "^0.3.2",
65-
"bytebuffer": "^5.0.1",
6665
"cgbi-to-png": "^1.0.7",
6766
"chalk": "4",
6867
"cli-arguments": "^0.2.1",
6968
"compare-versions": "^6.1.1",
7069
"filesize-parser": "^1.5.2",
71-
"form-data": "^4.0.6",
72-
"fs-extra": "^11.4.0",
7370
"global-dirs": "^4.0.0",
7471
"gradle-to-js": "^2.0.1",
7572
"https-proxy-agent": "^7.0.6",
7673
"i18next": "^26.4.0",
77-
"node-fetch": "^2.6.1",
7874
"plist": "^5.0.0",
7975
"progress": "^2.0.3",
8076
"properties": "^1.2.1",
@@ -98,9 +94,7 @@
9894
"@biomejs/biome": "^2.5.10",
9995
"@types/bun": "^1.4.0",
10096
"@types/filesize-parser": "^1.5.3",
101-
"@types/fs-extra": "^11.0.4",
10297
"@types/node": "^26.3.0",
103-
"@types/node-fetch": "^2.6.13",
10498
"@types/progress": "^2.0.7",
10599
"@types/yauzl": "^3.4.0",
106100
"@types/yazl": "^3.3.1",

‎scripts/fuzz-hermes-base.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
* caught with useful coverage, 1 otherwise; invalid arguments exit 2.
2525
*/
2626
import { spawnSync } from 'node:child_process';
27-
import fs from 'fs-extra';
27+
import fs from 'fs';
2828
import os from 'os';
2929
import path from 'path';
3030
import { failureFingerprint } from '../src/utils/failure-fingerprint';
31+
import { ensureDirSync, removeSync } from '../src/utils/fs-helpers';
3132
import { compareHermesBytecode } from '../src/utils/hermes-base';
3233
import { fuzzStringLiterals } from './hermes-fuzz-literals';
3334
import { hermesFuzzSucceeded } from './hermes-fuzz-result';
@@ -580,7 +581,7 @@ interface Finding {
580581
async function main() {
581582
const rng = new Rng(SEED);
582583
const gen = new Gen(rng);
583-
fs.ensureDirSync(OUT_DIR);
584+
ensureDirSync(OUT_DIR);
584585
console.log(
585586
`fuzz-hermes-base: ${ROUNDS} rounds, seed ${SEED}, hermesc ${hermesc}, out ${OUT_DIR}`,
586587
);
@@ -598,7 +599,7 @@ async function main() {
598599

599600
for (let round = 0; round < ROUNDS; round++) {
600601
const dir = path.join(OUT_DIR, `round-${String(round).padStart(4, '0')}`);
601-
fs.ensureDirSync(dir);
602+
ensureDirSync(dir);
602603
const next = gen.program();
603604
const baseSource =
604605
pool.length > 0 && rng.chance(0.5) ? rng.pick(pool) : gen.mutate(next);
@@ -712,7 +713,7 @@ async function main() {
712713
}
713714
}
714715

715-
if (!keep) fs.removeSync(dir);
716+
if (!keep) removeSync(dir);
716717
}
717718

718719
const seconds = ((Date.now() - started) / 1000).toFixed(1);
@@ -751,7 +752,7 @@ async function main() {
751752
plantedCompileErrors,
752753
});
753754
if (!ok) console.log(`\nfailing cases kept under ${OUT_DIR}`);
754-
else if (!argValue('out')) fs.removeSync(OUT_DIR);
755+
else if (!argValue('out')) removeSync(OUT_DIR);
755756
process.exit(ok ? 0 : 1);
756757
}
757758

‎scripts/smoke-lib.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ async function proxyScenario() {
248248
});
249249
});
250250
// tunnels to the mock host: the API client (undici), the registry check
251-
// (http.get) and the upload (node-fetch) each open their own
251+
// (http.get) and the upload (http.request) each open their own
252252
const tunnels = () =>
253253
seenByProxy.filter((line) => line === `CONNECT 127.0.0.1:${apiPort}`)
254254
.length;

0 commit comments

Comments
 (0)