refactor: remove root node and npm workflow deps

This commit is contained in:
2026-03-07 21:19:14 -08:00
parent f0418c6e56
commit d0c11d347b
32 changed files with 215 additions and 299 deletions

View File

@@ -3,7 +3,7 @@ import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import test from 'node:test';
import type { DatabaseSync as NodeDatabaseSync } from 'node:sqlite';
import { Database } from './sqlite';
import { finalizeSessionRecord, startSessionRecord } from './session';
import {
createTrackerPreparedStatements,
@@ -13,22 +13,6 @@ import {
} from './storage';
import { EVENT_SUBTITLE_LINE, SESSION_STATUS_ENDED, SOURCE_TYPE_LOCAL } from './types';
type DatabaseSyncCtor = typeof NodeDatabaseSync;
const DatabaseSync: DatabaseSyncCtor | null = (() => {
try {
return (require('node:sqlite') as { DatabaseSync?: DatabaseSyncCtor }).DatabaseSync ?? null;
} catch {
return null;
}
})();
const testIfSqlite = DatabaseSync ? test : test.skip;
if (!DatabaseSync) {
console.warn(
'Skipping SQLite-backed immersion tracker storage/session tests in this runtime; run `bun run test:immersion:sqlite` for real DB coverage.',
);
}
function makeDbPath(): string {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'subminer-imm-storage-session-'));
return path.join(dir, 'immersion.sqlite');
@@ -41,9 +25,9 @@ function cleanupDbPath(dbPath: string): void {
}
}
testIfSqlite('ensureSchema creates immersion core tables', () => {
test('ensureSchema creates immersion core tables', () => {
const dbPath = makeDbPath();
const db = new DatabaseSync!(dbPath);
const db = new Database(dbPath);
try {
ensureSchema(db);
@@ -77,9 +61,9 @@ testIfSqlite('ensureSchema creates immersion core tables', () => {
}
});
testIfSqlite('start/finalize session updates ended_at and status', () => {
test('start/finalize session updates ended_at and status', () => {
const dbPath = makeDbPath();
const db = new DatabaseSync!(dbPath);
const db = new Database(dbPath);
try {
ensureSchema(db);
@@ -111,9 +95,9 @@ testIfSqlite('start/finalize session updates ended_at and status', () => {
}
});
testIfSqlite('executeQueuedWrite inserts event and telemetry rows', () => {
test('executeQueuedWrite inserts event and telemetry rows', () => {
const dbPath = makeDbPath();
const db = new DatabaseSync!(dbPath);
const db = new Database(dbPath);
try {
ensureSchema(db);
@@ -178,9 +162,9 @@ testIfSqlite('executeQueuedWrite inserts event and telemetry rows', () => {
}
});
testIfSqlite('executeQueuedWrite inserts and upserts word and kanji rows', () => {
test('executeQueuedWrite inserts and upserts word and kanji rows', () => {
const dbPath = makeDbPath();
const db = new DatabaseSync!(dbPath);
const db = new Database(dbPath);
try {
ensureSchema(db);