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.
- package/README.md +23 -27
- package/bin/viewig +3 -1
- package/out/src/browser/binds/index.d.ts +40 -21
- package/out/src/browser/binds/index.js +62 -48
- package/out/src/browser/binds/plugins/git.d.ts +22 -3
- package/out/src/browser/binds/plugins/git.js +57 -21
- package/out/src/browser/binds/plugins/npm.d.ts +36 -9
- package/out/src/browser/binds/plugins/npm.js +125 -59
- package/out/src/browser/binds/plugins/vsce.d.ts +24 -8
- package/out/src/browser/binds/plugins/vsce.js +56 -16
- package/out/src/browser/binds/plugins/yarn.d.ts +5 -10
- package/out/src/browser/binds/plugins/yarn.js +18 -68
- package/out/src/browser/binds/scanner.d.ts +56 -0
- package/out/src/browser/binds/scanner.js +134 -0
- package/out/src/browser/binds/targets.d.ts +35 -11
- package/out/src/browser/binds/targets.js +10 -17
- package/out/src/browser/errors.d.ts +58 -7
- package/out/src/browser/errors.js +40 -12
- package/out/src/browser/filtering.d.ts +15 -0
- package/out/src/browser/filtering.js +12 -0
- package/out/src/browser/fs/directory.d.ts +181 -0
- package/out/src/browser/fs/directory.js +235 -0
- package/out/src/browser/{fileinfo.d.ts → fs/file-info.d.ts} +38 -27
- package/out/src/browser/fs/file-info.js +86 -0
- package/out/src/browser/fs/file.d.ts +41 -0
- package/out/src/browser/fs/file.js +43 -0
- package/out/src/browser/fs/index.d.ts +4 -0
- package/out/src/browser/fs/index.js +4 -0
- package/out/src/browser/fs/source-info.d.ts +29 -0
- package/out/src/browser/fs/source-info.js +31 -0
- package/out/src/browser/index.d.ts +2 -2
- package/out/src/browser/index.js +2 -2
- package/out/src/browser/lib.d.ts +102 -101
- package/out/src/browser/lib.js +86 -120
- package/out/src/browser/sorting.d.ts +22 -2
- package/out/src/browser/sorting.js +37 -32
- package/out/src/browser/styling.d.ts +41 -15
- package/out/src/browser/styling.js +28 -97
- package/out/src/cli.d.ts +73 -34
- package/out/src/cli.js +308 -155
- package/out/src/config.d.ts +163 -65
- package/out/src/config.js +285 -171
- package/out/src/errors.d.ts +7 -0
- package/out/src/errors.js +1 -0
- package/out/src/index.d.ts +2 -2
- package/out/src/index.js +2 -2
- package/out/src/lib.d.ts +4 -4
- package/out/src/lib.js +4 -4
- package/out/src/styling.d.ts +10 -4
- package/out/src/styling.js +46 -33
- package/package.json +37 -23
- package/out/src/bin.d.ts +0 -2
- package/out/src/bin.js +0 -3
- package/out/src/browser/fileinfo.js +0 -78
- package/out/src/browser/scanner.d.ts +0 -103
- package/out/src/browser/scanner.js +0 -161
- package/out/src/browser/sourceinfo.d.ts +0 -62
- package/out/src/browser/sourceinfo.js +0 -107
package/out/src/config.js
CHANGED
|
@@ -1,257 +1,371 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export const colorTypeList = [0, 1, 2, 3];
|
|
10
|
-
/**
|
|
11
|
-
* Checks if the value is the {@link ColorType}.
|
|
12
|
-
*/
|
|
13
|
-
export function isColorType(value) {
|
|
14
|
-
const num = Number(value);
|
|
15
|
-
return Number.isFinite(num) && colorTypeList.includes(num);
|
|
16
|
-
}
|
|
1
|
+
import * as os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { existsSync, readFileSync, rmSync, writeFileSync, } from 'node:fs';
|
|
4
|
+
import { format } from 'node:util';
|
|
5
|
+
import * as yaml from 'yaml';
|
|
6
|
+
import { decorNameList, highlight, styleNameList, } from './styling.js';
|
|
7
|
+
import { sortNameList } from './browser/sorting.js';
|
|
8
|
+
import { filterNameList } from './browser/filtering.js';
|
|
17
9
|
/**
|
|
18
10
|
* The full config file name - `".view-ignored"`.
|
|
11
|
+
* @public
|
|
19
12
|
*/
|
|
20
|
-
export const configFileName =
|
|
13
|
+
export const configFileName = '.view-ignored';
|
|
21
14
|
/**
|
|
22
15
|
* The user's home directory + the config file name.
|
|
23
16
|
* @see {@link os.homedir}
|
|
17
|
+
* @private
|
|
24
18
|
*/
|
|
25
|
-
|
|
19
|
+
const configFilePath = path.join(os.homedir(), configFileName);
|
|
26
20
|
/**
|
|
27
21
|
* Command-line configuration property list.
|
|
22
|
+
* @public
|
|
28
23
|
*/
|
|
29
|
-
export const configKeyList = [
|
|
24
|
+
export const configKeyList = ['posix', 'noColor', 'target', 'filter', 'sort', 'style', 'decor', 'depth', 'showSources', 'plugins', 'parsable', 'concurrency'];
|
|
30
25
|
/**
|
|
31
|
-
*
|
|
26
|
+
* @public
|
|
32
27
|
*/
|
|
33
|
-
export function isConfigKey(value) {
|
|
34
|
-
return typeof value === "string" && configKeyList.includes(value);
|
|
35
|
-
}
|
|
36
28
|
export function isShowSources(value) {
|
|
37
|
-
return typeof value ===
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Checks if the value is the {@link Config} value for the specific {@link ConfigKey}.
|
|
41
|
-
*/
|
|
42
|
-
export function isConfigValue(key, value) {
|
|
43
|
-
const c = {
|
|
44
|
-
parsable: v => typeof v === "boolean",
|
|
45
|
-
plugins: v => Array.isArray(v) && v.every(p => typeof p === "string"),
|
|
46
|
-
color: isColorType,
|
|
47
|
-
target: t => Plugins.isTargetId(t) && Plugins.targetGet(t) !== undefined,
|
|
48
|
-
filter: isFilterName,
|
|
49
|
-
sort: Sorting.isSortName,
|
|
50
|
-
style: Styling.isStyleName,
|
|
51
|
-
decor: Styling.isDecorName,
|
|
52
|
-
depth: Number.isInteger,
|
|
53
|
-
showSources: isShowSources
|
|
54
|
-
};
|
|
55
|
-
const check = c[key];
|
|
56
|
-
return check(value);
|
|
29
|
+
return typeof value === 'boolean';
|
|
57
30
|
}
|
|
58
31
|
/**
|
|
59
32
|
* Command-line default config values.
|
|
33
|
+
* @public
|
|
60
34
|
*/
|
|
61
35
|
export const configDefault = {
|
|
62
36
|
parsable: false,
|
|
37
|
+
noColor: false,
|
|
38
|
+
posix: false,
|
|
63
39
|
plugins: [],
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
decor: "normal",
|
|
40
|
+
target: 'git',
|
|
41
|
+
filter: 'included',
|
|
42
|
+
sort: 'firstFolders',
|
|
43
|
+
style: 'tree',
|
|
44
|
+
decor: 'normal',
|
|
70
45
|
depth: Infinity,
|
|
71
|
-
showSources: false
|
|
46
|
+
showSources: false,
|
|
47
|
+
concurrency: 8,
|
|
72
48
|
};
|
|
73
49
|
/**
|
|
74
|
-
* @
|
|
50
|
+
* @public
|
|
75
51
|
*/
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
52
|
+
export const configValueArray = (type) => {
|
|
53
|
+
const validator = value => {
|
|
54
|
+
if (Array.isArray(value)) {
|
|
55
|
+
if (type === undefined) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const badElementList = value.map(element => type(element)).filter(element => element !== undefined);
|
|
59
|
+
if (badElementList.length > 0) {
|
|
60
|
+
const list = badElementList.map((element, index) => `${index}: ${element}`).join('\n');
|
|
61
|
+
return `The value should be a typed array. Found bad elements:\n${list}`;
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
return 'The value should be an array.';
|
|
66
|
+
};
|
|
67
|
+
validator.typeName = `${type?.typeName ?? 'any'}[]`;
|
|
68
|
+
return validator;
|
|
69
|
+
};
|
|
88
70
|
/**
|
|
89
|
-
* @
|
|
90
|
-
* @param key The config property.
|
|
91
|
-
* @param fallbackDefault If `true`, the default value will be used when the value is `undefined`. Default `true`.
|
|
71
|
+
* @public
|
|
92
72
|
*/
|
|
93
|
-
export
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
73
|
+
export const configValueLiteral = (choices) => {
|
|
74
|
+
const validator = value => {
|
|
75
|
+
if (choices.includes(value)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
return `The value is invalid. Choices: ${choices.map(String).join(', ')}.`;
|
|
98
79
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
80
|
+
validator.typeName = choices.map(choice => format('%o', choice)).join('|');
|
|
81
|
+
return validator;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export const switchTrueValues = ['true', 'on', 'yes', 'y', 'enable', 'enabled', '1'];
|
|
87
|
+
/**
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
export const switchFalseValues = ['false', 'off', 'no', 'n', 'disable', 'disabled', '0'];
|
|
91
|
+
/**
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export const booleanValues = switchTrueValues.concat(switchFalseValues);
|
|
95
|
+
/**
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export const configValueSwitch = () => {
|
|
99
|
+
const validator = value => {
|
|
100
|
+
if (booleanValues.includes(value)) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
return `The value should be a boolean. Available boolean literals: ${booleanValues.join(', ')}.`;
|
|
113
104
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
105
|
+
validator.typeName = 'switch';
|
|
106
|
+
return validator;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export const configValueBoolean = () => {
|
|
112
|
+
const validator = value => {
|
|
113
|
+
if (typeof value === 'boolean') {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
return 'The value should be a boolean.';
|
|
117
|
+
};
|
|
118
|
+
validator.typeName = 'boolean';
|
|
119
|
+
return validator;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
export const configValueObject = () => {
|
|
125
|
+
const validator = value => {
|
|
126
|
+
if (value?.constructor === Object) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
return 'The value should be an object.';
|
|
130
|
+
};
|
|
131
|
+
validator.typeName = 'object';
|
|
132
|
+
return validator;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
export const configValueString = () => {
|
|
138
|
+
const validator = value => {
|
|
139
|
+
if (typeof value === 'string') {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
return 'The value should be a string.';
|
|
143
|
+
};
|
|
144
|
+
validator.typeName = 'string';
|
|
145
|
+
return validator;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* @public
|
|
149
|
+
*/
|
|
150
|
+
export const configValueNumber = () => {
|
|
151
|
+
const validator = value => {
|
|
152
|
+
if (typeof value === 'number') {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
return 'The value should be a number.';
|
|
156
|
+
};
|
|
157
|
+
validator.typeName = 'number';
|
|
158
|
+
return validator;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
export const configValueInteger = () => {
|
|
164
|
+
const validator = value => {
|
|
165
|
+
if (typeof value === 'number' && (Number.isSafeInteger(value) || Math.abs(value) === Infinity)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
return 'The value should be an integer.';
|
|
169
|
+
};
|
|
170
|
+
validator.typeName = 'integer';
|
|
171
|
+
return validator;
|
|
172
|
+
};
|
|
135
173
|
/**
|
|
136
174
|
* File-specific actions container.
|
|
175
|
+
* @public
|
|
137
176
|
*/
|
|
138
177
|
export class ConfigManager {
|
|
139
|
-
|
|
140
|
-
constructor(filePath) {
|
|
141
|
-
this.filePath = filePath;
|
|
142
|
-
}
|
|
178
|
+
path;
|
|
143
179
|
/**
|
|
144
180
|
* Do not change this value directly.
|
|
145
181
|
* @see {@link configManager}.
|
|
146
182
|
*/
|
|
147
183
|
data = {};
|
|
148
|
-
|
|
149
|
-
|
|
184
|
+
configValidation = new Map();
|
|
185
|
+
cliOptionLinkMap = new Map();
|
|
186
|
+
dataDefault = {};
|
|
187
|
+
constructor(path) {
|
|
188
|
+
this.path = path;
|
|
189
|
+
this.keySetValidator('parsable', configDefault.parsable, configValueBoolean());
|
|
190
|
+
this.keySetValidator('noColor', configDefault.noColor, configValueBoolean());
|
|
191
|
+
this.keySetValidator('posix', configDefault.posix, configValueBoolean());
|
|
192
|
+
this.keySetValidator('filter', configDefault.filter, configValueLiteral(filterNameList));
|
|
193
|
+
this.keySetValidator('sort', configDefault.sort, configValueLiteral(sortNameList));
|
|
194
|
+
this.keySetValidator('style', configDefault.style, configValueLiteral(styleNameList));
|
|
195
|
+
this.keySetValidator('decor', configDefault.decor, configValueLiteral(decorNameList));
|
|
196
|
+
this.keySetValidator('depth', configDefault.depth, configValueInteger());
|
|
197
|
+
this.keySetValidator('showSources', configDefault.showSources, configValueBoolean());
|
|
198
|
+
this.keySetValidator('concurrency', configDefault.concurrency, configValueInteger());
|
|
199
|
+
}
|
|
200
|
+
dataCheck(data) {
|
|
201
|
+
const propertyStack = new Map();
|
|
202
|
+
const object = data;
|
|
203
|
+
if (object?.constructor !== Object) {
|
|
204
|
+
return configValueObject()(object);
|
|
205
|
+
}
|
|
206
|
+
for (const key in object) {
|
|
207
|
+
if (!Object.hasOwn(object, key)) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const value = object[key];
|
|
211
|
+
const message = this.checkValue(key, value);
|
|
212
|
+
if (message === undefined) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
propertyStack.set(key, message);
|
|
216
|
+
}
|
|
217
|
+
return propertyStack;
|
|
218
|
+
}
|
|
219
|
+
getType(key) {
|
|
220
|
+
return this.configValidation.get(key)?.typeName ?? 'any';
|
|
150
221
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
222
|
+
keyGetValidator(key) {
|
|
223
|
+
return this.configValidation.get(key);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Define type checker for the key.
|
|
227
|
+
*/
|
|
228
|
+
keySetValidator(key, defaultValue, type) {
|
|
229
|
+
this.configValidation.set(key, type);
|
|
230
|
+
const errorMessage = type(defaultValue);
|
|
231
|
+
if (errorMessage !== undefined) {
|
|
232
|
+
throw new TypeError(`Invalid default value preset for configuration key ${format(key)} - ${errorMessage}`);
|
|
233
|
+
}
|
|
234
|
+
this.dataDefault[key] = defaultValue;
|
|
235
|
+
return this;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Checks if the key is defined.
|
|
239
|
+
* @returns Error message if the key is not defined.
|
|
240
|
+
*/
|
|
241
|
+
checkKey(key) {
|
|
242
|
+
if (this.configValidation.has(key)) {
|
|
154
243
|
return;
|
|
155
244
|
}
|
|
156
|
-
return
|
|
245
|
+
return `Unknown config key '${key}'. Choices: ${Array.from(this.configValidation.keys()).join(', ')}`;
|
|
246
|
+
}
|
|
247
|
+
checkValue(key, value) {
|
|
248
|
+
const validate = this.configValidation.get(key);
|
|
249
|
+
if (validate === undefined) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
return validate(value);
|
|
253
|
+
}
|
|
254
|
+
setOption(key, command, option, parseArgument) {
|
|
255
|
+
if (parseArgument) {
|
|
256
|
+
option.argParser(parseArgument);
|
|
257
|
+
}
|
|
258
|
+
const deflt = configManager.get(key);
|
|
259
|
+
option.default(deflt);
|
|
260
|
+
command.addOption(option);
|
|
261
|
+
this.cliOptionLinkMap.set(key, option);
|
|
262
|
+
return this;
|
|
263
|
+
}
|
|
264
|
+
getOption(key) {
|
|
265
|
+
return this.cliOptionLinkMap.get(key);
|
|
157
266
|
}
|
|
158
267
|
/**
|
|
159
|
-
* Loads the config from the file to {@link configManager.data}.
|
|
160
|
-
* @returns
|
|
268
|
+
* Loads the config from the file to {@link configManager.data}.
|
|
269
|
+
* @returns The error message for each invalid property.
|
|
161
270
|
*/
|
|
162
271
|
load() {
|
|
163
|
-
const parsed = existsSync(this.
|
|
272
|
+
const parsed = existsSync(this.path) ? yaml.parse(readFileSync(this.path).toString()) : undefined;
|
|
164
273
|
if (parsed === undefined) {
|
|
165
|
-
return
|
|
274
|
+
return;
|
|
166
275
|
}
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
return
|
|
276
|
+
const message = this.dataCheck(parsed);
|
|
277
|
+
if (typeof message === 'string') {
|
|
278
|
+
return message;
|
|
170
279
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (
|
|
280
|
+
const object = parsed;
|
|
281
|
+
for (const key in object) {
|
|
282
|
+
if (!Object.hasOwn(object, key) || message.has(key)) {
|
|
174
283
|
continue;
|
|
175
284
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
array.shift();
|
|
179
|
-
parsed[key] = array;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (!isConfigPartial(parsed)) {
|
|
183
|
-
throw new TypeError(`Invalid config.`, { cause: parsed });
|
|
285
|
+
const element = object[key];
|
|
286
|
+
this.data[key] = element;
|
|
184
287
|
}
|
|
185
|
-
|
|
186
|
-
return this;
|
|
288
|
+
return message;
|
|
187
289
|
}
|
|
188
290
|
/**
|
|
189
291
|
* Saves the partial config to the file. If there are no settings, the file will be deleted, if exists.
|
|
190
292
|
*/
|
|
191
293
|
save() {
|
|
192
294
|
if (Object.keys(this.data).length === 0) {
|
|
193
|
-
if (existsSync(this.
|
|
194
|
-
rmSync(this.
|
|
295
|
+
if (existsSync(this.path)) {
|
|
296
|
+
rmSync(this.path);
|
|
195
297
|
}
|
|
196
298
|
return this;
|
|
197
299
|
}
|
|
198
|
-
writeFileSync(this.
|
|
300
|
+
writeFileSync(this.path, yaml.stringify(this.data));
|
|
199
301
|
return this;
|
|
200
302
|
}
|
|
201
|
-
/**
|
|
202
|
-
* Sets a new value for the specified config property.
|
|
203
|
-
* Expects a valid value.
|
|
204
|
-
* @param key The name of the config property.
|
|
205
|
-
* @param value The new value for the config property.
|
|
206
|
-
*/
|
|
207
303
|
set(key, value) {
|
|
304
|
+
const errorMessage = this.checkValue(key, value);
|
|
305
|
+
if (errorMessage !== undefined) {
|
|
306
|
+
return errorMessage;
|
|
307
|
+
}
|
|
208
308
|
this.data[key] = value;
|
|
209
|
-
return this;
|
|
210
309
|
}
|
|
211
|
-
/**
|
|
212
|
-
* Deletes the specified property from the config.
|
|
213
|
-
* If the property is not specified, then all properties will be deleted.
|
|
214
|
-
* @param key The config property.
|
|
215
|
-
*/
|
|
216
310
|
unset(key) {
|
|
217
311
|
if (key === undefined) {
|
|
218
312
|
for (const key of Object.keys(this.data)) {
|
|
219
|
-
delete this.data[key];
|
|
313
|
+
delete this.data[key]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
|
|
220
314
|
}
|
|
221
315
|
return this;
|
|
222
316
|
}
|
|
223
|
-
delete this.data[key];
|
|
317
|
+
delete this.data[key]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
|
|
224
318
|
return this;
|
|
225
319
|
}
|
|
226
320
|
/**
|
|
227
321
|
* @returns An array of properties which defined in the configuration file.
|
|
228
322
|
*/
|
|
229
|
-
|
|
230
|
-
const keys = Object.keys(this.data);
|
|
231
|
-
return keys
|
|
323
|
+
keyList(real = true) {
|
|
324
|
+
const keys = real ? Array.from(this.configValidation.keys()) : Object.keys(this.data);
|
|
325
|
+
return keys;
|
|
232
326
|
}
|
|
233
|
-
get(key,
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
327
|
+
get(key, options) {
|
|
328
|
+
const { real = true } = options ?? {};
|
|
329
|
+
let value = this.data[key];
|
|
330
|
+
if (real && value === undefined) {
|
|
331
|
+
value = this.dataDefault[key];
|
|
332
|
+
if (value === undefined) {
|
|
333
|
+
throw new Error(`Excpected default value for config property '${key}'.`);
|
|
334
|
+
}
|
|
237
335
|
}
|
|
238
336
|
return value;
|
|
239
337
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
338
|
+
getPairString(keys, options) {
|
|
339
|
+
const { real = true, types = true, chalk, parsable } = options ?? {};
|
|
340
|
+
if (keys === undefined) {
|
|
341
|
+
return this.getPairString(this.keyList(real), options);
|
|
342
|
+
}
|
|
343
|
+
if (typeof keys === 'string') {
|
|
344
|
+
return this.getPairString([keys], options);
|
|
345
|
+
}
|
|
346
|
+
if (parsable) {
|
|
347
|
+
return keys.map((key) => {
|
|
348
|
+
const value = format('%o', this.get(key, options));
|
|
349
|
+
if (types) {
|
|
350
|
+
const type = this.getType(key);
|
|
351
|
+
return `${key}\n${value}\n${type}`;
|
|
352
|
+
}
|
|
353
|
+
return `${key}\n${value}`;
|
|
354
|
+
}).join('\n');
|
|
249
355
|
}
|
|
250
|
-
|
|
251
|
-
|
|
356
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
357
|
+
const keyMaxLength = keys.reduce((maxLength, key) => Math.max(maxLength, key.length), 0);
|
|
358
|
+
return keys.map((key) => {
|
|
359
|
+
const value = format('%o', this.get(key, options));
|
|
360
|
+
const type = this.getType(key);
|
|
361
|
+
const pad = keyMaxLength - key.length;
|
|
362
|
+
const line = types ? format(`${' '.repeat(pad)}%s ${highlight('=', chalk)} %s${highlight(':', chalk)} %s`, (chalk ? chalk.hex('#FFBC42')(key) : key), chalk ? highlight(value, chalk) : value, (chalk ? chalk.dim(highlight(type, chalk)) : type)) : format(`${' '.repeat(pad)}%s ${highlight('=', chalk)} %s`, (chalk ? chalk.hex('#FFBC42')(key) : key), chalk ? highlight(value, chalk) : value);
|
|
363
|
+
return line;
|
|
364
|
+
}).join('\n');
|
|
252
365
|
}
|
|
253
366
|
}
|
|
254
367
|
/**
|
|
255
368
|
* File-specific actions container. Contains get, set, unset, save, load and other configuration actions.
|
|
369
|
+
* @public
|
|
256
370
|
*/
|
|
257
371
|
export const configManager = new ConfigManager(configFilePath);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './browser/errors.js';
|
package/out/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as ViewIgnored from
|
|
1
|
+
import * as ViewIgnored from './lib.js';
|
|
2
2
|
export default ViewIgnored;
|
|
3
|
-
export * from
|
|
3
|
+
export * from './lib.js';
|
package/out/src/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as ViewIgnored from
|
|
1
|
+
import * as ViewIgnored from './lib.js';
|
|
2
2
|
export default ViewIgnored;
|
|
3
|
-
export * from
|
|
3
|
+
export * from './lib.js';
|
package/out/src/lib.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * as Styling from
|
|
3
|
-
export * as Cli from
|
|
4
|
-
export * as Config from
|
|
1
|
+
export * from './browser/lib.js';
|
|
2
|
+
export * as Styling from './styling.js';
|
|
3
|
+
export * as Cli from './cli.js';
|
|
4
|
+
export * as Config from './config.js';
|
package/out/src/lib.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * as Styling from
|
|
3
|
-
export * as Cli from
|
|
4
|
-
export * as Config from
|
|
1
|
+
export * from './browser/lib.js';
|
|
2
|
+
export * as Styling from './styling.js';
|
|
3
|
+
export * as Cli from './cli.js';
|
|
4
|
+
export * as Config from './config.js';
|
package/out/src/styling.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { ChalkInstance } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { type ChalkInstance } from 'chalk';
|
|
2
|
+
export * from './browser/styling.js';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare function highlight(text: string, chalk?: ChalkInstance): string;
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare function stringTime(time: number, chalk: ChalkInstance): string;
|