Skip to content

Commit

Permalink
refactor: move entrypoint scripts into root level
Browse files Browse the repository at this point in the history
  • Loading branch information
samhwang committed Apr 13, 2024
1 parent 0938fca commit fbbd4b0
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ COPY --chown=node:node --from=build /app/build build

USER node
ENV NODE_ENV=production
CMD ["--enable-source-maps", "build/server/index.js"]
CMD ["--enable-source-maps", "build/server/main.js"]
8 changes: 4 additions & 4 deletions src/autobump.ts → bin/autobump.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ThreadChannel } from 'discord.js';
import { Result } from 'oxide.ts';
import { getDiscordClient } from './clients';
import { listAllThreads } from './commands/autobump-threads/util';
import { loadEnv } from './utils/load-env';
import { logger } from './utils/logger';
import { getDiscordClient } from '../src/clients';
import { listAllThreads } from '../src/commands/autobump-threads/util';
import { loadEnv } from '../src/utils/load-env';
import { logger } from '../src/utils/logger';

const autobump = async () => {
loadEnv();
Expand Down
12 changes: 6 additions & 6 deletions src/broadcast-reminder.ts → bin/broadcast-reminder.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ChannelType } from 'discord.js';
import { Result } from 'oxide.ts';
import { getDiscordClient } from './clients';
import { formatReminderMessage, getReminderByTime, removeReminders } from './commands/reminder/reminder-utils';
import { getReminderChannel } from './commands/serverSettings/server-utils';
import { getCurrentUnixTime } from './utils/date-utils';
import { loadEnv } from './utils/load-env';
import { logger } from './utils/logger';
import { getDiscordClient } from '../src/clients';
import { formatReminderMessage, getReminderByTime, removeReminders } from '../src/commands/reminder/reminder-utils';
import { getReminderChannel } from '../src/commands/serverSettings/server-utils';
import { getCurrentUnixTime } from '../src/utils/date-utils';
import { loadEnv } from '../src/utils/load-env';
import { logger } from '../src/utils/logger';

const broadcastReminder = async () => {
loadEnv();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Result } from 'oxide.ts';
import { cleanupExpiredCode } from './commands/referral/cleanupExpiredCode';
import { loadEnv } from './utils/load-env';
import { logger } from './utils/logger';
import { cleanupExpiredCode } from '../src/commands/referral/cleanupExpiredCode';
import { loadEnv } from '../src/utils/load-env';
import { logger } from '../src/utils/logger';

const cleanup = async () => {
loadEnv();
Expand Down
14 changes: 7 additions & 7 deletions src/index.ts → bin/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { InteractionType } from 'discord-api-types/v10';
import { Result } from 'oxide.ts';
import { getDiscordClient } from './clients';
import { commandList, contextMenuCommandList } from './commands';
import { deployGlobalCommands } from './commands/deploy-command';
import { getConfigs } from './config';
import { loadEnv } from './utils/load-env';
import { logger } from './utils/logger';
import { processMessage } from './utils/message-processor';
import { getDiscordClient } from '../src/clients';
import { commandList, contextMenuCommandList } from '../src/commands';
import { deployGlobalCommands } from '../src/commands/deploy-command';
import { getConfigs } from '../src/config';
import { loadEnv } from '../src/utils/load-env';
import { logger } from '../src/utils/logger';
import { processMessage } from '../src/utils/message-processor';

const main = async () => {
loadEnv();
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"files": {
"include": ["*.config.*", "*.setup.*", "src/**", "mocks/**", "**/*.json", "**/*.md", "**/*.yaml", "**/*.yml"],
"include": ["*.config.*", "*.setup.*", "bin/**", "src/**", "mocks/**", "**/*.json", "**/*.md", "**/*.yaml", "**/*.yml"],
"ignore": ["node_modules", "build", "coverage"]
},
"organizeImports": {
Expand Down
10 changes: 5 additions & 5 deletions esbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import pkg from './package.json';

const isProductionBuild = () => process.env.NODE_ENV === 'production';

const srcPath = path.resolve(__dirname, 'src');
const binPath = path.resolve(__dirname, 'bin');

const outputPath = path.resolve(__dirname, 'build');

Expand All @@ -32,10 +32,10 @@ async function build() {
bundle: true,
minify: false,
entryPoints: [
path.resolve(srcPath, 'index.ts'),
path.resolve(srcPath, 'broadcast-reminder.ts'),
path.resolve(srcPath, 'autobump.ts'),
path.resolve(srcPath, 'cleanup-expired-referrals.ts'),
path.resolve(binPath, 'main.ts'),
path.resolve(binPath, 'broadcast-reminder.ts'),
path.resolve(binPath, 'autobump.ts'),
path.resolve(binPath, 'cleanup-expired-referrals.ts'),
],
outdir: path.resolve(outputPath, 'server'),
sourcemap: isProductionBuild() ? 'both' : 'linked',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"deploy:command": "tsx src/scripts/deploy-guild-commands.ts",
"delete:command": "tsx src/scripts/delete-guild-commands.ts",
"delete:command-global": "tsx src/scripts/delete-global-commands.ts",
"start:only": "tsx watch --clear-screen=false ./src/index.ts",
"start:only": "tsx watch --clear-screen=false ./bin/main.ts",
"start": "pnpm prisma:migrate && pnpm prisma:gen && pnpm start:only",
"build:referrals": "tsx src/scripts/build-referral-list.ts"
},
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"outDir": "build",
"noEmit": true
},
"include": ["src", "mocks", "*.config.*", "*.setup.*"],
"include": ["bin", "src", "mocks", "*.config.*", "*.setup.*"],
"exclude": ["node_modules", "build"]
}

0 comments on commit fbbd4b0

Please sign in to comment.