Add Prettier and ESLint tooling (Refs #77)

This commit is contained in:
2026-10-09 15:56:13 -04:00
parent 8ed059b8d3
commit 16469e2d43
711 changed files with 99737 additions and 28286 deletions
+36 -13
View File
@@ -15,7 +15,8 @@ beforeEach(async () => {
vi.stubEnv('RCON_PASSWORD', '');
const { seedServerRegistry } = await import('../../src/lib/server/fleet/servers.js');
await seedServerRegistry();
for (const server of servers) await mkdir(join(fixture.t5, server, 'configs'), { recursive: true });
for (const server of servers)
await mkdir(join(fixture.t5, server, 'configs'), { recursive: true });
});
afterEach(async () => {
@@ -25,22 +26,32 @@ afterEach(async () => {
describe('map selection through config lifecycle', () => {
it('uses each server map on beta, promotion, and drift repair without map overlays', async () => {
const { createScript, getLatestVersion } = await import('../../src/lib/server/fleet/scripts.js');
const { createScript, getLatestVersion } =
await import('../../src/lib/server/fleet/scripts.js');
const { openBeta, promoteBeta } = await import('../../src/lib/server/fleet/beta.js');
const { scanServerDrift, runDriftDeployment } = await import('../../src/lib/server/fleet/drift.js');
const { scanServerDrift, runDriftDeployment } =
await import('../../src/lib/server/fleet/drift.js');
const { db } = await import('../../src/lib/server/db/index.js');
const { script } = createScript({
name: 'baseline', kind: 'baseline', scopeType: 'game', scopeValue: 't5',
name: 'baseline',
kind: 'baseline',
scopeType: 'game',
scopeValue: 't5',
content: Buffer.from('set sv_voice "1"\nset sv_maprotation "map zombie_moon"\n')
});
const version = getLatestVersion(script.id)!;
const { betaId } = await openBeta({
scripts: [{ scriptId: script.id, scriptVersionId: version.id }],
servers: [servers[0]], waitForHealth: false, waitForMatch: false
servers: [servers[0]],
waitForHealth: false,
waitForMatch: false
});
await activateFiles('beta', betaId);
expect(await readFile(cfgPath(servers[0]), 'utf8')).toContain('set sv_maprotation "map zombie_theater"');
db().prepare("UPDATE beta_servers SET stage = 'ready', restarted_at = ? WHERE beta_id = ?")
expect(await readFile(cfgPath(servers[0]), 'utf8')).toContain(
'set sv_maprotation "map zombie_theater"'
);
db()
.prepare("UPDATE beta_servers SET stage = 'ready', restarted_at = ? WHERE beta_id = ?")
.run(new Date().toISOString(), betaId);
db().prepare("UPDATE betas SET state = 'ready-promote' WHERE id = ?").run(betaId);
const promoted = await promoteBeta(betaId);
@@ -60,24 +71,35 @@ describe('map selection through config lifecycle', () => {
});
it('preserves unrelated legacy overlay settings and restores exact prior config on rollback', async () => {
const { createScript, getLatestVersion } = await import('../../src/lib/server/fleet/scripts.js');
const { createScript, getLatestVersion } =
await import('../../src/lib/server/fleet/scripts.js');
const { openBeta, rollbackBeta } = await import('../../src/lib/server/fleet/beta.js');
const { db } = await import('../../src/lib/server/db/index.js');
const baseline = createScript({
name: 'baseline', kind: 'baseline', scopeType: 'game', scopeValue: 't5',
name: 'baseline',
kind: 'baseline',
scopeType: 'game',
scopeValue: 't5',
content: Buffer.from('set sv_voice "1"\n')
}).script;
const baselineVersion = getLatestVersion(baseline.id)!;
db().prepare('UPDATE scripts SET current_version_id = ? WHERE id = ?').run(baselineVersion.id, baseline.id);
db()
.prepare('UPDATE scripts SET current_version_id = ? WHERE id = ?')
.run(baselineVersion.id, baseline.id);
const overlay = createScript({
name: 'legacy map choice', kind: 'config', scopeType: 'map', scopeValue: 'zombie_cosmodrome',
name: 'legacy map choice',
kind: 'config',
scopeType: 'map',
scopeValue: 'zombie_cosmodrome',
content: Buffer.from('set sv_maprotation "map zombie_moon"\nset g_inactivity "0"\n')
}).script;
const oldConfig = '// operator config\r\nset sv_maprotation "map zombie_cosmodrome"\r\n';
await writeFile(cfgPath(servers[1]), oldConfig);
const { betaId } = await openBeta({
scripts: [{ scriptId: overlay.id, scriptVersionId: getLatestVersion(overlay.id)!.id }],
servers: [servers[1]], waitForHealth: false, waitForMatch: false
servers: [servers[1]],
waitForHealth: false,
waitForMatch: false
});
await activateFiles('beta', betaId);
const preview = await readFile(cfgPath(servers[1]), 'utf8');
@@ -91,7 +113,8 @@ describe('map selection through config lifecycle', () => {
});
it('keeps Plutainer default config during reconciliation until a baseline is promoted', async () => {
const { scanServerDrift, runDriftDeployment } = await import('../../src/lib/server/fleet/drift.js');
const { scanServerDrift, runDriftDeployment } =
await import('../../src/lib/server/fleet/drift.js');
const defaults = 'set sv_voice "1"\nset sv_maprotation "map zombie_theater"\n';
await writeFile(cfgPath(servers[1]), defaults);
await writeFile(join(fixture.t5, servers[1], 'configs', 'stray.cfg'), 'set stray "1"');