afb62d1be4
Now that distribution will bundle a Node 24 runtime, node:sqlite (real SQLite
with WAL + FTS5) is always available. Collapse the three-backend adapter to
node:sqlite only and remove the machinery the other two needed:
- Remove better-sqlite3 (optionalDependency) and node-sqlite3-wasm (dependency).
- Remove WasmDatabaseAdapter, the named->positional param translation, the
SQLITE_BUSY read-retry, the wasm fallback banner, the backend env override,
and the native/node-sqlite/wasm selection chain.
- createDatabase now opens node:sqlite directly, with a clear error pointing at
the bundled release / Node 22.5+ when the module is absent.
- NodeSqliteAdapter.close() is idempotent and pragma() supports { simple }, to
match the better-sqlite3 behavior callers relied on.
- status (CLI + MCP) reports the single node:sqlite backend; journal-mode
diagnostics and the getCodeGraph single-connection fix are retained.
- Tests repointed off better-sqlite3 onto node:sqlite.
Net -1044 lines. Running from source now requires Node 22.5+.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
/**
|
|
* SQLite backend reporting.
|
|
*
|
|
* node:sqlite (Node's built-in real SQLite) is the sole backend. Pin that
|
|
* DatabaseConnection / CodeGraph report it and come up in WAL.
|
|
*/
|
|
|
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import * as os from 'os';
|
|
import { DatabaseConnection } from '../src/db';
|
|
import { CodeGraph } from '../src';
|
|
|
|
describe('DatabaseConnection — backend reporting', () => {
|
|
let dir: string;
|
|
|
|
beforeEach(() => {
|
|
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-backend-'));
|
|
});
|
|
|
|
afterEach(() => {
|
|
if (fs.existsSync(dir)) {
|
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it('reports the node-sqlite backend in WAL for an initialized DB', () => {
|
|
const conn = DatabaseConnection.initialize(path.join(dir, 'test.db'));
|
|
expect(conn.getBackend()).toBe('node-sqlite');
|
|
expect(conn.getJournalMode()).toBe('wal');
|
|
conn.close();
|
|
});
|
|
|
|
it('CodeGraph.getBackend() delegates to the underlying DatabaseConnection', async () => {
|
|
fs.writeFileSync(path.join(dir, 'x.ts'), `export function x(): void {}\n`);
|
|
const cg = await CodeGraph.init(dir, { index: true });
|
|
try {
|
|
expect(cg.getBackend()).toBe('node-sqlite');
|
|
} finally {
|
|
cg.destroy();
|
|
}
|
|
});
|
|
});
|