From a787a65bd9b6d89781f3b76309773b7488ced2fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl=20=28xHyroM=29?= Date: Sat, 30 Dec 2023 17:03:28 +0100 Subject: [PATCH] feat: show lilybird versions in version cmd, use bun glob --- src/commands/version.tsx | 14 ++++++++++++-- src/constants.ts | 6 ++++++ src/loaders/tags.ts | 6 ++++-- tsconfig.json | 1 + 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/commands/version.tsx b/src/commands/version.tsx index 115c902..2a79a43 100644 --- a/src/commands/version.tsx +++ b/src/commands/version.tsx @@ -1,4 +1,10 @@ -import { COMMIT_HASH, PRODUCTION } from "../constants.ts"; +import { + COMMIT_HASH, + PRODUCTION, + LILYBIRD_VERSION, + LILYBIRD_HANDLERS_VERSION, + LILYBIRD_JSX_VERSION, +} from "../constants.ts"; import { ApplicationCommand } from "@lilybird/jsx"; import { SlashCommand } from "@lilybird/handlers"; @@ -11,7 +17,11 @@ export default { `[git-bun-discord-bot-${COMMIT_HASH}]() ${ !PRODUCTION ? "(dev)" : "" }`, - `[v${Bun.version} (${Bun.revision})]()`, + `[Bun v${Bun.version} (${Bun.revision})]()`, + "", + `[Lilybird v${LILYBIRD_VERSION}]()`, + `[Lilybird JSX v${LILYBIRD_JSX_VERSION}]()`, + `[Lilybird Handlers v${LILYBIRD_HANDLERS_VERSION}]()`, ].join("\n"), ephemeral: true, }); diff --git a/src/constants.ts b/src/constants.ts index fdcd80a..d26a970 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,7 +1,13 @@ import { spawnSync } from "bun"; +import { dependencies } from "../package.json"; export const COMMIT_HASH = spawnSync({ cmd: ["git", "log", "--pretty=format:%h", "-n", "1"], }).stdout.toString(); +export const LILYBIRD_VERSION = dependencies.lilybird.slice(1); +export const LILYBIRD_JSX_VERSION = dependencies["@lilybird/jsx"].slice(1); +export const LILYBIRD_HANDLERS_VERSION = + dependencies["@lilybird/handlers"].slice(1); + export const PRODUCTION = process.env.NODE_ENV === "production"; diff --git a/src/loaders/tags.ts b/src/loaders/tags.ts index a7fca2d..d08abc6 100644 --- a/src/loaders/tags.ts +++ b/src/loaders/tags.ts @@ -3,16 +3,18 @@ import { GuildTextChannel, ApplicationCommandOptionChoiceStructure, } from "lilybird"; -import { globSync as glob } from "glob"; import { Tag } from "../structs/Tag.ts"; import { readFileSync } from "node:fs"; import { safeSlice } from "../util.ts"; import matter from "gray-matter"; import { join } from "node:path"; +import { Glob } from "bun"; type PartialGuildTextChannel = PartialChannel; -const tags = glob(join(import.meta.dir, "..", "..", "data", "tags", "*.md")); +const tags = Array.from( + new Glob(join(import.meta.dir, "..", "..", "data", "tags", "*.md")).scanSync() +); export const TAGS: Tag[] = []; diff --git a/tsconfig.json b/tsconfig.json index 9d7c1cd..c06423d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "allowSyntheticDefaultImports": true, "noEmit": true, "skipLibCheck": true, + "resolveJsonModule": true, "types": ["bun-types", "./globals"] }, "include": ["src/**/*"]