From ef4d786b7cae1ccf5ee83e29d70bae2959643b1f Mon Sep 17 00:00:00 2001 From: ayuhito Date: Tue, 30 Sep 2025 10:35:23 +0900 Subject: [PATCH 1/2] chore: remove node fetch --- npm-install/postinstall.js | 3 +-- package.json | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/npm-install/postinstall.js b/npm-install/postinstall.js index d3d82d2..fefec07 100644 --- a/npm-install/postinstall.js +++ b/npm-install/postinstall.js @@ -1,6 +1,5 @@ import { createWriteStream } from "fs"; import * as fs from "fs/promises"; -import fetch from "node-fetch"; import { pipeline } from "stream/promises"; import tar from "tar"; import { execSync } from "child_process"; @@ -54,4 +53,4 @@ install() .catch(async (err) => { console.error(err); process.exit(1); - }); \ No newline at end of file + }); diff --git a/package.json b/package.json index 8b26057..ccb8a9d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "git+https://github.com/pb33f/openapi-changes.git" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { "postinstall": "node ./npm-install/postinstall.js" @@ -24,7 +24,6 @@ ], "dependencies": { "adm-zip": "^0.5.10", - "node-fetch": "^3.2.10", "tar": "^6.1.11" }, "bugs": { From a54b371727938ea0fa41a3098502b177a8953c71 Mon Sep 17 00:00:00 2001 From: ayuhito Date: Tue, 30 Sep 2025 10:53:04 +0900 Subject: [PATCH 2/2] chore: use modern tar --- npm-install/postinstall.js | 18 +++++++++++------- package.json | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/npm-install/postinstall.js b/npm-install/postinstall.js index fefec07..dd9ddfd 100644 --- a/npm-install/postinstall.js +++ b/npm-install/postinstall.js @@ -1,8 +1,9 @@ -import { createWriteStream } from "fs"; -import * as fs from "fs/promises"; -import { pipeline } from "stream/promises"; -import tar from "tar"; -import { execSync } from "child_process"; +import { createReadStream, createWriteStream } from "node:fs"; +import * as fs from "node:fs/promises"; +import { pipeline } from "node:stream/promises"; +import { execSync } from "node:child_process"; +import { createGunzip } from "node:zlib"; +import { unpackTar } from "modern-tar/fs"; import { ARCH_MAPPING, CONFIG, PLATFORM_MAPPING } from "./config.js"; @@ -34,7 +35,7 @@ async function install() { console.log('fetching from URL', url) const response = await fetch(url); - if (!response.ok) { + if (!response.ok || !response.body) { throw new Error("Failed fetching the binary: " + response.statusText); } @@ -42,7 +43,10 @@ async function install() { await fs.mkdir(binPath, { recursive: true }); await pipeline(response.body, createWriteStream(tarFile)); - await tar.x({ file: tarFile, cwd: binPath }); + + const readStream = createReadStream(tarFile); + await pipeline(readStream, createGunzip(), unpackTar(binPath)); + await fs.rm(tarFile); } diff --git a/package.json b/package.json index ccb8a9d..5e655e0 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ ], "dependencies": { "adm-zip": "^0.5.10", - "tar": "^6.1.11" + "modern-tar": "^0.3.4" }, "bugs": { "url": "https://github.com/pb33f/openapi-changes/issues"