Remove legacy runtime deployment paths
This commit is contained in:
@@ -3,7 +3,16 @@ import { type CSSProperties, type FormEvent, useCallback, useEffect, useMemo, us
|
||||
import { createPortal } from "react-dom";
|
||||
|
||||
import { platformApiClient } from "../api/client";
|
||||
import type { GamePluginResponse, JobResponse, RunEndpointResponse, ServerInstanceResponse, ServerMetricsResponse } from "../api/types";
|
||||
import type {
|
||||
DependencyCatalogResponse,
|
||||
DependencyPlanViewResponse,
|
||||
DependencyProbeViewResponse,
|
||||
GamePluginResponse,
|
||||
JobResponse,
|
||||
RunEndpointResponse,
|
||||
ServerInstanceResponse,
|
||||
ServerMetricsResponse
|
||||
} from "../api/types";
|
||||
import {
|
||||
RuntimeTaskProgressDialog,
|
||||
type RuntimeTaskDialogAction,
|
||||
@@ -21,8 +30,8 @@ import type { PageComponentProps } from "../contracts/page";
|
||||
import {
|
||||
canDeleteServer,
|
||||
defaultServerCreateForm,
|
||||
pluginCreateInputDefaults,
|
||||
runtimeObservationFreshness,
|
||||
pluginCreateInputDefaults,
|
||||
runtimeObservationFreshness,
|
||||
type ServerCreateFormState
|
||||
} from "../contracts/serverManagement";
|
||||
import { summarizeServerOperations } from "../contracts/operationsConsole";
|
||||
@@ -223,11 +232,11 @@ export function ServersPage({ session, operations, onNavigate }: PageComponentPr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function openRunTargetSelection(instance: ServerInstanceResponse) {
|
||||
const defaults = quickRuntimeDefaultsForPlugin(instance.pluginId);
|
||||
const plugin = plugins.find((item) => item.id === instance.pluginId);
|
||||
const targetOs = runPlatformOptions(plugin, "linux")[0] ?? "linux";
|
||||
setRuntimeTaskActions([]);
|
||||
setRunTargetSelection({ instance, targetOs: defaults.runOs, targetArch: "amd64" });
|
||||
setRunTargetSelection({ instance, targetOs, targetArch: "amd64" });
|
||||
}
|
||||
|
||||
async function handleRunTargetSubmit(event: FormEvent<HTMLFormElement>) {
|
||||
@@ -292,7 +301,6 @@ export function ServersPage({ session, operations, onNavigate }: PageComponentPr
|
||||
return;
|
||||
}
|
||||
}
|
||||
const defaults = quickRuntimeDefaultsForPlugin(instance.pluginId);
|
||||
const intent = quickRuntimeActionLabel(action);
|
||||
const operationId = operations.begin({ intent, targetKind: "server", targetId: `${instance.id}:${action}`, requester: session.displayName });
|
||||
setRuntimeTaskActions([]);
|
||||
@@ -300,40 +308,40 @@ export function ServersPage({ session, operations, onNavigate }: PageComponentPr
|
||||
await requireQuickRuntimeActionAvailable(instance.id, action);
|
||||
let message: string;
|
||||
message = await runtimeTask.runTask({
|
||||
title: intent,
|
||||
description: quickRuntimeTaskDescription(instance, action),
|
||||
stages: quickRuntimeStages(action),
|
||||
executeStageIndex: quickRuntimeExecuteStageIndex(action),
|
||||
execute: async () => {
|
||||
if (action === "download-run") {
|
||||
title: intent,
|
||||
description: quickRuntimeTaskDescription(instance, action),
|
||||
stages: quickRuntimeStages(action),
|
||||
executeStageIndex: quickRuntimeExecuteStageIndex(action),
|
||||
execute: async () => {
|
||||
if (action === "download-run") {
|
||||
const reference = await platformApiClient.downloadLatestRunDistribution(instance.id);
|
||||
await downloadArtifactReference(reference, (artifactId) => platformApiClient.downloadArtifactContent(artifactId));
|
||||
return `run 下载已开始,artifact ${reference.artifactId},文件 ${safeArtifactFilename(reference.filename)}`;
|
||||
}
|
||||
if (action === "push-run-update") {
|
||||
}
|
||||
if (action === "push-run-update") {
|
||||
const reference = await platformApiClient.downloadLatestRunDistribution(instance.id);
|
||||
const update = await platformApiClient.pushRunUpdate(instance.id, runUpdateRequest(instance.id, reference.artifactId, reference.checksum));
|
||||
return `run 更新任务已排队,job ${update.jobId ?? update.id}`;
|
||||
}
|
||||
if (action === "reset-run-key") {
|
||||
}
|
||||
if (action === "reset-run-key") {
|
||||
const key = await platformApiClient.resetRunKey(instance.id);
|
||||
return `run 密钥已重置到第 ${key.generation} 代,旧 run 会话已失效,请重新生成并部署 run`;
|
||||
}
|
||||
if (action === "dependencies-check") {
|
||||
const job = await platformApiClient.checkDependencies(instance.id, dependencyJobRequest(instance.id, defaults.probeKey));
|
||||
return `依赖检查任务已排队,job ${job.id}`;
|
||||
}
|
||||
if (action === "dependencies-install") {
|
||||
}
|
||||
if (action === "dependencies-check") {
|
||||
const catalog = await platformApiClient.getDependencyCatalog(instance.id);
|
||||
const plan = catalog.plans.find((candidate) => candidate.key === defaults.installPlanKey);
|
||||
const probe = catalog.probes.find((candidate) => candidate.key === defaults.probeKey);
|
||||
if (!plan || probe?.installPlanKey !== plan.key) throw new Error("Platform 未返回与当前 probe 匹配的审核安装计划");
|
||||
const probe = firstDependencyProbe(catalog);
|
||||
const job = await platformApiClient.checkDependencies(instance.id, dependencyJobRequest(instance.id, probe.key));
|
||||
return `依赖检查任务已排队,job ${job.id}`;
|
||||
}
|
||||
if (action === "dependencies-install") {
|
||||
const catalog = await platformApiClient.getDependencyCatalog(instance.id);
|
||||
const { probe, plan } = firstInstallableDependency(catalog);
|
||||
const job = await platformApiClient.installDependencies(instance.id, dependencyJobRequest(instance.id, probe.key, plan.key, plan.digest));
|
||||
return `依赖安装任务已排队,job ${job.id}`;
|
||||
}
|
||||
throw new Error("该运行操作已下线");
|
||||
}
|
||||
});
|
||||
throw new Error("该运行操作已下线");
|
||||
}
|
||||
});
|
||||
operations.succeed(operationId, message);
|
||||
runtimeTask.succeedTask(message);
|
||||
await refresh();
|
||||
@@ -905,15 +913,6 @@ function quickRuntimeTaskDescription(instance: ServerInstanceResponse, action: S
|
||||
return `${instance.name}(${instance.id})${label},通过平台 API 派发并保留可追踪进度。`;
|
||||
}
|
||||
|
||||
function quickRuntimeDefaultsForPlugin(pluginId: string) {
|
||||
const isScum = pluginId.toLowerCase().includes("scum");
|
||||
return {
|
||||
runOs: isScum ? "windows" : "linux",
|
||||
probeKey: isScum ? "steamcmd" : "java-21",
|
||||
installPlanKey: isScum ? "install-steamcmd-linux" : "install-java-linux"
|
||||
};
|
||||
}
|
||||
|
||||
export function runPlatformOptions(plugin: GamePluginResponse | undefined, fallback: string): string[] {
|
||||
const options = new Set<string>();
|
||||
const add = (value: string | undefined) => {
|
||||
@@ -932,6 +931,21 @@ export function runPlatformOptions(plugin: GamePluginResponse | undefined, fallb
|
||||
return [...options];
|
||||
}
|
||||
|
||||
function firstDependencyProbe(catalog: DependencyCatalogResponse): DependencyProbeViewResponse {
|
||||
const probe = catalog.probes.find((candidate) => candidate.required) ?? catalog.probes[0];
|
||||
if (!probe) throw new Error("插件未声明可检查的运行依赖");
|
||||
return probe;
|
||||
}
|
||||
|
||||
function firstInstallableDependency(catalog: DependencyCatalogResponse): { probe: DependencyProbeViewResponse; plan: DependencyPlanViewResponse } {
|
||||
for (const probe of catalog.probes) {
|
||||
if (!probe.installPlanKey) continue;
|
||||
const plan = catalog.plans.find((candidate) => candidate.key === probe.installPlanKey);
|
||||
if (plan) return { probe, plan };
|
||||
}
|
||||
throw new Error("插件未声明可安装的运行依赖计划");
|
||||
}
|
||||
|
||||
function runPlatformLabel(platform: string): string {
|
||||
switch (platform) {
|
||||
case "linux":
|
||||
|
||||
Reference in New Issue
Block a user