From ace03af4f411ecd0d05323915d6df2f49e97f099 Mon Sep 17 00:00:00 2001 From: Sam Huynh Date: Sun, 14 Apr 2024 08:51:33 +1000 Subject: [PATCH] refactor date utils (#237) * refactor: rename date-utils to utils/date * docs: update pnpm commands --- README.md | 16 ++++++++-------- bin/broadcast-reminder.ts | 2 +- scripts/delete-guild-commands.ts | 2 +- scripts/deploy-guild-commands.ts | 2 +- src/commands/referral/parseDate.ts | 2 +- src/commands/reminder/list.test.ts | 2 +- src/commands/reminder/remind-duration.test.ts | 2 +- src/commands/reminder/remind-on-date.test.ts | 2 +- src/commands/reminder/remind-on-date.ts | 2 +- src/commands/reminder/update.test.ts | 2 +- src/commands/reminder/update.ts | 2 +- src/utils/{date-utils.ts => date.ts} | 0 12 files changed, 18 insertions(+), 18 deletions(-) rename src/utils/{date-utils.ts => date.ts} (100%) diff --git a/README.md b/README.md index b10aeb4a..345d35bb 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,9 @@ Run these commands at the root of the project docker compose up -d db pnpm install -pnpm prisma:gen -pnpm deploy:command -pnpm start +pnpm run prisma:gen +pnpm run deploy:command +pnpm run start ``` --- @@ -133,8 +133,8 @@ pnpm start ### DB migration & Client Generation ```bash -pnpm prisma:migrate -pnpm prisma:gen +pnpm run prisma:migrate +pnpm run prisma:gen ``` ### DB GUI @@ -158,7 +158,7 @@ export const commandList: Command[] = [yourCommand]; - Run the `deploy:command` command. ```bash -pnpm deploy:command +pnpm run deploy:command ``` - **IMPORTANT:** You should only deploy your commands **ONCE ONLY** after @@ -182,8 +182,8 @@ pnpm deploy:command ### Running lints and tests ```bash -pnpm format -pnpm test +pnpm run format +pnpm run test ``` --- diff --git a/bin/broadcast-reminder.ts b/bin/broadcast-reminder.ts index e0b852a8..94ebc122 100644 --- a/bin/broadcast-reminder.ts +++ b/bin/broadcast-reminder.ts @@ -3,7 +3,7 @@ import { Result } from 'oxide.ts'; import { getDiscordClient } from '../src/clients'; import { formatReminderMessage, getReminderByTime, removeReminders } from '../src/commands/reminder/utils'; import { getReminderChannel } from '../src/commands/serverSettings/utils'; -import { getCurrentUnixTime } from '../src/utils/date-utils'; +import { getCurrentUnixTime } from '../src/utils/date'; import { loadEnv } from '../src/utils/load-env'; import { logger } from '../src/utils/logger'; diff --git a/scripts/delete-guild-commands.ts b/scripts/delete-guild-commands.ts index 33b2814e..0b8a8bc0 100644 --- a/scripts/delete-guild-commands.ts +++ b/scripts/delete-guild-commands.ts @@ -1,6 +1,6 @@ import { Result } from 'oxide.ts'; import { deployGuildCommands } from '../src/commands/deploy-command'; -import { getCurrentUnixTime } from '../src/utils/date-utils'; +import { getCurrentUnixTime } from '../src/utils/date'; import { loadEnv } from '../src/utils/load-env'; import { logger } from '../src/utils/logger'; diff --git a/scripts/deploy-guild-commands.ts b/scripts/deploy-guild-commands.ts index 6dc0ed5e..3ede43fd 100644 --- a/scripts/deploy-guild-commands.ts +++ b/scripts/deploy-guild-commands.ts @@ -1,7 +1,7 @@ import { Result } from 'oxide.ts'; import { commandList, contextMenuCommandList } from '../src/commands'; import { deployGuildCommands } from '../src/commands/deploy-command'; -import { getCurrentUnixTime } from '../src/utils/date-utils'; +import { getCurrentUnixTime } from '../src/utils/date'; import { loadEnv } from '../src/utils/load-env'; import { logger } from '../src/utils/logger'; diff --git a/src/commands/referral/parseDate.ts b/src/commands/referral/parseDate.ts index 8914af1f..d788a159 100644 --- a/src/commands/referral/parseDate.ts +++ b/src/commands/referral/parseDate.ts @@ -1,5 +1,5 @@ import { isAfter, isEqual, isValid, parse } from 'date-fns'; -import { DAY_MONTH_YEAR_FORMAT } from '../../utils/date-utils'; +import { DAY_MONTH_YEAR_FORMAT } from '../../utils/date'; type ParseInvalidDateError = ['INVALID_DATE']; type ParseExpiredDateError = ['EXPIRED_DATE']; diff --git a/src/commands/reminder/list.test.ts b/src/commands/reminder/list.test.ts index 448cf5e4..c318e2ec 100644 --- a/src/commands/reminder/list.test.ts +++ b/src/commands/reminder/list.test.ts @@ -2,7 +2,7 @@ import { getYear } from 'date-fns'; import type { ChatInputCommandInteraction } from 'discord.js'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { mockDeep, mockReset } from 'vitest-mock-extended'; -import { convertDateToEpoch } from '../../utils/date-utils'; +import { convertDateToEpoch } from '../../utils/date'; import { execute } from './list'; import { getUserReminders } from './utils'; diff --git a/src/commands/reminder/remind-duration.test.ts b/src/commands/reminder/remind-duration.test.ts index 75bb0ee9..cfc39edb 100644 --- a/src/commands/reminder/remind-duration.test.ts +++ b/src/commands/reminder/remind-duration.test.ts @@ -2,7 +2,7 @@ import { addSeconds, getUnixTime, parse } from 'date-fns'; import type { ChatInputCommandInteraction } from 'discord.js'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { mockDeep, mockReset } from 'vitest-mock-extended'; -import { DAY_MONTH_YEAR_HOUR_MINUTE_FORMAT } from '../../utils/date-utils'; +import { DAY_MONTH_YEAR_HOUR_MINUTE_FORMAT } from '../../utils/date'; import { execute } from './remind-duration'; import { saveReminder } from './utils'; diff --git a/src/commands/reminder/remind-on-date.test.ts b/src/commands/reminder/remind-on-date.test.ts index dcfa6425..f6797916 100644 --- a/src/commands/reminder/remind-on-date.test.ts +++ b/src/commands/reminder/remind-on-date.test.ts @@ -2,7 +2,7 @@ import { getYear } from 'date-fns'; import type { ChatInputCommandInteraction } from 'discord.js'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { mockDeep, mockReset } from 'vitest-mock-extended'; -import { convertDateToEpoch } from '../../utils/date-utils'; +import { convertDateToEpoch } from '../../utils/date'; import { execute } from './remind-on-date'; import { saveReminder } from './utils'; diff --git a/src/commands/reminder/remind-on-date.ts b/src/commands/reminder/remind-on-date.ts index c4f4c3e1..db96f5b9 100644 --- a/src/commands/reminder/remind-on-date.ts +++ b/src/commands/reminder/remind-on-date.ts @@ -1,6 +1,6 @@ import { SlashCommandSubcommandBuilder } from 'discord.js'; import { Result } from 'oxide.ts'; -import { convertDateToEpoch } from '../../utils/date-utils'; +import { convertDateToEpoch } from '../../utils/date'; import type { CommandHandler, Subcommand } from '../builder'; import { saveReminder } from './utils'; diff --git a/src/commands/reminder/update.test.ts b/src/commands/reminder/update.test.ts index f85ba383..3109521c 100644 --- a/src/commands/reminder/update.test.ts +++ b/src/commands/reminder/update.test.ts @@ -2,7 +2,7 @@ import { getYear } from 'date-fns'; import type { ChatInputCommandInteraction } from 'discord.js'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { mockDeep, mockReset } from 'vitest-mock-extended'; -import { convertDateToEpoch } from '../../utils/date-utils'; +import { convertDateToEpoch } from '../../utils/date'; import { execute } from './update'; import { updateReminder } from './utils'; diff --git a/src/commands/reminder/update.ts b/src/commands/reminder/update.ts index 006c2a7f..cd6d343a 100644 --- a/src/commands/reminder/update.ts +++ b/src/commands/reminder/update.ts @@ -1,6 +1,6 @@ import { SlashCommandSubcommandBuilder } from 'discord.js'; import { Result } from 'oxide.ts'; -import { convertDateToEpoch } from '../../utils/date-utils'; +import { convertDateToEpoch } from '../../utils/date'; import type { CommandHandler, Subcommand } from '../builder'; import { updateReminder } from './utils'; diff --git a/src/utils/date-utils.ts b/src/utils/date.ts similarity index 100% rename from src/utils/date-utils.ts rename to src/utils/date.ts