Skip to content

Commit

Permalink
refactor: migrate to deno (#22)
Browse files Browse the repository at this point in the history
* refactor: migrate to deno

* ci: attempt fix

* remove more code

* ci: pass deno fmt

* refactor: dotenv, envalid & graphql_request

* make it 100% working with deno
  • Loading branch information
ArnabXD authored Sep 3, 2022
1 parent de83893 commit 2b18076
Show file tree
Hide file tree
Showing 48 changed files with 729 additions and 3,688 deletions.
19 changes: 0 additions & 19 deletions .eslintrc

This file was deleted.

File renamed without changes.
19 changes: 9 additions & 10 deletions README.md → .github/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
# AnimeDB-tgbot
# AnimeDB-tgbot

A [Telegram Bot](https://telegram.dog/animedb_bot) to Search Anime & Manga Details using [AniList](https://anilist.co) API
A [Telegram Bot](https://telegram.dog/animedb_bot) to Search Anime & Manga
Details using [AniList](https://anilist.co) API

[![CI](https://github.com/ArnabXD/AnimeDB-tgbot/actions/workflows/CI.yml/badge.svg)](https://github.com/ArnabXD/AnimeDB-tgbot/actions/workflows/CI.yml)

### Run Locally

```shell
git clone https://github.com/ArnabXD/AnimeDB-tgbot.git
cd AnimeDB-tgbot
pnpm install
pnpm run build
vim .env
pnpm run start
deno task start
```

#### .env File

```
BOT_TOKEN=YOUR BOT TOKEN FROM @BOTFATHER
# OPTIONAL FOR WEBHOOK
PORT=yourWebhookPort
```

### License & Copyright :

- This Project is [GNU General Public License v3.0](https://github.com/ArnabXD/AnimeDB-tgbot/blob/main/LICENSE) Licensed
- This Project is
[GNU General Public License v3.0](https://github.com/ArnabXD/AnimeDB-tgbot/blob/main/LICENSE)
Licensed
- Copyright 2021 by [ArnabXD](https://telegram.dog/Arnab431)
4 changes: 0 additions & 4 deletions .github/renovate.json

This file was deleted.

72 changes: 17 additions & 55 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,78 +12,40 @@ jobs:
if: "!contains(github.event.head_commit.message, '#skip-lint')"
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
- uses: denoland/setup-deno@v1
with:
version: 7.0.0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
cache: pnpm

- name: Install dependencies
run: pnpm install --no-frozen-lockfile
deno-version: vx.x.x
- name: Linter Check
run: deno lint

- name: Run Linter
run: pnpm run lint

test:
fmt:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '#skip-test')"
if: "!contains(github.event.head_commit.message, '#skip-fmt')"
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
with:
version: 7.0.0
- name: Setup Node
uses: actions/setup-node@v3
- uses: denoland/setup-deno@v1
with:
node-version: "16"
cache: pnpm

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Run Ava Tests
run: pnpm run test
deno-version: vx.x.x
- name: Formatter Check
run: deno fmt --check

build:
test:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '#skip-build')"
if: "!contains(github.event.head_commit.message, '#skip-test')"
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
- uses: denoland/setup-deno@v1
with:
version: 7.0.0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
cache: pnpm

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Build
run: pnpm run build
deno-version: vx.x.x
- name: Run Tests
run: deno test --allow-all

release:
runs-on: ubuntu-latest
needs: [ lint, build, test ]
needs: [ lint, fmt, test ]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
with:
version: 7.0.0
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: pnpm

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
build/
node_modules/
.env
6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"deno.enable": true,
"deno.lint": true,
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"prettier.enable": false,
"editor.formatOnSave": true
}
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

9 changes: 0 additions & 9 deletions ava.config.ts

This file was deleted.

7 changes: 7 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"importMap": "./import_map.json",
"tasks": {
"server": "deno run --allow-net --allow-read --allow-env server.ts",
"serverless": "deno run --allow-net --allow-read --allow-env serverless.ts"
}
}
8 changes: 8 additions & 0 deletions env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { config } from "dotenv";
import { cleanEnv, str } from "envalid";

await config({ export: true });

export default cleanEnv(Deno.env.toObject(), {
BOT_TOKEN: str(),
});
11 changes: 11 additions & 0 deletions import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"imports": {
"grammy": "https://deno.land/x/[email protected]/mod.ts",
"grammy/": "https://deno.land/x/[email protected]/",
"gql": "https://raw.githubusercontent.com/ArnabXD/graphql-request/temp/mod.ts",
"dotenv": "https://deno.land/[email protected]/dotenv/mod.ts",
"envalid": "https://deno.land/x/[email protected]/mod.ts",
"server": "https://deno.land/[email protected]/http/server.ts",
"testing/": "https://deno.land/[email protected]/testing/"
}
}
47 changes: 0 additions & 47 deletions package.json

This file was deleted.

Loading

0 comments on commit 2b18076

Please sign in to comment.