From 0f6b2764ac2b63693b63ddc336ce873eadcb9d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 6 Nov 2026 11:31:42 -0800 Subject: [PATCH 1/2] Use yauzl directly --- package.json | 5 +++-- tool/prepare-optional-release.ts | 8 ++++---- tool/utils.ts | 21 ++++++++++++++++++++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 20fd2edb..9270b0a9 100644 --- a/package.json +++ b/package.json @@ -83,8 +83,8 @@ "@types/tar": "^7.0.87", "@types/varint": "^6.0.1", "@types/yargs": "^17.0.4", + "@types/yauzl": "^3.4.0", "@typescript/native": "npm:typescript@^7.0.2", - "extract-zip": "^2.0.1", "gts": "^7.0.0", "jest": "^30.0.3", "npm-run-all": "^4.1.5", @@ -96,6 +96,7 @@ "ts-node": "^10.2.1", "typescript": "npm:@typescript/typescript6@^6.0.2", "yaml": "^2.2.1", - "yargs": "^17.2.1" + "yargs": "^17.2.1", + "yauzl": "^3.4.0" } } diff --git a/tool/prepare-optional-release.ts b/tool/prepare-optional-release.ts index 299568e1..f71e0571 100644 --- a/tool/prepare-optional-release.ts +++ b/tool/prepare-optional-release.ts @@ -1,4 +1,3 @@ -import extractZip = require('extract-zip'); import {promises as fs} from 'fs'; import * as p from 'path'; import {extract as extractTar} from 'tar'; @@ -93,9 +92,10 @@ async function downloadRelease(options: { options.outPath + '/' + options.repo + archiveExtension; await fs.writeFile(zippedAssetPath, releaseAsset); if (archiveExtension === '.zip') { - await extractZip(zippedAssetPath, { - dir: p.join(process.cwd(), options.outPath), - }); + await utils.extractZip( + zippedAssetPath, + p.join(process.cwd(), options.outPath), + ); } else { extractTar({ file: zippedAssetPath, diff --git a/tool/utils.ts b/tool/utils.ts index 96fd2c9e..dbcc88ad 100644 --- a/tool/utils.ts +++ b/tool/utils.ts @@ -2,9 +2,11 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {existsSync, promises as fs, lstatSync} from 'fs'; +import {createWriteStream, existsSync, promises as fs, lstatSync} from 'fs'; +import stream from 'stream'; import * as p from 'path'; import * as shell from 'shelljs'; +import * as yauzl from 'yauzl'; shell.config.fatal = true; @@ -87,3 +89,20 @@ async function tryRealpath(path: string): Promise { return null; } } + +// Extract a zip file. +// +// Use this function only on trusted zip files. +export async function extractZip(source: string, dest: string): Promise { + const zipfile = await yauzl.openPromise(source); + for await (const entry of zipfile.eachEntry()) { + if (entry.fileName.endsWith('/')) { + continue; + } else { + const file = p.join(dest, entry.fileName); + await fs.mkdir(p.dirname(file), {recursive: true}); + const readStream = await zipfile.openReadStreamPromise(entry); + await stream.promises.pipeline(readStream, createWriteStream(file)); + } + } +} From fe9fd74d0c0a9201970767f8b1ac1011d84aa4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 6 Nov 2026 16:48:19 -0800 Subject: [PATCH 2/2] Revert "Lock the Node version used for releasing to 24.x (#459)" This reverts commit 19b094ed2441be1a62ab5dd20cfaeff2166aefab. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 40d6956f..3c0666a1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: package-manager-cache: false - node-version: '24.x' # max-mapper/extract-zip#154 and sass/embedded-host-node#457 + node-version: 'lts/*' check-latest: true registry-url: 'https://registry.npmjs.org'