UNPKG

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