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
+35 -9
View File
@@ -4,16 +4,30 @@ import { newFixture, type Fixture } from '../helpers/fixture.js';
import { migrateVersionLayout } from '../../src/lib/server/db/version-layout.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();
});
it('returns metadata without plugin bytes and lists many artifacts in two queries', async () => {
const { createScript, getVersion, getVersionContent, getLatestVersion, listVersions } = await import('../../src/lib/server/fleet/scripts.js');
const { scriptCatalog, betaScriptMetadata } = await import('../../src/lib/server/fleet/library-metadata.js');
const { createScript, getVersion, getVersionContent, getLatestVersion, listVersions } =
await import('../../src/lib/server/fleet/scripts.js');
const { scriptCatalog, betaScriptMetadata } =
await import('../../src/lib/server/fleet/library-metadata.js');
const { db } = await import('../../src/lib/server/db/index.js');
const content = Buffer.alloc(1024 * 1024, 77);
let id = 0;
for (let i = 0; i < 20; i++) id = createScript({ name: `plugin-${i}`, kind: 'plugin', targetRelPath: 'plugin.dll', content }).version.id;
for (let i = 0; i < 20; i++)
id = createScript({
name: `plugin-${i}`,
kind: 'plugin',
targetRelPath: 'plugin.dll',
content
}).version.id;
expect(getVersionContent(id)).toEqual(content);
expect(getVersion(id)).not.toHaveProperty('content');
expect(getLatestVersion(getVersion(id)!.script_id)).not.toHaveProperty('content');
@@ -43,11 +57,23 @@ it('moves legacy content last without losing bytes, IDs, indexes, triggers or re
migrateVersionLayout(handle);
migrateVersionLayout(handle);
expect(handle.prepare('SELECT * FROM script_versions').all()).toEqual(before);
expect((handle.pragma('table_info(script_versions)') as { name: string }[]).at(-1)?.name).toBe('content');
expect(
(handle.pragma('table_info(script_versions)') as { name: string }[]).at(-1)?.name
).toBe('content');
expect(handle.pragma('foreign_key_check')).toEqual([]);
expect(handle.prepare("INSERT INTO script_versions(script_id,version,content) VALUES(1,3,x'01')").run().lastInsertRowid).toBe(101);
expect(
handle
.prepare("INSERT INTO script_versions(script_id,version,content) VALUES(1,3,x'01')")
.run().lastInsertRowid
).toBe(101);
handle.prepare("UPDATE script_versions SET state='tested' WHERE id=101").run();
expect(handle.prepare('SELECT n FROM updates').get()).toEqual({ n: 1 });
expect((handle.pragma('index_list(script_versions)') as { name: string }[]).some(index => index.name === 'version_state')).toBe(true);
} finally { handle.close(); }
expect(
(handle.pragma('index_list(script_versions)') as { name: string }[]).some(
(index) => index.name === 'version_state'
)
).toBe(true);
} finally {
handle.close();
}
});