Skip to content

Commit 1b1d416

Browse files
IMB11Prospector
andauthored
refactor: Huge pyro servers composable cleanup (#3745)
* refactor: start refactor of pyro servers module-based class * refactor: finish modules * refactor: start on type checking + matching api * refactor: finish pyro servers composable refactor * refactor: pyro -> modrinth * fix: import not refactored * fix: broken power action enums * fix: remove pyro mentions * fix: lint * refactor: fix option pages * fix: error renames * remove empty pyro-servers.ts file --------- Signed-off-by: IMB11 <hendersoncal117@gmail.com> Co-authored-by: Prospector <prospectordev@gmail.com>
1 parent 6955731 commit 1b1d416

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1791
-2513
lines changed

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/frontend/src/components/ui/servers/BackupCreateModal.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@
4545
import { ref, nextTick, computed } from "vue";
4646
import { ButtonStyled, NewModal } from "@modrinth/ui";
4747
import { IssuesIcon, PlusIcon, XIcon } from "@modrinth/assets";
48+
import { ModrinthServersFetchError, type ServerBackup } from "@modrinth/utils";
49+
import { ModrinthServer } from "~/composables/servers/modrinth-servers.ts";
4850
4951
const props = defineProps<{
50-
server: Server<["general", "content", "backups", "network", "startup", "ws", "fs"]>;
52+
server: ModrinthServer;
5153
}>();
5254
5355
const modal = ref<InstanceType<typeof NewModal>>();
@@ -64,7 +66,7 @@ const trimmedName = computed(() => backupName.value.trim());
6466
const nameExists = computed(() => {
6567
if (!props.server.backups?.data) return false;
6668
return props.server.backups.data.some(
67-
(backup) => backup.name.trim().toLowerCase() === trimmedName.value.toLowerCase(),
69+
(backup: ServerBackup) => backup.name.trim().toLowerCase() === trimmedName.value.toLowerCase(),
6870
);
6971
});
7072
@@ -98,7 +100,7 @@ const createBackup = async () => {
98100
hideModal();
99101
await props.server.refresh();
100102
} catch (error) {
101-
if (error instanceof PyroFetchError && error.statusCode === 429) {
103+
if (error instanceof ModrinthServersFetchError && error?.statusCode === 429) {
102104
isRateLimited.value = true;
103105
addNotification({
104106
type: "error",

apps/frontend/src/components/ui/servers/BackupDeleteModal.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@
2020
<script setup lang="ts">
2121
import { ref } from "vue";
2222
import { ConfirmModal } from "@modrinth/ui";
23-
import type { Server } from "~/composables/pyroServers";
23+
import type { Backup } from "@modrinth/utils";
2424
import BackupItem from "~/components/ui/servers/BackupItem.vue";
2525
26-
defineProps<{
27-
server: Server<["general", "content", "backups", "network", "startup", "ws", "fs"]>;
28-
}>();
29-
3026
const emit = defineEmits<{
3127
(e: "delete", backup: Backup | undefined): void;
3228
}>();

apps/frontend/src/components/ui/servers/BackupItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
import { ButtonStyled, commonMessages, OverflowMenu, ProgressBar } from "@modrinth/ui";
1818
import { defineMessages, useVIntl } from "@vintl/vintl";
1919
import { ref } from "vue";
20-
import type { Backup } from "~/composables/pyroServers.ts";
20+
import type { Backup } from "@modrinth/utils";
2121
2222
const flags = useFeatureFlags();
2323
const { formatMessage } = useVIntl();

apps/frontend/src/components/ui/servers/BackupRenameModal.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@
4848
import { ref, nextTick, computed } from "vue";
4949
import { ButtonStyled, NewModal } from "@modrinth/ui";
5050
import { SpinnerIcon, SaveIcon, XIcon, IssuesIcon } from "@modrinth/assets";
51-
import type { Server } from "~/composables/pyroServers";
51+
import type { Backup } from "@modrinth/utils";
52+
import { ModrinthServer } from "~/composables/servers/modrinth-servers.ts";
5253
5354
const props = defineProps<{
54-
server: Server<["general", "content", "backups", "network", "startup", "ws", "fs"]>;
55+
server: ModrinthServer;
5556
}>();
5657
5758
const modal = ref<InstanceType<typeof NewModal>>();
@@ -70,7 +71,7 @@ const nameExists = computed(() => {
7071
}
7172
7273
return props.server.backups.data.some(
73-
(backup) => backup.name.trim().toLowerCase() === trimmedName.value.toLowerCase(),
74+
(backup: Backup) => backup.name.trim().toLowerCase() === trimmedName.value.toLowerCase(),
7475
);
7576
});
7677

apps/frontend/src/components/ui/servers/BackupRestoreModal.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
<script setup lang="ts">
2020
import { ref } from "vue";
2121
import { ConfirmModal, NewModal } from "@modrinth/ui";
22-
import type { Server } from "~/composables/pyroServers";
22+
import type { Backup } from "@modrinth/utils";
2323
import BackupItem from "~/components/ui/servers/BackupItem.vue";
24+
import { ModrinthServer } from "~/composables/servers/modrinth-servers.ts";
2425
2526
const props = defineProps<{
26-
server: Server<["general", "content", "backups", "network", "startup", "ws", "fs"]>;
27+
server: ModrinthServer;
2728
}>();
2829
2930
const modal = ref<InstanceType<typeof NewModal>>();

apps/frontend/src/components/ui/servers/BackupSettingsModal.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
import { ButtonStyled, NewModal } from "@modrinth/ui";
6060
import { XIcon, SaveIcon } from "@modrinth/assets";
6161
import { ref, computed } from "vue";
62-
import type { Server } from "~/composables/pyroServers";
62+
import { ModrinthServer } from "~/composables/servers/modrinth-servers.ts";
6363
6464
const props = defineProps<{
65-
server: Server<["backups"]>;
65+
server: ModrinthServer;
6666
}>();
6767
6868
const modal = ref<InstanceType<typeof NewModal>>();

apps/frontend/src/components/ui/servers/ContentVersionEditModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ import {
239239
import { Admonition, ButtonStyled, NewModal } from "@modrinth/ui";
240240
import TagItem from "@modrinth/ui/src/components/base/TagItem.vue";
241241
import { ref, computed } from "vue";
242-
import { formatCategory, formatVersionsForDisplay, type Version } from "@modrinth/utils";
242+
import { formatCategory, formatVersionsForDisplay, type Mod, type Version } from "@modrinth/utils";
243243
import Accordion from "~/components/ui/Accordion.vue";
244244
import Checkbox from "~/components/ui/Checkbox.vue";
245245
import ContentVersionFilter, {

apps/frontend/src/components/ui/servers/FilesUploadDropdown.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
import { FolderOpenIcon, CheckCircleIcon, XCircleIcon } from "@modrinth/assets";
100100
import { ButtonStyled } from "@modrinth/ui";
101101
import { ref, computed, watch, nextTick } from "vue";
102-
import type { FSModule } from "~/composables/pyroServers.ts";
102+
import { FSModule } from "~/composables/servers/modules/fs.ts";
103103
104104
interface UploadItem {
105105
file: File;

apps/frontend/src/components/ui/servers/FilesUploadZipUrlModal.vue

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@
7575
<script setup lang="ts">
7676
import { ExternalIcon, SpinnerIcon, DownloadIcon, XIcon } from "@modrinth/assets";
7777
import { BackupWarning, ButtonStyled, NewModal } from "@modrinth/ui";
78+
import { ModrinthServersFetchError } from "@modrinth/utils";
7879
import { ref, computed, nextTick } from "vue";
79-
import { handleError, type Server } from "~/composables/pyroServers.ts";
80+
import { handleError, ModrinthServer } from "~/composables/servers/modrinth-servers.ts";
8081
8182
const cf = ref(false);
8283
8384
const props = defineProps<{
84-
server: Server<["general", "content", "backups", "network", "startup", "ws", "fs"]>;
85+
server: ModrinthServer;
8586
}>();
8687
8788
const modal = ref<typeof NewModal>();
@@ -110,24 +111,18 @@ const handleSubmit = async () => {
110111
if (!error.value) {
111112
// hide();
112113
try {
113-
const dry = await props.server.fs?.extractFile(trimmedUrl.value, true, true);
114+
const dry = await props.server.fs.extractFile(trimmedUrl.value, true, true);
114115
115116
if (!cf.value || dry.modpack_name) {
116-
await props.server.fs?.extractFile(trimmedUrl.value, true, false, true);
117+
await props.server.fs.extractFile(trimmedUrl.value, true, false, true);
117118
hide();
118119
} else {
119120
submitted.value = false;
120121
handleError(
121-
new ServersError(
122+
new ModrinthServersFetchError(
122123
"Could not find CurseForge modpack at that URL.",
123-
undefined,
124-
undefined,
125-
undefined,
126-
{
127-
context: "Error installing modpack",
128-
error: `url: ${url.value}`,
129-
description: "Could not find CurseForge modpack at that URL.",
130-
},
124+
404,
125+
new Error(`No modpack found at ${url.value}`),
131126
),
132127
);
133128
}

0 commit comments

Comments
 (0)