Compare commits

..

No commits in common. "trunk" and "v1.0.0" have entirely different histories.

6 changed files with 53 additions and 26 deletions

View file

@ -1,14 +1,8 @@
{ {
"version": "1.0.1", "version": "1.0.0",
"exports": "./mod.ts", "exports": "./mod.ts",
"tasks": { "tasks": {
"check": "deno fmt --check && deno lint && deno check .", "check": "deno fmt --check && deno lint && deno check .",
"test": "deno test --allow-read=. --allow-write=./tests/site/_site,./tests/__snapshots__ --deny-env" "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",
"lume/": "https://deno.land/x/lume@v2.4.1/"
} }
} }

BIN
deno.lock

Binary file not shown.

26
deps.ts
View file

@ -14,4 +14,30 @@
* limitations under the License. * limitations under the License.
*/ */
// Lume
export {
default as LumeSite,
type SiteOptions as LumeSiteOptions,
} from "https://deno.land/x/lume@v2.4.0/core/site.ts";
export {
default as lume,
type PluginOptions as LumePluginOptions,
} from "https://deno.land/x/lume@v2.4.0/mod.ts";
export {
type DeepPartial as LumeDeepPartial,
} from "https://deno.land/x/lume@v2.4.0/core/utils/object.ts";
export {
type Writer as LumeWriter,
} from "https://deno.land/x/lume@v2.4.0/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"; export * as valibot from "jsr:@valibot/valibot@0.42.1";

7
mod.ts
View file

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { valibot as v } from "./deps.ts";
import Site from "lume/core/site.ts";
import diagrams from "./resources/diagrams.json" with { type: "json" }; import diagrams from "./resources/diagrams.json" with { type: "json" };
import { LumeSite, valibot as v } from "./deps.ts";
import { deflateSync } from "node:zlib"; import { deflateSync } from "node:zlib";
const textEncoder = new TextEncoder(); const textEncoder = new TextEncoder();
@ -67,10 +66,10 @@ const OptionsSchema = v.optional(
export type Options = v.InferInput<typeof OptionsSchema>; export type Options = v.InferInput<typeof OptionsSchema>;
export default function (options?: Options): (site: Site) => void { export default function (options?: Options): (site: LumeSite) => void {
const opts = v.parse(OptionsSchema, options); const opts = v.parse(OptionsSchema, options);
return (site: Site) => { return (site: LumeSite) => {
site.process([".html"], (pages) => { site.process([".html"], (pages) => {
pages.forEach((page) => { pages.forEach((page) => {
diagrams.forEach((diagram) => { diagrams.forEach((diagram) => {

View file

@ -15,10 +15,13 @@
*/ */
import mod from "../mod.ts"; import mod from "../mod.ts";
import { valibot as v } from "../deps.ts";
import { assertExists, assertInstanceOf } from "@std/assert";
import { assertSnapshot } from "@std/testing/snapshot";
import { getSite } from "./utils.ts"; import { getSite } from "./utils.ts";
import {
assertExists,
assertInstanceOf,
assertSnapshot,
valibot,
} from "../deps.ts";
Deno.test("Error thrown on invalid options", async (t) => { Deno.test("Error thrown on invalid options", async (t) => {
await t.step("Invalid server", () => { await t.step("Invalid server", () => {
@ -29,7 +32,7 @@ Deno.test("Error thrown on invalid options", async (t) => {
error = err; error = err;
} }
assertExists(error); assertExists(error);
assertInstanceOf(error, v.ValiError); assertInstanceOf(error, valibot.ValiError);
}); });
await t.step("Invalid enabledDiagrams", () => { await t.step("Invalid enabledDiagrams", () => {
@ -40,7 +43,7 @@ Deno.test("Error thrown on invalid options", async (t) => {
error = err; error = err;
} }
assertExists(error); assertExists(error);
assertInstanceOf(error, v.ValiError); assertInstanceOf(error, valibot.ValiError);
}); });
await t.step("Invalid format", () => { await t.step("Invalid format", () => {
@ -52,7 +55,7 @@ Deno.test("Error thrown on invalid options", async (t) => {
error = err; error = err;
} }
assertExists(error); assertExists(error);
assertInstanceOf(error, v.ValiError); assertInstanceOf(error, valibot.ValiError);
}); });
}); });

View file

@ -14,15 +14,20 @@
* limitations under the License. * limitations under the License.
*/ */
import Site, { SiteOptions } from "lume/core/site.ts"; import {
import lume, { PluginOptions } from "lume/mod.ts"; fromFileUrl,
import { DeepPartial } from "lume/core/utils/object.ts"; join,
import { Writer } from "lume/core/writer.ts"; lume,
import { fromFileUrl, join } from "@std/path"; type LumeDeepPartial,
type LumePluginOptions,
LumeSite,
type LumeSiteOptions,
type LumeWriter,
} from "../deps.ts";
const cwd = fromFileUrl(import.meta.resolve("./")); const cwd = fromFileUrl(import.meta.resolve("./"));
class TestWriter implements Writer { class TestWriter implements LumeWriter {
savePages() { savePages() {
return Promise.resolve([]); return Promise.resolve([]);
} }
@ -41,9 +46,9 @@ class TestWriter implements Writer {
} }
export function getSite( export function getSite(
siteOptions: DeepPartial<SiteOptions> = {}, siteOptions: LumeDeepPartial<LumeSiteOptions> = {},
pluginOptions: PluginOptions = {}, pluginOptions: LumePluginOptions = {},
): Site { ): LumeSite {
siteOptions.cwd = join(cwd, "site"); siteOptions.cwd = join(cwd, "site");
const site = lume( const site = lume(