Skip to content

Commit 1e69b3c

Browse files
committed
Restructure project as monorepo with workspace support
- Move main package to packages/botkit/ - Reorganize examples with individual deno.json configs - Convert root deno.json to workspace configuration - Update pnpm workspace and dependency management - Add shared catalogs for common dependencies - Adjust version check script paths
1 parent e95bf3e commit 1e69b3c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+249
-203
lines changed

.github/workflows/main.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
token: ${{ secrets.CODECOV_TOKEN }}
4141
files: coverage.lcov
4242
- run: pnpm install
43-
- run: pnpm test
43+
- run: pnpm run -r test
4444
- run: deno task check
4545

4646
publish:
@@ -68,14 +68,14 @@ jobs:
6868
--arg build "$GITHUB_RUN_NUMBER" \
6969
--arg commit "${GITHUB_SHA::8}" \
7070
'.version = .version + "-dev." + $build + "+" + $commit' \
71-
deno.json > deno.json.tmp
72-
mv deno.json.tmp deno.json
71+
packages/botkit/deno.json > deno.json.tmp
72+
mv deno.json.tmp packages/botkit/deno.json
7373
jq \
7474
--arg build "$GITHUB_RUN_NUMBER" \
7575
--arg commit "${GITHUB_SHA::8}" \
7676
'.version = .version + "-dev." + $build + "+" + $commit' \
77-
package.json > package.json.tmp
78-
mv package.json.tmp package.json
77+
packages/botkit/package.json > package.json.tmp
78+
mv package.json.tmp packages/botkit/package.json
7979
- if: github.ref_type == 'tag'
8080
run: |
8181
set -euo pipefail

README.md

Lines changed: 0 additions & 73 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages/botkit/README.md

deno.json

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,34 @@
11
{
2-
"name": "@fedify/botkit",
3-
"version": "0.3.0",
4-
"license": "AGPL-3.0-only",
2+
"workspace": [
3+
"packages/*",
4+
"examples/*"
5+
],
56
"unstable": [
67
"kv",
78
"temporal"
89
],
9-
"exports": {
10-
".": "./src/mod.ts",
11-
"./bot": "./src/bot.ts",
12-
"./emoji": "./src/emoji.ts",
13-
"./events": "./src/events.ts",
14-
"./follow": "./src/follow.ts",
15-
"./message": "./src/message.ts",
16-
"./poll": "./src/poll.ts",
17-
"./reaction": "./src/reaction.ts",
18-
"./repository": "./src/repository.ts",
19-
"./session": "./src/session.ts",
20-
"./text": "./src/text.ts"
21-
},
2210
"imports": {
2311
"@fedify/fedify": "jsr:@fedify/fedify@1.8.1-dev.1262+8e4bd2e7",
24-
"@fedify/markdown-it-hashtag": "jsr:@fedify/markdown-it-hashtag@^0.3.0",
25-
"@fedify/markdown-it-mention": "jsr:@fedify/markdown-it-mention@^0.3.0",
26-
"@logtape/logtape": "jsr:@logtape/logtape@^1.0.0",
27-
"@phensley/language-tag": "npm:@phensley/language-tag@^1.12.2",
2812
"hono": "jsr:@hono/hono@^4.8.2",
29-
"html-entities": "npm:html-entities@^2.6.0",
30-
"markdown-it": "npm:markdown-it@^14.1.0",
31-
"mime-db": "npm:mime-db@^1.54.0",
32-
"tsdown": "npm:tsdown@^0.12.8",
33-
"uuid": "npm:uuid@^11.1.0",
34-
"x-forwarded-fetch": "jsr:@hongminhee/x-forwarded-fetch@^0.2.0",
35-
"xss": "npm:xss@^1.0.15"
13+
"x-forwarded-fetch": "jsr:@hongminhee/x-forwarded-fetch@^0.2.0"
3614
},
3715
"nodeModulesDir": "none",
3816
"exclude": [
3917
".github",
40-
".vscode",
41-
"dist",
4218
"docs",
43-
"junit.xml",
44-
"src/css"
19+
"dist"
4520
],
4621
"fmt": {
4722
"exclude": [
4823
"*.md",
4924
"*.yaml",
50-
"*.yml",
51-
"src/static/*.ts"
25+
"*.yml"
5226
]
5327
},
5428
"tasks": {
55-
"check": "deno check src/ && deno lint && deno fmt --check && deno publish --dry-run --allow-dirty && deno run scripts/check_versions.ts",
29+
"check": "deno check && deno lint && deno fmt --check && deno publish --dry-run --allow-dirty && deno run scripts/check_versions.ts",
5630
"test": "deno test --allow-env=NODE_V8_COVERAGE,JEST_WORKER_ID --allow-net=hollo.social --parallel",
57-
"test:node": "pnpm install && pnpm test",
31+
"test:node": "pnpm install && pnpm run -r test",
5832
"test-all": {
5933
"dependencies": [
6034
"check",

deno.lock

Lines changed: 34 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/greet/deno.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"tasks": {
3+
"dev": "deno serve --allow-net --allow-env --watch greet.ts",
4+
"prod": "deno serve --allow-net --allow-env greet.ts"
5+
}
6+
}
File renamed without changes.

examples/otp/deno.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"tasks": {
3+
"dev": "deno serve --allow-net --allow-env --watch otp.tsx",
4+
"prod": "deno serve --allow-net --allow-env otp.tsx"
5+
}
6+
}
File renamed without changes.

packages/botkit/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<img src="./logo.svg" alt="BotKit by Fedify" width="203" height="165">
2+
3+
[BotKit] by Fedify
4+
==================
5+
6+
[![JSR][JSR badge]][JSR]
7+
[![npm][npm badge]][npm]
8+
[![GitHub Actions][GitHub Actions badge]][GitHub Actions]
9+
[![Codecov][Codecov badge]][Codecov]
10+
[![Fediverse][Fediverse badge]][Fediverse]
11+
12+
[BotKit] is a framework for creating [ActivityPub] bots. It is powered by
13+
[Fedify], a lower-level library for creating ActivityPub server applications.
14+
Unlike Mastodon bots, BotKit is designed to create a standalone ActivityPub bot,
15+
which is a complete ActivityPub server in itself and not limited to Mastodon's
16+
capabilities (such as the 500-character limit per post).
17+
18+
BotKit's API is so simple and easy to use that you can create a complete bot in
19+
a single TypeScript file. Here's an example of a simple bot that just greets:
20+
21+
~~~~ typescript
22+
import { createBot, mention, text } from "@fedify/botkit";
23+
import { RedisKvStore } from "@fedify/redis";
24+
import { Redis } from "ioredis";
25+
26+
// Create a bot instance:
27+
const bot = createBot<void>({
28+
// The bot will have fediverse handle "@greetbot@mydomain":
29+
username: "greetbot",
30+
// Set the display name:
31+
name: "Greet Bot",
32+
// Set the profile icon (avatar):
33+
icon: new URL("https://mydomain/icon.png"),
34+
// Set the bio:
35+
summary: text`Hi, there! I'm a simple fediverse bot created by ${
36+
mention("@hongminhee@hollo.social")}.`,
37+
// Use Redis as a key-value store:
38+
kv: new RedisKvStore(new Redis()),
39+
// Use Redis as a message queue:
40+
queue: new RedisMessageQueue(() => new Redis()),
41+
});
42+
43+
// A bot can respond to a mention:
44+
bot.onMention = async (session, message) => {
45+
await message.reply(text`Hi, ${message.actor}!`);
46+
};
47+
48+
// Or, a bot also can actively publish a post:
49+
const session = bot.getSession("https://mydomain/");
50+
setInterval(async () => {
51+
await session.publish(text`Hi, folks! It's an hourly greeting.`);
52+
}, 1000 * 60 * 60);
53+
54+
export default bot;
55+
~~~~
56+
57+
For more information, see the [BotKit docs][BotKit].
58+
59+
[BotKit]: https://botkit.fedify.dev/
60+
[JSR]: https://jsr.io/@fedify/botkit
61+
[JSR badge]: https://jsr.io/badges/@fedify/botkit
62+
[npm]: https://www.npmjs.com/package/@fedify/botkit
63+
[npm badge]: https://img.shields.io/npm/v/@fedify/botkit?logo=npm
64+
[GitHub Actions]: https://github.com/fedify-dev/botkit/actions/workflows/main.yaml
65+
[GitHub Actions badge]: https://github.com/fedify-dev/botkit/actions/workflows/main.yaml/badge.svg
66+
[Codecov]: https://codecov.io/gh/fedify-dev/botkit
67+
[Codecov badge]: https://codecov.io/gh/fedify-dev/botkit/graph/badge.svg?token=1KVVER1626
68+
[Fediverse]: https://hollo.social/@botkit
69+
[Fediverse badge]: https://fedi-badge.deno.dev/@botkit@hollo.social/followers.svg
70+
[ActivityPub]: https://activitypub.rocks/
71+
[Fedify]: https://fedify.dev/
72+
73+
<!-- cSpell: ignore greetbot mydomain -->

0 commit comments

Comments
 (0)