Add custom path support for cli/tui in terminal config

This commit is contained in:
2026-06-01 11:49:23 +02:00
parent 5e9c6db412
commit b30243f674
12 changed files with 264 additions and 42 deletions

View File

@@ -1,5 +1,5 @@
/**
* Global XO CLI config layout (XDG-style: ~/.config/xo-cli/).
* Global XO CLI config layout (`XO_CONFIG_DIR` or ~/.config/xo-cli/).
* User-provided paths (templates, invitation JSON) stay relative to cwd.
*/
@@ -11,7 +11,7 @@ import { basename, isAbsolute, join, resolve } from "node:path";
* Base config directory. Created on first access.
*/
export function getConfigDir(): string {
const dir = join(homedir(), ".config", "xo-cli");
const dir = process.env["XO_CONFIG_DIR"] || join(homedir(), ".config", "xo-cli");
mkdirSync(dir, { recursive: true });
return dir;
}
@@ -50,7 +50,7 @@ export function getWalletConfigPath(): string {
/**
* Resolves a mnemonic reference to an absolute path.
* Order: absolute path if it exists → path relative to cwd → ~/.config/xo-cli/mnemonics/<basename>.
* Order: absolute path if it exists → path relative to cwd → config mnemonics directory/<basename>.
*
* @param mnemonicRef - Path or basename (e.g. `mnemonic-nuclear`)
* @returns Absolute path to the mnemonic file