mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 22:55:24 +00:00
feat: make each plugin an npm workspace built by a termix-plugin CLI
This commit is contained in:
1 parent
4758016f41
commit
5796186a1c
448 files changed
+3087
-2003
No files matched your search
@@ -0,0 +1,11 @@
|
||||
import type { PluginContext } from "@termix/plugin-sdk/backend";
|
||||
import { startProxmoxService, stopProxmoxService } from "./routes.js";
|
||||
|
||||
export async function activate(ctx: PluginContext) {
|
||||
startProxmoxService();
|
||||
ctx.log.info("Proxmox router registered at /proxmox");
|
||||
}
|
||||
|
||||
export async function deactivate() {
|
||||
stopProxmoxService();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Pure decision: which auth settings an imported Proxmox guest inherits.
|
||||
//
|
||||
// The frontend carries a parallel copy in
|
||||
// plugins/proxmox/frontend/proxmox-import-auth.ts. The two drifting apart is
|
||||
// what produced the reported import bug, so both are kept behaviourally
|
||||
// identical and each is unit-tested against the same matrix.
|
||||
export function resolveProxmoxImportAuth(
|
||||
defaultAuthType: string | undefined,
|
||||
credentialId: number | null | undefined,
|
||||
): {
|
||||
authType: string;
|
||||
credentialId: number | null;
|
||||
overrideCredentialUsername: number;
|
||||
} {
|
||||
// An explicit special auth type (none/opkssh/tailscale/vault/…) wins.
|
||||
if (
|
||||
defaultAuthType &&
|
||||
defaultAuthType !== "credential" &&
|
||||
!["password", "key"].includes(defaultAuthType)
|
||||
) {
|
||||
return {
|
||||
authType: defaultAuthType,
|
||||
credentialId: null,
|
||||
overrideCredentialUsername: 0,
|
||||
};
|
||||
}
|
||||
|
||||
// A credential (configured default OR inherited from the source host) is a
|
||||
// concrete auth source -> use it, even when defaultAuthType is the
|
||||
// "password"/"key" default.
|
||||
if (credentialId) {
|
||||
return {
|
||||
authType: "credential",
|
||||
credentialId,
|
||||
overrideCredentialUsername: 0,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
authType: "none",
|
||||
credentialId: null,
|
||||
overrideCredentialUsername: 0,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
export function parseProxmoxJumpHosts(raw: unknown): unknown[] | null {
|
||||
if (!raw) return null;
|
||||
if (Array.isArray(raw)) return raw;
|
||||
if (typeof raw !== "string") return null;
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(raw);
|
||||
return Array.isArray(parsed) ? parsed : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function serializeProxmoxJumpHosts(raw: unknown): string | null {
|
||||
const parsed = parseProxmoxJumpHosts(raw);
|
||||
return parsed ? JSON.stringify(parsed) : null;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user