view-ignored 0.3.2 → 0.4.1
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/LICENSE.txt +21 -21
- package/README.md +95 -95
- package/bin/viewig +1 -1
- package/out/{src/browser → browser}/binds/index.d.ts +0 -19
- package/out/{src/browser → browser}/binds/index.js +2 -9
- package/out/browser/binds/plugins/git.d.ts +3 -0
- package/out/{src/browser → browser}/binds/plugins/git.js +7 -7
- package/out/browser/binds/plugins/npm.d.ts +3 -0
- package/out/{src/browser → browser}/binds/plugins/npm.js +8 -8
- package/out/browser/binds/plugins/vsce.d.ts +3 -0
- package/out/{src/browser → browser}/binds/plugins/vsce.js +5 -5
- package/out/browser/binds/plugins/yarn.d.ts +3 -0
- package/out/{src/browser → browser}/binds/plugins/yarn.js +3 -4
- package/out/{src/browser → browser}/binds/scanner.d.ts +0 -12
- package/out/{src/browser → browser}/binds/scanner.js +1 -7
- package/out/{src/browser → browser}/binds/targets.d.ts +2 -13
- package/out/{src/browser → browser}/binds/targets.js +2 -7
- 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 +3 -56
- package/out/{src/browser → browser}/fs/directory.js +3 -6
- package/out/{src/browser → browser}/fs/file-info.d.ts +0 -5
- package/out/{src/browser → browser}/fs/file-info.js +13 -10
- 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 +2 -5
- 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 +0 -14
- 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} +13 -45
- package/out/{src/config.d.ts → config.d.ts} +0 -57
- package/out/{src/config.js → config.js} +23 -50
- 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} +0 -6
- package/package.json +39 -47
- 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
|
@@ -1,37 +1,30 @@
|
|
|
1
1
|
import { type ScanOptions } from '../lib.js';
|
|
2
2
|
/**
|
|
3
3
|
* The target icon/logo as a {@link https://www.nerdfonts.com/ NF} icon.
|
|
4
|
-
* @public
|
|
5
4
|
*/
|
|
6
5
|
export type TargetIcon = {
|
|
7
6
|
/**
|
|
8
7
|
* Glyph character.
|
|
9
8
|
*/
|
|
10
|
-
|
|
9
|
+
value: string;
|
|
11
10
|
/**
|
|
12
11
|
* The icon's color.
|
|
13
12
|
*/
|
|
14
|
-
color?:
|
|
13
|
+
color?: string;
|
|
15
14
|
};
|
|
16
|
-
/**
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
15
|
export type TargetName = string;
|
|
20
16
|
/**
|
|
21
17
|
* Should satisfy RegExp: `/^[-a-zA-Z0-9]+$/`.
|
|
22
|
-
* @public
|
|
23
18
|
*/
|
|
24
19
|
export type TargetId = string;
|
|
25
20
|
/**
|
|
26
21
|
* @param value Target's id. Simple name.
|
|
27
22
|
* @returns `true`, if the id is available for binding.
|
|
28
|
-
* @public
|
|
29
23
|
*/
|
|
30
24
|
export declare function isTargetId(value: unknown): value is TargetId;
|
|
31
25
|
/**
|
|
32
26
|
* The bind which allows use predefined options for scan functions.
|
|
33
27
|
* @see {@link scanFolder}
|
|
34
|
-
* @public
|
|
35
28
|
*/
|
|
36
29
|
export type TargetBind = {
|
|
37
30
|
/**
|
|
@@ -61,12 +54,10 @@ export type TargetBind = {
|
|
|
61
54
|
};
|
|
62
55
|
/**
|
|
63
56
|
* Checks if the value is the {@link TargetBind}.
|
|
64
|
-
* @public
|
|
65
57
|
*/
|
|
66
58
|
export declare function isTargetBind(value: unknown): value is TargetBind;
|
|
67
59
|
/**
|
|
68
60
|
* Allows to create targets for view-ignored scan* functions.
|
|
69
|
-
* @public
|
|
70
61
|
* @example
|
|
71
62
|
* scanFolder("abc") // error
|
|
72
63
|
* Bindings.targetSet("abc", {...})
|
|
@@ -75,7 +66,6 @@ export declare function isTargetBind(value: unknown): value is TargetBind;
|
|
|
75
66
|
export declare function targetSet(bind: TargetBind): void;
|
|
76
67
|
/**
|
|
77
68
|
* Get all target ids.
|
|
78
|
-
* @public
|
|
79
69
|
* @example
|
|
80
70
|
* ["git", "npm", "vsce", ...]
|
|
81
71
|
*/
|
|
@@ -83,6 +73,5 @@ export declare function targetList(): string[];
|
|
|
83
73
|
/**
|
|
84
74
|
* Get target bind by target id.
|
|
85
75
|
* @param id Target id.
|
|
86
|
-
* @public
|
|
87
76
|
*/
|
|
88
77
|
export declare function targetGet(id: TargetId): TargetBind | undefined;
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param value Target's id. Simple name.
|
|
3
3
|
* @returns `true`, if the id is available for binding.
|
|
4
|
-
* @public
|
|
5
4
|
*/
|
|
6
5
|
export function isTargetId(value) {
|
|
7
6
|
return typeof value === 'string' && (/^[-a-zA-Z\d]+$/.exec(value)) !== null;
|
|
8
7
|
}
|
|
9
8
|
/**
|
|
10
9
|
* Checks if the value is the {@link TargetBind}.
|
|
11
|
-
* @public
|
|
12
10
|
*/
|
|
13
11
|
export function isTargetBind(value) {
|
|
14
12
|
return value?.constructor === Object;
|
|
15
13
|
}
|
|
16
14
|
/**
|
|
17
15
|
* The container for binds: id=bind.
|
|
18
|
-
* @
|
|
16
|
+
* @internal
|
|
19
17
|
*/
|
|
20
18
|
const targetBindMap = new Map();
|
|
21
19
|
/**
|
|
22
20
|
* Allows to create targets for view-ignored scan* functions.
|
|
23
|
-
* @public
|
|
24
21
|
* @example
|
|
25
22
|
* scanFolder("abc") // error
|
|
26
23
|
* Bindings.targetSet("abc", {...})
|
|
@@ -31,18 +28,16 @@ export function targetSet(bind) {
|
|
|
31
28
|
}
|
|
32
29
|
/**
|
|
33
30
|
* Get all target ids.
|
|
34
|
-
* @public
|
|
35
31
|
* @example
|
|
36
32
|
* ["git", "npm", "vsce", ...]
|
|
37
33
|
*/
|
|
38
34
|
export function targetList() {
|
|
39
|
-
const list =
|
|
35
|
+
const list = [...targetBindMap.keys()];
|
|
40
36
|
return list;
|
|
41
37
|
}
|
|
42
38
|
/**
|
|
43
39
|
* Get target bind by target id.
|
|
44
40
|
* @param id Target id.
|
|
45
|
-
* @public
|
|
46
41
|
*/
|
|
47
42
|
export function targetGet(id) {
|
|
48
43
|
return targetBindMap.get(id);
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { type File } from './lib.js';
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
2
|
export declare class ViewIgnoredError extends Error {
|
|
6
3
|
name: string;
|
|
7
4
|
}
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
5
|
export declare class NoSourceError extends ViewIgnoredError {
|
|
12
6
|
static joinOr(fileBaseList: string[]): string;
|
|
13
7
|
static joinAnd(fileBaseList: string[]): string;
|
|
@@ -25,9 +19,6 @@ export declare class NoSourceError extends ViewIgnoredError {
|
|
|
25
19
|
*/
|
|
26
20
|
constructor(file: File);
|
|
27
21
|
}
|
|
28
|
-
/**
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
22
|
export declare class BadSourceError extends ViewIgnoredError {
|
|
32
23
|
name: string;
|
|
33
24
|
/**
|
|
@@ -45,16 +36,10 @@ export declare class BadSourceError extends ViewIgnoredError {
|
|
|
45
36
|
*/
|
|
46
37
|
constructor(file: File, message: string);
|
|
47
38
|
}
|
|
48
|
-
/**
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
39
|
export declare class InvalidPatternError extends ViewIgnoredError {
|
|
52
40
|
name: string;
|
|
53
41
|
constructor(file: File, pattern?: string | string[]);
|
|
54
42
|
}
|
|
55
|
-
/**
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
43
|
export declare class TargetNotBoundError extends ViewIgnoredError {
|
|
59
44
|
name: string;
|
|
60
45
|
constructor(targetId: string);
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
*/
|
|
4
1
|
export class ViewIgnoredError extends Error {
|
|
5
2
|
name = 'ViewIgnoredError';
|
|
6
3
|
}
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
4
|
export class NoSourceError extends ViewIgnoredError {
|
|
11
5
|
static joinOr(fileBaseList) {
|
|
12
6
|
return fileBaseList.map(base => `'${base}'`).join(' or ');
|
|
@@ -19,27 +13,18 @@ export class NoSourceError extends ViewIgnoredError {
|
|
|
19
13
|
super(`There was no configuration file (${typeof argument0 === 'string' ? argument0 : argument0.relativePath}) in the folders and subfolders that would correctly describe the ignoring.`);
|
|
20
14
|
}
|
|
21
15
|
}
|
|
22
|
-
/**
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
16
|
export class BadSourceError extends ViewIgnoredError {
|
|
26
17
|
name = 'BadSourceError';
|
|
27
18
|
constructor(argument0, message) {
|
|
28
19
|
super(`Invalid ${typeof argument0 === 'string' ? argument0 : argument0.relativePath}: ${message}`);
|
|
29
20
|
}
|
|
30
21
|
}
|
|
31
|
-
/**
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
22
|
export class InvalidPatternError extends ViewIgnoredError {
|
|
35
23
|
name = 'InvalidPatternError';
|
|
36
24
|
constructor(file, pattern) {
|
|
37
25
|
super(`Invalid pattern in ${file.relativePath}: ${pattern === undefined ? '' : ` Pattern: ${JSON.stringify(pattern)}`}`);
|
|
38
26
|
}
|
|
39
27
|
}
|
|
40
|
-
/**
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
28
|
export class TargetNotBoundError extends ViewIgnoredError {
|
|
44
29
|
name = 'TargetNotBoundError';
|
|
45
30
|
constructor(targetId) {
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Contains all filter names.
|
|
3
|
-
* @public
|
|
4
3
|
*/
|
|
5
4
|
export declare const filterNameList: readonly ["ignored", "included", "all"];
|
|
6
5
|
/**
|
|
7
6
|
* Contains all filter names as a type.
|
|
8
|
-
* @public
|
|
9
7
|
*/
|
|
10
8
|
export type FilterName = typeof filterNameList[number];
|
|
11
9
|
/**
|
|
12
10
|
* Checks if the value is the {@link FilterName}.
|
|
13
|
-
* @public
|
|
14
11
|
*/
|
|
15
12
|
export declare function isFilterName(value: unknown): value is FilterName;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Contains all filter names.
|
|
3
|
-
* @public
|
|
4
3
|
*/
|
|
5
4
|
export const filterNameList = ['ignored', 'included', 'all'];
|
|
6
5
|
/**
|
|
7
6
|
* Checks if the value is the {@link FilterName}.
|
|
8
|
-
* @public
|
|
9
7
|
*/
|
|
10
8
|
export function isFilterName(value) {
|
|
11
9
|
return typeof value === 'string' && filterNameList.includes(value);
|
|
@@ -2,83 +2,38 @@ import { type ParsedPath } from 'node:path';
|
|
|
2
2
|
import EventEmitter from 'node:events';
|
|
3
3
|
import { type RealScanOptions } from '../lib.js';
|
|
4
4
|
import { File } from './file.js';
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
5
|
export type DeepStreamEventEmitter = EventEmitter<DeepStreamEventMap> & {
|
|
9
6
|
endPromise: Promise<DeepStreamDataRoot>;
|
|
10
7
|
run(): void;
|
|
11
8
|
};
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
9
|
export type DeepStreamDataRoot = {
|
|
16
10
|
tree: Directory;
|
|
17
11
|
progress: DeepStreamProgress;
|
|
18
12
|
};
|
|
19
|
-
/**
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
13
|
export type DeepStreamData = {
|
|
23
14
|
target: Entry;
|
|
24
15
|
progress: DeepStreamProgress;
|
|
25
16
|
};
|
|
26
|
-
/**
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
17
|
export type DeepStreamProgress = {
|
|
30
18
|
directories: number;
|
|
31
19
|
files: number;
|
|
32
20
|
current: number;
|
|
33
21
|
total: number;
|
|
34
22
|
};
|
|
35
|
-
/**
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
23
|
export type DeepStreamEventMap = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
24
|
+
data: [DeepStreamData];
|
|
25
|
+
end: [DeepStreamDataRoot];
|
|
26
|
+
progress: [DeepStreamProgress];
|
|
42
27
|
};
|
|
43
|
-
/**
|
|
44
|
-
* @public
|
|
45
|
-
*/
|
|
46
28
|
export type DeepStream = ReadableStream<Entry>;
|
|
47
|
-
/**
|
|
48
|
-
* @private
|
|
49
|
-
*/
|
|
50
|
-
type DeepStreamNestedOptions = DeepStreamOptions & {
|
|
51
|
-
controller?: DeepStreamEventEmitter;
|
|
52
|
-
parent?: Directory;
|
|
53
|
-
progress?: DeepStreamProgress;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
29
|
export type DeepCountOptions = Pick<DeepStreamNestedOptions, 'modules' | 'cwd' | 'concurrency' | 'progress'>;
|
|
59
|
-
/**
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
30
|
export type DeepModifiedTimeOptions = Pick<RealScanOptions, 'concurrency' | 'modules'>;
|
|
63
|
-
/**
|
|
64
|
-
* @public
|
|
65
|
-
*/
|
|
66
31
|
export type DeepStreamOptions = Pick<RealScanOptions, 'cwd' | 'modules' | 'concurrency'>;
|
|
67
|
-
/**
|
|
68
|
-
* @public
|
|
69
|
-
*/
|
|
70
32
|
export type Entry = Directory | File;
|
|
71
|
-
/**
|
|
72
|
-
* @public
|
|
73
|
-
*/
|
|
74
33
|
export type EntryClass = typeof Directory | typeof File;
|
|
75
|
-
/**
|
|
76
|
-
* @public
|
|
77
|
-
*/
|
|
78
34
|
export type EntryInstanceFrom<T extends undefined | EntryClass> = T extends undefined ? Entry : T extends typeof Directory ? Directory : File;
|
|
79
35
|
/**
|
|
80
36
|
* File system directory representation.
|
|
81
|
-
* @public
|
|
82
37
|
*/
|
|
83
38
|
export declare class Directory implements ParsedPath {
|
|
84
39
|
/**
|
|
@@ -125,13 +80,6 @@ export declare class Directory implements ParsedPath {
|
|
|
125
80
|
* Get deep iterator for the directory.
|
|
126
81
|
*/
|
|
127
82
|
static deepIterator: <T extends undefined | EntryClass>(directory: Directory, instanceOf?: T) => IterableIterator<EntryInstanceFrom<T>>;
|
|
128
|
-
/**
|
|
129
|
-
* Read directories and files progressively.
|
|
130
|
-
* @private This function should be wrapped by {@link deepStream}.
|
|
131
|
-
* @param directoryPath Relative path to the directory.
|
|
132
|
-
* @param options The reader options.
|
|
133
|
-
*/
|
|
134
|
-
private static deepStreamNested;
|
|
135
83
|
readonly base: string;
|
|
136
84
|
readonly dir: string;
|
|
137
85
|
readonly ext: string;
|
|
@@ -178,4 +126,3 @@ export declare class Directory implements ParsedPath {
|
|
|
178
126
|
*/
|
|
179
127
|
deepModifiedTime(out: Map<File, number>, realOptions: DeepModifiedTimeOptions): Promise<Map<File, number>>;
|
|
180
128
|
}
|
|
181
|
-
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable unicorn/prefer-event-target */
|
|
2
1
|
import { join, parse, relative, } from 'node:path';
|
|
3
2
|
import EventEmitter from 'node:events';
|
|
4
3
|
import * as FSP from 'node:fs/promises';
|
|
@@ -8,7 +7,6 @@ import { configDefault } from '../../config.js';
|
|
|
8
7
|
import { File } from './file.js';
|
|
9
8
|
/**
|
|
10
9
|
* File system directory representation.
|
|
11
|
-
* @public
|
|
12
10
|
*/
|
|
13
11
|
export class Directory {
|
|
14
12
|
parent;
|
|
@@ -70,7 +68,6 @@ export class Directory {
|
|
|
70
68
|
const tree = new Directory(undefined, '.', cwd, new Map());
|
|
71
69
|
for (const path of pathList) {
|
|
72
70
|
const entryNameList = path.toString().split(/[\\/]/);
|
|
73
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
74
71
|
entryNameList.reduce((tree, entryName, index) => {
|
|
75
72
|
const absolutePath = join(tree.absolutePath, entryName);
|
|
76
73
|
const relativePath = relative(cwd, absolutePath);
|
|
@@ -79,7 +76,7 @@ export class Directory {
|
|
|
79
76
|
tree.set(file.base, file);
|
|
80
77
|
return tree;
|
|
81
78
|
}
|
|
82
|
-
let directory =
|
|
79
|
+
let directory = [...tree.children.values()].find(c => c instanceof Directory && c.absolutePath === absolutePath);
|
|
83
80
|
if (directory === undefined) {
|
|
84
81
|
directory = new Directory(tree, relativePath, absolutePath, new Map());
|
|
85
82
|
tree.set(`${directory.base}/`, directory);
|
|
@@ -108,7 +105,7 @@ export class Directory {
|
|
|
108
105
|
};
|
|
109
106
|
/**
|
|
110
107
|
* Read directories and files progressively.
|
|
111
|
-
* @
|
|
108
|
+
* @internal This function should be wrapped by {@link deepStream}.
|
|
112
109
|
* @param directoryPath Relative path to the directory.
|
|
113
110
|
* @param options The reader options.
|
|
114
111
|
*/
|
|
@@ -198,7 +195,7 @@ export class Directory {
|
|
|
198
195
|
* @param instanceOf Optionally filter children by type.
|
|
199
196
|
*/
|
|
200
197
|
deep(instanceOf) {
|
|
201
|
-
return
|
|
198
|
+
return [...Directory.deepIterator(this, instanceOf)];
|
|
202
199
|
}
|
|
203
200
|
/**
|
|
204
201
|
* @returns The relative path to the directory.
|
|
@@ -6,7 +6,6 @@ import { type SourceInfo } from './source-info.js';
|
|
|
6
6
|
import { type Directory } from './directory.js';
|
|
7
7
|
/**
|
|
8
8
|
* @see {@link FileInfo.prototype.toString}
|
|
9
|
-
* @public
|
|
10
9
|
*/
|
|
11
10
|
export type FileInfoToStringOptions = {
|
|
12
11
|
/**
|
|
@@ -45,13 +44,9 @@ export type FileInfoToStringOptions = {
|
|
|
45
44
|
*/
|
|
46
45
|
entire?: boolean;
|
|
47
46
|
};
|
|
48
|
-
/**
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
47
|
export type FileInfoStatus = 'ignored' | 'included' | 'non-target';
|
|
52
48
|
/**
|
|
53
49
|
* The result of the file path scan.
|
|
54
|
-
* @public
|
|
55
50
|
*/
|
|
56
51
|
export declare class FileInfo extends File {
|
|
57
52
|
/**
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import PATH from 'node:path';
|
|
2
|
-
import nf from '@m234/nerd-fonts';
|
|
2
|
+
import * as nf from '@m234/nerd-fonts';
|
|
3
3
|
import { decorCondition } from '../styling.js';
|
|
4
4
|
import { File } from './file.js';
|
|
5
5
|
/**
|
|
6
6
|
* The result of the file path scan.
|
|
7
|
-
* @public
|
|
8
7
|
*/
|
|
9
8
|
export class FileInfo extends File {
|
|
10
9
|
source;
|
|
@@ -34,7 +33,8 @@ export class FileInfo extends File {
|
|
|
34
33
|
source) {
|
|
35
34
|
super(parent, relativePath, absolutePath);
|
|
36
35
|
this.source = source;
|
|
37
|
-
this.status = source === undefined
|
|
36
|
+
this.status = source === undefined
|
|
37
|
+
? 'non-target'
|
|
38
38
|
: (source.scanner.ignores(relativePath) ? 'ignored' : 'included');
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -45,18 +45,21 @@ export class FileInfo extends File {
|
|
|
45
45
|
const { fileIcon, chalk, usePrefix = false, source: useSource = false, entire = true, posix = false } = options ?? {};
|
|
46
46
|
const patha = posix ? PATH.posix : PATH;
|
|
47
47
|
const parsed = PATH.parse(this.relativePath);
|
|
48
|
-
const glyph = nf.
|
|
49
|
-
const fIcon = fileIcon
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
const glyph = nf.Seti.fromParsedPath(parsed);
|
|
49
|
+
const fIcon = fileIcon
|
|
50
|
+
? decorCondition(fileIcon, {
|
|
51
|
+
ifEmoji: '📄',
|
|
52
|
+
ifNerd: chalk && glyph.color !== undefined ? chalk.hex(glyph.color)(glyph.value) : glyph.value,
|
|
53
|
+
postfix: ' ',
|
|
54
|
+
})
|
|
55
|
+
: '';
|
|
54
56
|
let prefix = usePrefix && this.status !== 'non-target' ? (this.status === 'ignored' ? '!' : '+') : '';
|
|
55
57
|
let postfix = useSource && this.source !== undefined ? ' < ' + this.source.toString() : '';
|
|
56
58
|
if (chalk) {
|
|
57
59
|
prefix = chalk.dim(prefix);
|
|
58
60
|
postfix = chalk.dim(postfix);
|
|
59
|
-
const clr = this.status === 'non-target'
|
|
61
|
+
const clr = this.status === 'non-target'
|
|
62
|
+
? chalk.white
|
|
60
63
|
: (this.status === 'included' ? chalk.green : chalk.white);
|
|
61
64
|
if (entire) {
|
|
62
65
|
return fIcon + clr(prefix + this.relativePath + postfix);
|
|
@@ -10,12 +10,10 @@ export * as Sorting from './sorting.js';
|
|
|
10
10
|
export * as Plugins from './binds/index.js';
|
|
11
11
|
/**
|
|
12
12
|
* ViewIgnored's package.json.
|
|
13
|
-
|
|
14
|
-
*/
|
|
13
|
+
*/
|
|
15
14
|
export declare const package_: typeof import("../../package.json");
|
|
16
15
|
/**
|
|
17
16
|
* Uses `node:fs` and `node:fs/promises` by default.
|
|
18
|
-
* @public
|
|
19
17
|
*/
|
|
20
18
|
export type FileSystemAdapter = {
|
|
21
19
|
readFileSync?: typeof FS.readFileSync;
|
|
@@ -29,7 +27,6 @@ export type FileSystemAdapter = {
|
|
|
29
27
|
};
|
|
30
28
|
/**
|
|
31
29
|
* The custom scanner.
|
|
32
|
-
* @public
|
|
33
30
|
*/
|
|
34
31
|
export type Scanner = {
|
|
35
32
|
/**
|
|
@@ -42,12 +39,10 @@ export type Scanner = {
|
|
|
42
39
|
* @throws If the target does not allow the current ignore configurations: {@link ViewIgnoredError}.
|
|
43
40
|
* For example, {@link https://www.npmjs.com/package/@vscode/vsce vsce} considers it invalid if your manifest is missing the 'engines' field.
|
|
44
41
|
* Similarly, npm will raise an error if you attempt to publish a package without a basic 'package.json'.
|
|
45
|
-
* @public
|
|
46
42
|
*/
|
|
47
43
|
export type Methodology = (tree: Directory, realOptions: RealScanOptions) => Map<File, SourceInfo>;
|
|
48
44
|
/**
|
|
49
45
|
* Options with defaults and additional properties.
|
|
50
|
-
* @public
|
|
51
46
|
*/
|
|
52
47
|
export type RealScanOptions = Required<Omit<ScanOptions, 'fsa'>> & {
|
|
53
48
|
modules: {
|
|
@@ -63,7 +58,6 @@ export type RealScanOptions = Required<Omit<ScanOptions, 'fsa'>> & {
|
|
|
63
58
|
};
|
|
64
59
|
/**
|
|
65
60
|
* Folder deep scanning options.
|
|
66
|
-
* @public
|
|
67
61
|
*/
|
|
68
62
|
export type ScanOptions = {
|
|
69
63
|
/**
|
|
@@ -111,32 +105,27 @@ export type ScanOptions = {
|
|
|
111
105
|
* Gets info about the each file: it is ignored or not.
|
|
112
106
|
* @param directoryPath The relative path to the directory.
|
|
113
107
|
* @throws If no valid sources: {@link ErrorNoSources}.
|
|
114
|
-
* @public
|
|
115
108
|
*/
|
|
116
109
|
export declare function scan(directoryPath: string, options?: ScanOptions): Promise<FileInfo[]>;
|
|
117
110
|
/**
|
|
118
111
|
* Gets info about the each file: it is ignored or not.
|
|
119
112
|
* @param directory The current working directory.
|
|
120
113
|
* @throws If no valid sources: {@link ErrorNoSources}.
|
|
121
|
-
* @public
|
|
122
114
|
*/
|
|
123
115
|
export declare function scan(directory: Directory, options?: ScanOptions): Promise<FileInfo[]>;
|
|
124
116
|
/**
|
|
125
117
|
* Gets info about the each file: it is ignored or not.
|
|
126
118
|
* @param stream The stream of the current working directory reading.
|
|
127
119
|
* @throws If no valid sources: {@link ErrorNoSources}.
|
|
128
|
-
* @public
|
|
129
120
|
*/
|
|
130
121
|
export declare function scan(stream: DeepStreamEventEmitter, options?: ScanOptions): Promise<FileInfo[]>;
|
|
131
122
|
/**
|
|
132
123
|
* Gets info about the each file: it is ignored or not.
|
|
133
124
|
* @param pathList The list of relative paths. The should be relative to the current working directory.
|
|
134
125
|
* @throws If no valid sources: {@link ErrorNoSources}.
|
|
135
|
-
* @public
|
|
136
126
|
*/
|
|
137
127
|
export declare function scan(pathList: string[], options?: ScanOptions): Promise<FileInfo[]>;
|
|
138
128
|
/**
|
|
139
129
|
* @returns Options with defaults and additional properties.
|
|
140
|
-
* @public
|
|
141
130
|
*/
|
|
142
131
|
export declare function makeOptionsReal(options?: ScanOptions): RealScanOptions;
|
|
@@ -16,9 +16,7 @@ export * as Sorting from './sorting.js';
|
|
|
16
16
|
export * as Plugins from './binds/index.js';
|
|
17
17
|
/**
|
|
18
18
|
* ViewIgnored's package.json.
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
19
|
+
*/
|
|
22
20
|
export const package_ = createRequire(import.meta.url)('../../package.json');
|
|
23
21
|
export async function scan(argument0, options) {
|
|
24
22
|
options ??= {};
|
|
@@ -49,7 +47,7 @@ export async function scan(argument0, options) {
|
|
|
49
47
|
const fileInfoList = [];
|
|
50
48
|
const promiseList = [];
|
|
51
49
|
const cacheDirectories = new Map();
|
|
52
|
-
for (const directory of [tree
|
|
50
|
+
for (const directory of [tree, ...tree.deep(Directory)]) {
|
|
53
51
|
cacheDirectories.set(directory, pLimit(optionsReal.concurrency));
|
|
54
52
|
}
|
|
55
53
|
for (const entry of tree.deepIterator(File)) {
|
|
@@ -69,7 +67,6 @@ export async function scan(argument0, options) {
|
|
|
69
67
|
}
|
|
70
68
|
/**
|
|
71
69
|
* @returns Options with defaults and additional properties.
|
|
72
|
-
* @public
|
|
73
70
|
*/
|
|
74
71
|
export function makeOptionsReal(options) {
|
|
75
72
|
options ??= {};
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Contains all file sort names.
|
|
3
|
-
* @public
|
|
4
3
|
*/
|
|
5
4
|
export declare const sortNameList: readonly ["firstFolders", "firstFiles", "type", "mixed", "modified"];
|
|
6
5
|
/**
|
|
7
6
|
* Contains all file sort names as a type.
|
|
8
|
-
* @public
|
|
9
7
|
*/
|
|
10
8
|
export type SortName = typeof sortNameList[number];
|
|
11
9
|
/**
|
|
12
10
|
* {@link Array.prototype.sort}'s file path comparator.
|
|
13
|
-
* @public
|
|
14
11
|
*/
|
|
15
12
|
export type SortFunction = (a: string, b: string) => number;
|
|
16
13
|
/**
|
|
17
14
|
* Checks if the value is the {@link SortName}.
|
|
18
|
-
* @public
|
|
19
15
|
*/
|
|
20
16
|
export declare function isSortName(value: unknown): value is SortName;
|
|
21
17
|
/**
|
|
22
|
-
* @public
|
|
23
18
|
* @example
|
|
24
19
|
* "path/to/the/file" -> ["path", "to/the/file", false]
|
|
25
20
|
* "file" -> ["file", "file", true]
|
|
@@ -29,20 +24,17 @@ export declare function shiftPath(p: string): [next: string, other: string, isLa
|
|
|
29
24
|
/**
|
|
30
25
|
* Files and folders are sorted by their names.
|
|
31
26
|
* Folders are displayed before files.
|
|
32
|
-
* @public
|
|
33
27
|
*/
|
|
34
28
|
export declare function firstFolders(a: string, b: string): number;
|
|
35
29
|
/**
|
|
36
30
|
* Files and folders are sorted by their names.
|
|
37
31
|
* Files are displayed before folders.
|
|
38
|
-
* @public
|
|
39
32
|
*/
|
|
40
33
|
export declare function firstFiles(a: string, b: string): number;
|
|
41
34
|
/**
|
|
42
35
|
* Files and folders are sorted by last modified date in descending order.
|
|
43
36
|
* Folders are displayed before files.
|
|
44
37
|
* @see {@link makeMtimeCache}
|
|
45
|
-
* @public
|
|
46
38
|
*/
|
|
47
39
|
export declare function modified(a: string, b: string, map: Map<{
|
|
48
40
|
toString(): string;
|
|
@@ -50,12 +42,10 @@ export declare function modified(a: string, b: string, map: Map<{
|
|
|
50
42
|
/**
|
|
51
43
|
* Files and folders are grouped by extension type then sorted by thir names.
|
|
52
44
|
* Folders are displayed before files.
|
|
53
|
-
* @public
|
|
54
45
|
*/
|
|
55
46
|
export declare function type(a: string, b: string): number;
|
|
56
47
|
/**
|
|
57
48
|
* Files and folders are sorted by their names.
|
|
58
49
|
* Files are interwoven with folders.
|
|
59
|
-
* @public
|
|
60
50
|
*/
|
|
61
51
|
export declare function mixed(a: string, b: string): number;
|