@anycli/config
Version:
base config object and standard interfaces for anycli components
114 lines (113 loc) • 3.08 kB
TypeScript
import { Hooks } from './hooks';
import { PJSON } from './pjson';
import * as Plugin from './plugin';
export declare type PlatformTypes = 'darwin' | 'linux' | 'win32' | 'aix' | 'freebsd' | 'openbsd' | 'sunos';
export declare type ArchTypes = 'arm' | 'arm64' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 's390' | 's390x' | 'x32' | 'x64' | 'x86';
export declare type Options = Plugin.Options | string | IConfig | undefined;
export interface IConfig extends Plugin.IPlugin {
pjson: PJSON.CLI;
/**
* process.arch
*/
arch: ArchTypes;
/**
* bin name of CLI command
*/
bin: string;
/**
* cache directory to use for CLI
*
* example ~/Library/Caches/mycli or ~/.cache/mycli
*/
cacheDir: string;
/**
* config directory to use for CLI
*
* example: ~/.config/mycli
*/
configDir: string;
/**
* data directory to use for CLI
*
* example: ~/.local/share/mycli
*/
dataDir: string;
/**
* base dirname to use in cacheDir/configDir/dataDir
*/
dirname: string;
/**
* points to a file that should be appended to for error logs
*
* example: ~/Library/Caches/mycli/error.log
*/
errlog: string;
/**
* path to home directory
*
* example: /home/myuser
*/
home: string;
/**
* process.platform
*/
platform: PlatformTypes;
/**
* active shell
*/
shell: string;
/**
* user agent to use for http calls
*
* example: mycli/1.2.3 (darwin-x64) node-9.0.0
*/
userAgent: string;
/**
* if windows
*/
windows: boolean;
/**
* debugging level
*
* set by ${BIN}_DEBUG or DEBUG=$BIN
*/
debug: number;
/**
* npm registry to use for installing plugins
*/
npmRegistry: string;
userPJSON?: PJSON.User;
runCommand(id: string, argv?: string[]): Promise<void>;
}
export declare class Config extends Plugin.Plugin implements IConfig {
arch: ArchTypes;
bin: string;
cacheDir: string;
configDir: string;
dataDir: string;
dirname: string;
errlog: string;
home: string;
platform: PlatformTypes;
shell: string;
windows: boolean;
userAgent: string;
debug: number;
npmRegistry: string;
pjson: PJSON.CLI;
userPJSON?: PJSON.User;
constructor(opts: Plugin.Options);
runHook<T extends Hooks, K extends keyof T>(event: K, opts: T[K]): Promise<void>;
runCommand(id: string, argv?: string[]): Promise<void>;
scopedEnvVar(k: string): string | undefined;
scopedEnvVarTrue(k: string): boolean;
scopedEnvVarKey(k: string): string;
protected dir(category: 'cache' | 'data' | 'config'): string;
protected windowsHome(): string | undefined;
protected windowsHomedriveHome(): string | undefined;
protected windowsUserprofileHome(): string | undefined;
protected macosCacheDir(): string | undefined;
protected _shell(): string;
protected _debug(): number;
}
export declare function load(opts?: Options): IConfig;