@mono-labs/project
v0.1.274
Published
Project configuration utilities for mono-labs
Readme
@mono-labs/project
Foundational utility package for Mono. Provides project root discovery, .mono config loading, and environment variable merging.
Installation
yarn add @mono-labs/projectAPI Reference
Project Root
import {
findProjectRoot,
getRootDirectory,
getRootJson
} from "@mono-labs/project";findProjectRoot(startDir?)-- Walk up the directory tree fromstartDir(orcwd) to find the nearestpackage.json. Returns the directory path.getRootDirectory()-- Returns the project root directory path.getRootJson()-- Reads and returns the rootpackage.jsonas a parsed object.
Mono Configuration
import {
resolveMonoDirectory,
getMonoFiles,
getMonoConfig
} from "@mono-labs/project";resolveMonoDirectory()-- Resolves the path to the.mono/directory (checks project root and cwd).getMonoFiles()-- Returns aMonoFilesrecord of all.mono/*.jsoncommand definitions (excludingconfig.json).getMonoConfig()-- Loads and returns the parsed.mono/config.jsonas aMonoConfigobject.clearMonoConfigCache()-- Clears the cached mono config, forcing a fresh read on the next call togetMonoConfig().
App Configuration
import {
loadAppConfig,
loadProjectConfig
} from "@mono-labs/project";loadAppConfig(configType?, startDir?)-- Loads a typed config file (mono.app.json,mono.deployment.json, etc.) from the project. Supports both local development (workspace discovery) and Lambda runtime (bundled config).loadProjectConfig()-- Alias forloadAppConfig().
Environment Merging
import { loadMergedEnv } from "@mono-labs/project";loadMergedEnv()-- Loads.envand.env.localfrom the project root, merges them (.env.localtakes precedence), and injects intoprocess.envwithout overwriting existing variables.
Environment Filtering
import {
filterEnvByPrefixes,
filterEnvByConfig
} from "@mono-labs/project";filterEnvByPrefixes(env, prefixes, include?)-- Returns only env vars whose keys start with one of the given prefixes. Pass an optionalincludearray for specific keys that should always be kept regardless of prefix.filterEnvByConfig(env?, include?)-- Reads prefixes from.mono/config.jsonenvMapand combines them with default prefixes (MONO_,EAS_,APP_,TAMAGUI_). Defaults toprocess.envifenvis omitted.
Subpath Export
The @mono-labs/project/project subpath provides access to app config loading, environment filtering, and documentation generation utilities.
Config Types
import type {
MonoConfig,
MonoProjectConfig,
MonoWorkspaceConfig,
MonoFiles
} from "@mono-labs/project";MonoConfig-- Full mono configuration:envMap?: string[],workspace?: MonoWorkspaceConfig,prodFlag?: stringMonoWorkspaceConfig-- Workspace settings:packageMaps?: Record<string, string>,preactions?: string[]MonoProjectConfig-- Project config withenvMap,workspace, andprodFlagMonoFiles-- Record of command definition objects keyed by filename
Development
Build the project package:
yarn build:projectThis package has no internal dependencies -- it sits at the base of the dependency graph. Both @mono-labs/expo and @mono-labs/cli depend on it.
See the Contributing guide for full development setup.
