Commit Graph

41 Commits

Author SHA1 Message Date
TheSparta
c3e203922e bundle-crc-cache (!274)
This PR is required by SPT-AKI/Modules!104 in order for it to function correctly.

## Overview

- Adds the package `buffer-crc32`, it can generate CRC32 hashes from buffers or strings
- Splits `HashCacheService` into 2 classes `ModHashCacheService` does exactly the same `HashCacheService` used to do, and added a new `BundleHashCacheService`
- `BundleLoader` now generates a CRC32 hash of every bundle file from every loaded mod
- Reworked `BundleInfo` to better represent the data expected by the client when requesting `/singleplayer/bundles`
- Removes all checks on `BundleLoader` that verified if the request was made to a localhost address, this is now addressed by the client.

## Testing

The code has been tested by @Senko-san and me.

Co-authored-by: chomp <chomp@noreply.dev.sp-tarkov.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/274
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2024-03-29 18:43:36 +00:00
DrakiaXYZ
757c4506f5 Fix loading bundles from different local folders (!270)
Return a full path to the request for getBundles if running locally

Ran into this while working on updating Gilded Key Storage, looks like bundle files are expected to live in the same local folder as the client any time the server address is `127.0.0.1` or `localhost`.

While working in VSCode for the server, and a different folder for the client, this causes issues trying to work on mods that add bundles, as the server only passes a relative path back to the client

This PR resolves that by returning the full path to bundles when running locally

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/270
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
2024-03-25 08:30:41 +00:00
TheSparta
5e8fb7b303 defered addBundles after PostDBModLoader is run
- defered addBundles after PostDBModLoader is run
- removed unused injected class instances
2024-03-24 17:52:38 +00:00
TheSparta
9de6b19c28 export BundleInfo class 2024-03-24 00:49:53 +00:00
TheSparta
d4c04fc718 Simplified autoInstallDependencies() 2024-03-18 00:06:08 +00:00
TheSparta
e73fea8776 Fixed undefined behaviour
- Would break out of the loop at the first dependency removed from `dependenciesToInstall`.
2024-03-17 23:19:56 +00:00
Dev
252d009283 Prevent outdated mods from loading 2024-03-16 19:18:25 +00:00
Refringe
69a1723646
Fixes Linting Issues
- Reorders imports
- Removes unnecessary `else` control statements
- Simplifies some logic
- Converts key access to dot notation
- Converts Array.forEach loops to for...of loops
2024-02-02 15:00:21 -05:00
Refringe
90492f3aa2
Formatting
Have you been using the recommended VSCode extensions? ;)
2024-02-02 15:00:21 -05:00
Dev
268a9b8abd Merge branch 'master' of https://dev.sp-tarkov.com/SPT-AKI/Server into 3.8.0
# Conflicts:
#	project/src/callbacks/BundleCallbacks.ts
#	project/src/controllers/RepeatableQuestController.ts
#	project/src/helpers/InRaidHelper.ts
#	project/src/loaders/PreAkiModLoader.ts
2023-12-15 14:16:15 +00:00
Dev
bda6d66e92 Log names of files being serialsied 2023-12-13 22:16:21 +00:00
Dev
9e6c12a9b2 Log file being deserialized 2023-12-13 20:02:44 +00:00
Refringe
4ac12ef70a Formatting/Linting Changes (!168)
These are the formatting & linting configuration changes from the `3.8.0` branch and the changes that they make to the overall project.

The majority of these changes are from running two commands:

`npm run lint:fix`
`npm run style:fix`

This has already been run on the `3.8.0` branch and this PR should make `master` play nicer when it comes to merges going forward.

There are now four VSCode plugins recommended for server development. They've been added to the workspace file and a user should get a UI notification when the workspace is opened if they're not installed.

The four plugins are:
https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig
https://marketplace.visualstudio.com/items?itemName=dprint.dprint
https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
https://marketplace.visualstudio.com/items?itemName=biomejs.biome

Once installed they should just work within the workspace.

Also, be sure to `npm i` to get the new dprint application.

Co-authored-by: Refringe <brownelltyler@gmail.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/168
2023-11-16 21:42:06 +00:00
Refringe
a4d2013ff6
Converts forEach loop to for...of loop 2023-11-16 10:15:52 -05:00
Refringe
8066eb942e
Merge branch 'fix/linting-errors' into 3.8.0
# Conflicts:
#	project/src/callbacks/DataCallbacks.ts
#	project/src/callbacks/DialogueCallbacks.ts
#	project/src/callbacks/GameCallbacks.ts
#	project/src/callbacks/HandbookCallbacks.ts
#	project/src/callbacks/HealthCallbacks.ts
#	project/src/callbacks/HttpCallbacks.ts
#	project/src/callbacks/InventoryCallbacks.ts
#	project/src/callbacks/LauncherCallbacks.ts
#	project/src/callbacks/ModCallbacks.ts
#	project/src/callbacks/PresetCallbacks.ts
#	project/src/callbacks/TraderCallbacks.ts
#	project/src/context/ApplicationContext.ts
#	project/src/context/ContextVariableType.ts
#	project/src/controllers/BotController.ts
#	project/src/controllers/CustomizationController.ts
#	project/src/controllers/DialogueController.ts
#	project/src/controllers/GameController.ts
#	project/src/controllers/HideoutController.ts
#	project/src/controllers/InraidController.ts
#	project/src/controllers/InsuranceController.ts
#	project/src/controllers/InventoryController.ts
#	project/src/controllers/LauncherController.ts
#	project/src/controllers/LocationController.ts
#	project/src/controllers/QuestController.ts
#	project/src/controllers/RagfairController.ts
#	project/src/controllers/RepeatableQuestController.ts
#	project/src/controllers/TradeController.ts
#	project/src/di/Container.ts
#	project/src/di/Router.ts
#	project/src/generators/BotEquipmentModGenerator.ts
#	project/src/generators/BotGenerator.ts
#	project/src/generators/BotWeaponGenerator.ts
#	project/src/generators/LocationGenerator.ts
#	project/src/generators/LootGenerator.ts
#	project/src/generators/RepeatableQuestGenerator.ts
#	project/src/generators/WeatherGenerator.ts
#	project/src/generators/weapongen/InventoryMagGen.ts
#	project/src/generators/weapongen/implementations/BarrelInventoryMagGen.ts
#	project/src/generators/weapongen/implementations/ExternalInventoryMagGen.ts
#	project/src/helpers/AssortHelper.ts
#	project/src/helpers/BotGeneratorHelper.ts
#	project/src/helpers/HttpServerHelper.ts
#	project/src/helpers/InRaidHelper.ts
#	project/src/helpers/TradeHelper.ts
#	project/src/helpers/TraderHelper.ts
#	project/src/loaders/PostDBModLoader.ts
#	project/src/loaders/PreAkiModLoader.ts
#	project/src/models/eft/common/tables/IProfileTemplate.ts
#	project/src/models/eft/common/tables/ITemplateItem.ts
#	project/src/models/eft/dialog/IAcceptFriendRequestData.ts
#	project/src/models/eft/dialog/IDeleteFriendRequest.ts
#	project/src/models/eft/game/IGameConfigResponse.ts
#	project/src/models/eft/game/IGameKeepAliveResponse.ts
#	project/src/models/eft/game/IGameStartResponse.ts
#	project/src/models/eft/match/IJoinMatchResult.ts
#	project/src/models/eft/notifier/INotifier.ts
#	project/src/models/eft/profile/GetProfileStatusResponseData.ts
#	project/src/models/eft/trade/IProcessSellTradeRequestData.ts
#	project/src/models/external/HttpFramework.ts
#	project/src/models/external/tsyringe.ts
#	project/src/models/spt/config/ILocationConfig.ts
#	project/src/models/spt/server/ILocations.ts
#	project/src/routers/dynamic/BundleDynamicRouter.ts
#	project/src/routers/dynamic/DataDynamicRouter.ts
#	project/src/routers/dynamic/HttpDynamicRouter.ts
#	project/src/routers/dynamic/NotifierDynamicRouter.ts
#	project/src/routers/save_load/HealthSaveLoadRouter.ts
#	project/src/routers/save_load/InraidSaveLoadRouter.ts
#	project/src/routers/save_load/InsuranceSaveLoadRouter.ts
#	project/src/routers/save_load/ProfileSaveLoadRouter.ts
#	project/src/routers/static/BundleStaticRouter.ts
#	project/src/routers/static/ClientLogStaticRouter.ts
#	project/src/routers/static/DataStaticRouter.ts
#	project/src/routers/static/DialogStaticRouter.ts
#	project/src/routers/static/GameStaticRouter.ts
#	project/src/routers/static/HealthStaticRouter.ts
#	project/src/routers/static/InraidStaticRouter.ts
#	project/src/routers/static/LauncherStaticRouter.ts
#	project/src/routers/static/LocationStaticRouter.ts
#	project/src/routers/static/MatchStaticRouter.ts
#	project/src/routers/static/ProfileStaticRouter.ts
#	project/src/routers/static/QuestStaticRouter.ts
#	project/src/routers/static/RagfairStaticRouter.ts
#	project/src/routers/static/WeatherStaticRouter.ts
#	project/src/services/BotGenerationCacheService.ts
#	project/src/services/BotLootCacheService.ts
#	project/src/services/LocalisationService.ts
#	project/src/services/ProfileFixerService.ts
#	project/src/services/RagfairOfferService.ts
#	project/src/services/RagfairTaxService.ts
#	project/src/services/RepairService.ts
#	project/src/utils/App.ts
#	project/src/utils/DatabaseImporter.ts
#	project/src/utils/RagfairOfferHolder.ts
#	project/src/utils/collections/queue/Queue.ts
#	project/tests/__factories__/ProfileInsurance.factory.ts
#	project/tests/controllers/InsuranceController.test.ts

Manually resolved by Refringe
2023-11-15 22:28:43 -05:00
Refringe
622949cd83
Auto-formatting Sweep 2023-11-15 21:12:40 -05:00
Refringe
0793df60c2
Formatting Change - Space is now given around object properties. 2023-11-13 12:38:16 -05:00
Refringe
7533d33358
Formatting Change - Operator positions are now at the start of the next line (for multi-line statements). 2023-11-13 12:29:16 -05:00
Refringe
3f2d36a2fc
Formatting for loader classes. 2023-11-13 11:10:44 -05:00
TheSparta
09a64b801a fixed lint/style/noNonNullAssertion 2023-11-08 19:53:01 +00:00
TheSparta
3eee163aae fixed lint/complexity/noForEach 2023-11-08 19:51:52 +00:00
Dev
214e81ba83 Merge branch '3.8.0' of https://dev.sp-tarkov.com/SPT-AKI/Server into testing-redux 2023-11-06 14:54:34 +00:00
TheSparta
a244e89abe Skip mods that are duplicated (!165)
- Instead of loading duplicated mods, it now skips all of them.
- Changed a few localisation strings, deleted the ones that became outdated.

Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/165
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-11-06 14:51:31 +00:00
TheSparta
f354811ca8 A few changes to Watermark and Error Handling
- Made it so Watermark doesn't initialize on the constructor, this makes it possible for tests to use `@spt-aki/di/Container`;
- Removed unnecessary calls to `ErrorHandler.handleCriticalError`, all you really need to do is `throw new Error()` and it'll get caught automatically.
2023-10-29 22:20:33 +00:00
Dev
3f07fc1bfc Cleanup of async method names
Add method comments
Reduction of code complexity inside `executeModsAsync()`
Add error message when loaded mod has no `main` property
2023-10-20 12:23:19 +01:00
TheSparta
418d9f2a8f Import path alias on the whole project (!157)
- Ability to use @spt-aki path alias on the whole project.
- Swapped all imports from relative paths, for imports using the path alias.

Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/157
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-19 17:21:17 +00:00
Dev
5af4abab91 Handle critical errors on mod load better - show player error in console instead of closing it on error 2023-10-19 15:25:52 +01:00
Dev
6589bcc0a2 Show human readable error when two mods have conflciting load order requirements
Improve cyclic error message text
2023-10-19 15:18:07 +01:00
Dev
e8d3fb805e updates to modLoadOrder 2023-10-18 17:36:36 +01:00
TheSparta
6231d73109 Implemented loadBefore and loadAfter (!156)
This PR adds the ability to set `loadBefore` and `loadAfter` on a mod's package.json, this allows for modders to define an array of mods their current mod needs to load before or after.

Examples:

if we have <u>__MOD1__</u> that has `loadAfter` = `[ "MOD2" ]` the loading order would be:

1 - MOD2
2 - MOD1

if we have <u>__MOD2__</u> that has `loadBefore` = `[ "MOD1" ]` the loading order would also be:
1 - MOD2
2 - MOD1

Begone zzzzzz, name your mods the way you want to.

Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/156
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-18 14:44:29 +00:00
TheSparta
723f8db572 Updated dependencies + A few other things (!150)
Initially this was going to be an update to dependencies but it seems i got a little carried away!

Anyways this PR removes 2 unused dependencies (`jshint` and `utf-8-validate`), and 2 other, `del` and `fs-extra` that were replaced by the built-in `fs/promises`.

It also renames all `tsconfig` and `Dockerfile` files, in a way that when viewed in a file tree sorted alphabetically they will be next to each other.

It also updates the typescript target to `ES2022`, and changes moduleResolution from `Node` to `Node10` (this isn't an update, they are the same thing but `Node` is now deprecated).

It also adds the `node:` discriminator to every import from built-in modules.

It also has major changes to the build script, `del` and `fs-extra` were only being used in the build script, it's now using `fs/promises` instead, cleaned up the code from some functions, adds better documentation to a few functions, and renames some gulp tasks and npm scripts to better represent what they actually do.

And finally it updates dependencies, except for `atomically` which can't be updated unless the project switches to ESM.

Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/150
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-14 09:01:41 +00:00
Dev
87e2948806 Remove scripts content from imported mods package data 2023-10-14 09:48:24 +01:00
Dev
f67c4293d8 Merge used profile mods onto a single record for each mod by name, choosing newest 2023-10-10 17:01:29 +01:00
chomp
0b67a9a0e9 0.13.5.0 (!147)
Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Co-authored-by: Terkoiz <terkoiz@noreply.dev.sp-tarkov.com>
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-authored-by: Refringe <refringe@noreply.dev.sp-tarkov.com>
Co-authored-by: Kaeno <e>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/147
2023-10-10 11:03:20 +00:00
chomp
c1a4c544bc Add JSONC support to server configs + use by modders (!112)
Replaced calls (where possible) to JSON.parse/stringify with use of `jsonUtil` functions
`VFS.ts` was tricky, it can't be updated as it'd create a circular dependency

Also add json5 to package.json for modders to have access to

Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/112
2023-08-09 10:49:45 +00:00
Dev
3876e1ae15 Pull mod sorting code into its own function 2023-08-02 08:50:04 +01:00
Dev
1617617cf2 Improve localisation to reduce confusion that server mods are loaded, not client and server mods
Small comment typo fix
2023-07-22 11:46:38 +01:00
Dev
5d20b6b781 Further comment improvements 2023-07-15 11:00:35 +01:00
Dev
28ca90b02c Convert duplicate mods into comma separated string prior to being logged in checkForDuplicateMods() 2023-06-26 07:39:22 +01:00
Aria Adair
eb9af28c1b Make it possible to dynamically add bundles. (!87)
I'm experimenting around with this to allow for loading bundles from ZIP files to help with texture pack distribution, wanted to get it out in front of folks for review.

Co-authored-by: Ari <a@silversupre.me>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/87
Co-authored-by: Aria Adair <gaylatea@noreply.dev.sp-tarkov.com>
Co-committed-by: Aria Adair <gaylatea@noreply.dev.sp-tarkov.com>
2023-04-23 09:50:52 +00:00
Dev
e1310d74ca Add Repo 2023-03-03 15:23:46 +00:00