Compare commits

..

No commits in common. "11b3e6dc9128d6121b1d906e09c22f17e04cd49a" and "808314701e2ea8dbcf9419466bfd6da1ec5faabb" have entirely different histories.

14 changed files with 31 additions and 75 deletions

View file

@ -16,8 +16,6 @@ BOT_ENV=4
ABOUT_FUNDING= ABOUT_FUNDING=
ABOUT_REPO= ABOUT_REPO=
DATA_DIR=
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
DB_PORT=3301 DB_PORT=3301
DB_NAME=carddrop DB_NAME=carddrop

View file

@ -4,36 +4,16 @@ kind: pipeline
name: deployment name: deployment
steps: steps:
- name: build - name: deploy
image: node image: appleboy/drone-ssh
commands:
- npm ci
- npm run build
- name: test
image: node
commands:
- npm test
- name: deploy to prod
image: drillster/drone-rsync
secrets: [ ssh_key, bot_token_prod ]
settings: settings:
hosts: host: 192.168.68.120
- 192.168.68.120 username: vylpes
user: vylpes password:
key: from_secret: ssh_password
from_secret: ssh_key port: 22
source: .
target: ~/apps/card-drop/card-drop_prod
recursive: true
script: script:
- export PATH="$HOME/.yarn/bin:$PATH" - sh /home/vylpes/scripts/card-drop/deploy_prod.sh
- export PATH="$HOME/.nodeuse/bin:$PATH"
- export BOT_TOKEN="$BOT_TOKEN_PROD"
- cd ~/apps/card-drop/card-drop_prod
- docker compose --file docker-compose.prod.yml up -d
- sleep 10
- cp .prod.env .env
- pm2 restart card-drop_prod || pm2 start --name card-drop_prod dist/bot.js
trigger: trigger:
event: event:
@ -45,36 +25,16 @@ kind: pipeline
name: staging name: staging
steps: steps:
- name: build - name: stage
image: node image: appleboy/drone-ssh
commands:
- npm ci
- npm run build
- name: test
image: node
commands:
- npm test
- name: deploy to stage
image: drillster/drone-rsync
secrets: [ ssh_key, bot_token_stage ]
settings: settings:
hosts: host: 192.168.68.120
- 192.168.68.120 username: vylpes
user: vylpes password:
key: from_secret: ssh_password
from_secret: ssh_key port: 22
source: .
target: ~/apps/card-drop/card-drop_stage
recursive: true
script: script:
- export PATH="$HOME/.yarn/bin:$PATH" - sh /home/vylpes/scripts/card-drop/deploy_stage.sh
- export PATH="$HOME/.nodeuse/bin:$PATH"
- export BOT_TOKEN="$BOT_TOKEN_STAGE"
- cd ~/apps/card-drop/card-drop_stage
- docker compose --file docker-compose.stage.yml up -d
- sleep 10
- cp .stage.env .env
- pm2 restart card-drop_stage || pm2 start --name card-drop_stage dist/bot.js
trigger: trigger:
branch: branch:
@ -102,10 +62,13 @@ steps:
- name: test - name: test
image: node image: node
commands: commands:
- npm ci
- npm test - npm test
trigger: trigger:
branch: branch:
- main
- develop
- hotfix/* - hotfix/*
- feature/* - feature/*
- renovate/* - renovate/*

View file

@ -16,8 +16,6 @@ BOT_ENV=1
ABOUT_FUNDING= ABOUT_FUNDING=
ABOUT_REPO= ABOUT_REPO=
DATA_DIR=/home/vylpes/appdata/card-drop/card-drop_prod
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
DB_PORT=3321 DB_PORT=3321
DB_NAME=carddrop DB_NAME=carddrop

View file

@ -16,8 +16,6 @@ BOT_ENV=2
ABOUT_FUNDING= ABOUT_FUNDING=
ABOUT_REPO= ABOUT_REPO=
DATA_DIR=/home/vylpes/appdata/card-drop/card-drop_stage
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
DB_PORT=3311 DB_PORT=3311
DB_NAME=carddrop DB_NAME=carddrop

6
package-lock.json generated
View file

@ -1884,9 +1884,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "20.10.6", "version": "20.10.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.6.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.5.tgz",
"integrity": "sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==", "integrity": "sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==",
"dependencies": { "dependencies": {
"undici-types": "~5.26.4" "undici-types": "~5.26.4"
} }

View file

@ -42,6 +42,7 @@
"typeorm": "0.3.17" "typeorm": "0.3.17"
}, },
"resolutions": { "resolutions": {
"**/undici": "^5.26.2"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.0.0", "@types/node": "^20.0.0",

View file

@ -1,5 +1,4 @@
{ {
"$schema": "https://docs.renovatebot.com/renovate-schema.json", "$schema": "https://docs.renovatebot.com/renovate-schema.json",
"baseBranches": ["develop"], "baseBranches": ["develop"]
"labels": ["type/dependencies"]
} }

View file

@ -26,7 +26,7 @@ export default class CardMetadataFunction {
private static async FindMetadataJSONs(): Promise<SeriesMetadata[]> { private static async FindMetadataJSONs(): Promise<SeriesMetadata[]> {
const res: SeriesMetadata[] = []; const res: SeriesMetadata[] = [];
const seriesJSONs = await glob(path.join(process.env.DATA_DIR!, "cards", "/**/*.json")); const seriesJSONs = await glob(path.join(process.cwd(), "cards", "/**/*.json"));
for (const jsonPath of seriesJSONs) { for (const jsonPath of seriesJSONs) {
console.log(`Reading file ${jsonPath}`); console.log(`Reading file ${jsonPath}`);

View file

@ -14,7 +14,6 @@ const requiredConfigs: string[] = [
"BOT_OWNERID", "BOT_OWNERID",
"BOT_CLIENTID", "BOT_CLIENTID",
"BOT_ENV", "BOT_ENV",
"DATA_DIR",
"DB_HOST", "DB_HOST",
"DB_PORT", "DB_PORT",
"DB_AUTH_USER", "DB_AUTH_USER",
@ -40,7 +39,7 @@ Registry.RegisterCommands();
Registry.RegisterEvents(); Registry.RegisterEvents();
Registry.RegisterButtonEvents(); Registry.RegisterButtonEvents();
if (!existsSync(`${process.env.DATA_DIR}/cards`) && process.env.GDRIVESYNC_AUTO && process.env.GDRIVESYNC_AUTO == "true") { if (!existsSync(`${process.cwd()}/cards`) && process.env.GDRIVESYNC_AUTO && process.env.GDRIVESYNC_AUTO == "true") {
console.log("Card directory not found, syncing..."); console.log("Card directory not found, syncing...");
CoreClient.AllowDrops = false; CoreClient.AllowDrops = false;

View file

@ -28,7 +28,7 @@ export default class Reroll extends ButtonEvent {
} }
try { try {
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", randomCard.card.path)); const image = readFileSync(path.join(process.cwd(), "cards", randomCard.card.path));
const imageFileName = randomCard.card.path.split("/").pop()!; const imageFileName = randomCard.card.path.split("/").pop()!;
await interaction.deferReply(); await interaction.deferReply();

View file

@ -36,7 +36,7 @@ export default class Drop extends Command {
} }
try { try {
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", randomCard.card.path)); const image = readFileSync(path.join(process.cwd(), "cards", randomCard.card.path));
const imageFileName = randomCard.card.path.split("/").pop()!; const imageFileName = randomCard.card.path.split("/").pop()!;
await interaction.deferReply(); await interaction.deferReply();

View file

@ -29,7 +29,7 @@ export default class Gdrivesync extends Command {
CoreClient.AllowDrops = false; CoreClient.AllowDrops = false;
exec(`rclone sync card-drop-gdrive: ${process.env.DATA_DIR}/cards`, async (error: ExecException | null) => { exec(`rclone sync card-drop-gdrive: ${process.cwd()}/cards`, async (error: ExecException | null) => {
if (error) { if (error) {
await interaction.editReply(`Error while running sync command. Safe Mode has been activated. Code: ${error.code}`); await interaction.editReply(`Error while running sync command. Safe Mode has been activated. Code: ${error.code}`);
await Config.SetValue("safemode", "true"); await Config.SetValue("safemode", "true");

View file

@ -47,7 +47,7 @@ export default class Dropnumber extends Command {
const imageFileName = card.path.split("/").pop()!; const imageFileName = card.path.split("/").pop()!;
try { try {
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path)); image = readFileSync(path.join(process.cwd(), "cards", card.path));
} catch { } catch {
await interaction.reply(`Unable to fetch image for card ${card.id}`); await interaction.reply(`Unable to fetch image for card ${card.id}`);
return; return;

View file

@ -50,7 +50,7 @@ export default class Droprarity extends Command {
const imageFileName = card.card.path.split("/").pop()!; const imageFileName = card.card.path.split("/").pop()!;
try { try {
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path)); image = readFileSync(path.join(process.cwd(), "cards", card.card.path));
} catch { } catch {
await interaction.reply(`Unable to fetch image for card ${card.card.id}`); await interaction.reply(`Unable to fetch image for card ${card.card.id}`);
return; return;