brick.ts

@brickkit/cli/config

Define and validate brick.config.ts, resolve project paths, and apply CLI flag defaults.

llms.txt

@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

FunctionDescription
defineConfigTypes the config file in the editor; the CLI validates it at load.
findConfigFileThe nearest brick.config.ts in cwd or its parents.
loadConfigLoad and validate the project's config: explicit (--config) when given, else the nearest brick.config.ts.
resolveDevDashboardWhether brick dev serves its dashboard, and its port and history, from the config's dev.dashboard and the flags.
resolvePortA port from a flag, else PORT, else the config, else 4000; throws outside 1-65535.
resolveProjectThe project, from explicit (--config) when given, else the nearest brick.config.ts, validated.
validateConfigThrows on an unknown key, a bad type, or dev.frontend without client.output.

defineConfig

function defineConfig(config: BrickConfig): BrickConfig

Types the config file in the editor; the CLI validates it at load.

Parameters

NameTypeDescription
configBrickConfig

Returns BrickConfig

Source: packages/cli/src/config.ts:144

findConfigFile

function findConfigFile(cwd = process.cwd()): string | undefined

The nearest brick.config.ts in cwd or its parents.

Parameters

NameTypeDescription
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

NameTypeDescription
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 } | false

Whether 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

NameTypeDescription
configuredNonNullable<BrickConfig["dev"]>["dashboard"]
flagsDevDashboardFlags

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,
): number

A port from a flag, else PORT, else the config, else 4000; throws outside 1-65535.

Parameters

NameTypeDescription
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

NameTypeDescription
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 BrickConfig

Throws on an unknown key, a bad type, or dev.frontend without client.output.

Parameters

NameTypeDescription
configunknown
label?string default CONFIG_FILE

Returns asserts config is BrickConfig

Source: packages/cli/src/config.ts:304

Classes

ConfigError

class ConfigError extends Error

A 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 DashboardExtensionOptions

What dashboard accepts wherever the dashboard starts or is built.

Properties

NameTypeDescription
extension?stringA 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 DashboardTheme

Token values for the dashboard's light and dark themes, its radius and fonts.

Properties

NameTypeDescription
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?stringThe 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 DevDashboardFlags

The dashboard flags of brick dev.

Properties

NameTypeDescription
dashboard?booleanfalse with --no-dashboard.
dashboardPort?number
historyDays?number
dashboardExtension?string

Source: packages/cli/src/config.ts:225

LoadedConfig

interface LoadedConfig

The project: its config file, if any, and every path with defaults applied.

Properties

NameTypeDescription
file?stringAbsolute path of the config file; absent when the project has none.
rootstringFolder the config's paths are relative to (the working folder without a file).
configBrickConfig
entrystringAbsolute paths with defaults applied.
servicesstring
generatedstring
contractstringWhere the client contract goes: client.output, else <generated>/contract.ts.
outdirstringWhere 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: 9400

Source: packages/cli/src/config.ts:25

DEFAULT_HISTORY_DAYS

const DEFAULT_HISTORY_DAYS: 90

Source: 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: 4000

Source: 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