UNPKG

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