From ff233ba2895e99954eb7eaa49766d47ed2fc1185 Mon Sep 17 00:00:00 2001 From: Foster Hangdaan Date: Fri, 8 Nov 2024 17:42:43 -0500 Subject: [PATCH] refactor: Move deps into import map --- deno.json | 7 +++++++ deno.lock | Bin 31801 -> 31979 bytes deps.ts | 43 ------------------------------------------- mod.ts | 7 ++++--- tests/mod.test.ts | 15 ++++++--------- tests/utils.ts | 23 +++++++++-------------- 6 files changed, 26 insertions(+), 69 deletions(-) delete mode 100644 deps.ts diff --git a/deno.json b/deno.json index c90acde..9aa47df 100644 --- a/deno.json +++ b/deno.json @@ -4,5 +4,12 @@ "tasks": { "check": "deno fmt --check && deno lint && deno check .", "test": "deno test --allow-read=. --allow-write=./tests/site/_site,./tests/__snapshots__ --deny-env" + }, + "imports": { + "@std/assert": "jsr:@std/assert@1.0.7", + "@std/path": "jsr:@std/path@1.0.8", + "@std/testing": "jsr:@std/testing@1.0.4", + "@valibot/valibot": "jsr:@valibot/valibot@0.42.1", + "lume/": "https://deno.land/x/lume@v2.4.1/" } } diff --git a/deno.lock b/deno.lock index a015b51bd8fd04b9b28b5162326870e1c89af7a5..a6aa433813c6fa18b00d830043facefbef9e2093 100644 GIT binary patch delta 73 zcmdn_gYorG#tmjQ!a7_E3QFbqMcKs#iOH!-RtnWzlLh%@CU%HV+#xjiJuB; -export default function (options?: Options): (site: LumeSite) => void { +export default function (options?: Options): (site: Site) => void { const opts = v.parse(OptionsSchema, options); - return (site: LumeSite) => { + return (site: Site) => { site.process([".html"], (pages) => { pages.forEach((page) => { diagrams.forEach((diagram) => { diff --git a/tests/mod.test.ts b/tests/mod.test.ts index ed44014..cb44f94 100644 --- a/tests/mod.test.ts +++ b/tests/mod.test.ts @@ -15,13 +15,10 @@ */ import mod from "../mod.ts"; +import { ValiError } from "@valibot/valibot"; +import { assertExists, assertInstanceOf } from "@std/assert"; +import { assertSnapshot } from "@std/testing/snapshot"; import { getSite } from "./utils.ts"; -import { - assertExists, - assertInstanceOf, - assertSnapshot, - valibot, -} from "../deps.ts"; Deno.test("Error thrown on invalid options", async (t) => { await t.step("Invalid server", () => { @@ -32,7 +29,7 @@ Deno.test("Error thrown on invalid options", async (t) => { error = err; } assertExists(error); - assertInstanceOf(error, valibot.ValiError); + assertInstanceOf(error, ValiError); }); await t.step("Invalid enabledDiagrams", () => { @@ -43,7 +40,7 @@ Deno.test("Error thrown on invalid options", async (t) => { error = err; } assertExists(error); - assertInstanceOf(error, valibot.ValiError); + assertInstanceOf(error, ValiError); }); await t.step("Invalid format", () => { @@ -55,7 +52,7 @@ Deno.test("Error thrown on invalid options", async (t) => { error = err; } assertExists(error); - assertInstanceOf(error, valibot.ValiError); + assertInstanceOf(error, ValiError); }); }); diff --git a/tests/utils.ts b/tests/utils.ts index f2f22ca..c5f20c1 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -14,20 +14,15 @@ * limitations under the License. */ -import { - fromFileUrl, - join, - lume, - type LumeDeepPartial, - type LumePluginOptions, - LumeSite, - type LumeSiteOptions, - type LumeWriter, -} from "../deps.ts"; +import Site, { SiteOptions } from "lume/core/site.ts"; +import lume, { PluginOptions } from "lume/mod.ts"; +import { DeepPartial } from "lume/core/utils/object.ts"; +import { Writer } from "lume/core/writer.ts"; +import { fromFileUrl, join } from "@std/path"; const cwd = fromFileUrl(import.meta.resolve("./")); -class TestWriter implements LumeWriter { +class TestWriter implements Writer { savePages() { return Promise.resolve([]); } @@ -46,9 +41,9 @@ class TestWriter implements LumeWriter { } export function getSite( - siteOptions: LumeDeepPartial = {}, - pluginOptions: LumePluginOptions = {}, -): LumeSite { + siteOptions: DeepPartial = {}, + pluginOptions: PluginOptions = {}, +): Site { siteOptions.cwd = join(cwd, "site"); const site = lume(