From c4bb64c2869c299e56123f7e9d223a3c66a5cf3f Mon Sep 17 00:00:00 2001 From: Souma <101255979+5ouma@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:50:35 +0900 Subject: [PATCH] refactor(import-map): Use local import map (#87) For readability and writability. --- deno.json | 2 ++ src/libs/convert.ts | 7 ++++++- src/libs/io.ts | 2 +- src/libs/sites.ts | 2 +- src/main.ts | 4 ++-- src/types/feed.ts | 2 ++ test/libs/convert_test.ts | 2 +- test/libs/io_test.ts | 4 ++-- test/libs/sites_test.ts | 2 +- 9 files changed, 18 insertions(+), 9 deletions(-) diff --git a/deno.json b/deno.json index 6a6f354..a0e958c 100644 --- a/deno.json +++ b/deno.json @@ -8,6 +8,8 @@ "cov": "deno task test --coverage && deno coverage --lcov > coverage.lcov" }, "imports": { + "@5ouma/opml-generator/libs": "./src/libs/mod.ts", + "@5ouma/opml-generator/types": "./src/types/mod.ts", "@libs/xml": "jsr:@libs/xml@5.4.7", "@std/assert": "jsr:@std/assert@0.226.0", "@std/cli": "jsr:@std/cli@0.224.6", diff --git a/src/libs/convert.ts b/src/libs/convert.ts index 485cac1..3fba2d0 100644 --- a/src/libs/convert.ts +++ b/src/libs/convert.ts @@ -1,7 +1,12 @@ import { stringify } from "@libs/xml"; import { parse } from "@std/toml"; import { transcodeXmlUrl } from "./sites.ts"; -import type { Feed, List, Lists, OPMLOutline } from "../types/mod.ts"; +import type { + Feed, + List, + Lists, + OPMLOutline, +} from "@5ouma/opml-generator/types"; export function convertFromTOML(data: string): Lists { const lists: Lists = parse(data) as Lists; diff --git a/src/libs/io.ts b/src/libs/io.ts index 4a6edc7..741ba34 100644 --- a/src/libs/io.ts +++ b/src/libs/io.ts @@ -1,7 +1,7 @@ import { paramCase } from "@wok/case"; import { format } from "@std/path"; import { convertFromTOML, convertToOPML } from "./convert.ts"; -import type { List, Lists } from "../types/mod.ts"; +import type { List, Lists } from "@5ouma/opml-generator/types"; export async function readTOML(file: string): Promise { try { diff --git a/src/libs/sites.ts b/src/libs/sites.ts index abfeed3..b64b5cf 100644 --- a/src/libs/sites.ts +++ b/src/libs/sites.ts @@ -1,4 +1,4 @@ -import type { site } from "../types/mod.ts"; +import type { site } from "@5ouma/opml-generator/types"; const sites: site[] = [ { type: "bluesky", url: new URL("https://bsky.app/profile/{id}/rss") }, diff --git a/src/main.ts b/src/main.ts index 45924e2..705e127 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,7 @@ import { parseArgs } from "@std/cli"; import { basename, resolve } from "@std/path"; -import { readTOML, writeXML } from "./libs/mod.ts"; -import type { Lists } from "./types/mod.ts"; +import { readTOML, writeXML } from "@5ouma/opml-generator/libs"; +import type { Lists } from "@5ouma/opml-generator/types"; const flags = parseArgs(Deno.args, { string: ["feeds", "output"], diff --git a/src/types/feed.ts b/src/types/feed.ts index d185870..d588be4 100644 --- a/src/types/feed.ts +++ b/src/types/feed.ts @@ -1,10 +1,12 @@ export type Lists = { lists: List[]; }; + export type List = { name: string; feeds: Feed[]; }; + export type Feed = { title: string; type?: string; diff --git a/test/libs/convert_test.ts b/test/libs/convert_test.ts index 46b6d29..4682ebc 100644 --- a/test/libs/convert_test.ts +++ b/test/libs/convert_test.ts @@ -1,6 +1,6 @@ import { assertEquals } from "@std/assert"; import { convertFromTOML, convertToOPML } from "../../src/libs/convert.ts"; -import type { List, Lists } from "../../src/types/mod.ts"; +import type { List, Lists } from "@5ouma/opml-generator/types"; Deno.test("Parse TOML", async (t: Deno.TestContext) => { await t.step("rss", () => { diff --git a/test/libs/io_test.ts b/test/libs/io_test.ts index adee569..4f0527d 100644 --- a/test/libs/io_test.ts +++ b/test/libs/io_test.ts @@ -1,8 +1,8 @@ import { assertEquals, assertIsError } from "@std/assert"; import { join } from "@std/path"; -import { readTOML, writeXML } from "../../src/libs/io.ts"; +import { readTOML, writeXML } from "@5ouma/opml-generator/libs"; import { convertFromTOML, convertToOPML } from "../../src/libs/convert.ts"; -import type { Lists } from "../../src/types/mod.ts"; +import type { Lists } from "@5ouma/opml-generator/types"; Deno.test("Read TOML", async (t: Deno.TestContext) => { await t.step("normal", async () => { diff --git a/test/libs/sites_test.ts b/test/libs/sites_test.ts index fda4a18..ae0a8cc 100644 --- a/test/libs/sites_test.ts +++ b/test/libs/sites_test.ts @@ -1,6 +1,6 @@ import { assertEquals } from "@std/assert"; import { transcodeXmlUrl } from "../../src/libs/sites.ts"; -import type { Feed } from "../../src/types/mod.ts"; +import type { Feed } from "@5ouma/opml-generator/types"; Deno.test("Get XML URL", async (t: Deno.TestContext) => { await t.step("site", () => {