From 74d44a6fd48316abd98f9db78e73f65cbde761cd Mon Sep 17 00:00:00 2001 From: Yohe-Am <56622350+Yohe-Am@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:21:02 +0000 Subject: [PATCH] fix: get tests working --- deps/plug.ts | 1 - ghjk.ts | 4 ++-- plug.ts | 5 +++-- plugs/node.ts | 18 ++++++++++++++++-- plugs/wasmedge.ts | 14 ++++++++++++-- tests/test.Dockerfile | 2 +- 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/deps/plug.ts b/deps/plug.ts index d72be1f9..33d62761 100644 --- a/deps/plug.ts +++ b/deps/plug.ts @@ -2,7 +2,6 @@ export * from "./common.ts"; export * as zipjs from "https://deno.land/x/zipjs@v2.7.31/index.js"; -export * as compress from "https://deno.land/x/compress@v0.4.5/mod.ts"; export { Foras } from "https://deno.land/x/foras@v2.1.4/src/deno/mod.ts"; export * as std_tar from "https://deno.land/std@0.129.0/archive/tar.ts"; export * as std_streams from "https://deno.land/std@0.129.0/streams/mod.ts"; diff --git a/ghjk.ts b/ghjk.ts index 48747f7a..4987faaa 100644 --- a/ghjk.ts +++ b/ghjk.ts @@ -17,7 +17,7 @@ import ruff from "./plugs/ruff.ts"; import whiz from "./plugs/whiz.ts"; // node({}); -// wasmedge({}); +wasmedge({}); // pnpm({}); // cargo_binstall({}); // wasm_tools({}); @@ -33,4 +33,4 @@ import whiz from "./plugs/whiz.ts"; // protoc({}); // earthly({}); // ruff({}); -whiz({}); +// whiz({}); diff --git a/plug.ts b/plug.ts index 1eef6f50..10f3319e 100644 --- a/plug.ts +++ b/plug.ts @@ -12,7 +12,6 @@ import { validators, } from "./core/mod.ts"; import { - compress, Foras, log, std_fs, @@ -171,6 +170,7 @@ export async function downloadFile( } /// Uses file extension to determine type +/// Does not support symlinks export async function unarchive( path: string, dest = "./", @@ -212,6 +212,7 @@ export async function untgz( }, }); const buf = gzDec.finish().copyAndDispose(); + await Deno.writeFile("/tmp/my.tar", buf); await untarReader(new std_io.Buffer(buf), dest); } export async function untar( @@ -240,7 +241,7 @@ export async function untarReader( const filePath = std_path.resolve(dest, entry.fileName); if (entry.type === "directory") { await std_fs.ensureDir(filePath); - return; + continue; } await std_fs.ensureDir(std_path.dirname(filePath)); const file = await Deno.open(filePath, { diff --git a/plugs/node.ts b/plugs/node.ts index 43ec5310..d5c51fa4 100644 --- a/plugs/node.ts +++ b/plugs/node.ts @@ -1,5 +1,6 @@ import { addInstallGlobal, + depBinShimPath, DownloadArgs, downloadFile, ExecEnvArgs, @@ -10,17 +11,25 @@ import { PlugBase, registerDenoPlugGlobal, removeFile, + spawn, std_fs, std_path, std_url, - unarchive, } from "../plug.ts"; +// import * as std_plugs from "../std.ts"; + +const tar_aa_id = { + id: "tar@aa", +}; // TODO: sanity check exports of all plugs export const manifest = { name: "node@org", version: "0.1.0", moduleSpecifier: import.meta.url, + deps: [ + tar_aa_id, + ], }; registerDenoPlugGlobal(manifest, () => new Plug()); @@ -68,7 +77,12 @@ export class Plug extends PlugBase { artifactUrl(args.installVersion, args.platform), ); const fileDwnPath = std_path.resolve(args.downloadPath, fileName); - await unarchive(fileDwnPath, args.tmpDirPath); + await spawn([ + depBinShimPath(tar_aa_id, "tar", args.depShims), + "xf", + fileDwnPath, + `--directory=${args.tmpDirPath}`, + ]); if (await std_fs.exists(args.installPath)) { await removeFile(args.installPath, { recursive: true }); diff --git a/plugs/wasmedge.ts b/plugs/wasmedge.ts index 97acffaf..778f4de8 100644 --- a/plugs/wasmedge.ts +++ b/plugs/wasmedge.ts @@ -1,5 +1,6 @@ import { addInstallGlobal, + depBinShimPath, DownloadArgs, downloadFile, ExecEnvArgs, @@ -9,16 +10,20 @@ import { PlugBase, registerDenoPlugGlobal, removeFile, + spawn, std_fs, std_path, std_url, - unarchive, } from "../plug.ts"; +import * as std_plugs from "../std.ts"; const manifest = { name: "wasmedge@ghrel", version: "0.1.0", moduleSpecifier: import.meta.url, + deps: [ + std_plugs.tar_aa, + ], }; registerDenoPlugGlobal(manifest, () => new Plug()); @@ -105,7 +110,12 @@ export class Plug extends PlugBase { ); const fileDwnPath = std_path.resolve(args.downloadPath, fileName); - await unarchive(fileDwnPath, args.tmpDirPath); + await spawn([ + depBinShimPath(std_plugs.tar_aa, "tar", args.depShims), + "xf", + fileDwnPath, + `--directory=${args.tmpDirPath}`, + ]); if (await std_fs.exists(args.installPath)) { await removeFile(args.installPath, { recursive: true }); diff --git a/tests/test.Dockerfile b/tests/test.Dockerfile index b05529c3..d095baa9 100644 --- a/tests/test.Dockerfile +++ b/tests/test.Dockerfile @@ -5,7 +5,7 @@ RUN set -eux; \ apt update; \ apt install --yes \ # asdf deps - git curl \ + git curl xz-utils unzip \ ;\ apt clean autoclean; apt autoremove --yes; rm -rf /var/lib/{apt,dpkg,cache,log}/;