diff --git a/package.json b/package.json index a8b28b1..e1f343b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "build": "node src/build.js" }, "dependencies": { - "extract-zip": "^2.0.1" + "unzipper": "^0.12.3" }, "engines": { "node": ">= 18.12.0" diff --git a/src/build.js b/src/build.js index 3bc7034..10ef371 100644 --- a/src/build.js +++ b/src/build.js @@ -7,10 +7,9 @@ // Instead of using the API, I find it easier to failover to GitHub. // ref: https://gitlab.com/gitlab-org/gitlab/-/issues/29257 -import unzip from 'extract-zip' -import { basename, dirname, join } from 'node:path' +import { Extract } from 'unzipper' +import { dirname, join } from 'node:path' import { mkdir, readdir, rm } from 'node:fs/promises' -import { createWriteStream } from 'node:fs' import { pipeline } from 'node:stream/promises' import { fileURLToPath } from 'node:url' import { Readable } from 'node:stream' @@ -24,7 +23,7 @@ const projects = [ 'phishing-filter', 'tracking-filter', 'vn-badsite-filter', - 'botnet-filter', + 'botnet-filter' // 'pup-filter' ] @@ -41,15 +40,13 @@ const pipelineStatus = async (url) => { const dl = async (project) => { const filename = project + '.zip' const link = `https://gitlab.com/malware-filter/${project}/-/jobs/artifacts/main/download?job=pages` - const zipPath = join(tmpPath, filename) const pipelineUrl = `https://gitlab.com/malware-filter/${project}/badges/main/pipeline.svg` - let isMirror = false console.log(`Downloading ${filename} from "${link}"`) try { await pipeline( Readable.fromWeb((await fetch(link)).body), - createWriteStream(zipPath) + Extract({ path: rootPath }) ) await pipelineStatus(pipelineUrl) } catch ({ message }) { @@ -61,12 +58,11 @@ const dl = async (project) => { const mirrorLink = `https://nightly.link/curbengh/${project}/workflows/pages/main/public.zip` console.log(`Downloading ${filename} from "${mirrorLink}"`) - isMirror = true try { await pipeline( Readable.fromWeb((await fetch(mirrorLink)).body), - createWriteStream(zipPath) + Extract({ path: publicPath }) ) } catch ({ message }) { throw new Error(JSON.stringify({ @@ -76,13 +72,6 @@ const dl = async (project) => { })) } } - - console.log(`Extracting ${basename(zipPath)}...`) - if (isMirror === false) { - await unzip(zipPath, { dir: rootPath }) - } else { - await unzip(zipPath, { dir: publicPath }) - } } const f = async () => {