feat(audit): Batch 25 — project reorg (CC12), leading DI args (CC7), CC10 by-design
CC12: renderer views/ (5 screens + Onboarding + settings cards) + lib/ (theme/thumb/datetime/id/qualityOptions/useClipboardLink/queueStats); main core/ (buildArgs/validation/indexerCore/ytdlpPolicy). git mv preserved history; all src+test imports updated. Build emits view chunks from views/, 344 tests + typecheck green, live probe rendered all screens. CC7: wc/onProgress is the leading arg everywhere — downloadAppUpdate(wc,url), indexSource(onProgress,url,signal), indexSourceCancelable(onProgress,url). CC10: closed by-design — jsonStore backs all records; settings stay in electron-store for DPAPI secret encryption (a deliberate two-store split). Also closes the UI24/W4 context-menu cross-reference. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
aria2cArgs,
|
||||
DEST_MARKER,
|
||||
type AccessOptions
|
||||
} from '../src/main/buildArgs'
|
||||
} from '../src/main/core/buildArgs'
|
||||
import {
|
||||
DEFAULT_DOWNLOAD_OPTIONS,
|
||||
type DownloadOptions,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest'
|
||||
import { relTime, formatWhen, fmtSchedule } from '../src/renderer/src/datetime'
|
||||
import { relTime, formatWhen, fmtSchedule } from '../src/renderer/src/lib/datetime'
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers()
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { newId } from '../src/renderer/src/id'
|
||||
import { newId } from '../src/renderer/src/lib/id'
|
||||
|
||||
describe('newId', () => {
|
||||
it('produces unique ids across many calls', () => {
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
stripTabSuffix,
|
||||
stableSourceId,
|
||||
type RawEntry
|
||||
} from '../src/main/indexerCore'
|
||||
} from '../src/main/core/indexerCore'
|
||||
import type { MediaItem } from '@shared/ipc'
|
||||
|
||||
describe('classifySource', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { summarizeQueue, sameVideo } from '../src/renderer/src/store/queueStats'
|
||||
import { summarizeQueue, sameVideo } from '../src/renderer/src/lib/queueStats'
|
||||
import type { DownloadItem } from '../src/renderer/src/store/downloads'
|
||||
|
||||
// Minimal item factory — only the fields summarizeQueue reads.
|
||||
|
||||
@@ -13,7 +13,7 @@ import { spawnSync } from 'child_process'
|
||||
import { mkdtempSync, existsSync, rmSync, statSync, readFileSync } from 'fs'
|
||||
import { tmpdir } from 'os'
|
||||
import { join, resolve } from 'path'
|
||||
import { buildArgs, parseExtraArgs } from '../src/main/buildArgs'
|
||||
import { buildArgs, parseExtraArgs } from '../src/main/core/buildArgs'
|
||||
import { DEFAULT_DOWNLOAD_OPTIONS, type StartDownloadOptions } from '@shared/ipc'
|
||||
|
||||
const RUN = process.env.AEROFETCH_REAL_DOWNLOAD === '1'
|
||||
|
||||
@@ -138,7 +138,7 @@ afterAll(() => {
|
||||
describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
it('refuses an untrusted initial URL without making any request', async () => {
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate('https://evil.example/x.exe', wc)
|
||||
const r = await downloadAppUpdate(wc, 'https://evil.example/x.exe')
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/untrusted/i)
|
||||
expect(madeRequests.length).toBe(0)
|
||||
@@ -154,7 +154,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc, sends } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r).toEqual({ ok: true, filePath: installerPath })
|
||||
expect(readFileSync(installerPath).equals(INSTALLER)).toBe(true)
|
||||
expect(sends.length).toBeGreaterThan(0)
|
||||
@@ -171,7 +171,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/checksum/i)
|
||||
await expectGone(installerPath)
|
||||
@@ -186,7 +186,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/incomplete/i)
|
||||
await expectGone(installerPath)
|
||||
@@ -198,7 +198,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
req.emit('redirect', 302, 'GET', 'https://evil.example/attachments/x.exe')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/redirect.*untrusted/i)
|
||||
const installerReq = madeRequests[1]!
|
||||
@@ -216,7 +216,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(true)
|
||||
expect(madeRequests[1]!.redirectsFollowed).toBe(1)
|
||||
})
|
||||
@@ -226,7 +226,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
req.emit('redirect', 302, 'GET', 'https://evil.example/x.sha256')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/checksum/i)
|
||||
expect(madeRequests.length).toBe(1) // never reached the installer request
|
||||
@@ -237,7 +237,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
req.emit('response', new FakeResponse(404))
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/no checksum/i)
|
||||
expect(madeRequests.length).toBe(1)
|
||||
@@ -246,7 +246,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
it('refuses a malformed checksum file (no 64-hex digest)', async () => {
|
||||
requestScripts.push(checksumOk('not a digest at all\n'))
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/malformed/i)
|
||||
expect(madeRequests.length).toBe(1)
|
||||
@@ -262,7 +262,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/canceled/i)
|
||||
expect(madeRequests.length).toBe(1)
|
||||
@@ -277,7 +277,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
cancelAppUpdate()
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/canceled/i)
|
||||
expect(madeRequests[1]!.aborted).toBe(true)
|
||||
@@ -294,7 +294,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
// …and then nothing: the stream stalls.
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const pending = downloadAppUpdate(ASSET, wc)
|
||||
const pending = downloadAppUpdate(wc, ASSET)
|
||||
await vi.advanceTimersByTimeAsync(61_000)
|
||||
const r = await pending
|
||||
expect(r.ok).toBe(false)
|
||||
@@ -310,7 +310,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
req.emit('response', new FakeResponse(503))
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/503/)
|
||||
})
|
||||
@@ -327,7 +327,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
isTemplateLike,
|
||||
isValidSource,
|
||||
isValidMediaItem
|
||||
} from '../src/main/validation'
|
||||
} from '../src/main/core/validation'
|
||||
import {
|
||||
isValidSyncTime,
|
||||
type HistoryEntry,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { shouldAutoCheckYtdlp, AUTO_UPDATE_INTERVAL_MS } from '../src/main/ytdlpPolicy'
|
||||
import { shouldAutoCheckYtdlp, AUTO_UPDATE_INTERVAL_MS } from '../src/main/core/ytdlpPolicy'
|
||||
|
||||
const NOW = 1_782_435_469_486 // arbitrary fixed "now"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user