From d8cd98fc83058c00892fd2ddda7bae341f0ce266 Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Tue, 26 Nov 2024 11:48:27 +0100 Subject: [PATCH 1/6] refactor: project structure changes --- .github/workflows/website.yml | 2 +- .gitmodules | 4 +- .vscode/settings.json | 7 +- src/hooks.server.ts | 12 +- src/lib/components/AdditionStat.svelte | 4 +- src/lib/components/Bonus.svelte | 4 +- src/lib/components/Chip.svelte | 2 +- src/lib/components/Header.svelte | 2 +- src/lib/components/Item.svelte | 6 +- src/lib/components/Skillbar.svelte | 6 +- src/lib/components/Stat.svelte | 2 +- src/lib/components/Wardrobe.svelte | 2 +- src/lib/constants/NotEnoughUpdates-REPO | 1 - src/lib/constants/constants.ts | 22 --- src/lib/custom_resources.ts | 8 +- src/lib/index.ts | 1 - src/lib/layouts/stats/AdditionalStats.svelte | 4 +- src/lib/layouts/stats/Items.svelte | 2 +- src/lib/layouts/stats/Main.svelte | 2 +- src/lib/layouts/stats/PlayerProfile.svelte | 4 +- src/lib/layouts/stats/Skills.svelte | 2 +- src/lib/layouts/stats/Stats.svelte | 4 +- src/lib/renderer.ts | 4 +- src/lib/sections/stats/Accessories.svelte | 4 +- src/lib/sections/stats/Armor.svelte | 6 +- src/lib/sections/stats/Bestiary.svelte | 4 +- src/lib/sections/stats/Collections.svelte | 5 +- src/lib/sections/stats/CrimsonIsle.svelte | 7 +- src/lib/sections/stats/Dungeons.svelte | 4 +- src/lib/sections/stats/Inventory.svelte | 2 +- src/lib/sections/stats/Minions.svelte | 4 +- src/lib/sections/stats/MiscSection.svelte | 3 +- src/lib/sections/stats/Pets.svelte | 37 ++-- src/lib/sections/stats/Rift.svelte | 4 +- src/lib/sections/stats/Slayer.svelte | 2 +- src/lib/sections/stats/Weapons.svelte | 2 +- src/lib/sections/stats/misc/auctions.svelte | 2 +- src/lib/sections/stats/misc/claimed.svelte | 2 +- src/lib/sections/stats/misc/damage.svelte | 2 +- src/lib/sections/stats/misc/dragons.svelte | 2 +- src/lib/sections/stats/misc/endstone.svelte | 2 +- src/lib/sections/stats/misc/essence.svelte | 4 +- src/lib/sections/stats/misc/gifts.svelte | 2 +- src/lib/sections/stats/misc/jerry.svelte | 2 +- src/lib/sections/stats/misc/kills.svelte | 2 +- .../sections/stats/misc/mythological.svelte | 2 +- src/lib/sections/stats/misc/pet.svelte | 2 +- src/lib/sections/stats/misc/potions.svelte | 2 +- src/lib/sections/stats/misc/races.svelte | 4 +- .../sections/stats/misc/uncategorized.svelte | 8 +- src/lib/sections/stats/misc/upgrades.svelte | 2 +- .../sections/stats/skills/enchanting.svelte | 2 +- src/lib/sections/stats/skills/farming.svelte | 6 +- src/lib/sections/stats/skills/fishing.svelte | 6 +- src/lib/sections/stats/skills/mining.svelte | 6 +- .../server/constants/NotEnoughUpdates-REPO | 1 + src/lib/{ => server}/constants/accessories.ts | 2 +- src/lib/{ => server}/constants/armor.ts | 0 src/lib/{ => server}/constants/collections.ts | 0 src/lib/server/constants/constants.ts | 21 ++ .../{ => server}/constants/crimson_isle.ts | 0 src/lib/{ => server}/constants/dungeons.ts | 0 src/lib/{ => server}/constants/enchanting.ts | 0 src/lib/{ => server}/constants/error.ts | 0 src/lib/{ => server}/constants/farming.ts | 0 src/lib/{ => server}/constants/fishing.ts | 0 src/lib/{ => server}/constants/gemstones.ts | 0 src/lib/{ => server}/constants/mining.ts | 48 ++--- src/lib/{ => server}/constants/minions.ts | 0 src/lib/{ => server}/constants/misc.ts | 0 src/lib/{ => server}/constants/mobs.ts | 0 src/lib/{ => server}/constants/pets.ts | 0 src/lib/{ => server}/constants/ranks.ts | 0 src/lib/{ => server}/constants/rift.ts | 0 src/lib/{ => server}/constants/skills.ts | 0 src/lib/{ => server}/constants/skins.ts | 0 src/lib/{ => server}/constants/slayer.ts | 0 src/lib/{ => server}/constants/trophy_fish.ts | 2 +- .../server/constants/update-collections.ts | 2 +- src/lib/server/constants/update-items.ts | 4 +- src/lib/server/db/mongo/update-collections.ts | 2 +- src/lib/{ => server}/helper.ts | 69 +++++-- .../helper/NotEnoughUpdates}/NBTParser.ts | 0 .../NotEnoughUpdates}/parseNEURepository.ts | 18 +- .../NotEnoughUpdates/parsers}/bestiary.ts | 2 +- .../NotEnoughUpdates}/updateNEURepository.ts | 2 +- src/lib/{ => server}/helper/cache.ts | 0 src/lib/{ => server/helper}/hashes.ts | 0 src/lib/{ => server}/helper/item.ts | 0 src/lib/server/lib.ts | 2 +- src/lib/server/{lib => }/stats.ts | 0 src/lib/server/stats/accessories.ts | 6 +- src/lib/{ => server}/stats/bestiary.ts | 2 +- src/lib/{ => server}/stats/collections.ts | 4 +- src/lib/{ => server}/stats/crimson_isle.ts | 4 +- src/lib/{ => server}/stats/dungeons.ts | 4 +- src/lib/{ => server}/stats/enchanting.ts | 2 +- src/lib/{ => server}/stats/farming.ts | 2 +- src/lib/{ => server}/stats/fishing.ts | 4 +- src/lib/{ => server}/stats/hotm.ts | 6 +- src/lib/{ => server}/stats/items.ts | 8 +- src/lib/{ => server}/stats/items/armor.ts | 4 +- src/lib/{ => server}/stats/items/category.ts | 4 +- src/lib/{ => server}/stats/items/equipment.ts | 2 +- src/lib/server/stats/items/processing.ts | 16 +- src/lib/{ => server}/stats/items/stats.ts | 11 +- src/lib/{ => server}/stats/items/wardrobe.ts | 2 +- .../{ => server}/stats/leveling/leveling.ts | 2 +- src/lib/{ => server}/stats/main_stats.ts | 4 +- src/lib/{ => server}/stats/mining.ts | 4 +- src/lib/{ => server}/stats/minions.ts | 4 +- src/lib/{ => server}/stats/misc.ts | 4 +- src/lib/{ => server}/stats/missing.ts | 7 +- src/lib/{ => server}/stats/pets.ts | 17 +- src/lib/{ => server}/stats/rank.ts | 2 +- src/lib/{ => server}/stats/rift.ts | 2 +- src/lib/{ => server}/stats/skills.ts | 2 +- src/lib/{ => server}/stats/skyblock_level.ts | 0 src/lib/{ => server}/stats/slayer.ts | 9 +- src/lib/server/stats/stats.ts | 36 ++-- .../{ => shared}/constants/enchantments.ts | 0 src/lib/{ => shared}/constants/items.ts | 0 src/lib/{ => shared}/constants/stats.ts | 0 src/lib/shared/helper.ts | 187 ++++++++++++++++++ src/lib/{stats => shared}/player_stats.ts | 2 +- src/lib/{ => shared}/utils.ts | 0 src/lib/tools/formatting.ts | 119 ----------- src/lib/tools/helper.ts | 127 ------------ src/lib/tools/index.ts | 2 - src/{ => lib}/types/custom-resources.d.ts | 0 src/{ => lib}/types/global.d.ts | 0 src/lib/types/helper.d.ts | 2 + .../NotEnoughUpdates/NotEnoughUpdates.d.ts | 0 .../processed/NotEnoughUpdates/bestiary.d.ts | 0 .../types/processed/profile/bestiary.d.ts | 0 .../types/processed/profile/collections.d.ts | 0 .../types/processed/profile/crimson_isle.d.ts | 1 - .../types/processed/profile/dungeons.d.ts | 0 .../types/processed/profile/enchanting.d.ts | 0 .../types/processed/profile/farming.d.ts | 0 .../types/processed/profile/fishing.d.ts | 0 .../types/processed/profile/items.d.ts | 0 .../types/processed/profile/main_stats.d.ts | 0 .../types/processed/profile/mining.d.ts | 0 .../types/processed/profile/minions.d.ts | 0 .../types/processed/profile/misc.d.ts | 0 .../types/processed/profile/pet-stats.d.ts | 0 .../types/processed/profile/pets.d.ts | 0 .../types/processed/profile/rank.d.ts | 0 .../types/processed/profile/rift.d.ts | 0 .../types/processed/profile/skills.d.ts | 0 .../types/processed/profile/slayer.d.ts | 0 .../types/processed/profile/stats.d.ts | 0 .../types/raw/NotEnoughUpdates/bestiary.d.ts | 0 src/{ => lib}/types/raw/player/lib.d.ts | 0 src/{ => lib}/types/raw/profile/lib.d.ts | 0 src/{ => lib}/types/stats.d.ts | 0 .../api/stats/[paramPlayer=player]/+server.ts | 6 +- .../[paramProfile]/+server.ts | 6 +- svelte.config.js | 4 +- 160 files changed, 515 insertions(+), 541 deletions(-) delete mode 160000 src/lib/constants/NotEnoughUpdates-REPO delete mode 100644 src/lib/constants/constants.ts delete mode 100644 src/lib/index.ts create mode 160000 src/lib/server/constants/NotEnoughUpdates-REPO rename src/lib/{ => server}/constants/accessories.ts (99%) rename src/lib/{ => server}/constants/armor.ts (100%) rename src/lib/{ => server}/constants/collections.ts (100%) create mode 100644 src/lib/server/constants/constants.ts rename src/lib/{ => server}/constants/crimson_isle.ts (100%) rename src/lib/{ => server}/constants/dungeons.ts (100%) rename src/lib/{ => server}/constants/enchanting.ts (100%) rename src/lib/{ => server}/constants/error.ts (100%) rename src/lib/{ => server}/constants/farming.ts (100%) rename src/lib/{ => server}/constants/fishing.ts (100%) rename src/lib/{ => server}/constants/gemstones.ts (100%) rename src/lib/{ => server}/constants/mining.ts (92%) rename src/lib/{ => server}/constants/minions.ts (100%) rename src/lib/{ => server}/constants/misc.ts (100%) rename src/lib/{ => server}/constants/mobs.ts (100%) rename src/lib/{ => server}/constants/pets.ts (100%) rename src/lib/{ => server}/constants/ranks.ts (100%) rename src/lib/{ => server}/constants/rift.ts (100%) rename src/lib/{ => server}/constants/skills.ts (100%) rename src/lib/{ => server}/constants/skins.ts (100%) rename src/lib/{ => server}/constants/slayer.ts (100%) rename src/lib/{ => server}/constants/trophy_fish.ts (99%) rename src/lib/{ => server}/helper.ts (86%) rename src/lib/{scripts => server/helper/NotEnoughUpdates}/NBTParser.ts (100%) rename src/lib/{scripts => server/helper/NotEnoughUpdates}/parseNEURepository.ts (52%) rename src/lib/{scripts/NotEnoughUpdates => server/helper/NotEnoughUpdates/parsers}/bestiary.ts (97%) rename src/lib/{scripts => server/helper/NotEnoughUpdates}/updateNEURepository.ts (89%) rename src/lib/{ => server}/helper/cache.ts (100%) rename src/lib/{ => server/helper}/hashes.ts (100%) rename src/lib/{ => server}/helper/item.ts (100%) rename src/lib/server/{lib => }/stats.ts (100%) rename src/lib/{ => server}/stats/bestiary.ts (97%) rename src/lib/{ => server}/stats/collections.ts (97%) rename src/lib/{ => server}/stats/crimson_isle.ts (89%) rename src/lib/{ => server}/stats/dungeons.ts (98%) rename src/lib/{ => server}/stats/enchanting.ts (95%) rename src/lib/{ => server}/stats/farming.ts (98%) rename src/lib/{ => server}/stats/fishing.ts (95%) rename src/lib/{ => server}/stats/hotm.ts (96%) rename src/lib/{ => server}/stats/items.ts (94%) rename src/lib/{ => server}/stats/items/armor.ts (96%) rename src/lib/{ => server}/stats/items/category.ts (96%) rename src/lib/{ => server}/stats/items/equipment.ts (91%) rename src/lib/{ => server}/stats/items/stats.ts (77%) rename src/lib/{ => server}/stats/items/wardrobe.ts (93%) rename src/lib/{ => server}/stats/leveling/leveling.ts (99%) rename src/lib/{ => server}/stats/main_stats.ts (96%) rename src/lib/{ => server}/stats/mining.ts (97%) rename src/lib/{ => server}/stats/minions.ts (96%) rename src/lib/{ => server}/stats/misc.ts (98%) rename src/lib/{ => server}/stats/missing.ts (96%) rename src/lib/{ => server}/stats/pets.ts (94%) rename src/lib/{ => server}/stats/rank.ts (100%) rename src/lib/{ => server}/stats/rift.ts (96%) rename src/lib/{ => server}/stats/skills.ts (100%) rename src/lib/{ => server}/stats/skyblock_level.ts (100%) rename src/lib/{ => server}/stats/slayer.ts (87%) rename src/lib/{ => shared}/constants/enchantments.ts (100%) rename src/lib/{ => shared}/constants/items.ts (100%) rename src/lib/{ => shared}/constants/stats.ts (100%) create mode 100644 src/lib/shared/helper.ts rename src/lib/{stats => shared}/player_stats.ts (98%) rename src/lib/{ => shared}/utils.ts (100%) delete mode 100644 src/lib/tools/formatting.ts delete mode 100644 src/lib/tools/helper.ts delete mode 100644 src/lib/tools/index.ts rename src/{ => lib}/types/custom-resources.d.ts (100%) rename src/{ => lib}/types/global.d.ts (100%) create mode 100644 src/lib/types/helper.d.ts rename src/{ => lib}/types/processed/NotEnoughUpdates/NotEnoughUpdates.d.ts (100%) rename src/{ => lib}/types/processed/NotEnoughUpdates/bestiary.d.ts (100%) rename src/{ => lib}/types/processed/profile/bestiary.d.ts (100%) rename src/{ => lib}/types/processed/profile/collections.d.ts (100%) rename src/{ => lib}/types/processed/profile/crimson_isle.d.ts (94%) rename src/{ => lib}/types/processed/profile/dungeons.d.ts (100%) rename src/{ => lib}/types/processed/profile/enchanting.d.ts (100%) rename src/{ => lib}/types/processed/profile/farming.d.ts (100%) rename src/{ => lib}/types/processed/profile/fishing.d.ts (100%) rename src/{ => lib}/types/processed/profile/items.d.ts (100%) rename src/{ => lib}/types/processed/profile/main_stats.d.ts (100%) rename src/{ => lib}/types/processed/profile/mining.d.ts (100%) rename src/{ => lib}/types/processed/profile/minions.d.ts (100%) rename src/{ => lib}/types/processed/profile/misc.d.ts (100%) rename src/{ => lib}/types/processed/profile/pet-stats.d.ts (100%) rename src/{ => lib}/types/processed/profile/pets.d.ts (100%) rename src/{ => lib}/types/processed/profile/rank.d.ts (100%) rename src/{ => lib}/types/processed/profile/rift.d.ts (100%) rename src/{ => lib}/types/processed/profile/skills.d.ts (100%) rename src/{ => lib}/types/processed/profile/slayer.d.ts (100%) rename src/{ => lib}/types/processed/profile/stats.d.ts (100%) rename src/{ => lib}/types/raw/NotEnoughUpdates/bestiary.d.ts (100%) rename src/{ => lib}/types/raw/player/lib.d.ts (100%) rename src/{ => lib}/types/raw/profile/lib.d.ts (100%) rename src/{ => lib}/types/stats.d.ts (100%) diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 60b97cfc..c75be410 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -97,7 +97,7 @@ jobs: uses: actions/checkout@v3 with: repository: NotEnoughUpdates/NotEnoughUpdates-REPO - path: src/lib/constants/NotEnoughUpdates-REPO/items + path: src/lib/server/constants/NotEnoughUpdates-REPO/items token: ${{ secrets.GITHUB_TOKEN }} - name: PNPM Install diff --git a/.gitmodules b/.gitmodules index 5ed9afa6..183a6ea1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "src/lib/constants/NotEnoughUpdates-REPO"] - path = src/lib/constants/NotEnoughUpdates-REPO +[submodule "src/lib/constants/server/NotEnoughUpdates-REPO"] + path = src/lib/constants/server/NotEnoughUpdates-REPO url = https://github.com/NotEnoughUpdates/NotEnoughUpdates-REPO diff --git a/.vscode/settings.json b/.vscode/settings.json index 32821d0d..51077165 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,8 +2,7 @@ "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.fixAll": "always", - "source.organizeImports": "explicit" + "source.fixAll": "always" }, "files.associations": { "*.css": "tailwindcss", @@ -21,7 +20,7 @@ "typescript": "typescript", "svelte": "html" }, - "javascript.updateImportsOnFileMove.enabled": "prompt", - "typescript.updateImportsOnFileMove.enabled": "prompt", + "javascript.updateImportsOnFileMove.enabled": "always", + "typescript.updateImportsOnFileMove.enabled": "always", "eslint.validate": ["javascript", "typescript", "svelte"] } diff --git a/src/hooks.server.ts b/src/hooks.server.ts index a1376ca8..bd627255 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,11 +1,11 @@ -import { startMongo } from "./lib/server/db/mongo"; -import { startRedis } from "./lib/server/db/redis"; import { init } from "$lib/custom_resources"; -import { parseNEURepository } from "$lib/scripts/parseNEURepository"; -import { updateNotEnoughUpdatesRepository } from "$lib/scripts/updateNEURepository"; -import { getPrices } from "skyhelper-networth"; -import { updateItems } from "$lib/server/constants/update-items"; import { updateCollections } from "$lib/server/constants/update-collections"; +import { updateItems } from "$lib/server/constants/update-items"; +import { parseNEURepository } from "$lib/server/helper/NotEnoughUpdates/parseNEURepository"; +import { updateNotEnoughUpdatesRepository } from "$lib/server/helper/NotEnoughUpdates/updateNEURepository"; +import { getPrices } from "skyhelper-networth"; +import { startMongo } from "./lib/server/db/mongo"; +import { startRedis } from "./lib/server/db/redis"; init(); diff --git a/src/lib/components/AdditionStat.svelte b/src/lib/components/AdditionStat.svelte index f56bf7fd..77e6e87c 100644 --- a/src/lib/components/AdditionStat.svelte +++ b/src/lib/components/AdditionStat.svelte @@ -1,6 +1,6 @@

Miscellaneous

diff --git a/src/lib/sections/stats/Pets.svelte b/src/lib/sections/stats/Pets.svelte index 05dcccb4..d23fcd09 100644 --- a/src/lib/sections/stats/Pets.svelte +++ b/src/lib/sections/stats/Pets.svelte @@ -1,25 +1,31 @@ @@ -32,16 +38,7 @@

Pet score is calculated based on how many unique pets you have and the rarity of these pets.

You gain an additional score for each max level pet you have!

-
- {#each Object.entries(PET_REWARDS) as [score, data]} -
- {score} Score: +{data.magic_find} Magic Find - {#if data.magic_find === pets.petScore.amount} - « - {/if} -
- {/each} -
+
diff --git a/src/lib/sections/stats/Rift.svelte b/src/lib/sections/stats/Rift.svelte index 442b4ff8..36d38ea3 100644 --- a/src/lib/sections/stats/Rift.svelte +++ b/src/lib/sections/stats/Rift.svelte @@ -2,8 +2,8 @@ import AdditionStat from "$lib/components/AdditionStat.svelte"; import Chip from "$lib/components/Chip.svelte"; import Items from "$lib/layouts/stats/Items.svelte"; - import { cn } from "$lib/utils"; - import type { Stats as StatsType } from "$types/stats"; + import { cn } from "$lib/shared/utils"; + import type { Stats as StatsType } from "$lib/types/stats"; import { formatDate, formatDistanceToNowStrict } from "date-fns"; import { getContext } from "svelte"; diff --git a/src/lib/sections/stats/Slayer.svelte b/src/lib/sections/stats/Slayer.svelte index 60fadaa5..3d1a7662 100644 --- a/src/lib/sections/stats/Slayer.svelte +++ b/src/lib/sections/stats/Slayer.svelte @@ -1,7 +1,7 @@