view-ignored 0.0.2 → 0.1.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/README.md +47 -16
- package/lib/browser/binds/index.d.ts +2 -0
- package/lib/browser/binds/index.d.ts.map +1 -0
- package/lib/browser/binds/index.js +2 -0
- package/lib/browser/binds/index.js.map +1 -0
- package/lib/browser/binds/targets.d.ts +52 -0
- package/lib/browser/binds/targets.d.ts.map +1 -0
- package/lib/browser/binds/targets.js +43 -0
- package/lib/browser/binds/targets.js.map +1 -0
- package/lib/browser/fileinfo.d.ts +47 -10
- package/lib/browser/fileinfo.d.ts.map +1 -1
- package/lib/browser/fileinfo.js +37 -7
- package/lib/browser/fileinfo.js.map +1 -1
- package/lib/browser/lib.d.ts +38 -19
- package/lib/browser/lib.d.ts.map +1 -1
- package/lib/browser/lib.js +20 -18
- package/lib/browser/lib.js.map +1 -1
- package/lib/browser/looker.d.ts +24 -5
- package/lib/browser/looker.d.ts.map +1 -1
- package/lib/browser/looker.js +9 -0
- package/lib/browser/looker.js.map +1 -1
- package/lib/browser/plugins/git.d.ts.map +1 -1
- package/lib/browser/plugins/git.js +2 -2
- package/lib/browser/plugins/git.js.map +1 -1
- package/lib/browser/plugins/npm.d.ts.map +1 -1
- package/lib/browser/plugins/npm.js +2 -2
- package/lib/browser/plugins/npm.js.map +1 -1
- package/lib/browser/plugins/vsce.d.ts.map +1 -1
- package/lib/browser/plugins/vsce.js +2 -2
- package/lib/browser/plugins/vsce.js.map +1 -1
- package/lib/browser/plugins/yarn.js +1 -1
- package/lib/browser/plugins/yarn.js.map +1 -1
- package/lib/browser/sorting.d.ts.map +1 -1
- package/lib/browser/sorting.js.map +1 -1
- package/lib/browser/sourcepattern.d.ts +13 -3
- package/lib/browser/sourcepattern.d.ts.map +1 -1
- package/lib/browser/sourcepattern.js +13 -2
- package/lib/browser/sourcepattern.js.map +1 -1
- package/lib/browser/styling.d.ts +31 -0
- package/lib/browser/styling.d.ts.map +1 -1
- package/lib/browser/styling.js +10 -0
- package/lib/browser/styling.js.map +1 -1
- package/lib/cli.d.ts +35 -0
- package/lib/cli.d.ts.map +1 -1
- package/lib/cli.js +35 -4
- package/lib/cli.js.map +1 -1
- package/lib/config.d.ts +76 -22
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +51 -14
- package/lib/config.js.map +1 -1
- package/lib/git.d.ts.map +1 -1
- package/lib/git.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Retrieve list of files ignored/included by Git, NPM, Yarn and VSC Extension.
|
|
|
10
10
|
- **Multi-target.** Get list of included files, using configuration files reader, not command line wrapper.
|
|
11
11
|
- **Use in browser.** view-ignored supports file system adapter.
|
|
12
12
|
- **Command line.** Supports no-color and multiple output styles, including [nerd fonts](https://github.com/ryanoasis/nerd-fonts).
|
|
13
|
-
- **Plugins.**
|
|
13
|
+
- **Plugins.** view-ignored allows you to add new [targets](#targets) programmatically. Command line interface does NOT support plugins.
|
|
14
14
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
@@ -28,15 +28,18 @@ npm i -g view-ignored
|
|
|
28
28
|
viewig --help
|
|
29
29
|
view-ignored --help
|
|
30
30
|
|
|
31
|
-
# scan
|
|
31
|
+
# scan: git (default) and npm
|
|
32
32
|
viewig scan .
|
|
33
33
|
viewig scan . --target=npm
|
|
34
34
|
|
|
35
|
-
#
|
|
35
|
+
# config: print all
|
|
36
|
+
viewig config get
|
|
37
|
+
# config: print with defaults
|
|
38
|
+
viewig config get --safe
|
|
39
|
+
# config: set npm as default target and scan for npm
|
|
36
40
|
viewig config set target=npm
|
|
37
41
|
viewig scan .
|
|
38
|
-
|
|
39
|
-
# always use nerd font
|
|
42
|
+
# config: always use nerd font
|
|
40
43
|
viewig config set style=treeNerd
|
|
41
44
|
```
|
|
42
45
|
|
|
@@ -46,19 +49,46 @@ viewig config set style=treeNerd
|
|
|
46
49
|
import * as vign from "view-ignored";
|
|
47
50
|
import * as vign from "view-ignored/lib/browser"; // for web environment apps
|
|
48
51
|
|
|
49
|
-
const
|
|
52
|
+
const fileInfoList = vign.scanProject("git");
|
|
53
|
+
const fileInfoList = vign.scanPaths(pathList, "git");
|
|
54
|
+
const fileInfo = vign.scanFile(pathToFile, "git");
|
|
55
|
+
|
|
56
|
+
// options available
|
|
57
|
+
const fileInfoList = vign.scanProject("git", { cwd, ... });
|
|
58
|
+
|
|
59
|
+
// custom
|
|
60
|
+
/**@type {vign.ScanMethod}*/
|
|
61
|
+
export const method = function (data) {
|
|
62
|
+
const { looker, sourceFile: source } = data
|
|
63
|
+
if (!looker.isValidPattern(source.content)) {
|
|
64
|
+
return false
|
|
65
|
+
}
|
|
66
|
+
looker.add(source.content)
|
|
67
|
+
return true
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**@type {vign.Source[]}*/
|
|
71
|
+
export const sources = [
|
|
72
|
+
{ sources: new SourcePattern("**/.gitignore"), patternType: ".*ignore", method, addPatterns: addPatternsExclude },
|
|
73
|
+
]
|
|
74
|
+
vign.scanProject(sources)
|
|
75
|
+
|
|
76
|
+
// use results
|
|
77
|
+
if (fileInfo.ignored) {
|
|
78
|
+
vscode.explorer.colorFile(fileInfo.filePath, "gray")
|
|
79
|
+
}
|
|
50
80
|
```
|
|
51
81
|
|
|
52
82
|
#### Sorting:
|
|
53
83
|
|
|
54
84
|
```js
|
|
55
|
-
const
|
|
85
|
+
const fileInfoList = vign.scanProject("npm");
|
|
56
86
|
const sorter = vign.Sorting.Sorters.firstFolders;
|
|
57
|
-
|
|
87
|
+
fileInfoList.map(String).sort(sorter);
|
|
58
88
|
```
|
|
59
89
|
|
|
60
90
|
```js
|
|
61
|
-
const
|
|
91
|
+
const fileInfoList = vign.scanProject("npm")
|
|
62
92
|
const sorter = Sorting.Sorters[flags.sort]
|
|
63
93
|
const cacheEditDates = new Map<FileInfo, Date>()
|
|
64
94
|
for (const look of looked) {
|
|
@@ -73,13 +103,14 @@ const lookedSorted = looked.sort((a, b) => sorter(
|
|
|
73
103
|
### Targets
|
|
74
104
|
|
|
75
105
|
- `git`
|
|
76
|
-
-
|
|
106
|
+
- Test command: `git ls-tree -r <git-branch-name> --name-only`
|
|
77
107
|
- Sources walkthrough: '.gitignore' and git config `core.excludesFile`.
|
|
78
|
-
- `
|
|
79
|
-
|
|
80
|
-
-
|
|
108
|
+
- `core.excludesFile` does not work at this moment.
|
|
109
|
+
- `npm` (can be usable for PNPM and Bun)
|
|
110
|
+
- Test command: `npm pack --dry-run`
|
|
111
|
+
- Sources walkthrough: 'package.json'>"files" otherwise '.npmignore' otherwise '.gitignore'.
|
|
81
112
|
- `yarn`
|
|
82
|
-
- Sources walkthrough: 'package.json' otherwise '.yarnignore' otherwise '.npmignore' otherwise '.gitignore'.
|
|
113
|
+
- Sources walkthrough: 'package.json'>"files" otherwise '.yarnignore' otherwise '.npmignore' otherwise '.gitignore'.
|
|
83
114
|
- `vsce`
|
|
84
|
-
-
|
|
85
|
-
- Sources walkthrough: '.vscodeignore'
|
|
115
|
+
- Test command: `vsce ls`
|
|
116
|
+
- Sources walkthrough: '.vscodeignore'.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/binds/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/binds/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { LookFolderOptions, Source } from "../lib.js";
|
|
2
|
+
export interface TargetBind {
|
|
3
|
+
/**
|
|
4
|
+
* The target simple name.
|
|
5
|
+
* @see {@link isValidId}
|
|
6
|
+
*/
|
|
7
|
+
id: string;
|
|
8
|
+
/**
|
|
9
|
+
* The target readable name.
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* The walkthrough. Files including patterns.
|
|
14
|
+
*/
|
|
15
|
+
sources: Source[];
|
|
16
|
+
/**
|
|
17
|
+
* Folder deep scanning options for the target.
|
|
18
|
+
*/
|
|
19
|
+
scanOptions?: LookFolderOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Test command.
|
|
22
|
+
* @example
|
|
23
|
+
* "npm pack --dry run"
|
|
24
|
+
* "vsce ls"
|
|
25
|
+
*/
|
|
26
|
+
testCommad?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @param id The target simple name.
|
|
30
|
+
* @returns `true` if the target id is valid.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isValidId(id: unknown): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Allows to create targets for view-ignored scan* functions.
|
|
35
|
+
* @example
|
|
36
|
+
* scanProject("abc") // error
|
|
37
|
+
* Bindings.targetSet("abc", {...})
|
|
38
|
+
* scanProject("abc") // ok
|
|
39
|
+
*/
|
|
40
|
+
export declare function targetSet(bind: TargetBind): void;
|
|
41
|
+
/**
|
|
42
|
+
* Get all target ids.
|
|
43
|
+
* @example
|
|
44
|
+
* ["git", "npm", "vsce", ...]
|
|
45
|
+
*/
|
|
46
|
+
export declare function targetList(): string[];
|
|
47
|
+
/**
|
|
48
|
+
* Get target bind by target id.
|
|
49
|
+
* @param id Target id.
|
|
50
|
+
*/
|
|
51
|
+
export declare function targetGet(id: string): TargetBind | undefined;
|
|
52
|
+
//# sourceMappingURL=targets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../../../src/browser/binds/targets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAErD,MAAM,WAAW,UAAU;IACvB;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAA;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAE/B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAE9C;AAOD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAKhD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,MAAM,EAAE,CAErC;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAK5D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param id The target simple name.
|
|
3
|
+
* @returns `true` if the target id is valid.
|
|
4
|
+
*/
|
|
5
|
+
export function isValidId(id) {
|
|
6
|
+
return typeof id === "string" && id.match(/^[-a-zA-Z0-9]+$/) != null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The container for binds: id=bind.
|
|
10
|
+
*/
|
|
11
|
+
const targetBindMap = new Map();
|
|
12
|
+
/**
|
|
13
|
+
* Allows to create targets for view-ignored scan* functions.
|
|
14
|
+
* @example
|
|
15
|
+
* scanProject("abc") // error
|
|
16
|
+
* Bindings.targetSet("abc", {...})
|
|
17
|
+
* scanProject("abc") // ok
|
|
18
|
+
*/
|
|
19
|
+
export function targetSet(bind) {
|
|
20
|
+
if (!isValidId(bind.id)) {
|
|
21
|
+
throw TypeError(`view-ignored can not bind target with id '${bind.id}'`);
|
|
22
|
+
}
|
|
23
|
+
targetBindMap.set(bind.id, bind);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get all target ids.
|
|
27
|
+
* @example
|
|
28
|
+
* ["git", "npm", "vsce", ...]
|
|
29
|
+
*/
|
|
30
|
+
export function targetList() {
|
|
31
|
+
return Array.from(targetBindMap.keys());
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get target bind by target id.
|
|
35
|
+
* @param id Target id.
|
|
36
|
+
*/
|
|
37
|
+
export function targetGet(id) {
|
|
38
|
+
if (!isValidId(id)) {
|
|
39
|
+
throw TypeError(`view-ignored can not get bind for target with id '${id}'`);
|
|
40
|
+
}
|
|
41
|
+
return targetBindMap.get(id);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=targets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targets.js","sourceRoot":"","sources":["../../../src/browser/binds/targets.ts"],"names":[],"mappings":"AAiCA;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EAAW;IACjC,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAA;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,EAAsB,CAAA;AAEnD;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,IAAgB;IACtC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QACtB,MAAM,SAAS,CAAC,6CAA6C,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA;IAC5E,CAAC;IACD,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACtB,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAA;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EAAU;IAChC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;QACjB,MAAM,SAAS,CAAC,qDAAqD,EAAE,GAAG,CAAC,CAAA;IAC/E,CAAC;IACD,OAAO,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -1,35 +1,72 @@
|
|
|
1
1
|
import { ChalkInstance } from "chalk";
|
|
2
2
|
import { StyleName } from "./styling.js";
|
|
3
|
-
import { SourceFile } from "./lib.js";
|
|
3
|
+
import { FilterName, SourceFile } from "./lib.js";
|
|
4
4
|
import { Looker } from "./looker.js";
|
|
5
5
|
export interface FileInfoToStringOptions {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @default
|
|
9
|
-
* undefined
|
|
7
|
+
* The appearance behavior of the file icon.
|
|
8
|
+
* @default undefined
|
|
10
9
|
*/
|
|
11
10
|
styleName?: StyleName;
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
12
|
+
* The appearance behavior of the prefix.
|
|
13
|
+
* `"+"` for included, `"!"` for excluded.
|
|
14
|
+
* @default false
|
|
14
15
|
*/
|
|
15
16
|
usePrefix?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The behavior of colors.
|
|
19
|
+
* @default undefined
|
|
20
|
+
*/
|
|
16
21
|
chalk?: ChalkInstance;
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
|
-
*
|
|
24
|
+
* The result of the file path scan.
|
|
20
25
|
*/
|
|
21
26
|
export declare class FileInfo {
|
|
27
|
+
/**
|
|
28
|
+
* Relative path to the file.
|
|
29
|
+
*/
|
|
22
30
|
readonly filePath: string;
|
|
31
|
+
/**
|
|
32
|
+
* Parser instance. Can be used to determine if the file is ignored.
|
|
33
|
+
* @see {@link ignored} can be used instead of it.
|
|
34
|
+
*/
|
|
23
35
|
readonly looker: Looker;
|
|
36
|
+
/**
|
|
37
|
+
* Source of patterns, used by {@link looker}.
|
|
38
|
+
*/
|
|
24
39
|
readonly source: SourceFile;
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
constructor(
|
|
41
|
+
/**
|
|
42
|
+
* Relative path to the file.
|
|
43
|
+
*/
|
|
44
|
+
filePath: string,
|
|
45
|
+
/**
|
|
46
|
+
* Parser instance. Can be used to determine if the file is ignored.
|
|
47
|
+
* @see {@link ignored} can be used instead of it.
|
|
48
|
+
*/
|
|
49
|
+
looker: Looker,
|
|
50
|
+
/**
|
|
51
|
+
* Source of patterns, used by {@link looker}.
|
|
52
|
+
*/
|
|
53
|
+
source: SourceFile);
|
|
54
|
+
/**
|
|
55
|
+
* Determines if ignored file is ignored or not.
|
|
56
|
+
*/
|
|
57
|
+
get ignored(): boolean;
|
|
27
58
|
static from(paths: string[], looker: Looker, source?: SourceFile | string): FileInfo[];
|
|
28
59
|
static from(path: string, looker: Looker, source?: SourceFile | string): FileInfo;
|
|
29
60
|
/**
|
|
30
|
-
* @param options Styling options.
|
|
31
|
-
* @param formatEntire Determines if path base or entire
|
|
61
|
+
* @param options Styling options. Default `{}`.
|
|
62
|
+
* @param formatEntire Determines if the path's base or the entire path should be formatted. Default `true`.
|
|
63
|
+
* @returns Relative file path. Optionally formatted.
|
|
32
64
|
*/
|
|
33
65
|
toString(options?: FileInfoToStringOptions, formatEntire?: boolean): string;
|
|
66
|
+
/**
|
|
67
|
+
* @param filter The group name.
|
|
68
|
+
* @returns `true` if the file is contained by the filter.
|
|
69
|
+
*/
|
|
70
|
+
isIncludedBy(filter: FilterName): boolean;
|
|
34
71
|
}
|
|
35
72
|
//# sourceMappingURL=fileinfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileinfo.d.ts","sourceRoot":"","sources":["../../src/browser/fileinfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,EAAsB,SAAS,EAAE,MAAM,cAAc,CAAA;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"fileinfo.d.ts","sourceRoot":"","sources":["../../src/browser/fileinfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAA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
+
* The result of the file path scan.
|
|
5
5
|
*/
|
|
6
6
|
export class FileInfo {
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(
|
|
8
|
+
/**
|
|
9
|
+
* Relative path to the file.
|
|
10
|
+
*/
|
|
11
|
+
filePath,
|
|
12
|
+
/**
|
|
13
|
+
* Parser instance. Can be used to determine if the file is ignored.
|
|
14
|
+
* @see {@link ignored} can be used instead of it.
|
|
15
|
+
*/
|
|
16
|
+
looker,
|
|
17
|
+
/**
|
|
18
|
+
* Source of patterns, used by {@link looker}.
|
|
19
|
+
*/
|
|
20
|
+
source) {
|
|
8
21
|
this.filePath = filePath;
|
|
9
22
|
this.looker = looker;
|
|
10
23
|
this.source = source;
|
|
11
|
-
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Determines if ignored file is ignored or not.
|
|
27
|
+
*/
|
|
28
|
+
get ignored() {
|
|
29
|
+
return this.looker.ignores(this.filePath);
|
|
12
30
|
}
|
|
13
31
|
static from(arg, looker, source) {
|
|
14
32
|
if (Array.isArray(arg)) {
|
|
@@ -18,11 +36,12 @@ export class FileInfo {
|
|
|
18
36
|
return new FileInfo(arg, looker, src);
|
|
19
37
|
}
|
|
20
38
|
/**
|
|
21
|
-
* @param options Styling options.
|
|
22
|
-
* @param formatEntire Determines if path base or entire
|
|
39
|
+
* @param options Styling options. Default `{}`.
|
|
40
|
+
* @param formatEntire Determines if the path's base or the entire path should be formatted. Default `true`.
|
|
41
|
+
* @returns Relative file path. Optionally formatted.
|
|
23
42
|
*/
|
|
24
|
-
toString(options, formatEntire = true) {
|
|
25
|
-
const { styleName, usePrefix = false, chalk } = options
|
|
43
|
+
toString(options = {}, formatEntire = true) {
|
|
44
|
+
const { styleName, usePrefix = false, chalk } = options;
|
|
26
45
|
const parsed = path.parse(this.filePath);
|
|
27
46
|
const fileIcon = styleConditionFile(styleName, this.filePath);
|
|
28
47
|
const prefix = usePrefix ? (this.ignored ? '!' : '+') : '';
|
|
@@ -38,5 +57,16 @@ export class FileInfo {
|
|
|
38
57
|
}
|
|
39
58
|
return parsed.dir + '/' + fileIcon + prefix + parsed.base;
|
|
40
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* @param filter The group name.
|
|
62
|
+
* @returns `true` if the file is contained by the filter.
|
|
63
|
+
*/
|
|
64
|
+
isIncludedBy(filter) {
|
|
65
|
+
const filterIgnore = (filter === "ignored") && this.ignored;
|
|
66
|
+
const filterInclude = (filter === "included") && !this.ignored;
|
|
67
|
+
const filterAll = filter === "all";
|
|
68
|
+
const result = filterIgnore || filterInclude || filterAll;
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
41
71
|
}
|
|
42
72
|
//# sourceMappingURL=fileinfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileinfo.js","sourceRoot":"","sources":["../../src/browser/fileinfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAa,MAAM,cAAc,CAAA;AAC5D,OAAO,IAAI,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"fileinfo.js","sourceRoot":"","sources":["../../src/browser/fileinfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAa,MAAM,cAAc,CAAA;AAC5D,OAAO,IAAI,MAAM,MAAM,CAAA;AAyBvB;;GAEG;AACH,MAAM,OAAO,QAAQ;IACpB;IACC;;MAEE;IACc,QAAgB;IAEhC;;;OAGG;IACa,MAAc;IAE9B;;MAEE;IACc,MAAkB;QAXlB,aAAQ,GAAR,QAAQ,CAAQ;QAMhB,WAAM,GAAN,MAAM,CAAQ;QAKd,WAAM,GAAN,MAAM,CAAY;IAC/B,CAAC;IAEL;;OAEG;IACH,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC1C,CAAC;IAID,MAAM,CAAC,IAAI,CAAC,GAAsB,EAAE,MAAc,EAAE,MAA4B;QAC/E,IAAI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C,GAAG,GAAG,GAAG,GAAG,QAAQ,GAAG,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QAC/D,CAAC;QACD,IAAI,YAAY,EAAE,CAAC;YAClB,OAAO,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,CAAC;QACD,OAAO,MAAM,CAAC,GAAG,GAAG,GAAG,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC,IAAI,CAAA;IAC1D,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,MAAkB;QAC9B,MAAM,YAAY,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,IAAI,IAAI,CAAC,OAAO,CAAA;QAC3D,MAAM,aAAa,GAAG,CAAC,MAAM,KAAK,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAA;QAC9D,MAAM,SAAS,GAAG,MAAM,KAAK,KAAK,CAAA;QAClC,MAAM,MAAM,GAAG,YAAY,IAAI,aAAa,IAAI,SAAS,CAAA;QACzD,OAAO,MAAM,CAAA;IACd,CAAC;CACD"}
|
package/lib/browser/lib.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { Looker } from "./looker.js";
|
|
2
|
+
import { Looker, PatternType } from "./looker.js";
|
|
3
3
|
import FastGlob from "fast-glob";
|
|
4
4
|
import { FileInfo } from "./fileinfo.js";
|
|
5
5
|
import { SourcePattern } from "./sourcepattern.js";
|
|
@@ -8,51 +8,65 @@ export * from "./fileinfo.js";
|
|
|
8
8
|
export * from "./sourcepattern.js";
|
|
9
9
|
export * as Styling from "./styling.js";
|
|
10
10
|
export * as Sorting from "./sorting.js";
|
|
11
|
-
export * as Binding from "./binds.js";
|
|
11
|
+
export * as Binding from "./binds/index.js";
|
|
12
12
|
import "./plugins/git.js";
|
|
13
13
|
import "./plugins/npm.js";
|
|
14
14
|
import "./plugins/vsce.js";
|
|
15
15
|
import "./plugins/yarn.js";
|
|
16
|
-
export type PatternType = ".*ignore" | "minimatch";
|
|
17
16
|
export declare const filterNameList: readonly ["ignored", "included", "all"];
|
|
18
17
|
export type FilterName = typeof filterNameList[number];
|
|
19
18
|
export interface FileSystemAdapter extends FastGlob.FileSystemAdapter {
|
|
20
19
|
readFileSync: (path: string) => Buffer;
|
|
21
20
|
}
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
22
|
+
* The data passed to {@link ScanMethod}.
|
|
23
|
+
* @todo Rename -> ScanMethodData.
|
|
24
24
|
*/
|
|
25
25
|
export interface LookMethodData {
|
|
26
|
+
/**
|
|
27
|
+
* The {@link Looker} instance with parsed patterns.
|
|
28
|
+
*/
|
|
26
29
|
looker: Looker;
|
|
30
|
+
/**
|
|
31
|
+
* The path to the target file.
|
|
32
|
+
*/
|
|
27
33
|
filePath: string;
|
|
34
|
+
/**
|
|
35
|
+
* The information about where the patterns were taken from.
|
|
36
|
+
*/
|
|
28
37
|
sourceFile: SourceFile;
|
|
29
38
|
}
|
|
30
39
|
/**
|
|
31
|
-
*
|
|
40
|
+
* Also can write rules to the {@link Looker}.
|
|
41
|
+
* @returns `true` if the given source is valid.
|
|
32
42
|
*/
|
|
33
43
|
export type ScanMethod = (data: LookMethodData) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Contains file path and content.
|
|
46
|
+
*/
|
|
34
47
|
export interface SourceFile {
|
|
35
48
|
/**
|
|
36
|
-
*
|
|
49
|
+
* The source file path.
|
|
37
50
|
*/
|
|
38
51
|
path: string;
|
|
39
52
|
/**
|
|
40
|
-
*
|
|
53
|
+
* The source file content.
|
|
41
54
|
*/
|
|
42
55
|
content: string;
|
|
43
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Represents the methodology for reading the target source.
|
|
59
|
+
*/
|
|
44
60
|
export interface Source {
|
|
45
61
|
/**
|
|
46
62
|
* Git configuration property.
|
|
47
|
-
*
|
|
48
|
-
* @see {@link https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreignoreCase|git-config ignorecase}.
|
|
63
|
+
* @see Official git documentation: {@link https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreignoreCase|ignorecase}.
|
|
49
64
|
* @default false
|
|
50
65
|
*/
|
|
51
66
|
ignoreCase?: boolean;
|
|
52
67
|
/**
|
|
53
68
|
* Additional patterns, which will be used as
|
|
54
69
|
* other patterns in the `.gitignore` file, or `package.json` "files" property.
|
|
55
|
-
*
|
|
56
70
|
* @default []
|
|
57
71
|
*/
|
|
58
72
|
addPatterns?: string[];
|
|
@@ -65,57 +79,62 @@ export interface Source {
|
|
|
65
79
|
*/
|
|
66
80
|
patternType: PatternType;
|
|
67
81
|
/**
|
|
68
|
-
*
|
|
82
|
+
* Scanner function. Should return `true` if the given source is valid.
|
|
69
83
|
*/
|
|
70
84
|
method: ScanMethod;
|
|
71
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* File scanning options.
|
|
88
|
+
* @see {@link LookFolderOptions}
|
|
89
|
+
*/
|
|
72
90
|
export interface ScanFileOptions {
|
|
73
91
|
/**
|
|
74
92
|
* Custom implementation of methods for working with the file system.
|
|
75
|
-
*
|
|
76
93
|
* @default fs.*
|
|
77
94
|
*/
|
|
78
95
|
fs?: FileSystemAdapter;
|
|
79
96
|
/**
|
|
80
97
|
* The current working directory in which to search.
|
|
81
|
-
*
|
|
82
98
|
* @default process.cwd()
|
|
83
99
|
*/
|
|
84
100
|
cwd?: string;
|
|
85
101
|
/**
|
|
86
102
|
* Specifies the maximum number of concurrent requests from a reader to read
|
|
87
103
|
* directories.
|
|
88
|
-
*
|
|
89
104
|
* @default os.cpus().length
|
|
90
105
|
*/
|
|
91
106
|
concurrency?: number;
|
|
92
107
|
/**
|
|
93
108
|
* Specifies the maximum depth of a read directory relative to the start
|
|
94
109
|
* directory.
|
|
95
|
-
*
|
|
96
110
|
* @default Infinity
|
|
97
111
|
*/
|
|
98
112
|
deep?: number;
|
|
99
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Folder deep scanning options.
|
|
116
|
+
* @see {@link ScanFileOptions}
|
|
117
|
+
* @todo Rename -> ScanFolderOptions
|
|
118
|
+
*/
|
|
100
119
|
export interface LookFolderOptions extends ScanFileOptions {
|
|
101
120
|
/**
|
|
102
121
|
* Filter output.
|
|
103
|
-
*
|
|
104
122
|
* @default "included"
|
|
105
123
|
*/
|
|
106
124
|
filter?: FilterName;
|
|
107
125
|
}
|
|
108
126
|
/**
|
|
109
|
-
*
|
|
127
|
+
* Gets info about the file: it is ignored or not.
|
|
128
|
+
* @returns `undefined` if the source is bad.
|
|
110
129
|
*/
|
|
111
130
|
export declare function scanFile(filePath: string, sources: Source[], options: ScanFileOptions): Promise<FileInfo | undefined>;
|
|
112
131
|
/**
|
|
113
|
-
*
|
|
132
|
+
* Scans project directory paths to determine whether they are being ignored.
|
|
114
133
|
*/
|
|
115
134
|
export declare function scanPaths(allFilePaths: string[], sources: Source[], options: LookFolderOptions): Promise<FileInfo[] | undefined>;
|
|
116
135
|
export declare function scanPaths(allFilePaths: string[], target: string, options: LookFolderOptions): Promise<FileInfo[] | undefined>;
|
|
117
136
|
/**
|
|
118
|
-
*
|
|
137
|
+
* Scans project directory paths to determine whether they are being ignored.
|
|
119
138
|
*/
|
|
120
139
|
export declare function scanProject(sources: Source[], options: LookFolderOptions): Promise<FileInfo[] | undefined>;
|
|
121
140
|
export declare function scanProject(target: string, options: LookFolderOptions): Promise<FileInfo[] | undefined>;
|
package/lib/browser/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/browser/lib.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/browser/lib.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,QAAQ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