feat: show lilybird versions in version cmd, use bun glob

This commit is contained in:
Jozef Steinhübl 2023-12-30 17:03:28 +01:00
parent 16c842808d
commit a787a65bd9
No known key found for this signature in database
GPG key ID: E944BC293F5FF7E7
4 changed files with 23 additions and 4 deletions

View file

@ -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}](<https://github.com/xHyroM/bun-discord-bot/tree/${COMMIT_HASH}>) ${
!PRODUCTION ? "(dev)" : ""
}`,
`[v${Bun.version} (${Bun.revision})](<https://github.com/oven-sh/bun/releases/tag/bun-v${Bun.version}>)`,
`[Bun v${Bun.version} (${Bun.revision})](<https://github.com/oven-sh/bun/releases/tag/bun-v${Bun.version}>)`,
"",
`[Lilybird v${LILYBIRD_VERSION}](<https://npmjs.org/lilybird>)`,
`[Lilybird JSX v${LILYBIRD_JSX_VERSION}](<https://npmjs.org/@lilybird/jsx>)`,
`[Lilybird Handlers v${LILYBIRD_HANDLERS_VERSION}](<https://npmjs.org/@lilybird/handlers>)`,
].join("\n"),
ephemeral: true,
});

View file

@ -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";

View file

@ -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<GuildTextChannel>;
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[] = [];

View file

@ -11,6 +11,7 @@
"allowSyntheticDefaultImports": true,
"noEmit": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"types": ["bun-types", "./globals"]
},
"include": ["src/**/*"]