@brickkit/cli/config
Define and validate brick.config.ts, resolve project paths, and apply CLI flag defaults.
@brickkit/cli/config exports 21 names: 7 functions, 1 class, 4 interfaces, 3 types, 6 variables.
import { ConfigError, CONTRACT_FILE, DEFAULT_DASHBOARD_PORT } from "@brickkit/cli/config";Functions
| Function | Description |
|---|---|
defineConfig | Types the config file in the editor; the CLI validates it at load. |
findConfigFile | The nearest brick.config.ts in cwd or its parents. |
loadConfig | Load and validate the project's config: explicit (--config) when given, else the nearest brick.config.ts. |
resolveDevDashboard | Whether brick dev serves its dashboard, and its port and history, from the config's dev.dashboard and the flags. |
resolvePort | A port from a flag, else PORT, else the config, else 4000; throws outside 1-65535. |
resolveProject | The project, from explicit (--config) when given, else the nearest brick.config.ts, validated. |
validateConfig | Throws on an unknown key, a bad type, or dev.frontend without client.output. |
defineConfig
function defineConfig(config: BrickConfig): BrickConfigTypes the config file in the editor; the CLI validates it at load.
Parameters
| Name | Type | Description |
|---|---|---|
config | BrickConfig |
Returns BrickConfig
Source: packages/cli/src/config.ts:144
findConfigFile
function findConfigFile(cwd = process.cwd()): string | undefinedThe nearest brick.config.ts in cwd or its parents.
Parameters
| Name | Type | Description |
|---|---|---|
cwd? | string default process.cwd() |
Returns string \| undefined
Source: packages/cli/src/config.ts:169
loadConfig
function loadConfig(
explicit?: string,
cwd = process.cwd(),
): Promise<LoadedConfig | undefined>Load and validate the project's config: explicit (--config) when given,
else the nearest brick.config.ts. Returns undefined when there is none.
Parameters
| Name | Type | Description |
|---|---|---|
explicit? | string | |
cwd? | string default process.cwd() |
Returns Promise<LoadedConfig \| undefined>
Source: packages/cli/src/config.ts:216
resolveDevDashboard
function resolveDevDashboard(
configured: NonNullable<BrickConfig["dev"]>["dashboard"],
flags: DevDashboardFlags,
): { port?: number; historyDays?: number } | falseWhether brick dev serves its dashboard, and its port and history, from the
config's dev.dashboard and the flags. The config can turn it off; a port or
history flag turns it back on.
Parameters
| Name | Type | Description |
|---|---|---|
configured | NonNullable<BrickConfig["dev"]>["dashboard"] | |
flags | DevDashboardFlags |
Returns { port?: number; historyDays?: number } \| false
Throws
- ConfigError When a dashboard flag is combined with turning it off.
Source: packages/cli/src/config.ts:240
resolvePort
function resolvePort(
flag?: number | string,
configured?: number,
env = process.env.PORT,
): numberA port from a flag, else PORT, else the config, else 4000; throws outside 1-65535.
Parameters
| Name | Type | Description |
|---|---|---|
flag? | number | string | |
configured? | number | |
env? | string | undefined default process.env.PORT |
Returns number
Source: packages/cli/src/config.ts:274
resolveProject
function resolveProject(
explicit?: string,
cwd = process.cwd(),
): Promise<LoadedConfig>The project, from explicit (--config) when given, else the nearest
brick.config.ts, validated. Without a file, the defaults from cwd.
Parameters
| Name | Type | Description |
|---|---|---|
explicit? | string | |
cwd? | string default process.cwd() |
Returns Promise<LoadedConfig>
Source: packages/cli/src/config.ts:181
validateConfig
function validateConfig(
config: unknown,
label = CONFIG_FILE,
): asserts config is BrickConfigThrows on an unknown key, a bad type, or dev.frontend without client.output.
Parameters
| Name | Type | Description |
|---|---|---|
config | unknown | |
label? | string default CONFIG_FILE |
Returns asserts config is BrickConfig
Source: packages/cli/src/config.ts:304
Classes
ConfigError
class ConfigError extends ErrorA user's mistake: a missing file, an invalid config, or flags that conflict. brick prints the message alone.
Source: packages/cli/src/config.ts:149
Interfaces
DashboardExtensionOptions
interface DashboardExtensionOptionsWhat dashboard accepts wherever the dashboard starts or is built.
Properties
| Name | Type | Description |
|---|---|---|
extension? | string | A module whose default export is defineDashboard({ ... }), or the dashboard folder brick build wrote it to. |
theme? | DashboardTheme |
Source: packages/cli/src/dashboard-extension.ts:33
DashboardTheme
interface DashboardThemeToken values for the dashboard's light and dark themes, its radius and fonts.
Properties
| Name | Type | Description |
|---|---|---|
light? | Record<string, string> | Colour tokens in light mode, by name: { primary: "oklch(0.55 0.2 260)" }. |
dark? | Record<string, string> | Colour tokens in dark mode. |
radius? | string | The base corner radius, such as "0.5rem". |
fonts? | { sans?: string; mono?: string } | CSS font stacks. The page must be able to load the font. |
Source: packages/cli/src/dashboard-extension.ts:21
DevDashboardFlags
interface DevDashboardFlagsThe dashboard flags of brick dev.
Properties
| Name | Type | Description |
|---|---|---|
dashboard? | boolean | false with --no-dashboard. |
dashboardPort? | number | |
historyDays? | number | |
dashboardExtension? | string |
Source: packages/cli/src/config.ts:225
LoadedConfig
interface LoadedConfigThe project: its config file, if any, and every path with defaults applied.
Properties
| Name | Type | Description |
|---|---|---|
file? | string | Absolute path of the config file; absent when the project has none. |
root | string | Folder the config's paths are relative to (the working folder without a file). |
config | BrickConfig | |
entry | string | Absolute paths with defaults applied. |
services | string | |
generated | string | |
contract | string | Where the client contract goes: client.output, else <generated>/contract.ts. |
outdir | string | Where brick build writes: build.outdir, else dist/brick. |
Source: packages/cli/src/config.ts:152
Types
BrickConfig
type BrickConfig = Static<typeof BrickConfigSchema>;Source: packages/cli/src/config.ts:141
LintPreset
type LintPreset = (typeof PRESET_NAMES)[number];Source: packages/cli/src/config.ts:21
LintSeverity
type LintSeverity = (typeof SEVERITIES)[number];Source: packages/cli/src/config.ts:22
Variables
CONTRACT_FILE
const CONTRACT_FILE: "contract.ts"The client contract's name in the generated folder, when client.output names none.
Source: packages/cli/src/config.ts:35
DEFAULT_DASHBOARD_PORT
const DEFAULT_DASHBOARD_PORT: 9400Source: packages/cli/src/config.ts:25
DEFAULT_HISTORY_DAYS
const DEFAULT_HISTORY_DAYS: 90Source: packages/cli/src/config.ts:26
DEFAULT_OUTDIR
const DEFAULT_OUTDIR: "dist/brick"Source: packages/cli/src/config.ts:27
DEFAULT_PORT
const DEFAULT_PORT: 4000Source: packages/cli/src/config.ts:24
PROJECT_DEFAULTS
const PROJECT_DEFAULTS: { readonly entry: "src/app.ts"; readonly services: "src/services"; readonly generated: "_brick"; }Project paths a config leaves out, relative to its folder.
Source: packages/cli/src/config.ts:29