Skip to content

Merge InstallationRuleApplicator to InstallationRules #1746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: ei-no-installrule-files
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) => {
Expand Down
11 changes: 10 additions & 1 deletion src/r2mm/installing/InstallationRules.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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),
Expand All @@ -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) {
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions test/jest/__utils__/InstallLogicUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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");
}
Expand Down
Loading