Skip to content

Commit

Permalink
refactor(import-map): Use local import map (#87)
Browse files Browse the repository at this point in the history
For readability and writability.
  • Loading branch information
5ouma committed Jun 18, 2024
1 parent 0c122c0 commit c4bb64c
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]",
"@std/assert": "jsr:@std/[email protected]",
"@std/cli": "jsr:@std/[email protected]",
Expand Down
7 changes: 6 additions & 1 deletion src/libs/convert.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/io.ts
Original file line number Diff line number Diff line change
@@ -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<Lists> {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/sites.ts
Original file line number Diff line number Diff line change
@@ -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") },
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
2 changes: 2 additions & 0 deletions src/types/feed.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export type Lists = {
lists: List[];
};

export type List = {
name: string;
feeds: Feed[];
};

export type Feed = {
title: string;
type?: string;
Expand Down
2 changes: 1 addition & 1 deletion test/libs/convert_test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
4 changes: 2 additions & 2 deletions test/libs/io_test.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion test/libs/sites_test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down

0 comments on commit c4bb64c

Please sign in to comment.