Skip to content

@vltpkg/cli-sdk/config

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

Class that handles configuration for vlt.

Call Config.load to get one of these.

Constructors

new Config()
new Config(jack, projectRoot): Config

Defined in: src/cli-sdk/src/config/index.ts:309

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> = definition

projectRoot

string = ...

Returns

Config

Properties

command?
optional command:
| "install"
| "init"
| "config"
| "cache"
| "query"
| "token"
| "exec"
| "exec-local"
| "gui"
| "help"
| "login"
| "logout"
| "list"
| "pkg"
| "run-exec"
| "run"
| "uninstall"
| "whoami";

Defined in: src/cli-sdk/src/config/index.ts:307

Which command name to use for overriding with command-specific values, determined from the argv when parse() is called.

commands
commands: object

Defined in: src/cli-sdk/src/config/index.ts:301

Record<alias, canonical name> to dereference command aliases.

?
readonly ?: "help" = 'help';
add
readonly add: "install" = 'install';
cache
readonly cache: "cache" = 'cache';
conf
readonly conf: "config" = 'config';
config
readonly config: "config" = 'config';
exec
readonly exec: "exec" = 'exec';
exec-local
readonly exec-local: "exec-local" = 'exec-local';
gui
readonly gui: "gui" = 'gui';
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';
pkg
readonly pkg: "pkg" = 'pkg';
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: "uninstall" = 'uninstall';
uninstall
readonly uninstall: "uninstall" = 'uninstall';
whoami
readonly whoami: "whoami" = 'whoami';
x
readonly x: "exec" = 'exec';
xl
readonly xl: "exec-local" = 'exec-local';
commandValues
commandValues: object = {}

Defined in: src/cli-sdk/src/config/index.ts:229

Command-specific config values

cache?
optional cache: ConfigData;
config?
optional config: ConfigData;
exec?
optional exec: ConfigData;
exec-local?
optional exec-local: ConfigData;
gui?
optional gui: 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;
pkg?
optional pkg: ConfigData;
query?
optional query: ConfigData;
run?
optional run: ConfigData;
run-exec?
optional run-exec: ConfigData;
token?
optional token: ConfigData;
uninstall?
optional uninstall: ConfigData;
whoami?
optional whoami: ConfigData;
configFiles
configFiles: ConfigFiles = {}

Defined in: src/cli-sdk/src/config/index.ts:219

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
>

Defined in: src/cli-sdk/src/config/index.ts:212

The JackSpeak object representing vlt’s configuration

positionals?
optional positionals: string[];

Defined in: src/cli-sdk/src/config/index.ts:286

positional arguments to the vlt process

projectRoot
projectRoot: string

Defined in: src/cli-sdk/src/config/index.ts:296

The root of the project where a vlt.json, vlt-workspaces.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

stringifyOptions
stringifyOptions: object

Defined in: src/cli-sdk/src/config/index.ts:214

[kIndent]
[kIndent]: string;
[kNewline]
[kNewline]: string;
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>;

Defined in: src/cli-sdk/src/config/index.ts:224

Parsed values in effect

Accessors

options
Get Signature
get options(): ConfigOptions

Defined in: src/cli-sdk/src/config/index.ts:236

A flattened object of the parsed configuration

Returns

ConfigOptions

Methods

addConfigToFile()
addConfigToFile(which, values): Promise<ConfigFileData>

Defined in: src/cli-sdk/src/config/index.ts:418

Fold in the provided fields with the existing properties in the config file.

Parameters
which

"user" | "project"

values

ConfigFileData

Returns

Promise<ConfigFileData>

deleteConfigKeys()
deleteConfigKeys(which, fields): Promise<boolean>

Defined in: src/cli-sdk/src/config/index.ts:494

Parameters
which

"user" | "project"

fields

string[]

Returns

Promise<boolean>

editConfigFile()
editConfigFile(which, edit): Promise<void>

Defined in: src/cli-sdk/src/config/index.ts:555

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
which

"user" | "project"

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>[K]

Defined in: src/cli-sdk/src/config/index.ts:389

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 | "registry" | "workspace" | "version" | "os" | "tag" | "script-shell" | "registries" | "git-hosts" | "git-host-archives" | "scope-registries" | "workspace-group" | "arch" | "before" | "node-version" | "fetch-retries" | "fetch-retry-factor" | "fetch-retry-maxtimeout" | "fetch-retry-mintimeout" | "git-shallow" | "config" | "cache" | "identity" | "stale-while-revalidate-factor" | "recursive" | "package" | "help" | "color" | "no-color" | "bail" | "no-bail" | "editor" | "fallback-command" | "view" | "dashboard-root" | "save-dev" | "save-optional" | "save-peer" | "save-prod" | "expect-results"

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>[K]

getFilename()
getFilename(which): string

Defined in: src/cli-sdk/src/config/index.ts:488

Parameters
which

"user" | "project"

Returns

string

getRecord()
getRecord(k): RecordString

Defined in: src/cli-sdk/src/config/index.ts:365

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" | "workspace-group" | "dashboard-root"

Returns

RecordString

loadColor()
loadColor(): Promise<Config & object & object>

Defined in: src/cli-sdk/src/config/index.ts:651

Determine whether we should use colors in the output. Update chalk appropriately.

Implicitly calls this.parse() if it not parsed already.

Returns

Promise<Config & object & object>

loadConfigFile()
loadConfigFile(): Promise<Config>

Defined in: src/cli-sdk/src/config/index.ts:602

Find the local config file and load both it and the user-level config in the XDG config home.

Note: if working in a workspaces monorepo, then the vlt.json file MUST be in the same folder as the vlt-workspaces.json file, because we stop looking when we find either one.

Returns

Promise<Config>

parse()
parse(args): Config & object

Defined in: src/cli-sdk/src/config/index.ts:321

Parse the arguments and set configuration and positionals accordingly.

Parameters
args

string[] = process.argv

Returns

Config & object

resetOptions()
resetOptions(projectRoot): void

Defined in: src/cli-sdk/src/config/index.ts:275

Reset the options value, optionally setting a new project root to recalculate the options.

Parameters
projectRoot

string = ...

Returns

void

writeConfigFile()
writeConfigFile(which, values): Promise<ConfigFileData>

Defined in: src/cli-sdk/src/config/index.ts:399

Write the config values to the user or project config file.

Parameters
which

"user" | "project"

values

ConfigFileData

Returns

Promise<ConfigFileData>

load()
static load(projectRoot, argv): Promise<LoadedConfig>

Defined in: src/cli-sdk/src/config/index.ts:683

Load the configuration and return a Promise to a Config object

Parameters
projectRoot

string = ...

argv

string[] = process.argv

Returns

Promise<LoadedConfig>

Type Aliases

ConfigData

type ConfigData = OptionsResults<ConfigDefinitions> & object

Defined in: src/cli-sdk/src/config/index.ts:162

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: Record<string, OptionsResults<ConfigDefinitions>>;

ConfigDefinitions

type ConfigDefinitions = Unwrap<typeof definition>

Defined in: src/cli-sdk/src/config/index.ts:192

The base config definition set as a type


ConfigFileData

type ConfigFileData = {
[k in keyof ConfigData]?: k extends OptListKeys<ConfigData> ?
RecordString | string[]
: k extends 'command' ? ConfigFiles
: ConfigData[k]
}

Defined in: src/cli-sdk/src/config/index.ts:170

Config data as it appears in config files, with kv pair lists stored as Record<string, string>.


ConfigFiles

type ConfigFiles = Record<string, ConfigFileData>

Defined in: src/cli-sdk/src/config/index.ts:64


ConfigOptions

type ConfigOptions = {
[k in keyof ConfigData]: k extends RecordField ? RecordString
: k extends 'command' ? never
: ConfigData[k]
} & object

Defined in: src/cli-sdk/src/config/index.ts:177

Type declaration

monorepo?
optional monorepo: Monorepo;
packageInfo
packageInfo: PackageInfoClient
packageJson
packageJson: PackageJson
projectRoot
projectRoot: string
scurry
scurry: PathScurry

LoadedConfig

type LoadedConfig = ParsedConfig & object

Defined in: src/cli-sdk/src/config/index.ts:713

A fully loaded Config object

Type declaration

get()
Parameters
k

"color"

Returns

boolean


OptListKeys<O>

type OptListKeys<O> = Exclude<
StringListKeys<O>[keyof StringListKeys<O>],
undefined
>

Defined in: src/cli-sdk/src/config/index.ts:197

Type Parameters

O


PairsAsRecords

type PairsAsRecords = Omit<
ConfigOptions,
| 'projectRoot'
| 'scurry'
| 'packageJson'
| 'monorepo'
| 'packageInfo'
> &
object

Defined in: src/cli-sdk/src/config/index.ts:88

Type declaration

command?
optional command: Record<string, ConfigOptions>;

ParsedConfig

type ParsedConfig = Config & object

Defined in: src/cli-sdk/src/config/index.ts:704

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


RecordString

type RecordString = Record<string, string>

Defined in: src/cli-sdk/src/config/index.ts:63


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

Type Parameters

O

Variables

kCustomInspect

const kCustomInspect: typeof kCustomInspect

Defined in: src/cli-sdk/src/config/index.ts:60

Functions

pairsToRecords()

function pairsToRecords(obj): PairsAsRecords

Defined in: src/cli-sdk/src/config/index.ts:99

Parameters

obj

ConfigFileData

Returns

PairsAsRecords


recordsToPairs()

function recordsToPairs(obj): RecordPairs

Defined in: src/cli-sdk/src/config/index.ts:119

Parameters

obj

RecordPairs

Returns

RecordPairs

References

commands

Re-exports commands

Commands

Re-exports Commands

definition

Re-exports definition

isRecordField

Re-exports isRecordField

recordFields

Re-exports recordFields