Skip to content

Commit f029f8e

Browse files
authored
fix: add support for .zip files in binary download (#417)
1 parent c78ecb0 commit f029f8e

File tree

5 files changed

+56
-4
lines changed

5 files changed

+56
-4
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# https://git-scm.com/docs/gitattributes
2+
3+
# Ensure consistent EOL(LF) for all files that Git considers text files.
4+
* text=auto eol=lf

.github/workflows/ci.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ on:
88

99
jobs:
1010
build_and_lint:
11-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
1216
steps:
1317
- uses: actions/checkout@v4
1418

@@ -19,9 +23,18 @@ jobs:
1923

2024
- run: npm ci
2125
- run: npm run build
26+
2227
- run: npm run lint:commit -- --to "${{ github.sha }}"
28+
if: ${{ runner.os == 'Linux' }}
29+
2330
- run: npm run lint:typescript
31+
if: ${{ runner.os == 'Linux' }}
32+
2433
- run: npm run lint:eslint
34+
if: ${{ runner.os == 'Linux' }}
35+
2536
- run: npm run lint:prettier
37+
if: ${{ runner.os == 'Linux' }}
38+
2639
- run: npm run test
2740
- run: npm run start

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,20 @@
3737
"prepublishOnly": "npm run build",
3838
"build": "rimraf dist && ncc build src/index.ts --minify",
3939
"test": "node --import=tsx --test \"src/**/*.spec.ts\"",
40-
"start": "./dist/index.js",
40+
"start": "node ./dist/index.js",
4141
"release": "semantic-release"
4242
},
4343
"devDependencies": {
4444
"@commitlint/cli": "19.5.0",
4545
"@commitlint/config-conventional": "19.5.0",
4646
"@octokit/rest": "21.0.2",
47+
"@types/adm-zip": "0.5.7",
4748
"@types/node": "22.6.1",
4849
"@types/proxy-from-env": "1.0.4",
4950
"@typescript-eslint/eslint-plugin": "8.7.0",
5051
"@typescript-eslint/parser": "8.7.0",
5152
"@vercel/ncc": "0.38.2",
53+
"adm-zip": "0.5.16",
5254
"eslint": "8.57.1",
5355
"prettier": "3.3.3",
5456
"proxy": "2.2.0",

src/release.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { fetch, ProxyAgent } from "undici"
77
import type { RequestInit } from "undici"
88
import { extract } from "tar"
99
import tmp from "tmp-promise"
10+
import admzip from "adm-zip"
1011
import { COMBINED_PATH, NAME } from "./constants"
1112

1213
const octokit = new Octokit({ request: { fetch: proxiedFetch } })
@@ -15,7 +16,10 @@ export async function findRelease(version: string) {
1516
const release = await getRelease(version)
1617
const releasePrefix = getAssetPrefix()
1718
const matchedAsset = release.data.assets.find(({ name }) => {
18-
return name.startsWith(releasePrefix) && name.endsWith(".tar.gz")
19+
return (
20+
name.startsWith(releasePrefix) &&
21+
(name.endsWith(".tar.gz") || name.endsWith(".zip"))
22+
)
1923
})
2024
if (!matchedAsset) {
2125
throw new Error(`The binary '${releasePrefix}*' not found`)
@@ -27,7 +31,14 @@ export async function downloadBinary(url: string) {
2731
const response = await proxiedFetch(url)
2832
const tmpfile = await tmp.file()
2933
await writeFile(tmpfile.path, Buffer.from(await response.arrayBuffer()))
30-
await extract({ file: tmpfile.path, cwd: COMBINED_PATH, strict: true })
34+
35+
if (url.endsWith(".zip")) {
36+
const zip = new admzip(tmpfile.path)
37+
zip.extractAllTo(COMBINED_PATH, true)
38+
} else {
39+
await extract({ file: tmpfile.path, cwd: COMBINED_PATH, strict: true })
40+
}
41+
3142
await tmpfile.cleanup()
3243
}
3344

0 commit comments

Comments
 (0)