From 1d76d351c41ddb054118066e3be954c67c9708f9 Mon Sep 17 00:00:00 2001 From: Cade Ayres Date: Sun, 16 Apr 2023 18:12:32 +0100 Subject: [PATCH] Added yml/yaml file support to the config editor --- .../config-components/ConfigSelectionLayout.vue | 8 ++++---- src/r2mm/mods/ProfileModList.ts | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/config-components/ConfigSelectionLayout.vue b/src/components/config-components/ConfigSelectionLayout.vue index 9c5219202..2fd5116c8 100644 --- a/src/components/config-components/ConfigSelectionLayout.vue +++ b/src/components/config-components/ConfigSelectionLayout.vue @@ -68,6 +68,7 @@ import ConfigSort from '../../r2mm/configs/ConfigSort'; import FsProvider from '../../providers/generic/file/FsProvider'; import ManagerInformation from '../../_managerinf/ManagerInformation'; import LinkProvider from '../../providers/components/LinkProvider'; +import ProfileModList from '../../r2mm/mods/ProfileModList'; @Component({ components: { @@ -109,6 +110,7 @@ import LinkProvider from '../../providers/components/LinkProvider'; return; } tree.removeDirectories("dotnet"); + tree.removeDirectories("_state"); tree.navigateAndPerform(plugins => { plugins.getDirectories().forEach(value => { plugins.navigateAndPerform(sub => { @@ -118,11 +120,9 @@ import LinkProvider from '../../providers/components/LinkProvider'; }); }, "BepInEx", "plugins"); const files = tree.getDirectories().flatMap(value => value.getRecursiveFiles()); + const supportedExtensions = ProfileModList.SUPPORTED_CONFIG_FILE_EXTENSIONS; for (const file of files) { - if (path.extname(file).toLowerCase() === '.cfg' || path.extname(file).toLowerCase() === '.txt') { - const fileStat = await fs.lstat(file); - this.configFiles.push(new ConfigFile(file.substring(configLocation.length + 1), file, fileStat.mtime)); - } else if (path.extname(file).toLowerCase() === '.json') { + if (supportedExtensions.includes(path.extname(file).toLowerCase())) { const fileStat = await fs.lstat(file); this.configFiles.push(new ConfigFile(file.substring(configLocation.length + 1), file, fileStat.mtime)); } diff --git a/src/r2mm/mods/ProfileModList.ts b/src/r2mm/mods/ProfileModList.ts index 5084ed8d9..d42e2ccff 100644 --- a/src/r2mm/mods/ProfileModList.ts +++ b/src/r2mm/mods/ProfileModList.ts @@ -26,6 +26,8 @@ import { ProfileApiClient } from '../profiles/ProfilesClient'; export default class ProfileModList { + public static SUPPORTED_CONFIG_FILE_EXTENSIONS = [".cfg", ".txt", ".json", ".yml", ".yaml"]; + private static lock = new AsyncLock(); public static async requestLock(fn: () => any) { @@ -195,6 +197,7 @@ export default class ProfileModList { return tree; } tree.removeDirectories("dotnet"); + tree.removeDirectories("_state"); tree.navigateAndPerform(bepInExDir => { bepInExDir.removeDirectories("config"); bepInExDir.navigateAndPerform(pluginDir => { @@ -205,7 +208,7 @@ export default class ProfileModList { // Add all tree contents to buffer. for (const file of tree.getRecursiveFiles()) { const fileLower = file.toLowerCase(); - if (fileLower.endsWith(".cfg") || fileLower.endsWith(".txt") || fileLower.endsWith(".json")) { + if (this.SUPPORTED_CONFIG_FILE_EXTENSIONS.filter(value => fileLower.endsWith(value)).length > 0) { await builder.addBuffer(path.relative(profile.getPathOfProfile(), file), await FsProvider.instance.readFile(file)); } }