mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 13:36:48 +00:00
7a7903a799
The offline core only works when the views go through it: component, feature hook, store, repo, then api or Dexie, with writes through the mutation queue. A view that imports src/api/ skips the cache, the optimistic write and the idempotent replay. client/CLAUDE.md said so and noted that no ratchet held the line, and the number of view files importing api/client grew from 161 to 190 in two months. lint:offline lists the 213 files under components/, mobile/, pages/ and hooks/ that import anything from src/api/ for more than types (api/client, the websocket, the per-domain modules) in scripts/offline-baseline.json. No other view file may, and a listed file that stops leaves the list through --update, so the next file at that path does not inherit the exemption. Type-only imports do not count: they carry no request. client/CLAUDE.md describes the rule next to the data-flow section, including that an online-only domain puts its calls in a store or repo.
24 lines
1.2 KiB
JavaScript
24 lines
1.2 KiB
JavaScript
#!/usr/bin/env node
|
|
/*
|
|
* lint:offline: views go through the offline core, not around it.
|
|
*
|
|
* The data path is component, feature hook, store, repo, then api or Dexie,
|
|
* and writes go through the mutation queue. A view that imports src/api/
|
|
* skips the cache, the optimistic write and the idempotent replay, so the
|
|
* feature breaks offline. Such files kept growing, by about fifteen a month.
|
|
* The view files (components/, mobile/, pages/, hooks/) that already import
|
|
* src/api/ for more than types are listed in scripts/offline-baseline.json;
|
|
* no other view file may, and the list only shrinks.
|
|
*
|
|
* npm run lint:offline check against the baseline (CI)
|
|
* npm run lint:offline -- --list print every view file that imports src/api/
|
|
* npm run lint:offline -- --update take the files that stopped off the list;
|
|
* it never adds one
|
|
*/
|
|
import { fileURLToPath } from 'node:url'
|
|
import { check } from './lib/offline.mjs'
|
|
import { runCli } from './lib/ratchet.mjs'
|
|
|
|
const root = fileURLToPath(new URL('..', import.meta.url))
|
|
await runCli('lint:offline', (args) => check({ root, update: args.includes('--update'), list: args.includes('--list') }))
|