refactor(cli): ♻️ Rewrite CLI with Clerk. Removes a bunch of commands now covered by API.

This commit is contained in:
Jesse Wierzbinski 2025-02-26 00:00:21 +01:00
parent 28577d017a
commit 5b756ea2dd
No known key found for this signature in database
32 changed files with 536 additions and 2721 deletions

24
cli/utils.ts Normal file
View file

@ -0,0 +1,24 @@
import { parseUserAddress } from "@/api";
import { and, eq, isNull } from "drizzle-orm";
import { Instance } from "~/classes/database/instance";
import { User } from "~/classes/database/user";
import { Users } from "~/drizzle/schema";
export const retrieveUser = async (
usernameOrHandle: string,
): Promise<User | null> => {
const { username, domain } = parseUserAddress(usernameOrHandle);
const instance = domain ? await Instance.resolveFromHost(domain) : null;
const user = await User.fromSql(
and(
eq(Users.username, username),
instance
? eq(Users.instanceId, instance.data.id)
: isNull(Users.instanceId),
),
);
return user;
};