Skip to content

Commit 787a3d4

Browse files
authored
Improve the build, remove unused dependencies (#103)
1 parent cc16c6d commit 787a3d4

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

+490
-4221
lines changed

.github/workflows/node.js.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Setup node
2424
uses: actions/setup-node@v4
2525
with:
26-
node-version: 20
26+
node-version: 22
2727

2828
- run: npm ci
2929

@@ -40,7 +40,7 @@ jobs:
4040
- name: Setup node
4141
uses: actions/setup-node@v4
4242
with:
43-
node-version: 20
43+
node-version: 22
4444

4545
- run: npm ci
4646

@@ -57,7 +57,7 @@ jobs:
5757
- name: Setup node
5858
uses: actions/setup-node@v4
5959
with:
60-
node-version: 20
60+
node-version: 22
6161

6262
- run: npm ci
6363

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v22.12.0

app/commands/convene.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import type {
99
} from "discord.js";
1010
import { ApplicationCommandType } from "discord-api-types/v10";
1111

12-
import { reacord } from "~/discord/client.server";
13-
import { quoteAndEscape } from "~/helpers/discord";
14-
import { ReportReasons, reportUser } from "~/helpers/modLog";
15-
import { resolutions } from "~/helpers/modResponse";
12+
import { reacord } from "#~/discord/client.server";
13+
import { quoteAndEscape } from "#~/helpers/discord";
14+
import { ReportReasons, reportUser } from "#~/helpers/modLog";
15+
import { resolutions } from "#~/helpers/modResponse";
1616

17-
import { fetchSettings, SETTINGS } from "~/models/guilds.server";
18-
import { applyRestriction, ban, kick, timeout } from "~/models/discord.server";
19-
import { ModResponse } from "~/commands/reacord/ModResponse";
17+
import { fetchSettings, SETTINGS } from "#~/models/guilds.server";
18+
import { applyRestriction, ban, kick, timeout } from "#~/models/discord.server";
19+
import { ModResponse } from "#~/commands/reacord/ModResponse";
2020

2121
export const command = new ContextMenuCommandBuilder()
2222
.setName("Convene mods")

app/commands/reacord/ModResponse.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { ComponentEventUser } from "reacord";
22
import { Button } from "reacord";
33

4-
import type { Resolution } from "~/helpers/modResponse";
4+
import type { Resolution } from "#~/helpers/modResponse";
55
import {
66
humanReadableResolutions,
77
resolutions,
88
useVotes,
9-
} from "~/helpers/modResponse";
9+
} from "#~/helpers/modResponse";
1010

1111
const VOTES_TO_APPROVE = 3;
1212

app/commands/report.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { MessageContextMenuCommandInteraction } from "discord.js";
22
import { PermissionFlagsBits, ContextMenuCommandBuilder } from "discord.js";
33
import { ApplicationCommandType } from "discord-api-types/v10";
4-
import { ReportReasons, reportUser } from "~/helpers/modLog";
4+
import { ReportReasons, reportUser } from "#~/helpers/modLog";
55

66
export const command = new ContextMenuCommandBuilder()
77
.setName("Report")

app/commands/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ChatInputCommandInteraction } from "discord.js";
22
import { PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
33

4-
import { SETTINGS, setSettings, registerGuild } from "~/models/guilds.server";
4+
import { SETTINGS, setSettings, registerGuild } from "#~/models/guilds.server";
55

66
export const command = new SlashCommandBuilder()
77
.setName("setup")

app/commands/setupTickets.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ import {
1515
import { REST } from "@discordjs/rest";
1616
import { Routes, TextInputStyle } from "discord-api-types/v10";
1717

18-
import { discordToken } from "~/helpers/env.server";
19-
import { SETTINGS, fetchSettings } from "~/models/guilds.server";
18+
import { discordToken } from "#~/helpers/env.server";
19+
import { SETTINGS, fetchSettings } from "#~/models/guilds.server";
2020
import { format } from "date-fns";
2121
import type {
2222
AnyCommand,
2323
MessageComponentCommand,
2424
ModalCommand,
2525
SlashCommand,
26-
} from "~/helpers/discord";
27-
import { quoteMessageContent } from "~/helpers/discord";
26+
} from "#~/helpers/discord";
27+
import { quoteMessageContent } from "#~/helpers/discord";
2828

2929
const rest = new REST({ version: "10" }).setToken(discordToken);
3030

app/commands/track.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import type { MessageContextMenuCommandInteraction } from "discord.js";
22
import { PermissionFlagsBits, ContextMenuCommandBuilder } from "discord.js";
33
import { ApplicationCommandType } from "discord-api-types/v10";
44
import { Button } from "reacord";
5-
import { reacord } from "~/discord/client.server";
5+
import { reacord } from "#~/discord/client.server";
66

7-
import { ReportReasons, reportUser } from "~/helpers/modLog";
7+
import { ReportReasons, reportUser } from "#~/helpers/modLog";
88

99
export const command = new ContextMenuCommandBuilder()
1010
.setName("Track")

app/discord/activityTracker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Events, ChannelType } from "discord.js";
22
import type { Client, Message, PartialMessage, TextChannel } from "discord.js";
3-
import db from "~/db.server";
3+
import db from "#~/db.server";
44

55
export async function startActivityTracking(client: Client) {
66
const channelCache = new Map<string, TextChannel>();

app/discord/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { REST } from "discord.js";
2-
import { discordToken } from "~/helpers/env.server";
2+
import { discordToken } from "#~/helpers/env.server";
33

44
export const rest = new REST({ version: "10" }).setToken(discordToken);

app/discord/automod.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { isSpam } from "./automod";
22

3-
vi.mock("~/helpers/env.server");
3+
vi.mock("#~/helpers/env.server");
44

55
test("isSpam has a reasonable threshold", () => {
66
expect(isSpam("Hello @everyone")).toBe(true);

app/discord/automod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Client } from "discord.js";
22

3-
import { isStaff } from "~/helpers/discord";
4-
import { reportUser, ReportReasons } from "~/helpers/modLog";
3+
import { isStaff } from "#~/helpers/discord";
4+
import { reportUser, ReportReasons } from "#~/helpers/modLog";
55
import { client } from "./client.server";
66

77
const AUTO_SPAM_THRESHOLD = 3;

app/discord/client.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { GatewayIntentBits, Client, Partials, ActivityType } from "discord.js";
22
import { ReacordDiscordJs } from "reacord";
3-
import { discordToken } from "~/helpers/env.server";
3+
import { discordToken } from "#~/helpers/env.server";
44

55
export const client = new Client({
66
intents: [

app/discord/deployCommands.server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import type {
77
} from "discord.js";
88
import { InteractionType, Routes } from "discord.js";
99

10-
import { rest } from "~/discord/api";
11-
import type { AnyCommand } from "~/helpers/discord";
10+
import { rest } from "#~/discord/api";
11+
import type { AnyCommand } from "#~/helpers/discord";
1212
import {
1313
isMessageComponentCommand,
1414
isMessageContextCommand,
1515
isModalCommand,
1616
isSlashCommand,
1717
isUserContextCommand,
18-
} from "~/helpers/discord";
19-
import { applicationId, isProd } from "~/helpers/env.server";
20-
import { calculateChangedCommands } from "~/helpers/discordCommands";
18+
} from "#~/helpers/discord";
19+
import { applicationId, isProd } from "#~/helpers/env.server";
20+
import { calculateChangedCommands } from "#~/helpers/discordCommands";
2121

2222
/**
2323
* deployCommands notifies Discord of the latest commands to use and registers

app/discord/gateway.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import Sentry from "~/helpers/sentry.server";
1+
import Sentry from "#~/helpers/sentry.server";
22

3-
import { client, login } from "~/discord/client.server";
4-
import { deployCommands } from "~/discord/deployCommands.server";
3+
import { client, login } from "#~/discord/client.server";
4+
import { deployCommands } from "#~/discord/deployCommands.server";
55

6-
import automod from "~/discord/automod";
7-
import onboardGuild from "~/discord/onboardGuild";
8-
import { startActivityTracking } from "~/discord/activityTracker";
6+
import automod from "#~/discord/automod";
7+
import onboardGuild from "#~/discord/onboardGuild";
8+
import { startActivityTracking } from "#~/discord/activityTracker";
99

1010
export default function init() {
1111
login();

app/discord/onboardGuild.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Client, TextChannel } from "discord.js";
22
import { ChannelType } from "discord.js";
3-
import { retry } from "~/helpers/misc";
3+
import { retry } from "#~/helpers/misc";
44

5-
import { fetchGuild } from "~/models/guilds.server";
5+
import { fetchGuild } from "#~/models/guilds.server";
66

77
export default async (bot: Client) => {
88
// This is called any time the bot comes online, when a server becomes

app/helpers/__mocks__/env.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const isProd = () => false;
22

3-
export const databaseUrl = "DATABASE_URL";
3+
export const databaseUrl = undefined;
44
export const sessionSecret = "SESSION_SECRET";
55

66
export const applicationKey = "DISCORD_PUBLIC_KEY";

app/helpers/discordCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
} from "discord.js";
66
import { ApplicationCommandType } from "discord.js";
77

8-
import { difference } from "~/helpers/sets";
8+
import { difference } from "#~/helpers/sets";
99

1010
export const compareCommands = (
1111
localCommand: ContextMenuCommandBuilder | SlashCommandBuilder,

app/helpers/modLog.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import { MessageType, ChannelType } from "discord.js";
99
import { format, formatDistanceToNowStrict } from "date-fns";
1010
import TTLCache from "@isaacs/ttlcache";
1111

12-
import { fetchSettings, SETTINGS } from "~/models/guilds.server";
12+
import { fetchSettings, SETTINGS } from "#~/models/guilds.server";
1313
import {
1414
constructDiscordLink,
1515
describeAttachments,
1616
describeReactions,
1717
quoteAndEscape,
1818
quoteAndEscapePoll,
19-
} from "~/helpers/discord";
20-
import { simplifyString, truncateMessage } from "~/helpers/string";
19+
} from "#~/helpers/discord";
20+
import { simplifyString, truncateMessage } from "#~/helpers/string";
2121

2222
export const enum ReportReasons {
2323
anonReport = "anonReport",

app/models/activity.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { DB } from "~/db.server";
2-
import db from "~/db.server";
1+
import type { DB } from "#~/db.server";
2+
import db from "#~/db.server";
33

44
type MessageStats = DB["message_stats"];
55

app/models/discord.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { GuildMember } from "discord.js";
22
import type { AccessToken } from "simple-oauth2";
3-
import { fetchSettings, SETTINGS } from "~/models/guilds.server";
3+
import { fetchSettings, SETTINGS } from "#~/models/guilds.server";
44

55
export interface DiscordUserInfo {
66
id: string;

app/models/guilds.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Guild as DiscordGuild } from "discord.js";
2-
import db, { SqliteError } from "~/db.server";
3-
import type { DB } from "~/db.server";
2+
import db, { SqliteError } from "#~/db.server";
3+
import type { DB } from "#~/db.server";
44

55
export type Guild = DB["guilds"];
66

app/models/session.server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ import {
88
import { randomUUID } from "crypto";
99
import { AuthorizationCode } from "simple-oauth2";
1010

11-
import db from "~/db.server";
12-
import type { DB } from "~/db.server";
11+
import db from "#~/db.server";
12+
import type { DB } from "#~/db.server";
1313
import {
1414
createUser,
1515
getUserByExternalId,
1616
getUserById,
17-
} from "~/models/user.server";
18-
import { fetchUser } from "~/models/discord.server";
17+
} from "#~/models/user.server";
18+
import { fetchUser } from "#~/models/discord.server";
1919
import {
2020
applicationId,
2121
discordSecret,
2222
sessionSecret,
23-
} from "~/helpers/env.server";
23+
} from "#~/helpers/env.server";
2424

2525
export type Sessions = DB["sessions"];
2626

app/models/user.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { randomUUID } from "crypto";
22

3-
import type { DB } from "~/db.server";
4-
import db from "~/db.server";
3+
import type { DB } from "#~/db.server";
4+
import db from "#~/db.server";
55

66
export type User = DB["users"];
77

app/routes/__auth.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Outlet, useLoaderData, useLocation } from "react-router";
22

3-
import { Login } from "~/components/login";
4-
import { isProd } from "~/helpers/env.server";
5-
import { getUser } from "~/models/session.server";
6-
import { useOptionalUser } from "~/utils";
3+
import { Login } from "#~/components/login";
4+
import { isProd } from "#~/helpers/env.server";
5+
import { getUser } from "#~/models/session.server";
6+
import { useOptionalUser } from "#~/utils";
77

88
export async function loader({ request }: { request: Request }) {
99
return { user: await getUser(request), isProd: isProd() };

app/routes/__auth/dashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ActionFunction, LoaderFunction } from "react-router";
22
import { data, useLoaderData } from "react-router";
33
import type { LabelHTMLAttributes } from "react";
4-
import { getTopParticipants } from "~/models/activity.server";
4+
import { getTopParticipants } from "#~/models/activity.server";
55

66
export const loader = async ({
77
request,

app/routes/auth.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { ActionFunction, LoaderFunction } from "react-router";
22
import { redirect } from "react-router";
33

4-
import { initOauthLogin } from "~/models/session.server";
5-
import { Login } from "~/components/login";
4+
import { initOauthLogin } from "#~/models/session.server";
5+
import { Login } from "#~/components/login";
66

77
export const loader: LoaderFunction = async () => {
88
return redirect("/");

app/routes/discord-oauth.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { redirect, type LoaderFunction } from "react-router";
2-
import { completeOauthLogin } from "~/models/session.server";
2+
import { completeOauthLogin } from "#~/models/session.server";
33

44
export const loader: LoaderFunction = async ({ request }) => {
55
const url = new URL(request.url);

app/routes/healthcheck.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// learn more: https://fly.io/docs/reference/configuration/#services-http_checks
22
import type { LoaderFunction } from "react-router";
3-
import db from "~/db.server";
3+
import db from "#~/db.server";
44

55
export const loader: LoaderFunction = async ({ request }) => {
66
const host =

app/routes/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Login } from "~/components/login";
2-
import { Logout } from "~/components/logout";
1+
import { Login } from "#~/components/login";
2+
import { Logout } from "#~/components/logout";
33

4-
import { useOptionalUser } from "~/utils";
4+
import { useOptionalUser } from "#~/utils";
55

66
export default function Index() {
77
const user = useOptionalUser();

app/routes/logout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ActionFunction } from "react-router";
22

3-
import { logout } from "~/models/session.server";
3+
import { logout } from "#~/models/session.server";
44

55
export const action: ActionFunction = async ({ request }) => {
66
return await logout(request);

app/server.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import { createRequestHandler } from "@react-router/express";
44
import express from "express";
55
import bodyParser from "body-parser";
66

7-
import { applicationKey } from "~/helpers/env.server";
7+
import { applicationKey } from "#~/helpers/env.server";
88

9-
import discordBot from "~/discord/gateway";
10-
import { registerCommand } from "~/discord/deployCommands.server";
9+
import discordBot from "#~/discord/gateway";
10+
import { registerCommand } from "#~/discord/deployCommands.server";
1111

12-
import * as convene from "~/commands/convene";
13-
import * as setup from "~/commands/setup";
14-
import * as report from "~/commands/report";
15-
import * as track from "~/commands/track";
16-
import setupTicket from "~/commands/setupTickets";
12+
import * as convene from "#~/commands/convene";
13+
import * as setup from "#~/commands/setup";
14+
import * as report from "#~/commands/report";
15+
import * as track from "#~/commands/track";
16+
import setupTicket from "#~/commands/setupTickets";
1717

1818
export const app = express();
1919
app.use(

0 commit comments

Comments
 (0)