@xtandard/kit/cli — building blocks for the products’ CLIs: env (empty
counts as unset), parseArgs, buildAuthFromEnv and storageFromEnv (both
reject unknown modes/drivers), describeStorage, startServer (Bun or the
Node bridge), serve, pkgVersion and the isMainModule self-run guard.
A log-safe description of where a role persists data, for the startup banner: file and SQLite paths are resolved to absolute paths; drivers with a connection string print only their name (never the URL, which may carry credentials).
The self-run guard (au 6761a34): true when the module is the program’s entry point (bun src/cli.ts, node dist/cli.mjs), false when it is imported — by the bin/ wrapper, a test or the standalone app — so run() executes exactly once.
The serve command: read the common env (PORT, BASE_PATH, TITLE, LOGO_URL, READONLY), warn on AUTH_MODE=none, build the panel, print the banner and listen. The server owns the process: it never resolves, so the bin doesn’t exit (unless returnServer).
Serve a fetch handler under whatever runtime the CLI runs on: Bun.serve under Bun, a node:http server over the shared Node bridge under Node (multi-value headers, every Set-Cookie, streamed responses). Resolves once listening.
Build a StorageRegistry from entry-module loaders, with the kit’s env → options mapping. Products pass their own wrapped entries, so the CLI gets the product’s capability layers (webhooks’ claimDue) and persisted defaults (table names), which the kit’s defaultStorageRegistry cannot know. Drivers without a loader are not available.
The resolved settings a driver factory receives (connection strings are never logged). An optional field is undefined when neither its env var nor the role’s defaults set it (“no default given”). A field the role gives a default for is always set.
The loaders storageRegistryFrom accepts, by driver name. Each module must export the factory the driver uses: createMemoryStorage, createFileStorage, createSqliteStorage, createLibsqlStorage, createPostgresStorage, createMongoStorage, createRedisStorage / createRedisJSONStorage (redis, redis-json), createUnstorageStorage.
The default registry over the kit’s own storage entries: each driver lazily imports its entry, so an optional peer loads only when its driver is chosen. A product with capability layers or persisted defaults in its driver wrappers must pass its own registry instead (see storageRegistryFrom): this one bypasses them.