view-ignored 0.4.0 → 0.4.2
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.
- package/README.md +3 -4
- package/bin/viewig +1 -1
- package/out/{src/browser → browser}/binds/index.d.ts +1 -20
- package/out/{src/browser → browser}/binds/index.js +3 -9
- package/out/browser/binds/plugins/git.d.ts +3 -0
- package/out/{src/browser → browser}/binds/plugins/git.js +3 -3
- package/out/browser/binds/plugins/jsr.d.ts +3 -0
- package/out/browser/binds/plugins/jsr.js +96 -0
- package/out/browser/binds/plugins/npm.d.ts +3 -0
- package/out/{src/browser → browser}/binds/plugins/npm.js +15 -16
- package/out/browser/binds/plugins/vsce.d.ts +3 -0
- package/out/{src/browser → browser}/binds/plugins/vsce.js +3 -3
- package/out/browser/binds/plugins/yarn.d.ts +3 -0
- package/out/{src/browser → browser}/binds/plugins/yarn.js +2 -2
- package/out/{src/browser → browser}/binds/scanner.d.ts +0 -12
- package/out/{src/browser → browser}/binds/scanner.js +0 -6
- package/out/{src/browser → browser}/binds/targets.d.ts +0 -11
- package/out/{src/browser → browser}/binds/targets.js +1 -6
- package/out/{src/browser → browser}/errors.d.ts +0 -15
- package/out/{src/browser → browser}/errors.js +0 -15
- package/out/{src/browser → browser}/filtering.d.ts +0 -3
- package/out/{src/browser → browser}/filtering.js +0 -2
- package/out/{src/browser → browser}/fs/directory.d.ts +0 -53
- package/out/{src/browser → browser}/fs/directory.js +3 -6
- package/out/{src/browser → browser}/fs/file-info.d.ts +1 -6
- package/out/{src/browser → browser}/fs/file-info.js +1 -2
- package/out/{src/browser → browser}/fs/file.d.ts +0 -3
- package/out/{src/browser → browser}/fs/file.js +0 -3
- package/out/{src/browser → browser}/fs/source-info.d.ts +0 -1
- package/out/{src/browser → browser}/fs/source-info.js +0 -1
- package/out/{src/browser → browser}/lib.d.ts +1 -12
- package/out/{src/browser → browser}/lib.js +1 -4
- package/out/{src/browser → browser}/sorting.d.ts +0 -10
- package/out/{src/browser → browser}/sorting.js +0 -8
- package/out/{src/browser → browser}/styling.d.ts +2 -16
- package/out/{src/browser → browser}/styling.js +0 -7
- package/out/{src/cli.d.ts → cli.d.ts} +0 -47
- package/out/{src/cli.js → cli.js} +4 -39
- package/out/{src/config.d.ts → config.d.ts} +0 -57
- package/out/{src/config.js → config.js} +11 -53
- package/out/{src/errors.d.ts → errors.d.ts} +0 -1
- package/out/{src/styling.d.ts → styling.d.ts} +0 -6
- package/out/{src/styling.js → styling.js} +1 -7
- package/package.json +32 -39
- package/out/package.json +0 -122
- package/out/src/browser/binds/plugins/git.d.ts +0 -22
- package/out/src/browser/binds/plugins/npm.d.ts +0 -38
- package/out/src/browser/binds/plugins/vsce.d.ts +0 -25
- package/out/src/browser/binds/plugins/yarn.d.ts +0 -11
- /package/out/{src/browser → browser}/fs/index.d.ts +0 -0
- /package/out/{src/browser → browser}/fs/index.js +0 -0
- /package/out/{src/browser → browser}/index.d.ts +0 -0
- /package/out/{src/browser → browser}/index.js +0 -0
- /package/out/{src/errors.js → errors.js} +0 -0
- /package/out/{src/index.d.ts → index.d.ts} +0 -0
- /package/out/{src/index.js → index.js} +0 -0
- /package/out/{src/lib.d.ts → lib.d.ts} +0 -0
- /package/out/{src/lib.js → lib.js} +0 -0
|
@@ -2,20 +2,9 @@ import { Argument, Option, Command } from 'commander';
|
|
|
2
2
|
import * as Config from './config.js';
|
|
3
3
|
import { type DecorName, type StyleName } from './browser/styling.js';
|
|
4
4
|
import { type SortName } from './browser/sorting.js';
|
|
5
|
-
import { type BoxOptions } from './styling.js';
|
|
6
5
|
import { type FilterName } from './browser/filtering.js';
|
|
7
|
-
/**
|
|
8
|
-
* @private
|
|
9
|
-
*/
|
|
10
|
-
export declare function logError(message: string, options?: BoxOptions): void;
|
|
11
|
-
/**
|
|
12
|
-
* Use it instead of {@link program.parse}.
|
|
13
|
-
* @private
|
|
14
|
-
*/
|
|
15
|
-
export declare function programInit(): Promise<void>;
|
|
16
6
|
/**
|
|
17
7
|
* Command-line entire program flags.
|
|
18
|
-
* @public
|
|
19
8
|
*/
|
|
20
9
|
export type ProgramFlags = {
|
|
21
10
|
posix: boolean;
|
|
@@ -26,7 +15,6 @@ export type ProgramFlags = {
|
|
|
26
15
|
};
|
|
27
16
|
/**
|
|
28
17
|
* Command-line 'scan' command flags.
|
|
29
|
-
* @public
|
|
30
18
|
*/
|
|
31
19
|
export type ScanFlags = {
|
|
32
20
|
target: string;
|
|
@@ -39,7 +27,6 @@ export type ScanFlags = {
|
|
|
39
27
|
};
|
|
40
28
|
/**
|
|
41
29
|
* Command-line 'cfg get' command flags.
|
|
42
|
-
* @public
|
|
43
30
|
*/
|
|
44
31
|
export type ConfigGetFlags = {
|
|
45
32
|
real: boolean;
|
|
@@ -47,85 +34,51 @@ export type ConfigGetFlags = {
|
|
|
47
34
|
};
|
|
48
35
|
/**
|
|
49
36
|
* `view-ignored` command-line programl
|
|
50
|
-
* @public
|
|
51
37
|
*/
|
|
52
38
|
export declare const program: Command;
|
|
53
39
|
/**
|
|
54
40
|
* Command-line 'scan' command.
|
|
55
|
-
* @public
|
|
56
41
|
*/
|
|
57
42
|
export declare const scanProgram: Command;
|
|
58
43
|
/**
|
|
59
44
|
* Command-line 'config' command.
|
|
60
|
-
* @public
|
|
61
45
|
*/
|
|
62
46
|
export declare const cfgProgram: Command;
|
|
63
47
|
/**
|
|
64
48
|
* Command-line argument: key=value pair.
|
|
65
49
|
* @see {@link parseArgumentKeyValue}
|
|
66
|
-
* @public
|
|
67
50
|
*/
|
|
68
51
|
export declare const argumentConfigKeyValue: Argument;
|
|
69
52
|
/**
|
|
70
53
|
* Command-line argument: config property.
|
|
71
54
|
* @see {@link Config.configKeyList}
|
|
72
|
-
* @public
|
|
73
55
|
*/
|
|
74
56
|
export declare const argumentConfigKey: Argument;
|
|
75
|
-
/**
|
|
76
|
-
* @public
|
|
77
|
-
*/
|
|
78
57
|
export declare const cfgRealOption: Option;
|
|
79
|
-
/**
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
58
|
export declare const cfgTypesOption: Option;
|
|
83
|
-
/**
|
|
84
|
-
* @public
|
|
85
|
-
*/
|
|
86
59
|
export declare function parseArgumentArrayString(argument: string): string[];
|
|
87
|
-
/**
|
|
88
|
-
* @public
|
|
89
|
-
*/
|
|
90
60
|
export declare function parseArgumentBoolean(argument: string): boolean;
|
|
91
|
-
/**
|
|
92
|
-
* @public
|
|
93
|
-
*/
|
|
94
61
|
export declare function parseArgumentInteger(argument: string): number;
|
|
95
|
-
/**
|
|
96
|
-
* @public
|
|
97
|
-
*/
|
|
98
62
|
export declare function createArgumentParserStringLiteral(choices: string[]): (argument: string) => string;
|
|
99
|
-
/**
|
|
100
|
-
* @public
|
|
101
|
-
*/
|
|
102
63
|
export declare function parseArgumentKey(key: string): string;
|
|
103
|
-
/**
|
|
104
|
-
* @public
|
|
105
|
-
*/
|
|
106
64
|
export declare function parseArgumentKeyValue(pair: string): Config.ConfigPair;
|
|
107
65
|
/**
|
|
108
66
|
* Command-line 'scan' command action.
|
|
109
|
-
* @public
|
|
110
67
|
*/
|
|
111
68
|
export declare function actionScan(): Promise<void>;
|
|
112
69
|
/**
|
|
113
70
|
* Command-line 'config path' command action.
|
|
114
|
-
* @public
|
|
115
71
|
*/
|
|
116
72
|
export declare function actionCfgPath(): void;
|
|
117
73
|
/**
|
|
118
74
|
* Command-line 'config set' command action
|
|
119
|
-
* @public
|
|
120
75
|
*/
|
|
121
76
|
export declare function actionCfgSet(pair: Config.ConfigPair | undefined, options: ConfigGetFlags): void;
|
|
122
77
|
/**
|
|
123
78
|
* Command-line 'config unset' command action
|
|
124
|
-
* @public
|
|
125
79
|
*/
|
|
126
80
|
export declare function actionCfgUnset(key: Config.ConfigKey | undefined, options: ConfigGetFlags): void;
|
|
127
81
|
/**
|
|
128
82
|
* Command-line 'config unset' command action
|
|
129
|
-
* @public
|
|
130
83
|
*/
|
|
131
84
|
export declare function actionCfgGet(key: Config.ConfigKey | undefined, options: ConfigGetFlags): void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable unicorn/no-process-exit */
|
|
2
1
|
import { format } from 'node:util';
|
|
3
2
|
import * as process from 'node:process';
|
|
4
3
|
import { icons } from '@m234/nerd-fonts';
|
|
@@ -13,14 +12,14 @@ import { boxError, decorNameList, highlight, stringTime, styleNameList, } from '
|
|
|
13
12
|
import { Directory, package_, makeOptionsReal, scan, Sorting, ViewIgnoredError, } from './lib.js';
|
|
14
13
|
import { filterNameList } from './browser/filtering.js';
|
|
15
14
|
/**
|
|
16
|
-
* @
|
|
15
|
+
* @internal
|
|
17
16
|
*/
|
|
18
17
|
export function logError(message, options) {
|
|
19
18
|
console.log(boxError(message, { ...options }));
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
22
21
|
* Use it instead of {@link program.parse}.
|
|
23
|
-
* @
|
|
22
|
+
* @internal
|
|
24
23
|
*/
|
|
25
24
|
export async function programInit() {
|
|
26
25
|
try {
|
|
@@ -88,12 +87,10 @@ export async function programInit() {
|
|
|
88
87
|
}
|
|
89
88
|
/**
|
|
90
89
|
* `view-ignored` command-line programl
|
|
91
|
-
* @public
|
|
92
90
|
*/
|
|
93
91
|
export const program = new Command();
|
|
94
92
|
/**
|
|
95
93
|
* Command-line 'scan' command.
|
|
96
|
-
* @public
|
|
97
94
|
*/
|
|
98
95
|
export const scanProgram = program
|
|
99
96
|
.command('scan')
|
|
@@ -102,7 +99,6 @@ export const scanProgram = program
|
|
|
102
99
|
.action(actionScan);
|
|
103
100
|
/**
|
|
104
101
|
* Command-line 'config' command.
|
|
105
|
-
* @public
|
|
106
102
|
*/
|
|
107
103
|
export const cfgProgram = program
|
|
108
104
|
.command('config')
|
|
@@ -111,22 +107,14 @@ export const cfgProgram = program
|
|
|
111
107
|
/**
|
|
112
108
|
* Command-line argument: key=value pair.
|
|
113
109
|
* @see {@link parseArgumentKeyValue}
|
|
114
|
-
* @public
|
|
115
110
|
*/
|
|
116
111
|
export const argumentConfigKeyValue = new Argument('[pair]', 'the configuration entry key=value\'').argParser(parseArgumentKeyValue);
|
|
117
112
|
/**
|
|
118
113
|
* Command-line argument: config property.
|
|
119
114
|
* @see {@link Config.configKeyList}
|
|
120
|
-
* @public
|
|
121
115
|
*/
|
|
122
116
|
export const argumentConfigKey = new Argument('[key]', 'the configuration setting name').choices(Config.configKeyList);
|
|
123
|
-
/**
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
117
|
export const cfgRealOption = new Option('--real', 'use default value(s) as fallback').default(false);
|
|
127
|
-
/**
|
|
128
|
-
* @public
|
|
129
|
-
*/
|
|
130
118
|
export const cfgTypesOption = new Option('--types', 'use default value(s) as fallback').default(false);
|
|
131
119
|
cfgProgram
|
|
132
120
|
.command('path').description('print the config file path')
|
|
@@ -149,15 +137,9 @@ cfgProgram
|
|
|
149
137
|
.addOption(cfgTypesOption)
|
|
150
138
|
.addArgument(argumentConfigKey)
|
|
151
139
|
.action(actionCfgGet);
|
|
152
|
-
/**
|
|
153
|
-
* @public
|
|
154
|
-
*/
|
|
155
140
|
export function parseArgumentArrayString(argument) {
|
|
156
141
|
return argument.split(/[ ,|]/).filter(Boolean);
|
|
157
142
|
}
|
|
158
|
-
/**
|
|
159
|
-
* @public
|
|
160
|
-
*/
|
|
161
143
|
export function parseArgumentBoolean(argument) {
|
|
162
144
|
const errorMessage = Config.configValueSwitch()(argument);
|
|
163
145
|
if (errorMessage !== undefined) {
|
|
@@ -165,9 +147,6 @@ export function parseArgumentBoolean(argument) {
|
|
|
165
147
|
}
|
|
166
148
|
return Config.switchTrueValues.includes(argument);
|
|
167
149
|
}
|
|
168
|
-
/**
|
|
169
|
-
* @public
|
|
170
|
-
*/
|
|
171
150
|
export function parseArgumentInteger(argument) {
|
|
172
151
|
const value = Number.parseInt(argument, 10);
|
|
173
152
|
const errorMessage = Config.configValueInteger()(value);
|
|
@@ -176,9 +155,6 @@ export function parseArgumentInteger(argument) {
|
|
|
176
155
|
}
|
|
177
156
|
return value;
|
|
178
157
|
}
|
|
179
|
-
/**
|
|
180
|
-
* @public
|
|
181
|
-
*/
|
|
182
158
|
export function createArgumentParserStringLiteral(choices) {
|
|
183
159
|
return function (argument) {
|
|
184
160
|
const errorMessage = Config.configValueLiteral(choices)(argument);
|
|
@@ -188,9 +164,6 @@ export function createArgumentParserStringLiteral(choices) {
|
|
|
188
164
|
return argument;
|
|
189
165
|
};
|
|
190
166
|
}
|
|
191
|
-
/**
|
|
192
|
-
* @public
|
|
193
|
-
*/
|
|
194
167
|
export function parseArgumentKey(key) {
|
|
195
168
|
const errorMessage = Config.configManager.checkKey(key);
|
|
196
169
|
if (errorMessage !== undefined) {
|
|
@@ -198,9 +171,6 @@ export function parseArgumentKey(key) {
|
|
|
198
171
|
}
|
|
199
172
|
return key;
|
|
200
173
|
}
|
|
201
|
-
/**
|
|
202
|
-
* @public
|
|
203
|
-
*/
|
|
204
174
|
export function parseArgumentKeyValue(pair) {
|
|
205
175
|
const result = pair.split('=');
|
|
206
176
|
if (result.length > 2) {
|
|
@@ -224,7 +194,6 @@ export function parseArgumentKeyValue(pair) {
|
|
|
224
194
|
}
|
|
225
195
|
/**
|
|
226
196
|
* Command-line 'scan' command action.
|
|
227
|
-
* @public
|
|
228
197
|
*/
|
|
229
198
|
export async function actionScan() {
|
|
230
199
|
const flags = scanProgram.optsWithGlobals();
|
|
@@ -263,8 +232,8 @@ export async function actionScan() {
|
|
|
263
232
|
fileInfoList: [],
|
|
264
233
|
stream,
|
|
265
234
|
message: '',
|
|
266
|
-
reading: new Promise(resolve => {
|
|
267
|
-
stream.on('end', data => {
|
|
235
|
+
reading: new Promise((resolve) => {
|
|
236
|
+
stream.on('end', (data) => {
|
|
268
237
|
resolve(data);
|
|
269
238
|
});
|
|
270
239
|
}),
|
|
@@ -350,14 +319,12 @@ export async function actionScan() {
|
|
|
350
319
|
}
|
|
351
320
|
/**
|
|
352
321
|
* Command-line 'config path' command action.
|
|
353
|
-
* @public
|
|
354
322
|
*/
|
|
355
323
|
export function actionCfgPath() {
|
|
356
324
|
console.log(Config.configManager.path);
|
|
357
325
|
}
|
|
358
326
|
/**
|
|
359
327
|
* Command-line 'config set' command action
|
|
360
|
-
* @public
|
|
361
328
|
*/
|
|
362
329
|
export function actionCfgSet(pair, options) {
|
|
363
330
|
if (pair === undefined) {
|
|
@@ -379,7 +346,6 @@ export function actionCfgSet(pair, options) {
|
|
|
379
346
|
}
|
|
380
347
|
/**
|
|
381
348
|
* Command-line 'config unset' command action
|
|
382
|
-
* @public
|
|
383
349
|
*/
|
|
384
350
|
export function actionCfgUnset(key, options) {
|
|
385
351
|
if (key === undefined) {
|
|
@@ -394,7 +360,6 @@ export function actionCfgUnset(key, options) {
|
|
|
394
360
|
}
|
|
395
361
|
/**
|
|
396
362
|
* Command-line 'config unset' command action
|
|
397
|
-
* @public
|
|
398
363
|
*/
|
|
399
364
|
export function actionCfgGet(key, options) {
|
|
400
365
|
const flags = scanProgram.optsWithGlobals();
|
|
@@ -6,40 +6,26 @@ import { type SortName } from './browser/sorting.js';
|
|
|
6
6
|
import { type FilterName } from './browser/filtering.js';
|
|
7
7
|
/**
|
|
8
8
|
* The full config file name - `".view-ignored"`.
|
|
9
|
-
* @public
|
|
10
9
|
*/
|
|
11
10
|
export declare const configFileName = ".view-ignored";
|
|
12
11
|
/**
|
|
13
12
|
* Command-line configuration property list.
|
|
14
|
-
* @public
|
|
15
13
|
*/
|
|
16
14
|
export declare const configKeyList: readonly ["posix", "noColor", "target", "filter", "sort", "style", "decor", "depth", "showSources", "plugins", "parsable", "concurrency"];
|
|
17
15
|
/**
|
|
18
16
|
* Command-line configuration's property type.
|
|
19
|
-
* @public
|
|
20
17
|
*/
|
|
21
18
|
export type ConfigKey = typeof configKeyList[number] & keyof Config;
|
|
22
|
-
/**
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
19
|
export type ConfigValue<KeyT extends ConfigKey = ConfigKey> = Config[KeyT];
|
|
26
|
-
/**
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
20
|
export type ShowSourcesType = boolean;
|
|
30
|
-
/**
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
21
|
export declare function isShowSources(value: unknown): value is ShowSourcesType;
|
|
34
22
|
/**
|
|
35
23
|
* Represents array with the key nad the value.
|
|
36
|
-
* @public
|
|
37
24
|
*/
|
|
38
25
|
export type ConfigPair<KeyT extends ConfigKey = ConfigKey> = [key: KeyT, value: ConfigValue<KeyT>];
|
|
39
26
|
/**
|
|
40
27
|
* Command-line configuration structure.
|
|
41
28
|
* @see {@link configKeyList} Before adding new properties.
|
|
42
|
-
* @public
|
|
43
29
|
*/
|
|
44
30
|
export type Config = {
|
|
45
31
|
[key: string]: unknown;
|
|
@@ -58,63 +44,25 @@ export type Config = {
|
|
|
58
44
|
};
|
|
59
45
|
/**
|
|
60
46
|
* Command-line default config values.
|
|
61
|
-
* @public
|
|
62
47
|
*/
|
|
63
48
|
export declare const configDefault: Readonly<Config>;
|
|
64
49
|
/**
|
|
65
50
|
* @returns Error message and parsed value.
|
|
66
|
-
* @public
|
|
67
51
|
*/
|
|
68
52
|
export type ConfigValidator = ((value: unknown) => string | undefined) & {
|
|
69
53
|
typeName: string;
|
|
70
54
|
};
|
|
71
|
-
/**
|
|
72
|
-
* @public
|
|
73
|
-
*/
|
|
74
55
|
export declare const configValueArray: <T extends ConfigValidator>(type?: T) => ConfigValidator;
|
|
75
|
-
/**
|
|
76
|
-
* @public
|
|
77
|
-
*/
|
|
78
56
|
export declare const configValueLiteral: (choices: readonly unknown[]) => ConfigValidator;
|
|
79
|
-
/**
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
57
|
export declare const switchTrueValues: string[];
|
|
83
|
-
/**
|
|
84
|
-
* @public
|
|
85
|
-
*/
|
|
86
58
|
export declare const switchFalseValues: string[];
|
|
87
|
-
/**
|
|
88
|
-
* @public
|
|
89
|
-
*/
|
|
90
59
|
export declare const booleanValues: string[];
|
|
91
|
-
/**
|
|
92
|
-
* @public
|
|
93
|
-
*/
|
|
94
60
|
export declare const configValueSwitch: () => ConfigValidator;
|
|
95
|
-
/**
|
|
96
|
-
* @public
|
|
97
|
-
*/
|
|
98
61
|
export declare const configValueBoolean: () => ConfigValidator;
|
|
99
|
-
/**
|
|
100
|
-
* @public
|
|
101
|
-
*/
|
|
102
62
|
export declare const configValueObject: () => ConfigValidator;
|
|
103
|
-
/**
|
|
104
|
-
* @public
|
|
105
|
-
*/
|
|
106
63
|
export declare const configValueString: () => ConfigValidator;
|
|
107
|
-
/**
|
|
108
|
-
* @public
|
|
109
|
-
*/
|
|
110
64
|
export declare const configValueNumber: () => ConfigValidator;
|
|
111
|
-
/**
|
|
112
|
-
* @public
|
|
113
|
-
*/
|
|
114
65
|
export declare const configValueInteger: () => ConfigValidator;
|
|
115
|
-
/**
|
|
116
|
-
* @public
|
|
117
|
-
*/
|
|
118
66
|
export type ConfigManagerGetOptions = {
|
|
119
67
|
/**
|
|
120
68
|
* Use default value as fallback.
|
|
@@ -122,9 +70,6 @@ export type ConfigManagerGetOptions = {
|
|
|
122
70
|
*/
|
|
123
71
|
real?: boolean;
|
|
124
72
|
};
|
|
125
|
-
/**
|
|
126
|
-
* @public
|
|
127
|
-
*/
|
|
128
73
|
export type ConfigManagerGetPairStringOptions = ConfigManagerGetOptions & {
|
|
129
74
|
/**
|
|
130
75
|
* Add the type postfix.
|
|
@@ -144,7 +89,6 @@ export type ConfigManagerGetPairStringOptions = ConfigManagerGetOptions & {
|
|
|
144
89
|
};
|
|
145
90
|
/**
|
|
146
91
|
* File-specific actions container.
|
|
147
|
-
* @public
|
|
148
92
|
*/
|
|
149
93
|
export declare class ConfigManager<ConfigType extends Config = Config> {
|
|
150
94
|
readonly path: string;
|
|
@@ -234,6 +178,5 @@ export declare class ConfigManager<ConfigType extends Config = Config> {
|
|
|
234
178
|
}
|
|
235
179
|
/**
|
|
236
180
|
* File-specific actions container. Contains get, set, unset, save, load and other configuration actions.
|
|
237
|
-
* @public
|
|
238
181
|
*/
|
|
239
182
|
export declare const configManager: ConfigManager<Config>;
|
|
@@ -8,18 +8,16 @@ import { sortNameList } from './browser/sorting.js';
|
|
|
8
8
|
import { filterNameList } from './browser/filtering.js';
|
|
9
9
|
/**
|
|
10
10
|
* The full config file name - `".view-ignored"`.
|
|
11
|
-
* @public
|
|
12
11
|
*/
|
|
13
12
|
export const configFileName = '.view-ignored';
|
|
14
13
|
/**
|
|
15
14
|
* The user's home directory + the config file name.
|
|
16
15
|
* @see {@link os.homedir}
|
|
17
|
-
* @
|
|
16
|
+
* @internal
|
|
18
17
|
*/
|
|
19
18
|
const configFilePath = path.join(os.homedir(), configFileName);
|
|
20
19
|
/**
|
|
21
20
|
* Command-line configuration property list.
|
|
22
|
-
* @public
|
|
23
21
|
*/
|
|
24
22
|
export const configKeyList = [
|
|
25
23
|
'posix',
|
|
@@ -35,15 +33,11 @@ export const configKeyList = [
|
|
|
35
33
|
'parsable',
|
|
36
34
|
'concurrency',
|
|
37
35
|
];
|
|
38
|
-
/**
|
|
39
|
-
* @public
|
|
40
|
-
*/
|
|
41
36
|
export function isShowSources(value) {
|
|
42
37
|
return typeof value === 'boolean';
|
|
43
38
|
}
|
|
44
39
|
/**
|
|
45
40
|
* Command-line default config values.
|
|
46
|
-
* @public
|
|
47
41
|
*/
|
|
48
42
|
export const configDefault = {
|
|
49
43
|
parsable: false,
|
|
@@ -59,11 +53,8 @@ export const configDefault = {
|
|
|
59
53
|
showSources: false,
|
|
60
54
|
concurrency: 8,
|
|
61
55
|
};
|
|
62
|
-
/**
|
|
63
|
-
* @public
|
|
64
|
-
*/
|
|
65
56
|
export const configValueArray = (type) => {
|
|
66
|
-
const validator = value => {
|
|
57
|
+
const validator = (value) => {
|
|
67
58
|
if (Array.isArray(value)) {
|
|
68
59
|
if (type === undefined) {
|
|
69
60
|
return;
|
|
@@ -80,11 +71,8 @@ export const configValueArray = (type) => {
|
|
|
80
71
|
validator.typeName = `${type?.typeName ?? 'any'}[]`;
|
|
81
72
|
return validator;
|
|
82
73
|
};
|
|
83
|
-
/**
|
|
84
|
-
* @public
|
|
85
|
-
*/
|
|
86
74
|
export const configValueLiteral = (choices) => {
|
|
87
|
-
const validator = value => {
|
|
75
|
+
const validator = (value) => {
|
|
88
76
|
if (choices.includes(value)) {
|
|
89
77
|
return;
|
|
90
78
|
}
|
|
@@ -93,23 +81,11 @@ export const configValueLiteral = (choices) => {
|
|
|
93
81
|
validator.typeName = choices.map(choice => format('%o', choice)).join('|');
|
|
94
82
|
return validator;
|
|
95
83
|
};
|
|
96
|
-
/**
|
|
97
|
-
* @public
|
|
98
|
-
*/
|
|
99
84
|
export const switchTrueValues = ['true', 'on', 'yes', 'y', 'enable', 'enabled', '1'];
|
|
100
|
-
/**
|
|
101
|
-
* @public
|
|
102
|
-
*/
|
|
103
85
|
export const switchFalseValues = ['false', 'off', 'no', 'n', 'disable', 'disabled', '0'];
|
|
104
|
-
/**
|
|
105
|
-
* @public
|
|
106
|
-
*/
|
|
107
86
|
export const booleanValues = [...switchTrueValues, ...switchFalseValues];
|
|
108
|
-
/**
|
|
109
|
-
* @public
|
|
110
|
-
*/
|
|
111
87
|
export const configValueSwitch = () => {
|
|
112
|
-
const validator = value => {
|
|
88
|
+
const validator = (value) => {
|
|
113
89
|
if (booleanValues.includes(value)) {
|
|
114
90
|
return;
|
|
115
91
|
}
|
|
@@ -118,11 +94,8 @@ export const configValueSwitch = () => {
|
|
|
118
94
|
validator.typeName = 'switch';
|
|
119
95
|
return validator;
|
|
120
96
|
};
|
|
121
|
-
/**
|
|
122
|
-
* @public
|
|
123
|
-
*/
|
|
124
97
|
export const configValueBoolean = () => {
|
|
125
|
-
const validator = value => {
|
|
98
|
+
const validator = (value) => {
|
|
126
99
|
if (typeof value === 'boolean') {
|
|
127
100
|
return;
|
|
128
101
|
}
|
|
@@ -131,11 +104,8 @@ export const configValueBoolean = () => {
|
|
|
131
104
|
validator.typeName = 'boolean';
|
|
132
105
|
return validator;
|
|
133
106
|
};
|
|
134
|
-
/**
|
|
135
|
-
* @public
|
|
136
|
-
*/
|
|
137
107
|
export const configValueObject = () => {
|
|
138
|
-
const validator = value => {
|
|
108
|
+
const validator = (value) => {
|
|
139
109
|
if (value?.constructor === Object) {
|
|
140
110
|
return;
|
|
141
111
|
}
|
|
@@ -144,11 +114,8 @@ export const configValueObject = () => {
|
|
|
144
114
|
validator.typeName = 'object';
|
|
145
115
|
return validator;
|
|
146
116
|
};
|
|
147
|
-
/**
|
|
148
|
-
* @public
|
|
149
|
-
*/
|
|
150
117
|
export const configValueString = () => {
|
|
151
|
-
const validator = value => {
|
|
118
|
+
const validator = (value) => {
|
|
152
119
|
if (typeof value === 'string') {
|
|
153
120
|
return;
|
|
154
121
|
}
|
|
@@ -157,11 +124,8 @@ export const configValueString = () => {
|
|
|
157
124
|
validator.typeName = 'string';
|
|
158
125
|
return validator;
|
|
159
126
|
};
|
|
160
|
-
/**
|
|
161
|
-
* @public
|
|
162
|
-
*/
|
|
163
127
|
export const configValueNumber = () => {
|
|
164
|
-
const validator = value => {
|
|
128
|
+
const validator = (value) => {
|
|
165
129
|
if (typeof value === 'number') {
|
|
166
130
|
return;
|
|
167
131
|
}
|
|
@@ -170,11 +134,8 @@ export const configValueNumber = () => {
|
|
|
170
134
|
validator.typeName = 'number';
|
|
171
135
|
return validator;
|
|
172
136
|
};
|
|
173
|
-
/**
|
|
174
|
-
* @public
|
|
175
|
-
*/
|
|
176
137
|
export const configValueInteger = () => {
|
|
177
|
-
const validator = value => {
|
|
138
|
+
const validator = (value) => {
|
|
178
139
|
if (typeof value === 'number' && (Number.isSafeInteger(value) || Math.abs(value) === Infinity)) {
|
|
179
140
|
return;
|
|
180
141
|
}
|
|
@@ -185,7 +146,6 @@ export const configValueInteger = () => {
|
|
|
185
146
|
};
|
|
186
147
|
/**
|
|
187
148
|
* File-specific actions container.
|
|
188
|
-
* @public
|
|
189
149
|
*/
|
|
190
150
|
export class ConfigManager {
|
|
191
151
|
path;
|
|
@@ -323,11 +283,11 @@ export class ConfigManager {
|
|
|
323
283
|
unset(key) {
|
|
324
284
|
if (key === undefined) {
|
|
325
285
|
for (const key of Object.keys(this.data)) {
|
|
326
|
-
delete this.data[key];
|
|
286
|
+
delete this.data[key];
|
|
327
287
|
}
|
|
328
288
|
return this;
|
|
329
289
|
}
|
|
330
|
-
delete this.data[key];
|
|
290
|
+
delete this.data[key];
|
|
331
291
|
return this;
|
|
332
292
|
}
|
|
333
293
|
/**
|
|
@@ -366,7 +326,6 @@ export class ConfigManager {
|
|
|
366
326
|
return `${key}\n${value}`;
|
|
367
327
|
}).join('\n');
|
|
368
328
|
}
|
|
369
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
370
329
|
const keyMaxLength = keys.reduce((maxLength, key) => Math.max(maxLength, key.length), 0);
|
|
371
330
|
return keys.map((key) => {
|
|
372
331
|
const value = format('%o', this.get(key, options));
|
|
@@ -381,6 +340,5 @@ export class ConfigManager {
|
|
|
381
340
|
}
|
|
382
341
|
/**
|
|
383
342
|
* File-specific actions container. Contains get, set, unset, save, load and other configuration actions.
|
|
384
|
-
* @public
|
|
385
343
|
*/
|
|
386
344
|
export const configManager = new ConfigManager(configFilePath);
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { type ChalkInstance } from 'chalk';
|
|
2
2
|
export * from './browser/styling.js';
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
3
|
export declare function highlight(text: string, chalk?: ChalkInstance): string;
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
4
|
export declare function stringTime(time: number, chalk: ChalkInstance): string;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import ansiRegex from 'ansi-regex';
|
|
2
2
|
export * from './browser/styling.js';
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
3
|
export function highlight(text, chalk) {
|
|
7
4
|
if (chalk === undefined) {
|
|
8
5
|
return text;
|
|
@@ -19,7 +16,7 @@ export function highlight(text, chalk) {
|
|
|
19
16
|
const rall = new RegExp(`${[ansiRegex(), rstring, rseparator, rbracketsSquare, rnumber, rspecial]
|
|
20
17
|
.map(r => `(${typeof r === 'string' ? r : r.source})`)
|
|
21
18
|
.join('|')}`, 'g');
|
|
22
|
-
const colored = text.replaceAll(rall, match => {
|
|
19
|
+
const colored = text.replaceAll(rall, (match) => {
|
|
23
20
|
if (match.match(ansiRegex()) !== null) {
|
|
24
21
|
return match;
|
|
25
22
|
}
|
|
@@ -42,9 +39,6 @@ export function highlight(text, chalk) {
|
|
|
42
39
|
});
|
|
43
40
|
return colored;
|
|
44
41
|
}
|
|
45
|
-
/**
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
42
|
export function stringTime(time, chalk) {
|
|
49
43
|
if (time < 1000) {
|
|
50
44
|
return `${highlight(String(time), chalk)} milliseconds`;
|