Initial commit — SvelteKit fleet manager for T5 Plutonium servers
Ports push_scripts.sh (1497 lines of bash) to a SvelteKit + SQLite web app that manages a fleet of T5 Plutonium servers running on Komodo. Same push and beta workflow as the shell script, with a live SSE pipeline view, a !rt-token-gated auth modal that hard-pauses deployments on stale tokens, per-file audit diffs, and a Komodo-container deployment target. - Push/beta engines port the exact filter, held-by-beta, conflict, and stale-backup rules from the shell script - SQLite (better-sqlite3) replaces script_metadata.json; a one-shot importer moves legacy state over on first boot - 16 vitest tests cover push add/update/skip, beta open→rollback, open→promote, conflict guards, sweep frozen/manual branches, and IW4M login/status parsing - docker/ + komodo/stack.toml deploy as a managed container on the same host as the game servers, /root/zombies bind-mounted at the same path the shell script used
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
export interface Fixture {
|
||||
root: string;
|
||||
shared: string;
|
||||
staging: string;
|
||||
t5: string;
|
||||
dbPath: string;
|
||||
cleanup: () => Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a zombies/ tree in a temp dir and point env at it BEFORE the code
|
||||
* under test is imported. Returns paths + a cleanup fn.
|
||||
*/
|
||||
export async function newFixture(files: Record<string, string> = {}, servers: string[] = ['t5_kino_1']): Promise<Fixture> {
|
||||
const root = await mkdtemp(join(tmpdir(), 'cherry-'));
|
||||
const shared = join(root, 'shared/scripts');
|
||||
const staging = join(shared, 'betas');
|
||||
const t5 = join(root, 't5');
|
||||
const dbPath = join(root, 'cherry.db');
|
||||
await mkdir(staging, { recursive: true });
|
||||
await mkdir(t5, { recursive: true });
|
||||
|
||||
for (const [rel, body] of Object.entries(files)) {
|
||||
const p = join(shared, rel);
|
||||
await mkdir(join(p, '..'), { recursive: true });
|
||||
await writeFile(p, body);
|
||||
}
|
||||
for (const s of servers) {
|
||||
await mkdir(join(t5, s, 'runtime/plutonium/storage/t5/raw/scripts/sp'), { recursive: true });
|
||||
}
|
||||
|
||||
process.env.SHARED_SCRIPTS = shared;
|
||||
process.env.SERVERS_ROOT = t5;
|
||||
process.env.REL_DEST = 'runtime/plutonium/storage/t5/raw/scripts/sp';
|
||||
process.env.DB_PATH = dbPath;
|
||||
process.env.DEPLOY_KEEP_DAYS = '7';
|
||||
process.env.HTTP_TIMEOUT_MS = '2000';
|
||||
|
||||
return {
|
||||
root,
|
||||
shared,
|
||||
staging,
|
||||
t5,
|
||||
dbPath,
|
||||
cleanup: async () => {
|
||||
// On Windows the SQLite handle keeps a lock on cherry.db-shm/wal
|
||||
// and rmdir refuses to remove the temp tree. Close the singleton
|
||||
// (if this test imported it) before removing the dir. Fresh
|
||||
// dynamic import so we grab whatever handle the test opened.
|
||||
try {
|
||||
const mod = (await import('../../src/lib/server/db/index.js')) as {
|
||||
closeDb: () => void;
|
||||
};
|
||||
mod.closeDb();
|
||||
} catch {
|
||||
/* db module was never loaded — nothing to close */
|
||||
}
|
||||
await rm(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Fresh module-level state. Vitest caches modules per file — this forces a
|
||||
* re-import so the tests can rebuild the singleton DB handle against a new
|
||||
* fixture.
|
||||
*/
|
||||
export async function importFresh<T>(mod: string): Promise<T> {
|
||||
return (await import(`${mod}?t=${Date.now()}${Math.random()}`)) as T;
|
||||
}
|
||||
Reference in New Issue
Block a user