diff --git a/src/App.vue b/src/App.vue index 642a5498d..e813c6007 100644 --- a/src/App.vue +++ b/src/App.vue @@ -42,7 +42,6 @@ import PlatformInterceptorProvider from './providers/generic/game/platform_inter import PlatformInterceptorImpl from './providers/generic/game/platform_interceptor/PlatformInterceptorImpl'; import ProfileInstallerProvider from './providers/ror2/installing/ProfileInstallerProvider'; import InstallationRules from './r2mm/installing/InstallationRules'; -import InstallationRuleApplicator from './r2mm/installing/default_installation_rules/InstallationRuleApplicator'; import GenericProfileInstaller from './r2mm/installing/profile_installers/GenericProfileInstaller'; import UtilityMixin from './components/mixins/UtilityMixin.vue'; import ErrorModal from './components/modals/ErrorModal.vue'; @@ -63,7 +62,7 @@ export default class App extends mixins(UtilityMixin) { this.hookModInstallingViaProtocol(); await this.checkCdnConnection(); - InstallationRuleApplicator.apply(); + InstallationRules.apply(); InstallationRules.validate(); ipcRenderer.once('receive-appData-directory', async (_sender: any, appData: string) => { diff --git a/src/r2mm/installing/InstallationRules.ts b/src/r2mm/installing/InstallationRules.ts index 0bd04522d..80efd6b7d 100644 --- a/src/r2mm/installing/InstallationRules.ts +++ b/src/r2mm/installing/InstallationRules.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import { InstallRule as ThunderstoreEcosystemInstallRule } from '../../assets/data/ecosystem.d'; +import { EcosystemSchema } from '../../model/schema/ThunderstoreSchema'; import R2Error from '../../model/errors/R2Error'; import GameManager from '../../model/game/GameManager'; import { GetInstallerIdForPlugin } from '../../model/installing/PackageLoader'; @@ -44,7 +45,7 @@ export function trackingMethodFromString(method: string): TrackingMethod { ); } -export function normalizeRuleSubtype(apiData: ThunderstoreEcosystemInstallRule): RuleSubtype { +function normalizeRuleSubtype(apiData: ThunderstoreEcosystemInstallRule): RuleSubtype { return { ...apiData, trackingMethod: trackingMethodFromString(apiData.trackingMethod), @@ -64,6 +65,14 @@ export default class InstallationRules { this._RULES = value; } + public static apply() { + this._RULES = EcosystemSchema.supportedGames.map((x) => ({ + gameName: x.internalFolderName, + rules: x.installRules.map(normalizeRuleSubtype), + relativeFileExclusions: x.relativeFileExclusions, + })); + } + public static validate() { GameManager.gameList.forEach(value => { if (this._RULES.find(rule => rule.gameName === value.internalFolderName) === undefined) { diff --git a/src/r2mm/installing/default_installation_rules/InstallationRuleApplicator.ts b/src/r2mm/installing/default_installation_rules/InstallationRuleApplicator.ts deleted file mode 100644 index f001338e2..000000000 --- a/src/r2mm/installing/default_installation_rules/InstallationRuleApplicator.ts +++ /dev/null @@ -1,13 +0,0 @@ -import InstallationRules, { normalizeRuleSubtype } from '../InstallationRules'; -import { EcosystemSchema } from '../../../model/schema/ThunderstoreSchema'; - -export default class InstallationRuleApplicator { - - public static apply() { - InstallationRules.RULES = EcosystemSchema.supportedGames.map((x) => ({ - gameName: x.internalFolderName, - rules: x.installRules.map(normalizeRuleSubtype), - relativeFileExclusions: x.relativeFileExclusions, - })); - } -} diff --git a/test/jest/__utils__/InstallLogicUtils.ts b/test/jest/__utils__/InstallLogicUtils.ts index cac3bfede..b8da28d83 100644 --- a/test/jest/__utils__/InstallLogicUtils.ts +++ b/test/jest/__utils__/InstallLogicUtils.ts @@ -13,7 +13,7 @@ import ConflictManagementProvider from '../../../src/providers/generic/installin import ProfileInstallerProvider from '../../../src/providers/ror2/installing/ProfileInstallerProvider'; import ProfileProvider from '../../../src/providers/ror2/model_implementation/ProfileProvider'; import ConflictManagementProviderImpl from '../../../src/r2mm/installing/ConflictManagementProviderImpl'; -import InstallationRuleApplicator from '../../../src/r2mm/installing/default_installation_rules/InstallationRuleApplicator'; +import InstallationRules from '../../../src/r2mm/installing/InstallationRules'; import GenericProfileInstaller from '../../../src/r2mm/installing/profile_installers/GenericProfileInstaller'; import PathResolver from '../../../src/r2mm/manager/PathResolver'; @@ -47,7 +47,7 @@ export async function installLogicBeforeEach(internalFolderName: string) { await inMemoryFs.mkdirs(Profile.getActiveProfile().getProfilePath()); ProfileInstallerProvider.provide(() => new GenericProfileInstaller()); - InstallationRuleApplicator.apply(); + InstallationRules.apply(); ConflictManagementProvider.provide(() => new ConflictManagementProviderImpl()); InMemoryFsProvider.setMatchMode("CASE_SENSITIVE"); }