UNPKG

3.18 kBTypeScriptView Raw
1import { Hooks } from './hooks';
2import { PJSON } from './pjson';
3import * as Plugin from './plugin';
4export declare type PlatformTypes = 'darwin' | 'linux' | 'win32' | 'aix' | 'freebsd' | 'openbsd' | 'sunos';
5export declare type ArchTypes = 'arm' | 'arm64' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 's390' | 's390x' | 'x32' | 'x64' | 'x86';
6export interface Options extends Plugin.Options {
7 devPlugins?: boolean;
8 userPlugins?: boolean;
9}
10export interface IConfig extends Plugin.IPlugin {
11 pjson: PJSON.CLI;
12 /**
13 * process.arch
14 */
15 arch: ArchTypes;
16 /**
17 * bin name of CLI command
18 */
19 bin: string;
20 /**
21 * cache directory to use for CLI
22 *
23 * example ~/Library/Caches/mycli or ~/.cache/mycli
24 */
25 cacheDir: string;
26 /**
27 * config directory to use for CLI
28 *
29 * example: ~/.config/mycli
30 */
31 configDir: string;
32 /**
33 * data directory to use for CLI
34 *
35 * example: ~/.local/share/mycli
36 */
37 dataDir: string;
38 /**
39 * base dirname to use in cacheDir/configDir/dataDir
40 */
41 dirname: string;
42 /**
43 * points to a file that should be appended to for error logs
44 *
45 * example: ~/Library/Caches/mycli/error.log
46 */
47 errlog: string;
48 /**
49 * path to home directory
50 *
51 * example: /home/myuser
52 */
53 home: string;
54 /**
55 * process.platform
56 */
57 platform: PlatformTypes;
58 /**
59 * active shell
60 */
61 shell: string;
62 /**
63 * user agent to use for http calls
64 *
65 * example: mycli/1.2.3 (darwin-x64) node-9.0.0
66 */
67 userAgent: string;
68 /**
69 * if windows
70 */
71 windows: boolean;
72 /**
73 * debugging level
74 *
75 * set by ${BIN}_DEBUG or DEBUG=$BIN
76 */
77 debug: number;
78 /**
79 * npm registry to use for installing plugins
80 */
81 npmRegistry: string;
82 userPJSON?: PJSON.User;
83 runCommand(id: string, argv?: string[]): Promise<void>;
84}
85export declare class Config extends Plugin.Plugin implements IConfig {
86 arch: ArchTypes;
87 bin: string;
88 cacheDir: string;
89 configDir: string;
90 dataDir: string;
91 dirname: string;
92 errlog: string;
93 home: string;
94 platform: PlatformTypes;
95 shell: string;
96 windows: boolean;
97 userAgent: string;
98 debug: number;
99 npmRegistry: string;
100 pjson: PJSON.CLI;
101 userPJSON?: PJSON.User;
102 constructor(opts: Options);
103 runHook<T extends Hooks, K extends keyof T>(event: K, opts: T[K]): Promise<void>;
104 runCommand(id: string, argv?: string[]): Promise<void>;
105 scopedEnvVar(k: string): string | undefined;
106 scopedEnvVarTrue(k: string): boolean;
107 scopedEnvVarKey(k: string): string;
108 protected dir(category: 'cache' | 'data' | 'config'): string;
109 protected windowsHome(): string | undefined;
110 protected windowsHomedriveHome(): string | undefined;
111 protected windowsUserprofileHome(): string | undefined;
112 protected macosCacheDir(): string | undefined;
113 protected _shell(): string;
114 protected _debug(): number;
115}
116export declare type LoadOptions = Options | string | IConfig | undefined;
117export declare function load(opts?: LoadOptions): IConfig;