- Extract INSERT_MIGRATION_SQL constant; was repeated three times.
- Hoist db.exec(SCHEMA_MIGRATIONS_DDL) above the genesis-stamp branch
so it is no longer duplicated in both arms of the if/else.
- Prepare insertRow once and reuse it for both genesis-stamping and
the per-file insert in the apply loop.
- Simplify existence probe in stampMigration to SELECT 1 and drop the
misleading MigrationRow cast (only existence was checked).
Pre-compiled ESM JS + .d.ts from tsconfig.build.json. Consumers install
via 'git+https://gitea.bchen.dev/...#v0.1.0' so the built output must
travel with the source. CI verifies in-sync via 'git diff --exit-code
dist/'.
Install via git+https with pinned tag, quick-start, API reference for the
4 runtime exports + the CLI sub-path, genesis-stamping explainer, the
per-consumer probe-table table for the six fleet consumers, security note
on the trusted-SQL boundary.
Runs npm ci, typecheck, build, test, and a 'git diff --exit-code dist/'
gate that catches 'forgot to re-run npm run build' before merge. Fires on
PR / push to main / push to v* tags.
Appended '\!/dist/' override to the bottom of .gitignore so the committed
build output is tracked. node_modules and other Nuxt-template-default
entries remain ignored. Verified with 'git check-ignore -v dist/index.js'
(no match, exit 1).
ESM-only, Node 20+, ships pre-compiled dist/. Peer dependency on
better-sqlite3 >=11 <13. Dev pins: typescript ^5.5, vitest ^4.0
(resolved to 4.1.6), better-sqlite3 12.6.2 (matches authd).
tsconfig.json (noEmit) is the dev/test config; tsconfig.build.json
extends it and emits .js + .d.ts to dist/. Relative imports inside src/
use .js extensions so the emitted JS resolves correctly at runtime.
15 vitest specs total:
- 9 lifted from authd's tests/db/migrate.test.ts. Specs that referenced
the on-disk migrations dir now write fixtures into a per-test tmpdir
(package ships no migrations dir of its own).
- 3 new specs covering the genesisProbeTable parameter (default, custom
table name, opt-out via stampGenesis=false).
- 3 new specs covering runMigrateCli (migrate / status / stamp) using
PassThrough stream capture.
Extracts the union of authd's three CLI scripts (db-migrate.ts,
db-status.ts, db-stamp.ts) into one wrapper. Consumers wire a ~5-line shim
that injects their own openDb / migrationsDir / config-loading logic. The
wrapper returns an exit code rather than calling process.exit, which keeps
it testable via PassThrough stream capture.
Forward-only SQLite migration runner lifted from authd (src/db/migrate.ts,
PR #14 / merge ced21ab) and parameterized for cross-project use. The single
deliberate API change vs. authd's source: the previously-hardcoded
GENESIS_PROBE_TABLE = 'users' is now an ApplyOptions.genesisProbeTable?: string
option (default 'users').