Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clever-clouds-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@arethetypeswrong/core": patch
---

Fix extracting some non-compliant tarballs
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"dependencies": {
"@andrewbranch/untar.js": "^1.0.3",
"fflate": "^0.7.4",
"fflate": "^0.8.2",
"semver": "^7.5.4",
"ts-expose-internals-conditionally": "1.0.0-empty.0",
"typescript": "5.3.3",
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/createPackage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { untar } from "@andrewbranch/untar.js";
import { gunzipSync } from "fflate";
import { Gunzip } from "fflate";
import { major, maxSatisfying, minor, valid, validRange } from "semver";
import ts from "typescript";
import { parsePackageSpec, type ParsedPackageSpec } from "./utils.js";
Expand Down Expand Up @@ -279,7 +279,10 @@ export function createPackageFromTarballData(tarball: Uint8Array): Package {
}

function extractTarball(tarball: Uint8Array) {
const data = untar(gunzipSync(tarball));
// Use streaming API to work around https://github.com/101arrowz/fflate/issues/207
let unzipped: Uint8Array;
new Gunzip((chunk) => (unzipped = chunk)).push(tarball, /*final*/ true);
const data = untar(unzipped!);
const prefix = data[0].filename.substring(0, data[0].filename.indexOf("/") + 1);
const packageJsonText = data.find((f) => f.filename === `${prefix}package.json`)?.fileData;
const packageJson = JSON.parse(new TextDecoder().decode(packageJsonText));
Expand Down
Binary file added packages/core/test/fixtures/[email protected]
Binary file not shown.
5 changes: 5 additions & 0 deletions packages/core/test/snapshots/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packageName": "openurl",
"packageVersion": "1.0.2",
"types": false
}
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.