From 9eb9ac7a5d73e58e1776b5faabdbd979cf624f77 Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 16 May 2024 07:48:44 -0600 Subject: [PATCH] fix: fixes lost punctiation in display formatting (#270) fixes #266 --- package.json | 2 +- pnpm-lock.yaml | 16 ++++++++-------- src/commands/lookup/lookup.command-handler.ts | 4 ++-- src/commands/signup/signup-command.handler.ts | 6 +++--- .../send-signup-review-command.handler.ts | 6 +++--- src/sheets/sheets.service.ts | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index ca9ec17a..d3ee2da0 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "@sentry/cli": "^2.31.2", "@sentry/node": "^7.113.0", "@sentry/profiling-node": "^7.113.0", - "change-case": "^5.4.4", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", "dayjs": "^1.11.11", @@ -48,6 +47,7 @@ "pino-pretty": "^11.0.0", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1", + "title-case": "^4.3.1", "ts-pattern": "^5.1.1", "tslib": "^2.6.2" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c0c48607..b3fbbd46 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,9 +32,6 @@ importers: '@sentry/profiling-node': specifier: ^7.113.0 version: 7.113.0 - change-case: - specifier: ^5.4.4 - version: 5.4.4 class-transformer: specifier: ^0.5.1 version: 0.5.1 @@ -71,6 +68,9 @@ importers: rxjs: specifier: ^7.8.1 version: 7.8.1 + title-case: + specifier: ^4.3.1 + version: 4.3.1 ts-pattern: specifier: ^5.1.1 version: 5.1.1 @@ -1464,9 +1464,6 @@ packages: change-case@3.1.0: resolution: {integrity: sha512-2AZp7uJZbYEzRPsFoa+ijKdvp9zsrnnt6+yFokfwEpeJm0xuJDVoxiRCAaTzyJND8GJkofo2IcKWaUZ/OECVzw==} - change-case@5.4.4: - resolution: {integrity: sha512-HRQyTk2/YPEkt9TnUPbOpr64Uw3KOicFWPVBb+xiHvd6eBx/qPr9xqfBFDT8P2vWsvvz4jbEkfDe71W3VyNu2w==} - chardet@0.7.0: resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} @@ -3300,6 +3297,9 @@ packages: title-case@2.1.1: resolution: {integrity: sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==} + title-case@4.3.1: + resolution: {integrity: sha512-VnPxQ+/j0X2FZ4ceGq1oLruTLjtN5Ul4sam5ypd4mDZLm1eHwkwip1gLxqhON/j4qyTlUlfPKslE/t4NPSlxhg==} + tmp@0.0.33: resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} engines: {node: '>=0.6.0'} @@ -5045,8 +5045,6 @@ snapshots: upper-case: 1.1.3 upper-case-first: 1.1.2 - change-case@5.4.4: {} - chardet@0.7.0: {} check-error@1.0.3: @@ -7069,6 +7067,8 @@ snapshots: no-case: 2.3.2 upper-case: 1.1.3 + title-case@4.3.1: {} + tmp@0.0.33: dependencies: os-tmpdir: 1.0.2 diff --git a/src/commands/lookup/lookup.command-handler.ts b/src/commands/lookup/lookup.command-handler.ts index 0d423579..b0e0dafe 100644 --- a/src/commands/lookup/lookup.command-handler.ts +++ b/src/commands/lookup/lookup.command-handler.ts @@ -1,8 +1,8 @@ import { Logger } from '@nestjs/common'; import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; -import { capitalCase } from 'change-case'; import { plainToInstance } from 'class-transformer'; import { CommandInteractionOptionResolver, EmbedBuilder } from 'discord.js'; +import { titleCase } from 'title-case'; import { EncounterFriendlyDescription } from '../../encounters/encounters.consts.js'; import { SignupCollection } from '../../firebase/collections/signup.collection.js'; import { SignupDocument } from '../../firebase/models/signup.model.js'; @@ -32,7 +32,7 @@ class LookupCommandHandler implements ICommandHandler { ({ world, character, encounter, availability }) => [ { name: 'Character', - value: `${capitalCase(character)} @ ${capitalCase(world)}`, + value: `${titleCase(character)} @ ${titleCase(world)}`, inline: true, }, { diff --git a/src/commands/signup/signup-command.handler.ts b/src/commands/signup/signup-command.handler.ts index 491273a3..00ae7a0c 100644 --- a/src/commands/signup/signup-command.handler.ts +++ b/src/commands/signup/signup-command.handler.ts @@ -1,6 +1,5 @@ import { Logger } from '@nestjs/common'; import { CommandHandler, EventBus, ICommandHandler } from '@nestjs/cqrs'; -import { capitalCase } from 'change-case'; import { plainToInstance } from 'class-transformer'; import { ValidationError, validate } from 'class-validator'; import { @@ -12,6 +11,7 @@ import { DiscordjsErrorCodes, EmbedBuilder, } from 'discord.js'; +import { titleCase } from 'title-case'; import { P, match } from 'ts-pattern'; import { isSameUserFilter } from '../../common/collection-filters.js'; import { @@ -186,11 +186,11 @@ class SignupCommandHandler implements ICommandHandler { .addFields([ { name: 'Character', - value: capitalCase(character), + value: titleCase(character), inline: true, }, { name: '\u200B', value: '\u200B', inline: true }, - { name: 'Home World', value: capitalCase(world), inline: true }, + { name: 'Home World', value: titleCase(world), inline: true }, { name: 'Availability', value: availability, inline: true }, { name: '\u200B', value: '\u200B', inline: true }, { name: 'Role', value: role, inline: true }, diff --git a/src/commands/signup/subcommands/send-signup-review/send-signup-review-command.handler.ts b/src/commands/signup/subcommands/send-signup-review/send-signup-review-command.handler.ts index c09bfe29..f4ffcc08 100644 --- a/src/commands/signup/subcommands/send-signup-review/send-signup-review-command.handler.ts +++ b/src/commands/signup/subcommands/send-signup-review/send-signup-review-command.handler.ts @@ -1,7 +1,7 @@ import { Logger } from '@nestjs/common'; import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; -import { capitalCase } from 'change-case'; import { EmbedBuilder } from 'discord.js'; +import { titleCase } from 'title-case'; import { MissingChannelException } from '../../../../discord/discord.exceptions.js'; import { DiscordService } from '../../../../discord/discord.service.js'; import { EncounterFriendlyDescription } from '../../../../encounters/encounters.consts.js'; @@ -92,11 +92,11 @@ class SendSignupReviewCommandHandler }, { name: 'Character', - value: capitalCase(character), + value: titleCase(character), inline: true, }, { name: '\u200B', value: '\u200B', inline: true }, - { name: 'Home World', value: capitalCase(world), inline: true }, + { name: 'Home World', value: titleCase(world), inline: true }, { name: 'Availability', value: availability, inline: true }, { name: 'Job', value: role, inline: true }, { name: 'Prog Point', value: progPointRequested, inline: true }, diff --git a/src/sheets/sheets.service.ts b/src/sheets/sheets.service.ts index b79b45e6..f3af1705 100644 --- a/src/sheets/sheets.service.ts +++ b/src/sheets/sheets.service.ts @@ -2,7 +2,7 @@ import { sheets_v4 } from '@googleapis/sheets'; import { Inject, Injectable, Logger } from '@nestjs/common'; import { ConfigType } from '@nestjs/config'; import * as Sentry from '@sentry/node'; -import { capitalCase } from 'change-case'; +import { titleCase } from 'title-case'; import { AsyncQueue } from '../common/async-queue/async-queue.js'; import { PartyType, SignupDocument } from '../firebase/models/signup.model.js'; import { SignupCompositeKeyProps } from '../firebase/models/signup.model.js'; @@ -422,7 +422,7 @@ class SheetsService { role, progPoint = '', }: SignupDocument) { - return [capitalCase(character), capitalCase(world), role, progPoint]; + return [titleCase(character), titleCase(world), role, progPoint]; } }