From 917c85e097976d5ce0bfe488d612f8e56b74477e Mon Sep 17 00:00:00 2001 From: Herman Andgart Date: Tue, 13 Dec 2022 12:06:00 +0100 Subject: [PATCH 1/8] Pinning docker image to alpine 3.16 for better reproducibility --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 64aa3c26..84b55b4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:19-alpine AS builder +FROM node:19-alpine3.16 AS builder # Create app directory WORKDIR /app @@ -15,7 +15,7 @@ COPY . . RUN npm run build -FROM node:19-alpine +FROM node:19-alpine3.16 COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package*.json ./ From c47400a641a32f01ca5a02f2ff662560e3d3fb66 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 13 Dec 2022 16:43:59 +0100 Subject: [PATCH 2/8] build: :pushpin: Change from alpine --- Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 84b55b4a..caaa66b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:19-alpine3.16 AS builder +FROM node:19 AS builder # Create app directory WORKDIR /app @@ -10,16 +10,15 @@ COPY prisma ./prisma/ # Install app dependencies RUN npm install - COPY . . RUN npm run build -FROM node:19-alpine3.16 +FROM node:19 COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package*.json ./ COPY --from=builder /app/dist ./dist COPY --from=builder /app/prisma ./prisma -CMD [ "npm", "run", "start:migrate:prod" ] +CMD [ "npm", "run", "start:migrate:prod" ] From 696f6c746a0d3519f40233380cf6ca5f2a5a7b0d Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 13 Dec 2022 16:50:42 +0100 Subject: [PATCH 3/8] build: :green_heart: Fixed missing variable Missing client in about command made build job fail --- package-lock.json | 4 ++-- src/commands/utils/modules/about/index.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8a7d37d2..d19d8cf8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "xyter", - "version": "v1.1.0", + "version": "v1.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "xyter", - "version": "v1.1.0", + "version": "v1.1.1", "license": "GPL-3.0-only", "dependencies": { "@prisma/client": "^4.7.1", diff --git a/src/commands/utils/modules/about/index.ts b/src/commands/utils/modules/about/index.ts index ea8ba269..30035116 100644 --- a/src/commands/utils/modules/about/index.ts +++ b/src/commands/utils/modules/about/index.ts @@ -25,6 +25,8 @@ export default { if (!interaction.guild) throw new Error("You need to be in a guild"); + const { client } = interaction; + // await cooldown( // interaction.guild, // interaction.user, From b279e0aeed85c79d3c7af0f48f533285a126ec81 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 13 Dec 2022 16:57:18 +0100 Subject: [PATCH 4/8] build: :rocket: Use Alpine for image Found out that Alpine works after fixing issue in about command --- .vscode/settings.json | 5 ++++- Dockerfile | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 83191f46..e9ea9d9f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,5 +33,8 @@ "[prisma]": { "editor.defaultFormatter": "Prisma.prisma" }, - "conventionalCommits.scopes": ["git", "github", "prisma"] + "conventionalCommits.scopes": ["git", "github", "prisma"], + "[dockerfile]": { + "editor.defaultFormatter": "foxundermoon.shell-format" + } } diff --git a/Dockerfile b/Dockerfile index caaa66b5..487ea909 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:19 AS builder +FROM node:19-alpine3.16 AS builder # Create app directory WORKDIR /app @@ -14,7 +14,7 @@ COPY . . RUN npm run build -FROM node:19 +FROM node:19-alpine3.16 COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package*.json ./ From 3f051b06eee60bd4801243aa6f3756458168422b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 13 Dec 2022 14:00:08 +0100 Subject: [PATCH 5/8] chore(npm): :pushpin: updated packages Updated packages that may solve Prisma OpenSSL 3 problems --- .vscode/settings.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e9ea9d9f..b38f6a49 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,8 +33,5 @@ "[prisma]": { "editor.defaultFormatter": "Prisma.prisma" }, - "conventionalCommits.scopes": ["git", "github", "prisma"], - "[dockerfile]": { - "editor.defaultFormatter": "foxundermoon.shell-format" - } + "conventionalCommits.scopes": ["git", "github", "npm"] } From 6b022d7edc114f0a3f96b59284f24f20ab75a31b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 13 Dec 2022 14:08:21 +0100 Subject: [PATCH 6/8] feat(prisma): :triangular_flag_on_post: interactiveTransactions are no longer a preview feature Removed it frmo previewFeatures --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index b38f6a49..83191f46 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,5 +33,5 @@ "[prisma]": { "editor.defaultFormatter": "Prisma.prisma" }, - "conventionalCommits.scopes": ["git", "github", "npm"] + "conventionalCommits.scopes": ["git", "github", "prisma"] } From f022632de4ae05d5825a76957a87a9fedd650c91 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 13 Dec 2022 14:16:41 +0100 Subject: [PATCH 7/8] refactor: :coffin: Fixed some code smells Fixed some code smells from https://deepsource.io/gh/ZynerOrg/xyter/run/8058c521-9330-4c14-94b2-0c3a7d9d824b/javascript/ --- src/commands/utils/modules/about/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/commands/utils/modules/about/index.ts b/src/commands/utils/modules/about/index.ts index 30035116..5a9c9a81 100644 --- a/src/commands/utils/modules/about/index.ts +++ b/src/commands/utils/modules/about/index.ts @@ -38,6 +38,16 @@ export default { interaction.guild ); + const { client } = interaction; + if (client?.uptime === null) return; + let totalSeconds = client?.uptime / 1000; + const days = Math?.floor(totalSeconds / 86400); + totalSeconds %= 86400; + const hours = Math?.floor(totalSeconds / 3600); + totalSeconds %= 3600; + const minutes = Math?.floor(totalSeconds / 60); + const seconds = Math?.floor(totalSeconds % 60); + // // Initialize a storage for the user ids // const userIds = new Set(); // // Iterate over all guilds (always cached) From 2c6ec5ee2e5006add840f135029447dc388a348d Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 13 Dec 2022 14:27:00 +0100 Subject: [PATCH 8/8] refactor: :recycle: Fixed more code smells I have fixed more code smells --- src/events/messageCreate/modules/counters/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/events/messageCreate/modules/counters/index.ts b/src/events/messageCreate/modules/counters/index.ts index 4459a83d..70dd0e72 100644 --- a/src/events/messageCreate/modules/counters/index.ts +++ b/src/events/messageCreate/modules/counters/index.ts @@ -35,6 +35,7 @@ export default { `${author.username} sent the last message therefor not allowing again.` ); await message.delete(); + return false; } if (content !== channelCounter.triggerWord) { @@ -43,6 +44,7 @@ export default { ); await message.delete(); + return false; } const updateGuildCounter = await prisma.guildCounter.update({