WIP: Migrate to yarn
Some checks failed
Test / build (push) Failing after 16s

This commit is contained in:
Ethan Lane 2024-06-27 18:31:59 +01:00
parent 16bc43c30e
commit 739bd0713d
7 changed files with 4720 additions and 8866 deletions

View file

@ -17,9 +17,9 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 18.x node-version: 18.x
- run: npm ci - run: yarn install --frozen-lockfile
- run: npm run build - run: yarn build
- run: npm test - run: yarn test
- name: "Copy files over to location" - name: "Copy files over to location"
run: cp -r . ${{ secrets.PROD_REPO_PATH }} run: cp -r . ${{ secrets.PROD_REPO_PATH }}
@ -63,5 +63,5 @@ jobs:
&& (pm2 delete vylbot_prod || true) \ && (pm2 delete vylbot_prod || true) \
&& docker compose up -d \ && docker compose up -d \
&& sleep 10 \ && sleep 10 \
&& npm run db:up \ && yarn db:up \
&& pm2 start --name vylbot_prod dist/vylbot.js && pm2 start --name vylbot_prod dist/vylbot.js

View file

@ -17,9 +17,9 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 18.x node-version: 18.x
- run: npm ci - run: yarn install --frozen-lockfile
- run: npm run build - run: yarn build
- run: npm test - run: yarn test
- name: "Copy files over to location" - name: "Copy files over to location"
run: cp -r . ${{ secrets.STAGE_REPO_PATH }} run: cp -r . ${{ secrets.STAGE_REPO_PATH }}
@ -63,5 +63,5 @@ jobs:
&& (pm2 delete vylbot_stage || true) \ && (pm2 delete vylbot_stage || true) \
&& docker compose up -d \ && docker compose up -d \
&& sleep 10 \ && sleep 10 \
&& npm run db:up \ && yarn db:up \
&& pm2 start --name vylbot_stage dist/vylbot.js && pm2 start --name vylbot_stage dist/vylbot.js

View file

@ -19,6 +19,6 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 18.x node-version: 18.x
- run: npm ci - run: yarn install --frozen-lockfile
- run: npm run build - run: yarn build
- run: npm test - run: yarn test

8826
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -92,7 +92,7 @@ export default class Audits extends Command {
private async SendAuditForUser(interaction: CommandInteraction) { private async SendAuditForUser(interaction: CommandInteraction) {
if (!interaction.guildId) return; if (!interaction.guildId) return;
const user = interaction.options.getUser('target'); const user = interaction.options.get('target', true).user!;
if (!user) { if (!user) {
await interaction.reply("User not found."); await interaction.reply("User not found.");
@ -190,7 +190,7 @@ export default class Audits extends Command {
private async AddAudit(interaction: CommandInteraction) { private async AddAudit(interaction: CommandInteraction) {
if (!interaction.guildId) return; if (!interaction.guildId) return;
const user = interaction.options.getUser('target'); const user = interaction.options.get('target', true).user!;
const auditType = interaction.options.get('type'); const auditType = interaction.options.get('type');
const reasonInput = interaction.options.get('reason'); const reasonInput = interaction.options.get('reason');

View file

@ -130,7 +130,9 @@ describe("user", () => {
isChatInputCommand: jest.fn().mockReturnValue(true), isChatInputCommand: jest.fn().mockReturnValue(true),
options: { options: {
getSubcommand: jest.fn().mockReturnValue("user"), getSubcommand: jest.fn().mockReturnValue("user"),
getUser: jest.fn().mockReturnValue(user), get: jest.fn().mockReturnValue({
user: user
}),
}, },
guildId: "guildId", guildId: "guildId",
reply: jest.fn().mockImplementation((options) => { reply: jest.fn().mockImplementation((options) => {
@ -150,8 +152,8 @@ describe("user", () => {
expect(AuditTools.TypeToFriendlyText).toHaveBeenCalledTimes(1); expect(AuditTools.TypeToFriendlyText).toHaveBeenCalledTimes(1);
expect(AuditTools.TypeToFriendlyText).toHaveBeenCalledWith(AuditType.Warn); expect(AuditTools.TypeToFriendlyText).toHaveBeenCalledWith(AuditType.Warn);
expect(interaction.options.getUser).toHaveBeenCalledTimes(1); expect(interaction.options.get).toHaveBeenCalledTimes(1);
expect(interaction.options.getUser).toHaveBeenCalledWith("target"); expect(interaction.options.get).toHaveBeenCalledWith("target", true);
expect(interaction.reply).toHaveBeenCalledTimes(1); expect(interaction.reply).toHaveBeenCalledTimes(1);
expect(repliedWith).toBeDefined(); expect(repliedWith).toBeDefined();
@ -193,7 +195,9 @@ describe("user", () => {
isChatInputCommand: jest.fn().mockReturnValue(true), isChatInputCommand: jest.fn().mockReturnValue(true),
options: { options: {
getSubcommand: jest.fn().mockReturnValue("user"), getSubcommand: jest.fn().mockReturnValue("user"),
getUser: jest.fn().mockReturnValue(null), get: jest.fn().mockReturnValue({
user: null
}),
}, },
guildId: "guildId", guildId: "guildId",
reply: jest.fn(), reply: jest.fn(),
@ -202,7 +206,7 @@ describe("user", () => {
const audits = new Audits(); const audits = new Audits();
await audits.execute(interaction); await audits.execute(interaction);
expect(interaction.options.getUser).toHaveBeenCalledTimes(1); expect(interaction.options.get).toHaveBeenCalledTimes(1);
expect(interaction.reply).toHaveBeenCalledTimes(1); expect(interaction.reply).toHaveBeenCalledTimes(1);
expect(interaction.reply).toHaveBeenCalledWith("User not found."); expect(interaction.reply).toHaveBeenCalledWith("User not found.");
@ -213,7 +217,9 @@ describe("user", () => {
isChatInputCommand: jest.fn().mockReturnValue(true), isChatInputCommand: jest.fn().mockReturnValue(true),
options: { options: {
getSubcommand: jest.fn().mockReturnValue("user"), getSubcommand: jest.fn().mockReturnValue("user"),
getUser: jest.fn().mockReturnValue({}), get: jest.fn().mockReturnValue({
user: {},
}),
}, },
guildId: "guildId", guildId: "guildId",
reply: jest.fn(), reply: jest.fn(),
@ -226,7 +232,7 @@ describe("user", () => {
expect(Audit.FetchAuditsByUserId).toHaveBeenCalledTimes(1); expect(Audit.FetchAuditsByUserId).toHaveBeenCalledTimes(1);
expect(interaction.options.getUser).toHaveBeenCalledTimes(1); expect(interaction.options.get).toHaveBeenCalledTimes(1);
expect(interaction.reply).toHaveBeenCalledTimes(1); expect(interaction.reply).toHaveBeenCalledTimes(1);
expect(interaction.reply).toHaveBeenCalledWith("There are no audits for this user."); expect(interaction.reply).toHaveBeenCalledWith("There are no audits for this user.");
@ -237,7 +243,9 @@ describe("user", () => {
isChatInputCommand: jest.fn().mockReturnValue(true), isChatInputCommand: jest.fn().mockReturnValue(true),
options: { options: {
getSubcommand: jest.fn().mockReturnValue("user"), getSubcommand: jest.fn().mockReturnValue("user"),
getUser: jest.fn().mockReturnValue({}), get: jest.fn().mockReturnValue({
user: {},
}),
}, },
guildId: "guildId", guildId: "guildId",
reply: jest.fn(), reply: jest.fn(),
@ -250,7 +258,7 @@ describe("user", () => {
expect(Audit.FetchAuditsByUserId).toHaveBeenCalledTimes(1); expect(Audit.FetchAuditsByUserId).toHaveBeenCalledTimes(1);
expect(interaction.options.getUser).toHaveBeenCalledTimes(1); expect(interaction.options.get).toHaveBeenCalledTimes(1);
expect(interaction.reply).toHaveBeenCalledTimes(1); expect(interaction.reply).toHaveBeenCalledTimes(1);
expect(interaction.reply).toHaveBeenCalledWith("There are no audits for this user."); expect(interaction.reply).toHaveBeenCalledWith("There are no audits for this user.");
@ -593,8 +601,9 @@ describe("add", () => {
isChatInputCommand: jest.fn().mockReturnValue(true), isChatInputCommand: jest.fn().mockReturnValue(true),
options: { options: {
getSubcommand: jest.fn().mockReturnValue("add"), getSubcommand: jest.fn().mockReturnValue("add"),
getUser: jest.fn().mockReturnValue(user), get: jest.fn()
get: jest.fn().mockReturnValueOnce(type) .mockReturnValueOnce({ user })
.mockReturnValueOnce(type)
.mockReturnValue(reason), .mockReturnValue(reason),
}, },
user: { user: {
@ -637,8 +646,9 @@ describe("add", () => {
isChatInputCommand: jest.fn().mockReturnValue(true), isChatInputCommand: jest.fn().mockReturnValue(true),
options: { options: {
getSubcommand: jest.fn().mockReturnValue("add"), getSubcommand: jest.fn().mockReturnValue("add"),
getUser: jest.fn().mockReturnValue(null), get: jest.fn()
get: jest.fn().mockReturnValue({}), .mockReturnValueOnce({ user: null })
.mockReturnValue({}),
}, },
reply: jest.fn(), reply: jest.fn(),
} as unknown as CommandInteraction; } as unknown as CommandInteraction;
@ -656,8 +666,9 @@ describe("add", () => {
isChatInputCommand: jest.fn().mockReturnValue(true), isChatInputCommand: jest.fn().mockReturnValue(true),
options: { options: {
getSubcommand: jest.fn().mockReturnValue("add"), getSubcommand: jest.fn().mockReturnValue("add"),
getUser: jest.fn().mockReturnValue(null), get: jest.fn()
get: jest.fn().mockReturnValueOnce(null) .mockReturnValueOnce({ user: null })
.mockReturnValueOnce(null)
.mockReturnValue({}), .mockReturnValue({}),
}, },
reply: jest.fn(), reply: jest.fn(),
@ -676,10 +687,11 @@ describe("add", () => {
isChatInputCommand: jest.fn().mockReturnValue(true), isChatInputCommand: jest.fn().mockReturnValue(true),
options: { options: {
getSubcommand: jest.fn().mockReturnValue("add"), getSubcommand: jest.fn().mockReturnValue("add"),
getUser: jest.fn().mockReturnValue(null), get: jest.fn()
get: jest.fn().mockReturnValueOnce({ .mockReturnValueOnce({ user: null })
value: undefined .mockReturnValueOnce({
}) value: undefined
})
.mockReturnValue({}), .mockReturnValue({}),
}, },
reply: jest.fn(), reply: jest.fn(),
@ -708,8 +720,9 @@ describe("add", () => {
isChatInputCommand: jest.fn().mockReturnValue(true), isChatInputCommand: jest.fn().mockReturnValue(true),
options: { options: {
getSubcommand: jest.fn().mockReturnValue("add"), getSubcommand: jest.fn().mockReturnValue("add"),
getUser: jest.fn().mockReturnValue(user), get: jest.fn()
get: jest.fn().mockReturnValueOnce(type) .mockReturnValueOnce({ user })
.mockReturnValueOnce(type)
.mockReturnValue(null), .mockReturnValue(null),
}, },
user: { user: {
@ -752,8 +765,9 @@ describe("add", () => {
isChatInputCommand: jest.fn().mockReturnValue(true), isChatInputCommand: jest.fn().mockReturnValue(true),
options: { options: {
getSubcommand: jest.fn().mockReturnValue("add"), getSubcommand: jest.fn().mockReturnValue("add"),
getUser: jest.fn().mockReturnValue(user), get: jest.fn()
get: jest.fn().mockReturnValueOnce(type) .mockReturnValueOnce({ user })
.mockReturnValueOnce(type)
.mockReturnValue(reason), .mockReturnValue(reason),
}, },
user: { user: {

4666
yarn.lock Normal file

File diff suppressed because it is too large Load diff