feat(sync): add sync-hosts store, NDJSON --json mode, and --check to subminer sync

This commit is contained in:
2026-07-11 17:45:27 -07:00
parent 8797719a09
commit 0a3f76c0a8
16 changed files with 979 additions and 27 deletions
+41
View File
@@ -0,0 +1,41 @@
import fs from 'node:fs';
import os from 'node:os';
import { resolveConfigDir } from '../../src/config/path-resolution.js';
import {
getSyncHostsPath,
readSyncHostsState,
recordSyncResult,
writeSyncHostsState,
type SyncResultStatus,
} from '../../src/shared/sync/sync-hosts-store.js';
export function resolveSyncHostsFilePath(): string {
const configDir = resolveConfigDir({
platform: process.platform,
appDataDir: process.env.APPDATA,
xdgConfigHome: process.env.XDG_CONFIG_HOME,
homeDir: os.homedir(),
existsSync: fs.existsSync,
});
return getSyncHostsPath(configDir);
}
// Best-effort bookkeeping so hosts synced from the CLI show up in the sync UI;
// a failure to persist must never fail the sync itself.
export function recordHostSyncResultToDisk(
host: string,
status: SyncResultStatus,
detail: string | null,
): void {
try {
const filePath = resolveSyncHostsFilePath();
const state = recordSyncResult(readSyncHostsState(filePath), host, {
atMs: Date.now(),
status,
detail,
});
writeSyncHostsState(filePath, state);
} catch {
// best effort
}
}
+2 -16
View File
@@ -8,22 +8,8 @@ import { resolveConfigDir } from '../../src/config/path-resolution.js';
export { SCHEMA_VERSION };
export interface SyncMergeSummary {
sessionsMerged: number;
sessionsAlreadyPresent: number;
activeSessionsSkipped: number;
animeAdded: number;
videosAdded: number;
wordsAdded: number;
kanjiAdded: number;
subtitleLinesAdded: number;
telemetryRowsAdded: number;
eventsAdded: number;
excludedWordsAdded: number;
dailyRollupsCopied: number;
monthlyRollupsCopied: number;
rollupGroupsRecomputed: number;
}
export type { SyncMergeSummary } from '../../src/shared/sync/sync-events.js';
import type { SyncMergeSummary } from '../../src/shared/sync/sync-events.js';
export function createEmptyMergeSummary(): SyncMergeSummary {
return {