Skip to content

Commit

Permalink
Release v0.3.2 (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
5ouma committed Jun 12, 2024
2 parents bcebd7c + e5ccc4a commit f48e632
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ flowchart LR
end
feature1 & feature2 & feature3 -- Squash Merge --> dev
dev -- Rebase Merge --> main
dev -- Merge --> main
```

<br />
Expand Down
57 changes: 36 additions & 21 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[![Test](https://img.shields.io/github/actions/workflow/status/5ouma/opml-generator/test.yml?label=test&style=flat-square)](https://github.com/5ouma/opml-generator/actions/workflows/test.yml)
[![Gist Update](https://img.shields.io/github/actions/workflow/status/5ouma/opml-generator/gist-update.yml?label=Gist%20Update&style=flat-square)](https://github.com/5ouma/opml-generator/actions/workflows/gist-update.yml)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/5ouma/opml-generator/main.svg?style=flat-square)](https://results.pre-commit.ci/latest/github/5ouma/opml-generator/main)
[![codecov](https://codecov.io/github/5ouma/opml-generator/graph/badge.svg?token=ICJ7C3IDX7)](https://codecov.io/github/5ouma/opml-generator)

</div>

Expand All @@ -22,34 +23,48 @@

OPML Generator has 2 ways to convert TOML to OPML.

1. ### 💻 On Local
### 💻 On Local

1. 📰 Prepare your TOML file (Reference: [feeds.toml](./assets/example/feeds.toml)).
1. Prepare your TOML file (Reference: [feeds.toml](./assets/example/feeds.toml))

2. 🦕 Run Deno Task
2. Clone this repository

```shell
deno task gen
```
```sh
git clone https://github.com/5ouma/opml-generator.git
```

3. 🗞️ Outputs are stored in the `outputs` directory separated by `lists`.
3. Run Deno Task

2. ### 🐙 On GitHub Actions
```shell
deno task gen
```

1. 🗒️ Create [a Gist](https://gist.github.com):
- includes [`feeds.toml`](./assets/example/feeds.toml).
- for outputs.
2. 🔑 Create [a Personal Access Token] with the `Gist` permission.
3. 🍴 [Fork this repository](https://github.com/5ouma/opml-generator/fork)
4. 🔏 Add Actions secrets
from `Settings > Secrets and variables | Actions` in the sidebar:
- `TOML_GIST_ID`: Gist ID for [`feeds.toml`](./assets/example/feeds.toml)
- `OPML_GIST_ID`: Gist ID for outputs
- `TOKEN`: Personal Access Token
5. ✅ Enable GitHub Actions by checking `Allow all actions and reusable workflows`
from `Settings > Actions | General` in the sidebar.
4. Outputs are stored in the `outputs` directory separated by `lists`

🎉 Automatically update every 0 a.m. UTC
<br />

### 🐙 On GitHub Actions

1. Create [a Gist](https://gist.github.com):

- includes [`feeds.toml`](./assets/example/feeds.toml)
- for outputs

2. Create [a Personal Access Token] with the `Gist` permission

3. [Fork this repository](https://github.com/5ouma/opml-generator/fork)

4. Add Actions secrets
from `Settings > Secrets and variables | Actions` in the sidebar:

- `TOML_GIST_ID`: Gist ID for [`feeds.toml`](./assets/example/feeds.toml)
- `OPML_GIST_ID`: Gist ID for outputs
- `TOKEN`: Personal Access Token

5. Enable GitHub Actions by checking `Allow all actions and reusable workflows`
from `Settings > Actions | General` in the sidebar

🎉 Automatically update every 0 a.m. UTC

[a Personal Access Token]: https://github.com/settings/tokens

Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ on:
- dev
paths:
- "**.ts"
- "./deno.lock"
- "deno.lock"
- ".github/workflows/test.yml"
pull_request:
paths:
- "**.ts"
- "./deno.lock"
- "deno.lock"
- ".github/workflows/test.yml"

jobs:
Expand All @@ -28,5 +28,19 @@ jobs:
with:
deno-version: v1.x

- name: 🧪 Test Libraries
run: deno task test
- name: 🧪 Run Tests
run: deno task cov

- name: 🧹 Lint Check
run: deno lint

- name: 📝 Format Check
run: deno fmt --check

- name: 🔍 Type Check
run: deno check ./**/*.ts

- name: ☂️ Upload Coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/coverage
/coverage.lcov
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ repos:
args: [--whitespaces-count, "2"]

- repo: https://github.com/crate-ci/typos
rev: v1.21.0
rev: v1.22.0
hooks:
- id: typos

- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.2
rev: v8.18.3
hooks:
- id: gitleaks

- repo: https://github.com/rhysd/actionlint
rev: v1.7.0
rev: v1.7.1
hooks:
- id: actionlint

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.40.0
rev: v0.41.0
hooks:
- id: markdownlint-fix
args: ["--disable", "MD013", "MD023", "MD024", "MD033", "MD036"]
Expand Down
15 changes: 8 additions & 7 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"test": { "include": ["src/", "test/"] },
"tasks": {
"gen": "deno run --allow-read --allow-write ./src/main.ts",
"test": "deno test --allow-read --allow-write"
"test": "deno test --allow-read --allow-write --parallel --shuffle",
"cov": "deno task test --coverage && deno coverage --lcov > coverage.lcov"
},
"imports": {
"@libs/xml": "jsr:@libs/xml@^5.0.2",
"@std/assert": "jsr:@std/assert@^0.225.2",
"@std/cli": "jsr:@std/cli@^0.224.2",
"@std/path": "jsr:@std/path@^0.225.1",
"@std/toml": "jsr:@std/toml@^0.224.0",
"@wok/case": "jsr:@wok/case@^1.0.1"
"@libs/xml": "jsr:@libs/xml@5.4.7",
"@std/assert": "jsr:@std/assert@0.226.0",
"@std/cli": "jsr:@std/[email protected].6",
"@std/path": "jsr:@std/[email protected].2",
"@std/toml": "jsr:@std/[email protected].1",
"@wok/case": "jsr:@wok/[email protected]"
}
}
72 changes: 35 additions & 37 deletions deno.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,52 @@
"version": "3",
"packages": {
"specifiers": {
"jsr:@libs/typing@2": "jsr:@libs/[email protected]",
"jsr:@libs/xml@^5.0.2": "jsr:@libs/[email protected]",
"jsr:@std/assert@^0.225.2": "jsr:@std/[email protected]",
"jsr:@std/cli@^0.224.2": "jsr:@std/[email protected]",
"jsr:@std/collections@^0.224.0": "jsr:@std/[email protected]",
"jsr:@std/internal@^0.225.1": "jsr:@std/[email protected]",
"jsr:@std/path@^0.225.1": "jsr:@std/[email protected]",
"jsr:@std/toml@^0.224.0": "jsr:@std/[email protected]",
"jsr:@wok/case@^1.0.1": "jsr:@wok/[email protected]"
"jsr:@libs/typing@2": "jsr:@libs/[email protected]",
"jsr:@libs/[email protected]": "jsr:@libs/[email protected]",
"jsr:@std/[email protected]": "jsr:@std/[email protected]",
"jsr:@std/assert@^0.226.0": "jsr:@std/[email protected]",
"jsr:@std/[email protected]": "jsr:@std/[email protected]",
"jsr:@std/collections@^1.0.0-rc.1": "jsr:@std/[email protected]",
"jsr:@std/internal@^1.0.0": "jsr:@std/[email protected]",
"jsr:@std/[email protected]": "jsr:@std/[email protected]",
"jsr:@std/[email protected]": "jsr:@std/[email protected]",
"jsr:@wok/[email protected]": "jsr:@wok/[email protected]"
},
"jsr": {
"@libs/typing@2.0.3": {
"integrity": "e2fb7b9f4a09ffbe322377e05a16dfd48e04249ed667e4c9c06ca166c48b379e"
"@libs/typing@2.1.1": {
"integrity": "964e61860716140671718b170d8de4a8705e05d86e7ed0c41883fe2687c91c80"
},
"@libs/xml@5.0.2": {
"integrity": "f17bb52752acb83eda027245695508de566ddad816a935a08c3d75df5aed0ff8",
"@libs/xml@5.4.7": {
"integrity": "6a5ccb4ae832cbb6947e8cb73eaf41eeb38dabbf68e041252055a2d5233afca7",
"dependencies": [
"jsr:@libs/typing@2"
]
},
"@std/assert@0.225.2": {
"integrity": "6fd566c3ea01654d29c2b633298b7fc7599716336233852eb87e9843658fa192",
"@std/assert@0.226.0": {
"integrity": "0dfb5f7c7723c18cec118e080fec76ce15b4c31154b15ad2bd74822603ef75b3",
"dependencies": [
"jsr:@std/internal@^0.225.1"
"jsr:@std/internal@^1.0.0"
]
},
"@std/[email protected]": {
"integrity": "be330ce49928db596338b411037b082d8f8f218b34f8095bcad382fb0c3d6b31",
"dependencies": [
"jsr:@std/assert@^0.225.2"
]
"@std/[email protected]": {
"integrity": "98d7e17a70c1c24980baa2b9a511b29e0a460e7a3b8e3d4e220979d77d5f348e"
},
"@std/collections@0.224.2": {
"integrity": "e77819455294e92d4e7ddad1dbfd46f94174c09318e541e6621fac4a4d0ab326"
"@std/collections@1.0.0-rc.1": {
"integrity": "e69fa667e4bede8f1013be9fb48915e564707a2b054848ca4a4da1f3f10251d9"
},
"@std/internal@0.225.1": {
"integrity": "7d8a812be88c2792f15ab9cf46911e521ccca50435948a8f24df5cefda96bde9"
"@std/internal@1.0.0": {
"integrity": "ac6a6dfebf838582c4b4f61a6907374e27e05bedb6ce276e0f1608fe84e7cd9a"
},
"@std/[email protected].1": {
"integrity": "8c3220635a73730eb51fe43de9e10b79e2724a5bb8638b9355d35ae012fd9429",
"@std/[email protected].2": {
"integrity": "0f2db41d36b50ef048dcb0399aac720a5348638dd3cb5bf80685bf2a745aa506",
"dependencies": [
"jsr:@std/assert@^0.225.2"
"jsr:@std/assert@^0.226.0"
]
},
"@std/[email protected].0": {
"integrity": "15a60eb5eac12d8a81a48d99cb1aaed60a21c67dc94c2def696a7c39b815c74f",
"@std/[email protected].1": {
"integrity": "c364b9ca3b18207223c4e2a1f652ef2970ff80967f7575ddf89b6b0565a17148",
"dependencies": [
"jsr:@std/collections@^0.224.0"
"jsr:@std/collections@^1.0.0-rc.1"
]
},
"@wok/[email protected]": {
Expand All @@ -60,12 +58,12 @@
"remote": {},
"workspace": {
"dependencies": [
"jsr:@libs/xml@^5.0.2",
"jsr:@std/assert@^0.225.2",
"jsr:@std/cli@^0.224.2",
"jsr:@std/path@^0.225.1",
"jsr:@std/toml@^0.224.0",
"jsr:@wok/case@^1.0.1"
"jsr:@libs/xml@5.4.7",
"jsr:@std/assert@0.226.0",
"jsr:@std/[email protected].6",
"jsr:@std/[email protected].2",
"jsr:@std/[email protected].1",
"jsr:@wok/[email protected]"
]
}
}
3 changes: 2 additions & 1 deletion src/libs/convert.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { stringify } from "@libs/xml";
import { parse } from "@std/toml";
import { Feed, List, Lists, OPMLOutline } from "../types/mod.ts";
import type { Feed, List, Lists, OPMLOutline } from "../types/mod.ts";

export function convertToTOML(data: string): Lists {
const lists: Lists = parse(data) as Lists;
Expand All @@ -17,6 +17,7 @@ export function convertToOPML(list: List): string {
outline: list.feeds.map((feed: Feed): OPMLOutline => {
return {
"@title": feed.title,
"@text": feed.title,
"@xmlUrl": feed.xmlUrl,
"@type": "rss",
};
Expand Down
10 changes: 5 additions & 5 deletions src/libs/io.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { paramCase } from "@wok/case";
import { format } from "@std/path";
import { List, Lists } from "../types/mod.ts";
import { convertToOPML, convertToTOML } from "./mod.ts";
import { convertToOPML, convertToTOML } from "./convert.ts";
import type { List, Lists } from "../types/mod.ts";

export async function readTOML(file: string): Promise<Lists> {
try {
const data: string = await Deno.readTextFile(file);
return await convertToTOML(data);
return convertToTOML(data);
} catch (error) {
if (error instanceof Deno.errors.NotFound) {
throw Error(`File not found: "${file}"`);
throw new Error(`File not found: "${file}"`);
} else if (error instanceof Deno.errors.PermissionDenied) {
throw Error(`Permission denied: "${file}"`);
throw new Error(`Permission denied: "${file}"`);
} else throw error;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/libs/mod.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from "./io.ts";
export * from "./convert.ts";
2 changes: 1 addition & 1 deletion 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 { Lists } from "./types/mod.ts";
import type { Lists } from "./types/mod.ts";

const flags = parseArgs(Deno.args, {
string: ["feeds", "output"],
Expand Down
1 change: 1 addition & 0 deletions src/types/opml.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export type OPMLOutline = {
"@title": string;
"@text": string;
"@xmlUrl": URL;
"@type": "rss";
};
1 change: 1 addition & 0 deletions src/types/toml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export type List = {
};
export type Feed = {
title: string;
text: string;
xmlUrl: URL;
};
14 changes: 10 additions & 4 deletions test/libs/convert_test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { assertEquals } from "@std/assert";
import { convertToOPML, convertToTOML } from "../../src/libs/mod.ts";
import { List, Lists } from "../../src/types/mod.ts";
import { convertToOPML, convertToTOML } from "../../src/libs/convert.ts";
import type { List, Lists } from "../../src/types/mod.ts";

Deno.test("Parse TOML", () => {
const feeds: Lists = {
lists: [
{
name: "list name",
feeds: [
{ title: "feed title", xmlUrl: new URL("https://example.com/feed") },
{
title: "feed title",
text: "feed title",
xmlUrl: new URL("https://example.com/feed"),
},
],
},
],
Expand All @@ -20,6 +24,7 @@ name = "list name"
[[lists.feeds]]
title = "feed title"
text = "feed title"
xmlUrl = "https://example.com/feed"
`;

Expand All @@ -31,7 +36,7 @@ Deno.test("Convert Lists to OPML", () => {
<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0">
<body>
<outline title="feed title" xmlUrl="https://example.com/feed" type="rss"/>
<outline title="feed title" text="feed title" xmlUrl="https://example.com/feed" type="rss"/>
</body>
</opml>
`;
Expand All @@ -41,6 +46,7 @@ Deno.test("Convert Lists to OPML", () => {
feeds: [
{
title: "feed title",
text: "feed title",
xmlUrl: new URL("https://example.com/feed"),
},
],
Expand Down

0 comments on commit f48e632

Please sign in to comment.