view-ignored 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +23 -27
  2. package/bin/viewig +3 -1
  3. package/out/src/browser/binds/index.d.ts +40 -21
  4. package/out/src/browser/binds/index.js +62 -48
  5. package/out/src/browser/binds/plugins/git.d.ts +22 -3
  6. package/out/src/browser/binds/plugins/git.js +57 -21
  7. package/out/src/browser/binds/plugins/npm.d.ts +36 -9
  8. package/out/src/browser/binds/plugins/npm.js +125 -59
  9. package/out/src/browser/binds/plugins/vsce.d.ts +24 -8
  10. package/out/src/browser/binds/plugins/vsce.js +56 -16
  11. package/out/src/browser/binds/plugins/yarn.d.ts +5 -10
  12. package/out/src/browser/binds/plugins/yarn.js +18 -68
  13. package/out/src/browser/binds/scanner.d.ts +56 -0
  14. package/out/src/browser/binds/scanner.js +134 -0
  15. package/out/src/browser/binds/targets.d.ts +35 -11
  16. package/out/src/browser/binds/targets.js +10 -17
  17. package/out/src/browser/errors.d.ts +58 -7
  18. package/out/src/browser/errors.js +40 -12
  19. package/out/src/browser/filtering.d.ts +15 -0
  20. package/out/src/browser/filtering.js +12 -0
  21. package/out/src/browser/fs/directory.d.ts +181 -0
  22. package/out/src/browser/fs/directory.js +235 -0
  23. package/out/src/browser/{fileinfo.d.ts → fs/file-info.d.ts} +38 -27
  24. package/out/src/browser/fs/file-info.js +86 -0
  25. package/out/src/browser/fs/file.d.ts +41 -0
  26. package/out/src/browser/fs/file.js +43 -0
  27. package/out/src/browser/fs/index.d.ts +4 -0
  28. package/out/src/browser/fs/index.js +4 -0
  29. package/out/src/browser/fs/source-info.d.ts +29 -0
  30. package/out/src/browser/fs/source-info.js +31 -0
  31. package/out/src/browser/index.d.ts +2 -2
  32. package/out/src/browser/index.js +2 -2
  33. package/out/src/browser/lib.d.ts +102 -101
  34. package/out/src/browser/lib.js +86 -120
  35. package/out/src/browser/sorting.d.ts +22 -2
  36. package/out/src/browser/sorting.js +37 -32
  37. package/out/src/browser/styling.d.ts +41 -15
  38. package/out/src/browser/styling.js +28 -97
  39. package/out/src/cli.d.ts +73 -34
  40. package/out/src/cli.js +308 -155
  41. package/out/src/config.d.ts +163 -65
  42. package/out/src/config.js +285 -171
  43. package/out/src/errors.d.ts +7 -0
  44. package/out/src/errors.js +1 -0
  45. package/out/src/index.d.ts +2 -2
  46. package/out/src/index.js +2 -2
  47. package/out/src/lib.d.ts +4 -4
  48. package/out/src/lib.js +4 -4
  49. package/out/src/styling.d.ts +10 -4
  50. package/out/src/styling.js +46 -33
  51. package/package.json +37 -23
  52. package/out/src/bin.d.ts +0 -2
  53. package/out/src/bin.js +0 -3
  54. package/out/src/browser/fileinfo.js +0 -78
  55. package/out/src/browser/scanner.d.ts +0 -103
  56. package/out/src/browser/scanner.js +0 -161
  57. package/out/src/browser/sourceinfo.d.ts +0 -62
  58. package/out/src/browser/sourceinfo.js +0 -107
@@ -1,40 +1,53 @@
1
- import { decorCondition } from "./browser/styling.js";
2
- import { configFilePath, configValueList, isConfigKey, isConfigValue } from "./config.js";
3
- export * from "./browser/styling.js";
4
- export function formatConfigConflicts(chalk, decor, error) {
5
- if (!(error instanceof TypeError && error.cause?.constructor === Object)) {
6
- throw error;
1
+ import ansiRegex from 'ansi-regex';
2
+ export * from './browser/styling.js';
3
+ /**
4
+ * @public
5
+ */
6
+ export function highlight(text, chalk) {
7
+ if (chalk === undefined) {
8
+ return text;
7
9
  }
8
- const entries = Object.entries(error.cause);
9
- if (entries === undefined) {
10
- console.error('An object expected.');
11
- return;
10
+ const rtype = /^(?<=\s*)(switch|boolean|object|string|number|integer)(\[])*(?=\s*)$/;
11
+ if (rtype.test(text)) {
12
+ return chalk.hex('#9999ff')(text);
12
13
  }
13
- if (entries.length === 0) {
14
- return;
15
- }
16
- const badEntries = entries.filter(([key, value]) => {
17
- // keys can be undefined
18
- if (!isConfigKey(key)) {
19
- return false;
14
+ const rseparator = /([,.\-:="|])/g;
15
+ const rstring = /'[^']+'/g;
16
+ const rbracketsSquare = /(\[|])/g;
17
+ const rnumber = /\d+/g;
18
+ const rspecial = /(true|false|null|Infinity)/g;
19
+ const rall = new RegExp(`${[ansiRegex(), rstring, rseparator, rbracketsSquare, rnumber, rspecial]
20
+ .map(r => `(${typeof r === 'string' ? r : r.source})`)
21
+ .join('|')}`, 'g');
22
+ const colored = text.replaceAll(rall, match => {
23
+ if (match.match(ansiRegex()) !== null) {
24
+ return match;
25
+ }
26
+ if (match.match(rstring) !== null) {
27
+ return match.replace(/^'[^']*'$/, chalk.hex('#A2D2FF')('$&'));
28
+ }
29
+ if (match.match(rseparator) !== null) {
30
+ return chalk.hex('#D81159')(match);
20
31
  }
21
- if (isConfigValue(key, value)) {
22
- return false;
32
+ if (match.match(rbracketsSquare) !== null) {
33
+ return chalk.hex('#B171D9')(match);
23
34
  }
24
- // bad config value
25
- return true;
35
+ if (match.match(rnumber) !== null) {
36
+ return chalk.hex('#73DEA7')(match);
37
+ }
38
+ if (match.match(rspecial) !== null) {
39
+ return chalk.hex('#73A7DE')(match);
40
+ }
41
+ return match;
26
42
  });
27
- if (badEntries.length === 0) {
28
- return;
43
+ return colored;
44
+ }
45
+ /**
46
+ * @public
47
+ */
48
+ export function stringTime(time, chalk) {
49
+ if (time < 1000) {
50
+ return `${highlight(String(time), chalk)} milliseconds`;
29
51
  }
30
- let message = 'Configuration invalid properties:\n';
31
- const prefix = chalk.redBright(decorCondition(decor, { ifNerd: '\udb82\ude15', ifNormal: '-', postfix: ' ', prefix: ' ' }));
32
- message += badEntries.map(([key, value]) => {
33
- const choices = configValueList(key);
34
- const errorMessage = choices === undefined ? '' : decorCondition(decor, { ifNormal: typeof choices === "string" ? choices : `Choices: ${choices.join(', ')}.`, prefix });
35
- return '\t' + chalk.reset(`${key}=${value}`) + chalk.red(errorMessage);
36
- }).join('\n');
37
- console.error(message);
38
- console.log();
39
- console.log(configFilePath);
52
+ return `${highlight((time / 1000).toFixed(2), chalk)} seconds`;
40
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "view-ignored",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Retrieve list of files ignored/included by Git, NPM, Yarn and VSC Extension.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,9 +12,9 @@
12
12
  "test": "pnpm mocha ./out/test/**/*.test.js",
13
13
  "build": "pnpm shx rm -rf out && pnpm tsc",
14
14
  "build:pub": "pnpm shx rm -rf out && pnpm tsc --sourceMap false",
15
- "build:watch": "pnpm tsc --watch",
16
- "lint": "pnpm eslint .",
17
- "lint:fix": "pnpm eslint . --fix",
15
+ "build:watch": "pnpm shx rm -rf out && pnpm tsc --watch",
16
+ "lint": "pnpm xo",
17
+ "lint:fix": "pnpm xo --fix",
18
18
  "release:major": "pnpm release-it --increment=major",
19
19
  "release:minor": "pnpm release-it --increment=minor",
20
20
  "release:patch": "pnpm release-it --increment=patch"
@@ -23,7 +23,8 @@
23
23
  "license": "ISC",
24
24
  "main": "./out/src/index.js",
25
25
  "files": [
26
- "out/src"
26
+ "/bin",
27
+ "/out/src"
27
28
  ],
28
29
  "repository": {
29
30
  "type": "git",
@@ -33,6 +34,10 @@
33
34
  "url": "https://github.com/Mopsgamer/view-ignored/issues"
34
35
  },
35
36
  "homepage": "https://github.com/Mopsgamer/view-ignored",
37
+ "exports": {
38
+ ".": "./out/src/index.js",
39
+ "./browser": "./out/src/browser/index.js"
40
+ },
36
41
  "release-it": {
37
42
  "hooks": {
38
43
  "before:init": "pnpm prerelease"
@@ -51,6 +56,19 @@
51
56
  "publish": true
52
57
  }
53
58
  },
59
+ "xo": {
60
+ "ignores": "/out/",
61
+ "rules": {
62
+ "@typescript-eslint/promise-function-async": "off",
63
+ "@typescript-eslint/use-unknown-in-catch-callback-variable": "off",
64
+ "@typescript-eslint/no-unused-vars": "error",
65
+ "n/no-unpublished-bin": "off",
66
+ "linebreak-style": [
67
+ "error",
68
+ "unix"
69
+ ]
70
+ }
71
+ },
54
72
  "publishConfig": {
55
73
  "access": "public"
56
74
  },
@@ -58,37 +76,33 @@
58
76
  "lib": "out/src"
59
77
  },
60
78
  "dependencies": {
61
- "arrify": "^3.0.0",
79
+ "@humanwhocodes/gitignore-to-minimatch": "^1.0.2",
80
+ "@m234/nerd-fonts": "^0.1.2",
81
+ "ansi-regex": "^6.1.0",
62
82
  "boxen": "^8.0.1",
63
83
  "chalk": "^5.3.0",
64
84
  "commander": "^12.1.0",
65
- "get-value": "^3.0.1",
66
- "glob": "^11.0.0",
67
- "ignore": "^5.3.1",
68
85
  "jsonify-paths": "^1.1.0",
86
+ "listr2": "^8.2.4",
69
87
  "load-plugin": "^6.0.3",
70
88
  "minimatch": "^10.0.1",
71
- "ora": "^8.0.1",
89
+ "p-limit": "^6.1.0",
72
90
  "treeify": "^1.1.0",
73
- "tslib": "^2.6.3",
74
- "yaml": "^2.5.0"
91
+ "tslib": "^2.7.0",
92
+ "yaml": "^2.5.1"
75
93
  },
76
94
  "devDependencies": {
77
- "@eslint/js": "^9.4.0",
78
95
  "@release-it/keep-a-changelog": "^5.0.0",
79
- "@types/get-value": "^3.0.5",
80
- "@types/mocha": "^10.0.6",
81
- "@types/node": "^20.14.2",
96
+ "@types/mocha": "^10.0.8",
97
+ "@types/node": "^20.16.5",
82
98
  "@types/treeify": "^1.0.3",
83
- "eslint": "^8.57.0",
84
- "eslint-plugin-only-warn": "^1.1.0",
85
99
  "fs-fixture": "^2.4.0",
86
- "globals": "^15.4.0",
87
- "mocha": "^10.4.0",
88
- "release-it": "^17.3.0",
100
+ "globals": "^15.9.0",
101
+ "mocha": "^10.7.3",
102
+ "release-it": "^17.6.0",
89
103
  "shx": "^0.3.4",
90
- "typescript": "^5.4.5",
91
- "typescript-eslint": "^7.13.0"
104
+ "typescript": "^5.6.2",
105
+ "xo": "^0.59.3"
92
106
  },
93
107
  "keywords": [
94
108
  "tree",
package/out/src/bin.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #! /usr/bin/env node
2
- export {};
package/out/src/bin.js DELETED
@@ -1,3 +0,0 @@
1
- #! /usr/bin/env node
2
- import { programInit } from "./cli.js";
3
- programInit();
@@ -1,78 +0,0 @@
1
- import { decorFile } from "./styling.js";
2
- import path from "path";
3
- /**
4
- * The result of the file path scan.
5
- */
6
- export class FileInfo {
7
- filePath;
8
- source;
9
- /**
10
- * The pattern parser.
11
- */
12
- scanner;
13
- constructor(
14
- /**
15
- * Relative path to the file.
16
- */
17
- filePath,
18
- /**
19
- * Source of patterns, used by {@link scanner}.
20
- */
21
- source) {
22
- this.filePath = filePath;
23
- this.source = source;
24
- this.scanner = this.source.scanner;
25
- }
26
- /**
27
- * Determines if ignored file is ignored or not.
28
- */
29
- isIgnored() {
30
- return this.scanner.matches(this.filePath);
31
- }
32
- static from(arg, sourceInfo) {
33
- if (Array.isArray(arg)) {
34
- return arg.map(path => FileInfo.from(path, sourceInfo));
35
- }
36
- return new FileInfo(arg, sourceInfo);
37
- }
38
- /**
39
- * @param options Styling options.
40
- * @returns Relative file path. Optionally formatted.
41
- */
42
- toString(options) {
43
- const { fileIcon, chalk, usePrefix = false, source: useSource = false, entire = true } = options ?? {};
44
- const parsed = path.parse(this.filePath);
45
- const fIcon = decorFile(fileIcon, this.filePath);
46
- const ignored = this.isIgnored();
47
- let prefix = usePrefix ? (ignored ? '!' : '+') : '';
48
- let postfix = useSource ? " << " + this.source.toString() : '';
49
- if (chalk) {
50
- prefix = chalk.dim(prefix);
51
- postfix = chalk.dim(postfix);
52
- const clr = chalk[ignored ? "red" : "green"];
53
- if (entire) {
54
- return fIcon + clr(prefix + this.filePath + postfix);
55
- }
56
- return parsed.dir + '/' + fIcon + clr(prefix + parsed.base + postfix);
57
- }
58
- if (entire) {
59
- return prefix + this.filePath + postfix;
60
- }
61
- return parsed.dir + '/' + fIcon + prefix + parsed.base + postfix;
62
- }
63
- /**
64
- * @param filter The group name. Default: `"all"`
65
- * @returns `true`, if the file is contained by the filter.
66
- */
67
- isIncludedBy(filter) {
68
- if (typeof filter === "function") {
69
- return filter(this);
70
- }
71
- filter ??= "all";
72
- const filterIgnore = (filter === "ignored") && this.isIgnored();
73
- const filterInclude = (filter === "included") && !this.isIgnored();
74
- const filterAll = filter === "all";
75
- const result = filterIgnore || filterInclude || filterAll;
76
- return result;
77
- }
78
- }
@@ -1,103 +0,0 @@
1
- /**
2
- * Supported matchers/parsers by {@link Scanner}.
3
- */
4
- export type PatternType = typeof patternTypeList[number];
5
- export declare const patternTypeList: readonly ["gitignore", "minimatch"];
6
- export declare function isPatternType(value: unknown): value is PatternType;
7
- /**
8
- * @see {@link Scanner}
9
- */
10
- export interface ScannerOptions {
11
- /**
12
- * Use the patterns for including instead of excluding/ignoring.
13
- * @default false
14
- */
15
- negated?: boolean;
16
- /**
17
- * The parser for the patterns.
18
- * @default "gitignore"
19
- */
20
- patternType?: PatternType;
21
- /**
22
- * Git configuration property.
23
- * @see {@link https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreignoreCase|git-config ignorecase}.
24
- * @default false
25
- */
26
- ignoreCase?: boolean;
27
- }
28
- export type IsValidPatternOptions = Pick<ScannerOptions, "patternType">;
29
- /**
30
- * The Glob-like pattern of the specific matcher.
31
- */
32
- export type ScannerPattern = string | string[];
33
- /**
34
- * The pattern parser. Can check if the file path is ignored.
35
- */
36
- export declare class Scanner {
37
- /**
38
- * If `true`, when calling {@link Scanner.matches}, method will return `true` for ignored path.
39
- * @default false
40
- */
41
- readonly isNegated: boolean;
42
- /**
43
- * Defines way to check paths.
44
- * @default "gitignore"
45
- */
46
- readonly patternType: PatternType;
47
- /**
48
- * Git configuration property.
49
- * @see {@link https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreignoreCase|git-config ignorecase}.
50
- * @default false
51
- */
52
- readonly ignoreCase: boolean;
53
- private patternList;
54
- private patternListExclude;
55
- private patternListInclude;
56
- private ignoreInstance;
57
- private ignoreInstanceExclude;
58
- private ignoreInstanceInclude;
59
- constructor(options?: ScannerOptions);
60
- /**
61
- * Adds new ignore rule.
62
- * @param pattern .gitignore file specification pattern.
63
- */
64
- add(pattern?: ScannerPattern): this;
65
- /**
66
- * Force ignore pattern.
67
- * @param pattern .gitignore file specification pattern.
68
- */
69
- addExclude(pattern?: ScannerPattern): this;
70
- /**
71
- * Force ignore pattern.
72
- * @param pattern .gitignore file specification pattern.
73
- */
74
- addInclude(pattern?: ScannerPattern): this;
75
- /**
76
- * Checks if the scanner should ignore path.
77
- * @see {@link Scanner.isNegated} can change the return value.
78
- * @param path Dir entry, path.
79
- */
80
- matches(path: string): boolean;
81
- private matchesReal;
82
- private static matchesGitignore;
83
- private static matchesMinimatch;
84
- /**
85
- * Checks if given pattern is valid.
86
- * @param pattern Parser pattern.
87
- */
88
- patternIsValid(pattern: unknown): pattern is ScannerPattern;
89
- /**
90
- * Checks if given pattern is valid.
91
- * @param pattern Parser pattern.
92
- */
93
- static patternIsValid(pattern: unknown, options?: IsValidPatternOptions): pattern is ScannerPattern;
94
- /**
95
- * @returns New pattern array: `!pattern` for `pattern`, and `pattern` for `!pattern`.
96
- */
97
- static patternToNegated(pattern: string[]): string[];
98
- /**
99
- * @returns New pattern: `!pattern` for `pattern`, and `pattern` for `!pattern`.
100
- */
101
- static patternToNegated(pattern: string): string;
102
- static patternIsNegated(pattern: string): boolean;
103
- }
@@ -1,161 +0,0 @@
1
- import ignore from "ignore";
2
- import { minimatch } from "minimatch";
3
- export const patternTypeList = ["gitignore", "minimatch"];
4
- export function isPatternType(value) {
5
- return typeof value === "string" && patternTypeList.includes(value);
6
- }
7
- /**
8
- * The pattern parser. Can check if the file path is ignored.
9
- */
10
- export class Scanner {
11
- /**
12
- * If `true`, when calling {@link Scanner.matches}, method will return `true` for ignored path.
13
- * @default false
14
- */
15
- isNegated = false;
16
- /**
17
- * Defines way to check paths.
18
- * @default "gitignore"
19
- */
20
- patternType;
21
- /**
22
- * Git configuration property.
23
- * @see {@link https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreignoreCase|git-config ignorecase}.
24
- * @default false
25
- */
26
- ignoreCase;
27
- patternList = new Set();
28
- patternListExclude = new Set();
29
- patternListInclude = new Set();
30
- ignoreInstance;
31
- ignoreInstanceExclude;
32
- ignoreInstanceInclude;
33
- constructor(options) {
34
- this.patternType = options?.patternType ?? "gitignore";
35
- this.ignoreCase = options?.ignoreCase ?? false;
36
- this.isNegated = options?.negated ?? false;
37
- this.ignoreInstance = ignore.default(options);
38
- this.ignoreInstanceExclude = ignore.default(options);
39
- this.ignoreInstanceInclude = ignore.default(options);
40
- }
41
- /**
42
- * Adds new ignore rule.
43
- * @param pattern .gitignore file specification pattern.
44
- */
45
- add(pattern) {
46
- if (typeof pattern === "string") {
47
- pattern = pattern.split('\n');
48
- }
49
- if (Array.isArray(pattern)) {
50
- for (const pat of pattern) {
51
- this.patternList.add(pat);
52
- this.ignoreInstance.add(pat);
53
- }
54
- }
55
- return this;
56
- }
57
- /**
58
- * Force ignore pattern.
59
- * @param pattern .gitignore file specification pattern.
60
- */
61
- addExclude(pattern) {
62
- if (typeof pattern === "string") {
63
- pattern = pattern.split('\n');
64
- }
65
- if (Array.isArray(pattern)) {
66
- for (const pat of pattern) {
67
- this.patternListExclude.add(pat);
68
- this.ignoreInstanceExclude.add(pat);
69
- }
70
- }
71
- return this;
72
- }
73
- /**
74
- * Force ignore pattern.
75
- * @param pattern .gitignore file specification pattern.
76
- */
77
- addInclude(pattern) {
78
- if (typeof pattern === "string") {
79
- pattern = pattern.split('\n');
80
- }
81
- if (Array.isArray(pattern)) {
82
- for (const pat of pattern) {
83
- this.patternListInclude.add(pat);
84
- this.ignoreInstanceInclude.add(pat);
85
- }
86
- }
87
- return this;
88
- }
89
- /**
90
- * Checks if the scanner should ignore path.
91
- * @see {@link Scanner.isNegated} can change the return value.
92
- * @param path Dir entry, path.
93
- */
94
- matches(path) {
95
- if (this.patternType === "gitignore") {
96
- return this.matchesReal(() => Scanner.matchesGitignore(path, this.ignoreInstanceInclude), () => Scanner.matchesGitignore(path, this.ignoreInstanceExclude), () => Scanner.matchesGitignore(path, this.ignoreInstance));
97
- }
98
- // minimatch
99
- return this.matchesReal(() => Scanner.matchesMinimatch(path, Array.from(this.patternListInclude)), () => Scanner.matchesMinimatch(path, Array.from(this.patternListExclude)), () => Scanner.matchesMinimatch(path, Array.from(this.patternList)));
100
- }
101
- matchesReal(include, exclude, ignores) {
102
- if (include()) {
103
- return false;
104
- }
105
- if (exclude()) {
106
- return true;
107
- }
108
- const ign = ignores();
109
- return this.isNegated ? !ign : ign;
110
- }
111
- static matchesGitignore(path, ignoreInstance) {
112
- return ignoreInstance.ignores(path);
113
- }
114
- static matchesMinimatch(path, patternList) {
115
- return Array.from(patternList).some((pattern) => {
116
- return minimatch(path, pattern, { dot: true });
117
- });
118
- }
119
- /**
120
- * Checks if given pattern is valid.
121
- * @param pattern Parser pattern.
122
- */
123
- patternIsValid(pattern) {
124
- return Scanner.patternIsValid(pattern, { patternType: this.patternType });
125
- }
126
- /**
127
- * Checks if given pattern is valid.
128
- * @param pattern Parser pattern.
129
- */
130
- static patternIsValid(pattern, options) {
131
- const { patternType = "gitignore" } = options ?? {};
132
- if (Array.isArray(pattern)) {
133
- return pattern.every(p => this.patternIsValid(p, options));
134
- }
135
- if (typeof pattern !== "string") {
136
- return false;
137
- }
138
- if (patternType === "gitignore") {
139
- return ignore.default.isPathValid(pattern);
140
- }
141
- if (patternType === "minimatch") {
142
- try {
143
- minimatch.makeRe(pattern);
144
- return true;
145
- }
146
- catch (error) {
147
- return false;
148
- }
149
- }
150
- throw new TypeError(`Unknown pattern type '${patternType}'.`);
151
- }
152
- static patternToNegated(pattern) {
153
- if (Array.isArray(pattern)) {
154
- return pattern.map(Scanner.patternToNegated);
155
- }
156
- return Scanner.patternIsNegated(pattern) ? pattern.replace(/^!/, '') : `!${pattern}`;
157
- }
158
- static patternIsNegated(pattern) {
159
- return pattern.startsWith('!');
160
- }
161
- }
@@ -1,62 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { FileSystemAdapter, Methodology, ScanFileOptions, Scanner } from "./lib.js";
3
- export interface SourceInfoHierarcyOptions<T extends {
4
- toString(): string;
5
- }> {
6
- /**
7
- * @default true
8
- */
9
- closest?: boolean;
10
- /**
11
- * @default undefined
12
- */
13
- filter?: (path: T) => boolean;
14
- }
15
- /**
16
- * The source of patterns.
17
- */
18
- export declare class SourceInfo {
19
- /**
20
- * The relative path to the file.
21
- */
22
- readonly sourcePath: string;
23
- /**
24
- * The pattern parser.
25
- */
26
- readonly scanner: Scanner;
27
- /**
28
- * The last source file content.
29
- */
30
- content?: Buffer;
31
- constructor(
32
- /**
33
- * The relative path to the file.
34
- */
35
- sourcePath: string,
36
- /**
37
- * The pattern parser.
38
- */
39
- scanner: Scanner);
40
- /**
41
- * Creates new {@link SourceInfo} instance.
42
- */
43
- static from(path: string, methodology: Methodology): SourceInfo;
44
- /**
45
- * Gets sources from the methodology.
46
- */
47
- static fromMethodology(methodology: Methodology, options: ScanFileOptions): Promise<SourceInfo[]>;
48
- /**
49
- * Selects the closest or farthest siblings relative to the path.
50
- */
51
- static hierarcy<T extends {
52
- toString(): string;
53
- }>(target: string, pathList: T[], options?: SourceInfoHierarcyOptions<T>): T | undefined;
54
- /**
55
- * @returns File path of the source.
56
- */
57
- toString(): string;
58
- /**
59
- * @returns The contents of the source file.
60
- */
61
- readSync(cwd: string | undefined, readFileSync: Exclude<FileSystemAdapter["readFileSync"], undefined>): Buffer;
62
- }