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
@@ -5,16 +5,39 @@ import { newFixture, type Fixture } from '../helpers/fixture.js';
import type { LaunchRecipe } from '../../src/lib/server/fleet/launch-recipes.js';
let fixture: Fixture;
beforeEach(async () => { vi.resetModules(); fixture = await newFixture([]); });
afterEach(async () => { vi.restoreAllMocks(); await fixture.cleanup(); });
beforeEach(async () => {
vi.resetModules();
fixture = await newFixture([]);
});
afterEach(async () => {
vi.restoreAllMocks();
await fixture.cleanup();
});
describe('persisted launch recipe summaries', () => {
it('lazily upgrades legacy snapshots once without changing fingerprints or retained bytes', async () => {
const recipe: LaunchRecipe = {
format: 1, game: 't5', mapSlug: 'theater', mapName: 'Kino der Toten', expectedMap: 'zombie_theater',
capturedAt: '2025-01-01T00:00:00.000Z', image: 'plutainer:test', configFile: 'dedicated_sp.cfg', configSource: 'Defaults',
files: [{ name: 'Old plugin', kind: 'plugin', path: 'legacy.dll', versionId: 1, version: 1,
sha256: 'a'.repeat(64), size: 2 * 1024 ** 2, content: Buffer.alloc(2 * 1024 ** 2, 42).toString('base64') }]
format: 1,
game: 't5',
mapSlug: 'theater',
mapName: 'Kino der Toten',
expectedMap: 'zombie_theater',
capturedAt: '2025-01-01T00:00:00.000Z',
image: 'plutainer:test',
configFile: 'dedicated_sp.cfg',
configSource: 'Defaults',
files: [
{
name: 'Old plugin',
kind: 'plugin',
path: 'legacy.dll',
versionId: 1,
version: 1,
sha256: 'a'.repeat(64),
size: 2 * 1024 ** 2,
content: Buffer.alloc(2 * 1024 ** 2, 42).toString('base64')
}
]
};
const legacy = new Database(fixture.dbPath);
const encoded = JSON.stringify(recipe, null, 2);
@@ -22,13 +45,21 @@ describe('persisted launch recipe summaries', () => {
legacy.exec(schema.replace(' recipe_summary TEXT,\n', ''));
legacy.exec(`INSERT INTO server_deployments(id,server,action,state,stage,started_at,triggered_by)
VALUES('legacy','retired-server','create','done','Complete','2025-01-01','fixture');`);
legacy.prepare('INSERT INTO server_launch_recipes(deployment_id,recipe,blueprint_name) VALUES(?,?,?)')
legacy
.prepare(
'INSERT INTO server_launch_recipes(deployment_id,recipe,blueprint_name) VALUES(?,?,?)'
)
.run('legacy', encoded, 'Old collection');
} finally { legacy.close(); }
} finally {
legacy.close();
}
const { db, closeDb } = await import('../../src/lib/server/db/index.js');
const { recipeSummaryForDeployment, recipeForDeployment, summarizeRecipe } = await import('../../src/lib/server/fleet/launch-recipes.js');
const { recipeSummaryForDeployment, recipeForDeployment, summarizeRecipe } =
await import('../../src/lib/server/fleet/launch-recipes.js');
const expected = { recipe: summarizeRecipe(recipe), blueprintName: 'Old collection' };
expect(db().prepare('SELECT recipe_summary FROM server_launch_recipes').get()).toEqual({ recipe_summary: null });
expect(db().prepare('SELECT recipe_summary FROM server_launch_recipes').get()).toEqual({
recipe_summary: null
});
expect(recipeSummaryForDeployment('legacy')).toEqual(expected);
closeDb();
const parse = JSON.parse;
@@ -39,9 +70,13 @@ describe('persisted launch recipe summaries', () => {
try {
expect(recipeSummaryForDeployment('legacy')).toEqual(expected);
expect(recipeSummaryForDeployment('missing')).toBeNull();
} finally { parsing.mockRestore(); }
} finally {
parsing.mockRestore();
}
expect(recipeForDeployment('legacy')).toEqual({ recipe, blueprintName: 'Old collection' });
const stored = db().prepare('SELECT recipe FROM server_launch_recipes').get() as { recipe: string };
const stored = db().prepare('SELECT recipe FROM server_launch_recipes').get() as {
recipe: string;
};
expect(stored.recipe.length).toBeLessThan(1024);
expect(JSON.parse(stored.recipe).files[0]).not.toHaveProperty('content');
});