Skip to content

Commit

Permalink
fix: get tests working
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Nov 30, 2023
1 parent 0b0fb49 commit 74d44a6
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
1 change: 0 additions & 1 deletion deps/plug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

export * from "./common.ts";
export * as zipjs from "https://deno.land/x/[email protected]/index.js";
export * as compress from "https://deno.land/x/[email protected]/mod.ts";
export { Foras } from "https://deno.land/x/[email protected]/src/deno/mod.ts";
export * as std_tar from "https://deno.land/[email protected]/archive/tar.ts";
export * as std_streams from "https://deno.land/[email protected]/streams/mod.ts";
Expand Down
4 changes: 2 additions & 2 deletions ghjk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import ruff from "./plugs/ruff.ts";
import whiz from "./plugs/whiz.ts";

// node({});
// wasmedge({});
wasmedge({});
// pnpm({});
// cargo_binstall({});
// wasm_tools({});
Expand All @@ -33,4 +33,4 @@ import whiz from "./plugs/whiz.ts";
// protoc({});
// earthly({});
// ruff({});
whiz({});
// whiz({});
5 changes: 3 additions & 2 deletions plug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
validators,
} from "./core/mod.ts";
import {
compress,
Foras,
log,
std_fs,
Expand Down Expand Up @@ -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 = "./",
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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, {
Expand Down
18 changes: 16 additions & 2 deletions plugs/node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
addInstallGlobal,
depBinShimPath,
DownloadArgs,
downloadFile,
ExecEnvArgs,
Expand All @@ -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());
Expand Down Expand Up @@ -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 });
Expand Down
14 changes: 12 additions & 2 deletions plugs/wasmedge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
addInstallGlobal,
depBinShimPath,
DownloadArgs,
downloadFile,
ExecEnvArgs,
Expand All @@ -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());
Expand Down Expand Up @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion tests/test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}/;

Expand Down

0 comments on commit 74d44a6

Please sign in to comment.