Module that handles all vlt configuration needs
Project-level configs are set in a vlt.json file in the local
project if present. This will override the user-level configs in the
appropriate XDG config path.
Command-specific configuration can be specified by putting options in
a field in the command object. For example:
{ "registry": "https://registry.npmjs.org/", "command": { "publish": { "registry": "http://registry.internal" } }}Classes
Config
Defined in: src/cli-sdk/src/config/index.ts:213
Class that handles configuration for vlt.
Call Config.load to get one of these.
Constructors
new Config()
new Config(jack, projectRoot): ConfigDefined in: src/cli-sdk/src/config/index.ts:344
Parameters
jack
Jack<object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object> = definition
projectRoot
string = ...
Returns
Properties
command?
optional command: | "version" | "build" | "cache" | "ci" | "config" | "docs" | "exec" | "exec-cache" | "exec-local" | "help" | "init" | "install" | "list" | "login" | "logout" | "pack" | "pkg" | "publish" | "query" | "run" | "run-exec" | "token" | "uninstall" | "update" | "whoami" | "bugs";Defined in: src/cli-sdk/src/config/index.ts:342
Which command name to use for overriding with command-specific values, determined from the argv when parse() is called.
commands
commands: objectDefined in: src/cli-sdk/src/config/index.ts:336
Record<alias, canonical name> to dereference command aliases.
?
readonly ?: "help" = 'help';add
readonly add: "install" = 'install';b
readonly b: "build" = 'build';bugs
readonly bugs: "bugs" = 'bugs';build
readonly build: "build" = 'build';cache
readonly cache: "cache" = 'cache';ci
readonly ci: "ci" = 'ci';config
readonly config: "config" = 'config';docs
readonly docs: "docs" = 'docs';exec
readonly exec: "exec" = 'exec';exec-cache
readonly exec-cache: "exec-cache" = 'exec-cache';exec-local
readonly exec-local: "exec-local" = 'exec-local';h
readonly h: "help" = 'help';help
readonly help: "help" = 'help';i
readonly i: "install" = 'install';init
readonly init: "init" = 'init';install
readonly install: "install" = 'install';list
readonly list: "list" = 'list';login
readonly login: "login" = 'login';logout
readonly logout: "logout" = 'logout';ls
readonly ls: "list" = 'list';p
readonly p: "pkg" = 'pkg';pack
readonly pack: "pack" = 'pack';pkg
readonly pkg: "pkg" = 'pkg';pub
readonly pub: "publish" = 'publish';publish
readonly publish: "publish" = 'publish';q
readonly q: "query" = 'query';query
readonly query: "query" = 'query';r
readonly r: "run" = 'run';rm
readonly rm: "uninstall" = 'uninstall';run
readonly run: "run" = 'run';run-exec
readonly run-exec: "run-exec" = 'run-exec';run-script
readonly run-script: "run" = 'run';rx
readonly rx: "run-exec" = 'run-exec';token
readonly token: "token" = 'token';u
readonly u: "update" = 'update';uninstall
readonly uninstall: "uninstall" = 'uninstall';update
readonly update: "update" = 'update';version
readonly version: "version" = 'version';whoami
readonly whoami: "whoami" = 'whoami';x
readonly x: "exec" = 'exec';xc
readonly xc: "exec-cache" = 'exec-cache';xl
readonly xl: "exec-local" = 'exec-local';commandValues
commandValues: object = {}Defined in: src/cli-sdk/src/config/index.ts:228
Command-specific config values
bugs?
optional bugs: ConfigData;build?
optional build: ConfigData;cache?
optional cache: ConfigData;ci?
optional ci: ConfigData;config?
optional config: ConfigData;docs?
optional docs: ConfigData;exec?
optional exec: ConfigData;exec-cache?
optional exec-cache: ConfigData;exec-local?
optional exec-local: ConfigData;help?
optional help: ConfigData;init?
optional init: ConfigData;install?
optional install: ConfigData;list?
optional list: ConfigData;login?
optional login: ConfigData;logout?
optional logout: ConfigData;pack?
optional pack: ConfigData;pkg?
optional pkg: ConfigData;publish?
optional publish: ConfigData;query?
optional query: ConfigData;run?
optional run: ConfigData;run-exec?
optional run-exec: ConfigData;token?
optional token: ConfigData;uninstall?
optional uninstall: ConfigData;update?
optional update: ConfigData;version?
optional version: ConfigData;whoami?
optional whoami: ConfigData;jack
jack: Jack< object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object>Defined in: src/cli-sdk/src/config/index.ts:218
The JackSpeak object representing vlt’s configuration
positionals?
optional positionals: string[];Defined in: src/cli-sdk/src/config/index.ts:315
positional arguments to the vlt process
projectRoot
projectRoot: stringDefined in: src/cli-sdk/src/config/index.ts:331
The root of the project where a vlt.json, vlt.json, package.json, or
.git was found. Not necessarily the process.cwd(), though that is
the default location.
Never walks up as far as $HOME. So for example, if a project is in
~/projects/xyz, then the highest dir it will check is ~/projects
values?
optional values: OptionsResults<object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object>;Defined in: src/cli-sdk/src/config/index.ts:223
Parsed values in effect
Accessors
options
Get Signature
get options(): ConfigOptionsDefined in: src/cli-sdk/src/config/index.ts:235
A flattened object of the parsed configuration
Returns
Methods
addConfigToFile()
addConfigToFile( this, which,values): Promise<void>Defined in: src/cli-sdk/src/config/index.ts:450
Fold in the provided fields with the existing properties in the config file.
Parameters
this
which
values
NonNullable<ConfigFileData>
Returns
Promise<void>
deleteConfigKeys()
deleteConfigKeys( this, which,fields): Promise<boolean>Defined in: src/cli-sdk/src/config/index.ts:548
Deletes the specified config fields from the named file Returns true
if anything was changed.
Parameters
this
which
fields
string[]
Returns
Promise<boolean>
editConfigFile()
editConfigFile( this, which,edit): Promise<void>Defined in: src/cli-sdk/src/config/index.ts:601
Edit the user or project configuration file.
If the file isn’t present, then it starts with {} so the user has
something to work with.
If the result is not valid, or no config settings are contained in the file after editing, then it’s restored to what it was before, which might mean deleting the file.
Parameters
this
which
edit
(file) => void | Promise<void>
Returns
Promise<void>
get()
get<K>(k): OptionsResults<object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object & object>[K]Defined in: src/cli-sdk/src/config/index.ts:427
Get a configuration value.
Note: key=value pair configs are returned as a string array. To get
them as an object, use Config#getRecord.
Type Parameters
• K extends | "version" | "cache" | "config" |
"help" | "all" | "color" | "no-color" | "registry" |
"yes" | "workspace" | "registries" | "git-hosts" |
"git-host-archives" | "scope-registries" | "jsr-registries" |
"scope" | "os" | "libc" | "tag" | "script-shell" |
"workspace-group" | "before" | "node-version" | "arch" |
"fetch-retries" | "fetch-retry-factor" |
"fetch-retry-maxtimeout" | "fetch-retry-mintimeout" |
"git-shallow" | "identity" | "stale-while-revalidate-factor"
| "otp" | "target" | "recursive" | "package" |
"if-present" | "bail" | "no-bail" | "editor" |
"fallback-command" | "view" | "dashboard-root" | "save-dev"
| "save-optional" | "save-peer" | "save-prod" |
"expect-results" | "dry-run" | "expect-lockfile" |
"frozen-lockfile" | "lockfile-only" | "allow-scripts" |
"access" | "publish-directory"
Parameters
k
K
Returns
OptionsResults<object & object & object & object & object
& object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object>[K]
getRecord()
getRecord(k): RecordStringDefined in: src/cli-sdk/src/config/index.ts:403
Get a key=value list option value as an object.
For example, a list option with a vlaue of
['key=value', 'xyz=as=df' ] would be returned as
{key: 'value', xyz: 'as=df'}
Results are memoized, so subsequent calls for the same key will return the same object. If new strings are added to the list, then the memoized value is not updated, so only use once configurations have been fully loaded.
If the config value is not set at all, an empty object is returned.
Parameters
k
"workspace" | "registries" | "git-hosts" | "git-host-archives"
| "scope-registries" | "jsr-registries" | "workspace-group" |
"dashboard-root"
Returns
loadConfigFile()
loadConfigFile(): Promise<Config>Defined in: src/cli-sdk/src/config/index.ts:643
Find the local config file and load both it and the user-level config in the XDG config home.
Returns
Promise<Config>
parse()
parse(args): Config & objectDefined in: src/cli-sdk/src/config/index.ts:356
Parse the arguments and set configuration and positionals accordingly.
Parameters
args
string[] = process.argv
Returns
Config & object
reloadFromDisk()
reloadFromDisk(): Promise<void>Defined in: src/cli-sdk/src/config/index.ts:664
Force a complete reload of config files from disk. This clears all caches and re-reads config files. Useful for long-running processes that need to pick up config changes.
Returns
Promise<void>
resetOptions()
resetOptions(projectRoot): voidDefined in: src/cli-sdk/src/config/index.ts:303
Reset the options value, optionally setting a new project root to recalculate the options.
Parameters
projectRoot
string = ...
Returns
void
writeConfigFile()
writeConfigFile( this, which,values): Promise<void>Defined in: src/cli-sdk/src/config/index.ts:437
Write the config values to the user or project config file.
Parameters
this
which
values
NonNullable<ConfigFileData>
Returns
Promise<void>
load()
static load(projectRoot, argv): Promise<ParsedConfig>Defined in: src/cli-sdk/src/config/index.ts:698
Load the configuration and return a Promise to a Config object
Parameters
projectRoot
string = ...
argv
string[] = process.argv
Returns
Promise<ParsedConfig>
Type Aliases
ConfigData
type ConfigData = ConfigDataNoCommand & objectDefined in: src/cli-sdk/src/config/index.ts:153
Config data can be any options, and also a ‘command’ field which contains command names and override options for that command.
Type declaration
command?
optional command: { [k in keyof Commands]?: ConfigDataNoCommand };ConfigDataNoCommand
type ConfigDataNoCommand = { [k in keyof OptionsResults<ConfigDefinitions>]?: OptionsResults<ConfigDefinitions>[k]}Defined in: src/cli-sdk/src/config/index.ts:145
ConfigDefinitions
type ConfigDefinitions = Unwrap<typeof definition>Defined in: src/cli-sdk/src/config/index.ts:198
The base config definition set as a type
ConfigFileData
type ConfigFileData = ConfigFileDataNoCommand & objectDefined in: src/cli-sdk/src/config/index.ts:171
Config data as it appears in the config field of the vlt.json, with kv
pair lists stored as Record<string, string> and
Type declaration
command?
optional command: { [k in keyof Commands]?: ConfigFileDataNoCommand };ConfigFileDataNoCommand
type ConfigFileDataNoCommand = { [k in keyof ConfigDataNoCommand]: k extends ( OptListKeys<ConfigDataNoCommand> ) ? RecordString | string[] : ConfigDataNoCommand[k]}Defined in: src/cli-sdk/src/config/index.ts:159
ConfigOptions
type ConfigOptions = ConfigOptionsNoExtras & Pick<SpecOptions, 'catalog' | 'catalogs'> & objectDefined in: src/cli-sdk/src/config/index.ts:186
Type declaration
monorepo?
optional monorepo: Monorepo;packageInfo
packageInfo: PackageInfoClientpackageJson
packageJson: PackageJsonprojectRoot
projectRoot: stringscurry
scurry: PathScurryConfigOptionsNoExtras
type ConfigOptionsNoExtras = { [k in keyof OptionsResults<ConfigDefinitions>]: k extends ( RecordField ) ? RecordString : k extends 'command' ? never : OptionsResults<ConfigDefinitions>[k]}Defined in: src/cli-sdk/src/config/index.ts:177
LoadedConfig
type LoadedConfig = ParsedConfigDefined in: src/cli-sdk/src/config/index.ts:727
A fully loaded Config object
OptListKeys<O>
type OptListKeys<O> = Exclude< StringListKeys<O>[keyof StringListKeys<O>], undefined>Defined in: src/cli-sdk/src/config/index.ts:203
Type Parameters
• O
PairsAsRecords
type PairsAsRecords = ConfigOptionsNoExtras & objectDefined in: src/cli-sdk/src/config/index.ts:86
Type declaration
command?
optional command: { [k in keyof Commands]?: ConfigOptionsNoExtras };ParsedConfig
type ParsedConfig = Config & objectDefined in: src/cli-sdk/src/config/index.ts:718
Type declaration
command
command: NonNullable<Config['command']>positionals
positionals: string[];values
values: OptionsResults<ConfigDefinitions>RecordPairs
type RecordPairs = Record<string, unknown>Defined in: src/cli-sdk/src/config/index.ts:61
RecordString
type RecordString = Record<string, string>Defined in: src/cli-sdk/src/config/index.ts:62
StringListKeys<O>
type StringListKeys<O> = { [k in keyof O]: O[k] extends string[] | undefined ? k : never}Defined in: src/cli-sdk/src/config/index.ts:200
Type Parameters
• O
Variables
kCustomInspect
const kCustomInspect: typeof kCustomInspectDefined in: src/cli-sdk/src/config/index.ts:59
Functions
pairsToRecords()
function pairsToRecords(obj): PairsAsRecordsDefined in: src/cli-sdk/src/config/index.ts:92
Parameters
obj
OptionsResults<object & object & object & object & object
& object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object & object & object & object &
object & object & object> |
NonNullable<ConfigFileData>
Returns
recordsToPairs()
function recordsToPairs(obj): RecordPairsDefined in: src/cli-sdk/src/config/index.ts:114
Parameters
obj
Returns
References
commands
Re-exports commands
Commands
Re-exports Commands
definition
Re-exports definition
isRecordField
Re-exports isRecordField
recordFields
Re-exports recordFields