view-ignored 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +23 -27
  2. package/bin/viewig +3 -1
  3. package/out/src/browser/binds/index.d.ts +40 -21
  4. package/out/src/browser/binds/index.js +62 -48
  5. package/out/src/browser/binds/plugins/git.d.ts +22 -3
  6. package/out/src/browser/binds/plugins/git.js +57 -21
  7. package/out/src/browser/binds/plugins/npm.d.ts +36 -9
  8. package/out/src/browser/binds/plugins/npm.js +125 -59
  9. package/out/src/browser/binds/plugins/vsce.d.ts +24 -8
  10. package/out/src/browser/binds/plugins/vsce.js +56 -16
  11. package/out/src/browser/binds/plugins/yarn.d.ts +5 -10
  12. package/out/src/browser/binds/plugins/yarn.js +18 -68
  13. package/out/src/browser/binds/scanner.d.ts +56 -0
  14. package/out/src/browser/binds/scanner.js +134 -0
  15. package/out/src/browser/binds/targets.d.ts +35 -11
  16. package/out/src/browser/binds/targets.js +10 -17
  17. package/out/src/browser/errors.d.ts +58 -7
  18. package/out/src/browser/errors.js +40 -12
  19. package/out/src/browser/filtering.d.ts +15 -0
  20. package/out/src/browser/filtering.js +12 -0
  21. package/out/src/browser/fs/directory.d.ts +181 -0
  22. package/out/src/browser/fs/directory.js +235 -0
  23. package/out/src/browser/{fileinfo.d.ts → fs/file-info.d.ts} +38 -27
  24. package/out/src/browser/fs/file-info.js +86 -0
  25. package/out/src/browser/fs/file.d.ts +41 -0
  26. package/out/src/browser/fs/file.js +43 -0
  27. package/out/src/browser/fs/index.d.ts +4 -0
  28. package/out/src/browser/fs/index.js +4 -0
  29. package/out/src/browser/fs/source-info.d.ts +29 -0
  30. package/out/src/browser/fs/source-info.js +31 -0
  31. package/out/src/browser/index.d.ts +2 -2
  32. package/out/src/browser/index.js +2 -2
  33. package/out/src/browser/lib.d.ts +102 -101
  34. package/out/src/browser/lib.js +86 -120
  35. package/out/src/browser/sorting.d.ts +22 -2
  36. package/out/src/browser/sorting.js +37 -32
  37. package/out/src/browser/styling.d.ts +41 -15
  38. package/out/src/browser/styling.js +28 -97
  39. package/out/src/cli.d.ts +73 -34
  40. package/out/src/cli.js +308 -155
  41. package/out/src/config.d.ts +163 -65
  42. package/out/src/config.js +285 -171
  43. package/out/src/errors.d.ts +7 -0
  44. package/out/src/errors.js +1 -0
  45. package/out/src/index.d.ts +2 -2
  46. package/out/src/index.js +2 -2
  47. package/out/src/lib.d.ts +4 -4
  48. package/out/src/lib.js +4 -4
  49. package/out/src/styling.d.ts +10 -4
  50. package/out/src/styling.js +46 -33
  51. package/package.json +37 -23
  52. package/out/src/bin.d.ts +0 -2
  53. package/out/src/bin.js +0 -3
  54. package/out/src/browser/fileinfo.js +0 -78
  55. package/out/src/browser/scanner.d.ts +0 -103
  56. package/out/src/browser/scanner.js +0 -161
  57. package/out/src/browser/sourceinfo.d.ts +0 -62
  58. package/out/src/browser/sourceinfo.js +0 -107
@@ -1,103 +1,199 @@
1
- import { ColorSupportLevel } from "chalk";
2
- import { FilterName, Sorting, Styling } from "./browser/index.js";
3
- import { Command, Option } from "commander";
4
- /**
5
- * Contains all color level names.
6
- */
7
- export declare const colorTypeList: readonly [0, 1, 2, 3];
8
- /**
9
- * Contains all color level names as a type.
10
- */
11
- export type ColorType = ColorSupportLevel;
12
- /**
13
- * Checks if the value is the {@link ColorType}.
14
- */
15
- export declare function isColorType(value: unknown): value is ColorType;
1
+ import { type ChalkInstance } from 'chalk';
2
+ import { type Command, type Option } from 'commander';
3
+ import { type DecorName, type StyleName } from './styling.js';
4
+ import { type ConfigCheckMap } from './errors.js';
5
+ import { type SortName } from './browser/sorting.js';
6
+ import { type FilterName } from './browser/filtering.js';
16
7
  /**
17
8
  * The full config file name - `".view-ignored"`.
9
+ * @public
18
10
  */
19
11
  export declare const configFileName = ".view-ignored";
20
- /**
21
- * The user's home directory + the config file name.
22
- * @see {@link os.homedir}
23
- */
24
- export declare const configFilePath: string;
25
12
  /**
26
13
  * Command-line configuration property list.
14
+ * @public
27
15
  */
28
- export declare const configKeyList: readonly ["color", "target", "filter", "sort", "style", "decor", "depth", "showSources", "plugins", "parsable"];
16
+ export declare const configKeyList: readonly ["posix", "noColor", "target", "filter", "sort", "style", "decor", "depth", "showSources", "plugins", "parsable", "concurrency"];
29
17
  /**
30
- * Command-line configuration's key type.
18
+ * Command-line configuration's property type.
19
+ * @public
31
20
  */
32
21
  export type ConfigKey = typeof configKeyList[number] & keyof Config;
33
22
  /**
34
- * Checks if the value is the {@link ConfigKey}.
23
+ * @public
35
24
  */
36
- export declare function isConfigKey(value: unknown): value is ConfigKey;
37
25
  export type ConfigValue<KeyT extends ConfigKey = ConfigKey> = Config[KeyT];
26
+ /**
27
+ * @public
28
+ */
38
29
  export type ShowSourcesType = boolean;
39
- export declare function isShowSources(value: unknown): value is ShowSourcesType;
40
30
  /**
41
- * Checks if the value is the {@link Config} value for the specific {@link ConfigKey}.
31
+ * @public
42
32
  */
43
- export declare function isConfigValue<T extends ConfigKey>(key: T, value: unknown): value is Config[T];
33
+ export declare function isShowSources(value: unknown): value is ShowSourcesType;
44
34
  /**
45
35
  * Represents array with the key nad the value.
36
+ * @public
46
37
  */
47
38
  export type ConfigPair<KeyT extends ConfigKey = ConfigKey> = [key: KeyT, value: ConfigValue<KeyT>];
48
39
  /**
49
40
  * Command-line configuration structure.
50
41
  * @see {@link configKeyList} Before adding new properties.
42
+ * @public
51
43
  */
52
44
  export type Config = {
45
+ [key: string]: unknown;
53
46
  parsable: boolean;
47
+ noColor: boolean;
48
+ posix: boolean;
54
49
  plugins: string[];
55
- color: ColorType;
56
50
  target: string;
57
51
  filter: FilterName;
58
- sort: Sorting.SortName;
59
- style: Styling.StyleName;
60
- decor: Styling.DecorName;
52
+ sort: SortName;
53
+ style: StyleName;
54
+ decor: DecorName;
61
55
  depth: number;
62
56
  showSources: ShowSourcesType;
57
+ concurrency: number;
63
58
  };
64
59
  /**
65
60
  * Command-line default config values.
61
+ * @public
66
62
  */
67
63
  export declare const configDefault: Readonly<Config>;
68
64
  /**
69
- * @returns `true`, if the value can be used as a configuration.
65
+ * @returns Error message and parsed value.
66
+ * @public
67
+ */
68
+ export type ConfigValidator = ((value: unknown) => string | undefined) & {
69
+ typeName: string;
70
+ };
71
+ /**
72
+ * @public
73
+ */
74
+ export declare const configValueArray: <T extends ConfigValidator>(type?: T) => ConfigValidator;
75
+ /**
76
+ * @public
77
+ */
78
+ export declare const configValueLiteral: (choices: readonly unknown[]) => ConfigValidator;
79
+ /**
80
+ * @public
81
+ */
82
+ export declare const switchTrueValues: string[];
83
+ /**
84
+ * @public
85
+ */
86
+ export declare const switchFalseValues: string[];
87
+ /**
88
+ * @public
89
+ */
90
+ export declare const booleanValues: string[];
91
+ /**
92
+ * @public
93
+ */
94
+ export declare const configValueSwitch: () => ConfigValidator;
95
+ /**
96
+ * @public
97
+ */
98
+ export declare const configValueBoolean: () => ConfigValidator;
99
+ /**
100
+ * @public
101
+ */
102
+ export declare const configValueObject: () => ConfigValidator;
103
+ /**
104
+ * @public
105
+ */
106
+ export declare const configValueString: () => ConfigValidator;
107
+ /**
108
+ * @public
109
+ */
110
+ export declare const configValueNumber: () => ConfigValidator;
111
+ /**
112
+ * @public
113
+ */
114
+ export declare const configValueInteger: () => ConfigValidator;
115
+ /**
116
+ * @public
70
117
  */
71
- export declare function isConfigPartial(cfg: unknown): cfg is Partial<Config>;
72
- export declare const trueValues: string[];
73
- export declare const falseValues: string[];
74
- export declare const boolValues: string[];
118
+ export type ConfigManagerGetOptions = {
119
+ /**
120
+ * Use default value as fallback.
121
+ * @default true
122
+ */
123
+ real?: boolean;
124
+ };
75
125
  /**
76
- * @returns available values or requirement message for the specified property.
77
- * @param key The config property.
78
- * @param fallbackDefault If `true`, the default value will be used when the value is `undefined`. Default `true`.
126
+ * @public
79
127
  */
80
- export declare function configValueList<T extends ConfigKey>(key: T): readonly string[] | string;
81
- export declare function configValueLinkCliOption<T extends ConfigKey>(key: T, command: Command, option: Option, parseArg?: (arg: string) => unknown): Option;
82
- export declare function configValueGetCliOption<T extends ConfigKey>(key: T): Option | undefined;
128
+ export type ConfigManagerGetPairStringOptions = ConfigManagerGetOptions & {
129
+ /**
130
+ * Add the type postfix.
131
+ * @default true
132
+ */
133
+ types?: boolean;
134
+ /**
135
+ * Determine the colors behavior.
136
+ * @default undefined
137
+ */
138
+ chalk?: ChalkInstance;
139
+ /**
140
+ * Use parsable format. If enabled, `chalk` option ignored.
141
+ * @default false
142
+ */
143
+ parsable?: boolean;
144
+ };
83
145
  /**
84
146
  * File-specific actions container.
147
+ * @public
85
148
  */
86
- export declare class ConfigManager {
87
- readonly filePath: string;
88
- constructor(filePath: string);
149
+ export declare class ConfigManager<ConfigType extends Config = Config> {
150
+ readonly path: string;
89
151
  /**
90
152
  * Do not change this value directly.
91
153
  * @see {@link configManager}.
92
154
  */
93
155
  private data;
94
- dataRaw(): unknown;
95
- entries(): [string, any][] | undefined;
156
+ private readonly configValidation;
157
+ private readonly cliOptionLinkMap;
158
+ private readonly dataDefault;
159
+ constructor(path: string);
160
+ dataCheck(data: unknown): ConfigCheckMap | string;
161
+ /**
162
+ * Get type name for the key.
163
+ */
164
+ getType<T extends keyof ConfigType>(key: T): string;
165
+ getType(key: string): string;
166
+ /**
167
+ * Get type checker for the key.
168
+ */
169
+ keyGetValidator<T extends keyof ConfigType>(key: T): ConfigValidator | undefined;
170
+ /**
171
+ * Define type checker for the key.
172
+ */
173
+ keySetValidator<T extends keyof ConfigType & string>(key: T, defaultValue: ConfigType[T], type: ConfigValidator): this;
174
+ /**
175
+ * Checks if the key is defined.
176
+ * @returns Error message if the key is not defined.
177
+ */
178
+ checkKey(key: string): string | undefined;
179
+ /**
180
+ * Call the type checker for the key.
181
+ */
182
+ checkValue<T extends keyof ConfigType>(key: T, value: unknown): string | undefined;
183
+ /**
184
+ * Link a configuration property with a command-line option.
185
+ */
186
+ setOption<T extends keyof ConfigType>(key: T, command: Command, option: Option, parseArgument?: (argument: string) => unknown): this;
187
+ /**
188
+ * Get a command-line option for the configuration property.
189
+ */
190
+ getOption<T extends keyof ConfigType>(key: T): Option | undefined;
191
+ getOption(key: string): Option | undefined;
96
192
  /**
97
- * Loads the config from the file to {@link configManager.data}. If the data is not valid, throws an error without loading.
98
- * @returns `undefined` if the config file does not exist.
193
+ * Loads the config from the file to {@link configManager.data}.
194
+ * @returns The error message for each invalid property.
99
195
  */
100
- load(): this | undefined;
196
+ load(): ConfigCheckMap | string | undefined;
101
197
  /**
102
198
  * Saves the partial config to the file. If there are no settings, the file will be deleted, if exists.
103
199
  */
@@ -108,34 +204,36 @@ export declare class ConfigManager {
108
204
  * @param key The name of the config property.
109
205
  * @param value The new value for the config property.
110
206
  */
111
- set<T extends ConfigKey>(key: T, value: Config[T]): this;
207
+ set<T extends keyof ConfigType>(key: T, value: ConfigType[T]): string | undefined;
208
+ set(key: string, value: unknown): string | undefined;
112
209
  /**
113
210
  * Deletes the specified property from the config.
114
211
  * If the property is not specified, then all properties will be deleted.
115
212
  * @param key The config property.
116
213
  */
117
- unset<T extends ConfigKey>(key?: T): this;
214
+ unset<T extends keyof ConfigType>(key?: T): this;
215
+ unset(key?: string): this;
118
216
  /**
119
217
  * @returns An array of properties which defined in the configuration file.
120
218
  */
121
- definedKeys(): ConfigKey[];
219
+ keyList(real?: boolean): Array<keyof ConfigType>;
122
220
  /**
123
221
  * @param key The config property.
124
- * @param defs If `true`, the default value will be used when the value is `undefined`. Default `true`.
222
+ * @param real The options.
125
223
  * @returns The value for the specified property.
126
224
  */
127
- get<KeyT extends ConfigKey>(key: KeyT, defs: false): ConfigValue<KeyT> | undefined;
128
- get<KeyT extends ConfigKey>(key: KeyT, defs?: true): ConfigValue<KeyT>;
129
- get<KeyT extends ConfigKey>(key: KeyT, defs: boolean): ConfigValue<KeyT> | undefined;
130
- /**
131
- * @param key The config property.
132
- * @param defs If `true`, the default value will be used when the value is `undefined`. Default `true`.
133
- * @returns A string in the `"key=value"` format, if the property is specified.
134
- * Otherwise in format `"key=value\nkey=value\n..."` without the '\n' ending.
135
- */
136
- getPairString<KeyT extends ConfigKey>(key?: KeyT, defs?: boolean): string;
225
+ get<T extends keyof ConfigType>(key: T, options: ConfigManagerGetOptions & {
226
+ real?: false;
227
+ }): ConfigType[T] | undefined;
228
+ get<T extends keyof ConfigType>(key: T, options?: ConfigManagerGetOptions & {
229
+ real: true;
230
+ }): ConfigType[T];
231
+ get(key: string, options?: ConfigManagerGetOptions): unknown;
232
+ getPairString<T extends keyof ConfigType>(keys?: T | T[], options?: ConfigManagerGetPairStringOptions): string;
233
+ getPairString(keys?: string | string[], options?: ConfigManagerGetPairStringOptions): string;
137
234
  }
138
235
  /**
139
236
  * File-specific actions container. Contains get, set, unset, save, load and other configuration actions.
237
+ * @public
140
238
  */
141
- export declare const configManager: ConfigManager;
239
+ export declare const configManager: ConfigManager<Config>;