feat: support custom server deployment drafts

This commit is contained in:
npc0-hue
2026-07-24 16:56:28 +08:00
parent 292b380f3c
commit 220ef91a8e
36 changed files with 1520 additions and 85 deletions
+34 -10
View File
@@ -1,8 +1,9 @@
import type {
GamePluginResponse,
JobResponse,
RunEndpointResponse,
ServerInstanceResponse,
GamePluginResponse,
JobResponse,
RunEndpointResponse,
ServerDeploymentMode,
ServerInstanceResponse,
ServerInstanceState
} from "../api/types";
@@ -15,8 +16,17 @@ export interface ServerCreateFormState {
name: string;
pluginId: string;
runEndpointId: string;
profileKey: string;
bindings: Record<string, string>;
profileKey: string;
bindings: Record<string, string>;
createInputs: Record<string, string>;
deploymentMode: ServerDeploymentMode;
serverRoot: string;
workingDirectory: string;
installCommand: string;
startCommand: string;
stopCommand: string;
statusCommand: string;
shell: "" | "posix-sh" | "powershell" | "cmd";
}
export interface RuntimeBindingField {
@@ -55,8 +65,17 @@ export const emptyServerCreateForm: ServerCreateFormState = {
name: "",
pluginId: "",
runEndpointId: "",
profileKey: "",
bindings: {}
profileKey: "",
bindings: {},
createInputs: {},
deploymentMode: "guided-install",
serverRoot: "",
workingDirectory: "",
installCommand: "",
startCommand: "",
stopCommand: "",
statusCommand: "",
shell: ""
};
export function summarizeServerManagement(instances: ServerInstanceResponse[], jobs: JobResponse[]): ServerManagementSummary {
@@ -104,8 +123,13 @@ export function defaultServerCreateForm(plugins: GamePluginResponse[], endpoints
...emptyServerCreateForm,
pluginId: plugin?.id ?? "",
profileKey: plugin?.runtimeProfiles?.lifecycleProfiles?.[0]?.key ?? "",
runEndpointId: endpoints[0]?.id ?? ""
};
runEndpointId: "",
createInputs: pluginCreateInputDefaults(plugin)
};
}
export function pluginCreateInputDefaults(plugin: GamePluginResponse | undefined): Record<string, string> {
return Object.fromEntries((plugin?.createFields ?? []).map((field) => [field.key, field.defaultValue ?? ""]));
}
export function runtimeBindingFields(plugin: GamePluginResponse | undefined, profileKey: string): RuntimeBindingField[] {