From 0131e5f3dbd8e47faf36294b235f7a0e4855dee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6green?= Date: Tue, 9 Apr 2024 11:48:35 +0200 Subject: [PATCH] chore: add JSR imports to deno.json and fmt/lint --- deno.json | 6 ++++++ deps.ts | 13 ------------- download.ts | 8 ++++---- download_test.ts | 7 +++---- test_deps.ts | 2 -- test_import_map.json | 7 ++++++- util.ts | 12 +++--------- util_test.ts | 9 +++------ 8 files changed, 25 insertions(+), 39 deletions(-) delete mode 100644 deps.ts delete mode 100644 test_deps.ts diff --git a/deno.json b/deno.json index ad56697..1ef472a 100644 --- a/deno.json +++ b/deno.json @@ -7,5 +7,11 @@ "./download": "./download.ts", "./util": "./util.ts" }, + "imports": { + "@std/encoding/hex": "jsr:@std/encoding@^0.221.0/hex", + "@std/fmt/colors": "jsr:@std/fmt@^0.221.0/colors", + "@std/fs": "jsr:@std/fs@^0.221.0", + "@std/path": "jsr:@std/path@^0.221.0" + }, "lock": false } diff --git a/deps.ts b/deps.ts deleted file mode 100644 index 322521d..0000000 --- a/deps.ts +++ /dev/null @@ -1,13 +0,0 @@ -export { - dirname, - extname, - fromFileUrl, - isAbsolute, - join, - normalize, - resolve, - toFileUrl, -} from "jsr:@std/path@0.214"; -export { ensureDir } from "jsr:@std/fs@0.214"; -export { encodeHex as hex } from "jsr:@std/encoding@0.214/hex"; -export { green } from "jsr:@std/fmt@0.214/colors"; diff --git a/download.ts b/download.ts index 642e733..b1cfa9f 100644 --- a/download.ts +++ b/download.ts @@ -6,15 +6,15 @@ import { dirname, - ensureDir, extname, fromFileUrl, - green, join, normalize, resolve, -} from "./deps.ts"; -import { +} from "@std/path"; +import { ensureDir } from "@std/fs"; +import { green } from "@std/fmt/colors"; +import type { ArchRecord, CacheLocation, FetchOptions, diff --git a/download_test.ts b/download_test.ts index 029960a..4be8a34 100644 --- a/download_test.ts +++ b/download_test.ts @@ -3,10 +3,9 @@ import { assertEquals, assertMatch, assertRejects, - basename, - dirname, - normalize, -} from "./test_deps.ts"; +} from "jsr:@std/assert"; +import { basename, dirname, normalize } from "@std/path"; + import { createDownloadURL, ensureCacheLocation } from "./download.ts"; const ALL_ARCHS = ["x86_64", "aarch64"]; diff --git a/test_deps.ts b/test_deps.ts deleted file mode 100644 index 5064119..0000000 --- a/test_deps.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "jsr:@std/assert@0.214"; -export * from "jsr:@std/path@0.214"; diff --git a/test_import_map.json b/test_import_map.json index 94c20d3..7a09b5e 100644 --- a/test_import_map.json +++ b/test_import_map.json @@ -4,6 +4,11 @@ "@denosaurs/plug": "./mod.ts", "@denosaurs/plug/types": "./types.ts", "@denosaurs/plug/download": "./download.ts", - "@denosaurs/plug/util": "./util.ts" + "@denosaurs/plug/util": "./util.ts", + "@std/assert": "jsr:@std/assert@^0.221.0", + "@std/encoding/hex": "jsr:@std/encoding@^0.221.0/hex", + "@std/fmt/colors": "jsr:@std/fmt@^0.221.0/colors", + "@std/fs": "jsr:@std/fs@^0.221.0", + "@std/path": "jsr:@std/path@^0.221.0" } } diff --git a/util.ts b/util.ts index 4f7123c..74f88a0 100644 --- a/util.ts +++ b/util.ts @@ -4,14 +4,8 @@ * @module */ -import { - hex, - isAbsolute, - join, - normalize, - resolve, - toFileUrl, -} from "./deps.ts"; +import { isAbsolute, join, normalize, resolve, toFileUrl } from "@std/path"; +import { encodeHex } from "@std/encoding/hex"; const encoder = new TextEncoder(); @@ -61,7 +55,7 @@ export function stringToURL(url: string): URL { * @private */ export async function hash(value: string): Promise { - return hex( + return encodeHex( new Uint8Array( await crypto.subtle.digest("SHA-256", encoder.encode(value)), ), diff --git a/util_test.ts b/util_test.ts index c144e98..827f82c 100644 --- a/util_test.ts +++ b/util_test.ts @@ -3,12 +3,9 @@ import { assertEquals, assertRejects, assertThrows, - basename, - dirname, - fromFileUrl, - join, - normalize, -} from "./test_deps.ts"; +} from "jsr:@std/assert"; +import { basename, dirname, fromFileUrl, join, normalize } from "@std/path"; + import { cacheDir, denoCacheDir,