refactor: Move deps into import map
This commit is contained in:
parent
1c106b913c
commit
ff233ba289
6 changed files with 26 additions and 69 deletions
|
@ -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/"
|
||||
}
|
||||
}
|
||||
|
|
BIN
deno.lock
BIN
deno.lock
Binary file not shown.
43
deps.ts
43
deps.ts
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright 2024 Foster Hangdaan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Lume
|
||||
export {
|
||||
default as LumeSite,
|
||||
type SiteOptions as LumeSiteOptions,
|
||||
} from "https://deno.land/x/lume@v2.4.1/core/site.ts";
|
||||
export {
|
||||
default as lume,
|
||||
type PluginOptions as LumePluginOptions,
|
||||
} from "https://deno.land/x/lume@v2.4.1/mod.ts";
|
||||
export {
|
||||
type DeepPartial as LumeDeepPartial,
|
||||
} from "https://deno.land/x/lume@v2.4.1/core/utils/object.ts";
|
||||
export {
|
||||
type Writer as LumeWriter,
|
||||
} from "https://deno.land/x/lume@v2.4.1/core/writer.ts";
|
||||
|
||||
// STD Assert
|
||||
export { assertExists, assertInstanceOf } from "jsr:@std/assert@1.0.7";
|
||||
|
||||
// STD Testing
|
||||
export { assertSnapshot } from "jsr:@std/testing@1.0.4/snapshot";
|
||||
|
||||
// STD Path
|
||||
export { fromFileUrl, join } from "jsr:@std/path@1.0.8";
|
||||
|
||||
// Valibot
|
||||
export * as valibot from "jsr:@valibot/valibot@0.42.1";
|
7
mod.ts
7
mod.ts
|
@ -14,8 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import * as v from "@valibot/valibot";
|
||||
import Site from "lume/core/site.ts";
|
||||
import diagrams from "./resources/diagrams.json" with { type: "json" };
|
||||
import { LumeSite, valibot as v } from "./deps.ts";
|
||||
import { deflateSync } from "node:zlib";
|
||||
|
||||
const textEncoder = new TextEncoder();
|
||||
|
@ -66,10 +67,10 @@ const OptionsSchema = v.optional(
|
|||
|
||||
export type Options = v.InferInput<typeof OptionsSchema>;
|
||||
|
||||
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) => {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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<LumeSiteOptions> = {},
|
||||
pluginOptions: LumePluginOptions = {},
|
||||
): LumeSite {
|
||||
siteOptions: DeepPartial<SiteOptions> = {},
|
||||
pluginOptions: PluginOptions = {},
|
||||
): Site {
|
||||
siteOptions.cwd = join(cwd, "site");
|
||||
|
||||
const site = lume(
|
||||
|
|
Loading…
Reference in a new issue