diff --git a/deno.lock b/deno.lock index cf61d088..f318d02e 100644 --- a/deno.lock +++ b/deno.lock @@ -526,6 +526,35 @@ "https://deno.land/x/zip@v1.2.5/deps.ts": "79548387594b3ae1efaaa870b5a507c4d6bedede13dbd5d4ad42f6cda0aeef86", "https://deno.land/x/zip@v1.2.5/mod.ts": "28eecbc3e1e5adf564f4aa465e64268713a05653104bacdcb04561533f8caf57", "https://deno.land/x/zip@v1.2.5/utils.ts": "43c323f2b79f9db1976c5739bbb1f9cced20e8077ca7e7e703f9d01d4330bd9d", + "https://deno.land/x/zipjs@v2.7.31/index.js": "7c71926e0c9618e48a22d9dce701131704fd3148a1d2eefd5dba1d786c846a5f", + "https://deno.land/x/zipjs@v2.7.31/lib/core/codec-pool.js": "e5ab8ee3ec800ed751ef1c63a1bd8e50f162aa256a5f625d173d7a32e76e828c", + "https://deno.land/x/zipjs@v2.7.31/lib/core/codec-worker.js": "744b7e149df6f2d105afbcb9cce573df2fbf7bf1c2e14c3689220c2dedeabe65", + "https://deno.land/x/zipjs@v2.7.31/lib/core/configuration.js": "baa316a63df2f8239f9d52cd4863eaedaddd34ad887b7513588da75d19e84932", + "https://deno.land/x/zipjs@v2.7.31/lib/core/constants.js": "14fe1468b87cd0fe20c6f1fec916485f875d8592beba94c9241af4cbd12dd88f", + "https://deno.land/x/zipjs@v2.7.31/lib/core/io.js": "4c4e86ba187540be533003271f222183455897cd144cb542539e9480882c2dda", + "https://deno.land/x/zipjs@v2.7.31/lib/core/streams/aes-crypto-stream.js": "8242f23a221c496996071b68d498e821ca6b8f20d04bdf74ee0a589ac3367cc5", + "https://deno.land/x/zipjs@v2.7.31/lib/core/streams/codec-stream.js": "685f1120b94b6295dcd61b195d6202cd24a5344e4588dc52f42e8ac0f9dfe294", + "https://deno.land/x/zipjs@v2.7.31/lib/core/streams/codecs/crc32.js": "dfdde666f72b4a5ffc8cf5b1451e0db578ce4bd90de20df2cff5bfd47758cb23", + "https://deno.land/x/zipjs@v2.7.31/lib/core/streams/codecs/deflate.js": "08c1b24d1845528f6db296570d690ecbe23c6c01c6cb26b561e601e770281c3a", + "https://deno.land/x/zipjs@v2.7.31/lib/core/streams/codecs/inflate.js": "55d00eed332cf2c4f61e2ee23133e3257768d0608572ee3f9641a2921c3a6f67", + "https://deno.land/x/zipjs@v2.7.31/lib/core/streams/codecs/sjcl.js": "462289c5312f01bba8a757a7a0f3d8f349f471183cb4c49fb73d58bba18a5428", + "https://deno.land/x/zipjs@v2.7.31/lib/core/streams/common-crypto.js": "4d462619848d94427fcd486fd94e5c0741af60e476df6720da8224b086eba47e", + "https://deno.land/x/zipjs@v2.7.31/lib/core/streams/crc32-stream.js": "10e26bd18df0e1e89d61a62827a1a1c19f4e541636dd0eccbd85af3afabce289", + "https://deno.land/x/zipjs@v2.7.31/lib/core/streams/stream-adapter.js": "9e7f3fe1601cc447943cd37b5adb6d74c6e9c404d002e707e8eace7bc048929c", + "https://deno.land/x/zipjs@v2.7.31/lib/core/streams/zip-crypto-stream.js": "19305af1e8296e7fa6763f3391d0b8149a1e09c659e1d1ff32a484448b18243c", + "https://deno.land/x/zipjs@v2.7.31/lib/core/streams/zip-entry-stream.js": "01d4dc0843e8c43d32454cbb15e4d1f9b7122ab288d7650129d010df54bc0b8e", + "https://deno.land/x/zipjs@v2.7.31/lib/core/util/cp437-decode.js": "d665ded184037ffe5d255be8f379f90416053e3d0d84fac95b28f4aeaab3d336", + "https://deno.land/x/zipjs@v2.7.31/lib/core/util/decode-text.js": "c04a098fa7c16470c48b6abd4eb4ac48af53547de65e7c8f39b78ae62330ad57", + "https://deno.land/x/zipjs@v2.7.31/lib/core/util/default-mime-type.js": "177ae00e1956d3d00cdefc40eb158cb591d3d24ede452c056d30f98d73d9cd73", + "https://deno.land/x/zipjs@v2.7.31/lib/core/util/encode-text.js": "c51a8947c15b7fe31b0036b69fd68817f54b30ce29502b5c9609d8b15e3b20d9", + "https://deno.land/x/zipjs@v2.7.31/lib/core/util/mime-type.js": "6c6dfa4daf98ef59cd65118073b74f327ceab2ef28140e38934b0d15eb2b5c29", + "https://deno.land/x/zipjs@v2.7.31/lib/core/util/stream-codec-shim.js": "1323016ec3c743942dc887215832badc7f2c1e8dbb37b71c94bf54276d2b281a", + "https://deno.land/x/zipjs@v2.7.31/lib/core/zip-entry.js": "d30a535cd1e75ef98094cd04120f178c103cdc4055d23ff747ffc6a154da8d2d", + "https://deno.land/x/zipjs@v2.7.31/lib/core/zip-fs-core.js": "6fbd3ad9dbf0d07e19e1a59863743d2069f2b5fca691bdd6cd8d052ee7ce0c06", + "https://deno.land/x/zipjs@v2.7.31/lib/core/zip-reader.js": "4e63d88e4eb5f7419e2dc3ccb741014240267a49fb80a9cbcb024149990b532b", + "https://deno.land/x/zipjs@v2.7.31/lib/core/zip-writer.js": "b78c099828ec3134983c259adc4d6118fbfda7f033a7e95de8176a470e9a5a54", + "https://deno.land/x/zipjs@v2.7.31/lib/z-worker-inline.js": "9869579df96d7b75a10c70f231837c418b0cdd0ac26df12f17dade6bbaa6c17a", + "https://deno.land/x/zipjs@v2.7.31/lib/zip-fs.js": "a733360302f5fbec9cc01543cb9fcfe7bae3f35a50d0006626ce42fe8183b63f", "https://deno.land/x/zod@v3.22.4/ZodError.ts": "4de18ff525e75a0315f2c12066b77b5c2ae18c7c15ef7df7e165d63536fdf2ea", "https://deno.land/x/zod@v3.22.4/errors.ts": "5285922d2be9700cc0c70c95e4858952b07ae193aa0224be3cbd5cd5567eabef", "https://deno.land/x/zod@v3.22.4/external.ts": "a6cfbd61e9e097d5f42f8a7ed6f92f93f51ff927d29c9fbaec04f03cbce130fe", diff --git a/deps/plug.ts b/deps/plug.ts index c52ebfc1..59299bed 100644 --- a/deps/plug.ts +++ b/deps/plug.ts @@ -2,4 +2,4 @@ export * from "./common.ts"; export * as compress from "https://deno.land/x/compress@v0.4.5/mod.ts"; -export * as zip from "https://deno.land/x/zip@v1.2.5/mod.ts"; +export * as zipjs from "https://deno.land/x/zipjs@v2.7.31/index.js"; diff --git a/ghjk.ts b/ghjk.ts index 2c5e1096..48747f7a 100644 --- a/ghjk.ts +++ b/ghjk.ts @@ -33,4 +33,4 @@ import whiz from "./plugs/whiz.ts"; // protoc({}); // earthly({}); // ruff({}); -// whiz({}); +whiz({}); diff --git a/plug.ts b/plug.ts index 069bc732..783b3f92 100644 --- a/plug.ts +++ b/plug.ts @@ -2,18 +2,23 @@ import { addInstall, type AmbientAccessPlugManifest, type DenoWorkerPlugManifest, - type DepShims, type DownloadArgs, type GhjkConfig, type InstallConfig, type PlugBase, - type PlugDep, registerAmbientPlug, registerDenoPlug, registerPlug, validators, } from "./core/mod.ts"; -import { compress, log, std_fs, std_path, std_url, zip } from "./deps/plug.ts"; +import { + compress, + log, + std_fs, + std_path, + std_url, + zipjs, +} from "./deps/plug.ts"; import { initDenoWorkerPlug, isWorker } from "./core/worker.ts"; import * as asdf from "./core/asdf.ts"; import logger from "./core/logger.ts"; @@ -171,14 +176,44 @@ export async function unarchive( case ".gz": case ".tar.gz": case ".tgz": - await compress.tgz.uncompress(path, dest); + await compress.tgz.uncompress(path, dest, { + debug: true, + }); break; case ".tar": - await compress.tar.uncompress(path, dest); + await compress.tar.uncompress(path, dest, { + debug: true, + }); break; - case ".zip": - await zip.decompress(path, dest); + case ".zip": { + const zipFile = await Deno.open(path, { read: true }); + const zipReader = new zipjs.ZipReader(zipFile.readable); + try { + await Promise.allSettled( + (await zipReader.getEntries()).map(async (entry) => { + if (entry.directory) { + await std_fs.ensureDir(std_path.resolve(dest, entry.filename)); + return; + } + const filePath = std_path.resolve(dest, entry.filename); + await std_fs.ensureDir(std_path.dirname(filePath)); + const file = await Deno.open(filePath, { + create: true, + truncate: true, + write: true, + mode: entry.externalFileAttribute >> 16, + }); + if (!entry.getData) throw Error("impossible"); + await entry.getData(file.writable); + }), + ); + } catch (err) { + throw err; + } finally { + zipReader.close(); + } break; + } default: throw Error("unsupported archive extension: ${ext}"); } diff --git a/plugs/mold.ts b/plugs/mold.ts index 1e7ec983..4ff66102 100644 --- a/plugs/mold.ts +++ b/plugs/mold.ts @@ -70,7 +70,7 @@ export class Plug extends PlugBase { ); const fileDwnPath = std_path.resolve(args.downloadPath, fileName); - await unarchive(fileDwnPath args.tmpDirPath) + await unarchive(fileDwnPath, args.tmpDirPath); if (await std_fs.exists(args.installPath)) { await removeFile(args.installPath, { recursive: true }); @@ -108,8 +108,9 @@ function downloadUrl(installVersion: string, platform: PlatformInfo) { default: throw new Error(`unsupported arch: ${platform.arch}`); } - return `${repoAddress}/releases/download/${installVersion}/${repoName}-${installVersion.startsWith("v") ? installVersion.slice(1) : installVersion - }-${arch}-${os}.tar.gz`; + return `${repoAddress}/releases/download/${installVersion}/${repoName}-${ + installVersion.startsWith("v") ? installVersion.slice(1) : installVersion + }-${arch}-${os}.tar.gz`; } else { throw new Error(`unsupported os: ${platform.os}`); } diff --git a/plugs/ruff.ts b/plugs/ruff.ts index 874e592c..40ecb5dc 100644 --- a/plugs/ruff.ts +++ b/plugs/ruff.ts @@ -1,6 +1,5 @@ import { addInstallGlobal, - depBinShimPath, DownloadArgs, downloadFile, InstallArgs, @@ -9,7 +8,6 @@ import { PlugBase, registerDenoPlugGlobal, removeFile, - spawn, std_fs, std_path, std_url, @@ -81,6 +79,7 @@ export class Plug extends PlugBase { args.tmpDirPath, std_path.resolve(args.installPath, "bin"), ); + // await Deno.chmod(std_path.resolve(args.installPath, "bin", "ruff"), 0o700); } }