feat: 清理openspec

This commit is contained in:
npc0-hue
2026-08-20 17:58:36 +08:00
parent 49669a9d5d
commit 40b35b05c7
522 changed files with 168 additions and 19538 deletions
+6 -22
View File
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import type { GamePluginResponse, ServerInstanceResponse } from "../api/types";
import { defaultServerCreateForm, runtimeBindingFields } from "../contracts/serverManagement";
import { defaultServerCreateForm } from "../contracts/serverManagement";
import { minimalServerCreateRequestFromForm, serverCreateRequestFromForm, serverInstanceIdFromName, serverLifecycleCommandRequest } from "./serverManagement";
const plugin: GamePluginResponse = {
@@ -42,27 +42,14 @@ const plugin: GamePluginResponse = {
};
describe("runtime profile server creation contracts", () => {
it("derives logical binding fields from the selected profile", () => {
expect(runtimeBindingFields(plugin, "local")).toEqual([
{ key: "java-runtime", required: false, sensitive: false },
{ key: "log-source", required: true, sensitive: false },
{ key: "package-source", required: false, sensitive: false },
{ key: "rcon.password", required: true, sensitive: true },
{ key: "server-root", required: true, sensitive: false }
]);
expect(runtimeBindingFields(plugin, "local").some((field) => field.key === "ftp.profile")).toBe(false);
});
it("submits deployment inputs without binding a Run or runtime profile", () => {
const form = defaultServerCreateForm([plugin], []);
expect(form.profileKey).toBe("local");
const form = defaultServerCreateForm([plugin]);
expect(
serverCreateRequestFromForm(
{
...form,
id: " server-1 ",
name: " Runtime Server ",
bindings: { "server-root": " runtime.server-root ", "rcon.password": " secret://runtime/server-1/rcon ", "java-runtime": " " }
},
17
)
@@ -79,13 +66,10 @@ describe("runtime profile server creation contracts", () => {
});
it("maps the create UI to a minimal server request", () => {
const form = defaultServerCreateForm([plugin], []);
const form = defaultServerCreateForm([plugin]);
const request = minimalServerCreateRequestFromForm({
...form,
name: " Minimal Runtime Server ",
deploymentTargetId: "run-builder",
runEndpointId: "run-existing",
bindings: { "rcon.password": "secret://must-not-submit" },
serverRoot: "/srv/must-not-submit"
}, 16);
@@ -98,8 +82,8 @@ describe("runtime profile server creation contracts", () => {
});
it("generates server instance ids from the visible server name", () => {
const form = defaultServerCreateForm([plugin], []);
const request = serverCreateRequestFromForm({ ...form, name: " Runtime Server ", bindings: {} }, 17);
const form = defaultServerCreateForm([plugin]);
const request = serverCreateRequestFromForm({ ...form, name: " Runtime Server " }, 17);
expect(request).toMatchObject({
id: "server-runtime-server-17",
@@ -119,7 +103,7 @@ describe("runtime profile server creation contracts", () => {
});
it("keeps complete paths and commands in a write-only deployment payload", () => {
const form = defaultServerCreateForm([plugin], []);
const form = defaultServerCreateForm([plugin]);
const request = serverCreateRequestFromForm({ ...form, name: "Venv Server", deploymentMode: "custom-command", serverRoot: "/srv/venv-server", workingDirectory: "/srv/venv-server", startCommand: "/srv/venv-server/.venv/bin/python server.py", shell: "" }, 19);
expect("runEndpointId" in request).toBe(false);
expect("profileKey" in request).toBe(false);