@node-cli/search 1.0.7 → 1.1.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 +18 -0
- package/dist/core.d.ts +13 -1
- package/dist/core.js +90 -6
- package/dist/core.js.map +1 -1
- package/dist/defaults.d.ts +2 -0
- package/dist/defaults.js +3 -1
- package/dist/defaults.js.map +1 -1
- package/dist/gitIgnoreHandler.d.ts +44 -0
- package/dist/gitIgnoreHandler.js +119 -0
- package/dist/gitIgnoreHandler.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/parse.d.ts +2 -0
- package/dist/parse.js +16 -0
- package/dist/parse.js.map +1 -1
- package/dist/utilities.js.map +1 -1
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -23,6 +23,12 @@ Find all files with the extension ".jsx" in the "src" folder
|
|
|
23
23
|
> search --type f --pattern ".jsx$" src/
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
Find all files without the extension "jsx" or "md" in the "src" folder
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
> search --type f --ignore "jsx" --ignore "md" src/
|
|
30
|
+
```
|
|
31
|
+
|
|
26
32
|
Change the permissions to executable for all the files with the extension ".sh" found under the "bin" folder
|
|
27
33
|
|
|
28
34
|
```sh
|
|
@@ -35,6 +41,18 @@ Search in all the markdown files under the "src" folder for the keywords "Table
|
|
|
35
41
|
> search --type f --pattern ".md$" --grep "Table of Content"
|
|
36
42
|
```
|
|
37
43
|
|
|
44
|
+
Find all files with the extension ".jsx" in the "src" folder and print their content
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
> search --type f --pattern ".jsx$" --printMode simple src/
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Find all files with the extension ".jsx" in the "src" folder and print their content in a Claude XML format
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
> search --type f --pattern ".jsx$" --printMode xml src/
|
|
54
|
+
```
|
|
55
|
+
|
|
38
56
|
Get help
|
|
39
57
|
|
|
40
58
|
```sh
|
package/dist/core.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GitIgnoreHandler } from "./gitIgnoreHandler.js";
|
|
1
2
|
export declare class Search {
|
|
2
3
|
boring?: boolean;
|
|
3
4
|
command?: string;
|
|
@@ -14,7 +15,11 @@ export declare class Search {
|
|
|
14
15
|
totalFileFound?: number;
|
|
15
16
|
totalFileScanned?: number;
|
|
16
17
|
type?: string;
|
|
17
|
-
|
|
18
|
+
ignoreExtensions?: string[];
|
|
19
|
+
printMode?: string;
|
|
20
|
+
gitIgnoreHandler: GitIgnoreHandler;
|
|
21
|
+
ignoreGitIgnore?: boolean;
|
|
22
|
+
constructor({ boring, command, dot, foldersBlacklist, grep, ignoreCase, short, path, pattern, stats, type, ignore, printMode, ignoreGitIgnore, }: {
|
|
18
23
|
boring?: boolean;
|
|
19
24
|
command?: string;
|
|
20
25
|
dot?: boolean;
|
|
@@ -26,10 +31,17 @@ export declare class Search {
|
|
|
26
31
|
pattern?: string;
|
|
27
32
|
stats?: boolean;
|
|
28
33
|
type?: string;
|
|
34
|
+
ignore?: string[];
|
|
35
|
+
printMode?: string;
|
|
36
|
+
ignoreGitIgnore?: boolean;
|
|
29
37
|
});
|
|
30
38
|
ignoreFolders(directory: string): boolean;
|
|
39
|
+
shouldIgnoreFile(filePath: string): boolean;
|
|
31
40
|
filterHidden(value: string[] | string): boolean;
|
|
32
41
|
start(): Promise<void>;
|
|
33
42
|
scanFileSystem(nodes: string[]): Promise<void>;
|
|
43
|
+
readFileContent(filePath: string): Promise<string>;
|
|
44
|
+
printFilesContent(): Promise<void>;
|
|
45
|
+
shouldIgnoreByGitIgnore(nodePath: string, isDirectory: boolean): Promise<boolean>;
|
|
34
46
|
postProcessResults(): Promise<void>;
|
|
35
47
|
}
|
package/dist/core.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { basename, join, relative } from "node:path";
|
|
1
|
+
import { basename, extname, join, relative } from "node:path";
|
|
2
|
+
import { GitIgnoreHandler } from "./gitIgnoreHandler.js";
|
|
2
3
|
import { STR_TYPE_BOTH, STR_TYPE_DIRECTORY, STR_TYPE_FILE, checkPattern, formatLongListings, printStatistics, runCommandOnNode, runGrepOnNode } from "./utilities.js";
|
|
3
4
|
import { promisify } from "node:util";
|
|
4
5
|
import { Logger } from "@node-cli/logger";
|
|
@@ -8,6 +9,7 @@ import kleur from "kleur";
|
|
|
8
9
|
import plur from "plur";
|
|
9
10
|
const lstatAsync = promisify(fs.lstat);
|
|
10
11
|
const readdirAsync = promisify(fs.readdir);
|
|
12
|
+
const readFileAsync = promisify(fs.readFile);
|
|
11
13
|
const perf = new Performance();
|
|
12
14
|
const logger = new Logger({
|
|
13
15
|
boring: process.env.NODE_ENV === "test"
|
|
@@ -28,7 +30,11 @@ export class Search {
|
|
|
28
30
|
totalFileFound;
|
|
29
31
|
totalFileScanned;
|
|
30
32
|
type;
|
|
31
|
-
|
|
33
|
+
ignoreExtensions;
|
|
34
|
+
printMode;
|
|
35
|
+
gitIgnoreHandler;
|
|
36
|
+
ignoreGitIgnore;
|
|
37
|
+
constructor({ boring, command, dot, foldersBlacklist, grep, ignoreCase, short, path, pattern, stats, type, ignore, printMode, ignoreGitIgnore }){
|
|
32
38
|
this.path = path;
|
|
33
39
|
this.rePattern = pattern ? new RegExp(pattern, ignoreCase ? "i" : "") : undefined;
|
|
34
40
|
this.type = type || STR_TYPE_BOTH;
|
|
@@ -44,6 +50,10 @@ export class Search {
|
|
|
44
50
|
this.totalDirFound = 0;
|
|
45
51
|
this.totalFileFound = 0;
|
|
46
52
|
this.command = command ? command.trim() : undefined;
|
|
53
|
+
this.ignoreExtensions = ignore.map((ext)=>ext.toLowerCase());
|
|
54
|
+
this.printMode = printMode;
|
|
55
|
+
this.ignoreGitIgnore = ignoreGitIgnore;
|
|
56
|
+
this.gitIgnoreHandler = new GitIgnoreHandler();
|
|
47
57
|
try {
|
|
48
58
|
this.grep = grep ? new RegExp(grep, ignoreCase ? "gi" : "g") : undefined;
|
|
49
59
|
} catch (error) {
|
|
@@ -56,6 +66,13 @@ export class Search {
|
|
|
56
66
|
this.foldersBlacklist.lastIndex = 0;
|
|
57
67
|
return this.foldersBlacklist.test(basename(directory));
|
|
58
68
|
}
|
|
69
|
+
shouldIgnoreFile(filePath) {
|
|
70
|
+
if (!this.ignoreExtensions || this.ignoreExtensions.length === 0) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const extension = extname(filePath).toLowerCase().replace(/^\./, "");
|
|
74
|
+
return this.ignoreExtensions.includes(extension);
|
|
75
|
+
}
|
|
59
76
|
filterHidden(value) {
|
|
60
77
|
if (this.displayHiddenFilesAndFolders) {
|
|
61
78
|
return true;
|
|
@@ -92,7 +109,13 @@ export class Search {
|
|
|
92
109
|
} catch {
|
|
93
110
|
// ignore read permission denied errors silently...
|
|
94
111
|
}
|
|
95
|
-
|
|
112
|
+
const isDirectory = stat && stat.isDirectory();
|
|
113
|
+
const isFile = stat && stat.isFile();
|
|
114
|
+
// Add this check to respect .gitignore patterns
|
|
115
|
+
if (await this.shouldIgnoreByGitIgnore(node, isDirectory)) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (isDirectory && !this.ignoreFolders(node)) {
|
|
96
119
|
this.totalDirScanned++;
|
|
97
120
|
result = checkPattern(this.rePattern, node);
|
|
98
121
|
if (result) {
|
|
@@ -113,7 +136,11 @@ export class Search {
|
|
|
113
136
|
} catch {
|
|
114
137
|
// nothing to declare
|
|
115
138
|
}
|
|
116
|
-
} else if (
|
|
139
|
+
} else if (isFile) {
|
|
140
|
+
// Skip files with ignored extensions
|
|
141
|
+
if (this.shouldIgnoreFile(node)) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
117
144
|
this.totalFileScanned++;
|
|
118
145
|
shortname = basename(node);
|
|
119
146
|
const patternResult = checkPattern(this.rePattern, shortname);
|
|
@@ -130,6 +157,49 @@ export class Search {
|
|
|
130
157
|
}
|
|
131
158
|
}
|
|
132
159
|
}
|
|
160
|
+
async readFileContent(filePath) {
|
|
161
|
+
try {
|
|
162
|
+
const content = await readFileAsync(filePath, "utf8");
|
|
163
|
+
return content;
|
|
164
|
+
} catch (error) {
|
|
165
|
+
/* istanbul ignore next */ return `Error reading file: ${error.message}`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async printFilesContent() {
|
|
169
|
+
const fileNodes = this.nodesList.filter((node)=>node.type === STR_TYPE_FILE);
|
|
170
|
+
if (this.printMode === "simple") {
|
|
171
|
+
for (const node of fileNodes){
|
|
172
|
+
const relativePath = relative(process.cwd(), node.name);
|
|
173
|
+
logger.log(`---\n./${relativePath}\n---`);
|
|
174
|
+
const content = await this.readFileContent(node.name);
|
|
175
|
+
logger.log(content);
|
|
176
|
+
// adding a new line after each file content except the last one
|
|
177
|
+
if (node !== fileNodes[fileNodes.length - 1]) {
|
|
178
|
+
logger.log("");
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
} else if (this.printMode === "xml") {
|
|
182
|
+
logger.log("<documents>");
|
|
183
|
+
for(let i = 0; i < fileNodes.length; i++){
|
|
184
|
+
const node = fileNodes[i];
|
|
185
|
+
const relativePath = relative(process.cwd(), node.name);
|
|
186
|
+
const content = await this.readFileContent(node.name);
|
|
187
|
+
logger.log(`<document index="${i + 1}">`);
|
|
188
|
+
logger.log(`<source>./${relativePath}</source>`);
|
|
189
|
+
logger.log("<document_content>");
|
|
190
|
+
logger.log(content);
|
|
191
|
+
logger.log("</document_content>");
|
|
192
|
+
logger.log("</document>");
|
|
193
|
+
}
|
|
194
|
+
logger.log("</documents>");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async shouldIgnoreByGitIgnore(nodePath, isDirectory) {
|
|
198
|
+
/* istanbul ignore if */ if (this.ignoreGitIgnore) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
return this.gitIgnoreHandler.isIgnored(nodePath, isDirectory);
|
|
202
|
+
}
|
|
133
203
|
async postProcessResults() {
|
|
134
204
|
/* istanbul ignore if */ if (!this.boring) {
|
|
135
205
|
logger.log();
|
|
@@ -141,6 +211,14 @@ export class Search {
|
|
|
141
211
|
* pattern (in the file name).
|
|
142
212
|
*/ this.totalFileFound = 0;
|
|
143
213
|
}
|
|
214
|
+
// If printMode is enabled, handle file content printing and return
|
|
215
|
+
if (this.printMode && [
|
|
216
|
+
"simple",
|
|
217
|
+
"xml"
|
|
218
|
+
].includes(this.printMode)) {
|
|
219
|
+
await this.printFilesContent();
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
144
222
|
for (const node of this.nodesList){
|
|
145
223
|
if (this.type === STR_TYPE_FILE && node.type === STR_TYPE_FILE || this.type === STR_TYPE_DIRECTORY && node.type === STR_TYPE_DIRECTORY || this.type === STR_TYPE_BOTH) {
|
|
146
224
|
let list = {
|
|
@@ -156,8 +234,14 @@ export class Search {
|
|
|
156
234
|
}
|
|
157
235
|
const color = node.type === STR_TYPE_FILE ? kleur.gray : kleur.blue;
|
|
158
236
|
name = relative(process.cwd(), node.name);
|
|
159
|
-
|
|
160
|
-
|
|
237
|
+
if (node.match) {
|
|
238
|
+
const matchStr = String(node.match); // Ensure match is a string
|
|
239
|
+
const match = new RegExp(matchStr, "g");
|
|
240
|
+
const highlightedMatch = kleur.black().bgYellow(matchStr);
|
|
241
|
+
name = color(name.replace(match, highlightedMatch));
|
|
242
|
+
} else {
|
|
243
|
+
name = color(name);
|
|
244
|
+
}
|
|
161
245
|
if (this.grep && node.type === STR_TYPE_FILE) {
|
|
162
246
|
const { totalMatchingLines, results } = await runGrepOnNode(node.name, this.grep);
|
|
163
247
|
/* istanbul ignore else */ if (totalMatchingLines) {
|
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core.ts"],"sourcesContent":["import { basename, join, relative } from \"node:path\";\nimport {\n\tSTR_TYPE_BOTH,\n\tSTR_TYPE_DIRECTORY,\n\tSTR_TYPE_FILE,\n\tcheckPattern,\n\tformatLongListings,\n\tprintStatistics,\n\trunCommandOnNode,\n\trunGrepOnNode,\n} from \"./utilities.js\";\n\nimport { promisify } from \"node:util\";\nimport { Logger } from \"@node-cli/logger\";\nimport { Performance } from \"@node-cli/perf\";\nimport fs from \"fs-extra\";\nimport kleur from \"kleur\";\nimport plur from \"plur\";\n\nconst lstatAsync = promisify(fs.lstat);\nconst readdirAsync = promisify(fs.readdir);\nconst perf = new Performance();\nconst logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nexport class Search {\n\tboring?: boolean;\n\tcommand?: string;\n\tdisplayHiddenFilesAndFolders?: boolean;\n\tdisplayLongListing?: boolean;\n\tdisplayStats?: boolean;\n\tfoldersBlacklist?: RegExp;\n\tgrep?: RegExp;\n\tnodesList?: any[];\n\tpath?: string;\n\trePattern?: RegExp;\n\ttotalDirFound?: number;\n\ttotalDirScanned?: number;\n\ttotalFileFound?: number;\n\ttotalFileScanned?: number;\n\ttype?: string;\n\n\tconstructor({\n\t\tboring,\n\t\tcommand,\n\t\tdot,\n\t\tfoldersBlacklist,\n\t\tgrep,\n\t\tignoreCase,\n\t\tshort,\n\t\tpath,\n\t\tpattern,\n\t\tstats,\n\t\ttype,\n\t}: {\n\t\tboring?: boolean;\n\t\tcommand?: string;\n\t\tdot?: boolean;\n\t\tfoldersBlacklist?: RegExp;\n\t\tgrep?: string | RegExp;\n\t\tignoreCase?: boolean;\n\t\tshort?: boolean;\n\t\tpath?: string;\n\t\tpattern?: string;\n\t\tstats?: boolean;\n\t\ttype?: string;\n\t}) {\n\t\tthis.path = path;\n\t\tthis.rePattern = pattern\n\t\t\t? new RegExp(pattern, ignoreCase ? \"i\" : \"\")\n\t\t\t: undefined;\n\t\tthis.type = type || STR_TYPE_BOTH;\n\t\tthis.boring = boring;\n\t\tkleur.enabled = !boring;\n\t\tthis.displayLongListing = !short;\n\t\tthis.displayStats = stats;\n\t\tthis.displayHiddenFilesAndFolders = dot;\n\t\tthis.nodesList = [];\n\t\tthis.foldersBlacklist = foldersBlacklist;\n\t\tthis.totalDirScanned = 0;\n\t\tthis.totalFileScanned = 0;\n\t\tthis.totalDirFound = 0;\n\t\tthis.totalFileFound = 0;\n\t\tthis.command = command ? command.trim() : undefined;\n\t\ttry {\n\t\t\tthis.grep = grep ? new RegExp(grep, ignoreCase ? \"gi\" : \"g\") : undefined;\n\t\t} catch (error) {\n\t\t\tlogger.error(error);\n\t\t\t// eslint-disable-next-line unicorn/no-process-exit\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tignoreFolders(directory: string) {\n\t\tthis.foldersBlacklist.lastIndex = 0;\n\t\treturn this.foldersBlacklist.test(basename(directory));\n\t}\n\n\tfilterHidden(value: string[] | string) {\n\t\tif (this.displayHiddenFilesAndFolders) {\n\t\t\treturn true;\n\t\t}\n\t\treturn value[0] !== \".\";\n\t}\n\n\tasync start() {\n\t\tif (this.displayStats) {\n\t\t\tperf.start();\n\t\t}\n\t\tawait this.scanFileSystem([this.path]);\n\t\tawait this.postProcessResults();\n\n\t\tif (this.displayStats) {\n\t\t\tperf.stop();\n\t\t\tprintStatistics({\n\t\t\t\tduration: perf.results.duration,\n\t\t\t\tgrep: this.grep,\n\t\t\t\tpattern: this.rePattern,\n\t\t\t\ttotalDirScanned: this.totalDirScanned,\n\t\t\t\ttotalDirsFound: this.totalDirFound,\n\t\t\t\ttotalFileScanned: this.totalFileScanned,\n\t\t\t\ttotalFilesFound: this.totalFileFound,\n\t\t\t\ttype: this.type,\n\t\t\t});\n\t\t}\n\t}\n\n\tasync scanFileSystem(nodes: string[]) {\n\t\tfor (const node of nodes) {\n\t\t\tlet result: boolean | RegExpExecArray,\n\t\t\t\tfiles: string[],\n\t\t\t\tshortname: string,\n\t\t\t\tstat: fs.Stats;\n\t\t\ttry {\n\t\t\t\tstat = await lstatAsync(node);\n\t\t\t} catch {\n\t\t\t\t// ignore read permission denied errors silently...\n\t\t\t}\n\n\t\t\tif (stat && stat.isDirectory() && !this.ignoreFolders(node)) {\n\t\t\t\tthis.totalDirScanned++;\n\n\t\t\t\tresult = checkPattern(this.rePattern, node);\n\t\t\t\tif (result) {\n\t\t\t\t\tthis.totalDirFound++;\n\t\t\t\t\tthis.nodesList.push({\n\t\t\t\t\t\tcommand: this.command,\n\t\t\t\t\t\tmatch: result,\n\t\t\t\t\t\tname: node,\n\t\t\t\t\t\tstat,\n\t\t\t\t\t\ttype: STR_TYPE_DIRECTORY,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tfiles = await readdirAsync(node);\n\t\t\t\t\tawait this.scanFileSystem(\n\t\t\t\t\t\tfiles\n\t\t\t\t\t\t\t.filter((element) => this.filterHidden(element))\n\t\t\t\t\t\t\t.map(function (file) {\n\t\t\t\t\t\t\t\treturn join(node, file);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t} catch {\n\t\t\t\t\t// nothing to declare\n\t\t\t\t}\n\t\t\t} else if (stat && stat.isFile()) {\n\t\t\t\tthis.totalFileScanned++;\n\t\t\t\tshortname = basename(node);\n\t\t\t\tconst patternResult = checkPattern(this.rePattern, shortname);\n\t\t\t\tif (patternResult) {\n\t\t\t\t\tthis.totalFileFound++;\n\t\t\t\t\tthis.nodesList.push({\n\t\t\t\t\t\tcommand: this.command,\n\t\t\t\t\t\tmatch: patternResult[0],\n\t\t\t\t\t\tname: node,\n\t\t\t\t\t\tstat,\n\t\t\t\t\t\ttype: STR_TYPE_FILE,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tasync postProcessResults() {\n\t\t/* istanbul ignore if */\n\t\tif (!this.boring) {\n\t\t\tlogger.log();\n\t\t}\n\n\t\tif (this.grep) {\n\t\t\t/**\n\t\t\t * Resetting the number of files found, since we want to\n\t\t\t * show how many matched the grep, not how many matched the\n\t\t\t * pattern (in the file name).\n\t\t\t */\n\t\t\tthis.totalFileFound = 0;\n\t\t}\n\n\t\tfor (const node of this.nodesList) {\n\t\t\tif (\n\t\t\t\t(this.type === STR_TYPE_FILE && node.type === STR_TYPE_FILE) ||\n\t\t\t\t(this.type === STR_TYPE_DIRECTORY &&\n\t\t\t\t\tnode.type === STR_TYPE_DIRECTORY) ||\n\t\t\t\tthis.type === STR_TYPE_BOTH\n\t\t\t) {\n\t\t\t\tlet list: {\n\t\t\t\t\t\tgroup?: string;\n\t\t\t\t\t\tmdate?: string;\n\t\t\t\t\t\tmode?: string;\n\t\t\t\t\t\towner?: string;\n\t\t\t\t\t\tsize?: string;\n\t\t\t\t\t} = {\n\t\t\t\t\t\tgroup: \"\",\n\t\t\t\t\t\tmdate: \"\",\n\t\t\t\t\t\tmode: \"\",\n\t\t\t\t\t\towner: \"\",\n\t\t\t\t\t\tsize: \"\",\n\t\t\t\t\t},\n\t\t\t\t\tname: string,\n\t\t\t\t\tseparator: string = \"\";\n\n\t\t\t\t/* istanbul ignore if */\n\t\t\t\tif (this.displayLongListing) {\n\t\t\t\t\tlist = await formatLongListings(node.stat, node.type);\n\t\t\t\t\tseparator = \"\\t\";\n\t\t\t\t}\n\n\t\t\t\tconst color = node.type === STR_TYPE_FILE ? kleur.gray : kleur.blue;\n\t\t\t\tname = relative(process.cwd(), node.name);\n\t\t\t\tconst match = node.match ? new RegExp(node.match, \"g\") : node.match;\n\t\t\t\tname = color(name.replace(match, kleur.black().bgYellow(node.match)));\n\n\t\t\t\tif (this.grep && node.type === STR_TYPE_FILE) {\n\t\t\t\t\tconst { totalMatchingLines, results } = await runGrepOnNode(\n\t\t\t\t\t\tnode.name,\n\t\t\t\t\t\tthis.grep,\n\t\t\t\t\t);\n\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\tif (totalMatchingLines) {\n\t\t\t\t\t\tthis.totalFileFound++;\n\t\t\t\t\t\tconst occurrences = plur(\"occurrence\", totalMatchingLines);\n\t\t\t\t\t\tlogger.log(\n\t\t\t\t\t\t\t` %s${separator}%s${separator}%s${separator}%s${separator}%s`,\n\t\t\t\t\t\t\tlist.mode.trim(),\n\t\t\t\t\t\t\tlist.owner.trim(),\n\t\t\t\t\t\t\tlist.size.trim(),\n\t\t\t\t\t\t\tlist.mdate,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t`(${kleur.white(totalMatchingLines)} ${occurrences})`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlogger.log(`${results.join(\"\\n\")}\\n`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t/* istanbul ignore next */\n\t\t\t\t\tif (!this.grep) {\n\t\t\t\t\t\tlogger.log(\n\t\t\t\t\t\t\t` %s${separator}%s${separator}%s${separator}%s${separator}%s`,\n\t\t\t\t\t\t\tlist.mode.trim(),\n\t\t\t\t\t\t\tlist.owner.trim(),\n\t\t\t\t\t\t\tlist.size.trim(),\n\t\t\t\t\t\t\tlist.mdate,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (node.command) {\n\t\t\t\t\t\t\tawait runCommandOnNode(node.name, node.command);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["basename","join","relative","STR_TYPE_BOTH","STR_TYPE_DIRECTORY","STR_TYPE_FILE","checkPattern","formatLongListings","printStatistics","runCommandOnNode","runGrepOnNode","promisify","Logger","Performance","fs","kleur","plur","lstatAsync","lstat","readdirAsync","readdir","perf","logger","boring","process","env","NODE_ENV","Search","command","displayHiddenFilesAndFolders","displayLongListing","displayStats","foldersBlacklist","grep","nodesList","path","rePattern","totalDirFound","totalDirScanned","totalFileFound","totalFileScanned","type","constructor","dot","ignoreCase","short","pattern","stats","RegExp","undefined","enabled","trim","error","exit","ignoreFolders","directory","lastIndex","test","filterHidden","value","start","scanFileSystem","postProcessResults","stop","duration","results","totalDirsFound","totalFilesFound","nodes","node","result","files","shortname","stat","isDirectory","push","match","name","filter","element","map","file","isFile","patternResult","log","list","group","mdate","mode","owner","size","separator","color","gray","blue","cwd","replace","black","bgYellow","totalMatchingLines","occurrences","white"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,YAAY;AACrD,SACCC,aAAa,EACbC,kBAAkB,EAClBC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,QACP,iBAAiB;AAExB,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,UAAU,OAAO;AAExB,MAAMC,aAAaN,UAAUG,GAAGI,KAAK;AACrC,MAAMC,eAAeR,UAAUG,GAAGM,OAAO;AACzC,MAAMC,OAAO,IAAIR;AACjB,MAAMS,SAAS,IAAIV,OAAO;IACzBW,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK;AAClC;AAEA,OAAO,MAAMC;IACZJ,OAAiB;IACjBK,QAAiB;IACjBC,6BAAuC;IACvCC,mBAA6B;IAC7BC,aAAuB;IACvBC,iBAA0B;IAC1BC,KAAc;IACdC,UAAkB;IAClBC,KAAc;IACdC,UAAmB;IACnBC,cAAuB;IACvBC,gBAAyB;IACzBC,eAAwB;IACxBC,iBAA0B;IAC1BC,KAAc;IAEdC,YAAY,EACXnB,MAAM,EACNK,OAAO,EACPe,GAAG,EACHX,gBAAgB,EAChBC,IAAI,EACJW,UAAU,EACVC,KAAK,EACLV,IAAI,EACJW,OAAO,EACPC,KAAK,EACLN,IAAI,EAaJ,CAAE;QACF,IAAI,CAACN,IAAI,GAAGA;QACZ,IAAI,CAACC,SAAS,GAAGU,UACd,IAAIE,OAAOF,SAASF,aAAa,MAAM,MACvCK;QACH,IAAI,CAACR,IAAI,GAAGA,QAAQtC;QACpB,IAAI,CAACoB,MA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AIoC,KAAK5B,IAAI,KAAKpC,eAAe;oBAC7C,MAAM,EAAE8F,kBAAkB,EAAElC,OAAO,EAAE,GAAG,MAAMvD,cAC7C2D,KAAKQ,IAAI,EACT,IAAI,CAAC5C,IAAI;oBAEV,wBAAwB,GACxB,IAAIkE,oBAAoB;wBACvB,IAAI,CAAC5D,cAAc;wBACnB,MAAM6D,cAAcpF,KAAK,cAAcmF;wBACvC7E,OAAO8D,GAAG,CACT,CAAC,GAAG,EAAEO,UAAU,EAAE,EAAEA,UAAU,EAAE,EAAEA,UAAU,EAAE,EAAEA,UAAU,EAAE,CAAC,EAC7DN,KAAKG,IAAI,CAACrC,IAAI,IACdkC,KAAKI,KAAK,CAACtC,IAAI,IACfkC,KAAKK,IAAI,CAACvC,IAAI,IACdkC,KAAKE,KAAK,EACVV,MACA,CAAC,CAAC,EAAE9D,MAAMsF,KAAK,CAACF,oBAAoB,CAAC,EAAEC,YAAY,CAAC,CAAC;wBAEtD9E,OAAO8D,GAAG,CAAC,CAAC,EAAEnB,QAAQhE,IAAI,CAAC,MAAM,EAAE,CAAC;oBACrC;gBACD,OAAO;oBACN,wBAAwB,GACxB,IAAI,CAAC,IAAI,CAACgC,IAAI,EAAE;wBACfX,OAAO8D,GAAG,CACT,CAAC,GAAG,EAAEO,UAAU,EAAE,EAAEA,UAAU,EAAE,EAAEA,UAAU,EAAE,EAAEA,UAAU,EAAE,CAAC,EAC7DN,KAAKG,IAAI,CAACrC,IAAI,IACdkC,KAAKI,KAAK,CAACtC,IAAI,IACfkC,KAAKK,IAAI,CAACvC,IAAI,IACdkC,KAAKE,KAAK,EACVV;wBAED,IAAIR,KAAKzC,OAAO,EAAE;4BACjB,MAAMnB,iBAAiB4D,KAAKQ,IAAI,EAAER,KAAKzC,OAAO;wBAC/C;oBACD;gBACD;YACD;QACD;IACD;AACD"}
|
|
1
|
+
{"version":3,"sources":["../src/core.ts"],"sourcesContent":["import { basename, extname, join, relative } from \"node:path\";\nimport { GitIgnoreHandler } from \"./gitIgnoreHandler.js\";\nimport {\n\tSTR_TYPE_BOTH,\n\tSTR_TYPE_DIRECTORY,\n\tSTR_TYPE_FILE,\n\tcheckPattern,\n\tformatLongListings,\n\tprintStatistics,\n\trunCommandOnNode,\n\trunGrepOnNode,\n} from \"./utilities.js\";\n\nimport { promisify } from \"node:util\";\nimport { Logger } from \"@node-cli/logger\";\nimport { Performance } from \"@node-cli/perf\";\nimport fs from \"fs-extra\";\nimport kleur from \"kleur\";\nimport plur from \"plur\";\n\nconst lstatAsync = promisify(fs.lstat);\nconst readdirAsync = promisify(fs.readdir);\nconst readFileAsync = promisify(fs.readFile);\nconst perf = new Performance();\nconst logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nexport class Search {\n\tboring?: boolean;\n\tcommand?: string;\n\tdisplayHiddenFilesAndFolders?: boolean;\n\tdisplayLongListing?: boolean;\n\tdisplayStats?: boolean;\n\tfoldersBlacklist?: RegExp;\n\tgrep?: RegExp;\n\tnodesList?: any[];\n\tpath?: string;\n\trePattern?: RegExp;\n\ttotalDirFound?: number;\n\ttotalDirScanned?: number;\n\ttotalFileFound?: number;\n\ttotalFileScanned?: number;\n\ttype?: string;\n\tignoreExtensions?: string[];\n\tprintMode?: string;\n\tgitIgnoreHandler: GitIgnoreHandler;\n\tignoreGitIgnore?: boolean;\n\n\tconstructor({\n\t\tboring,\n\t\tcommand,\n\t\tdot,\n\t\tfoldersBlacklist,\n\t\tgrep,\n\t\tignoreCase,\n\t\tshort,\n\t\tpath,\n\t\tpattern,\n\t\tstats,\n\t\ttype,\n\t\tignore,\n\t\tprintMode,\n\t\tignoreGitIgnore,\n\t}: {\n\t\tboring?: boolean;\n\t\tcommand?: string;\n\t\tdot?: boolean;\n\t\tfoldersBlacklist?: RegExp;\n\t\tgrep?: string | RegExp;\n\t\tignoreCase?: boolean;\n\t\tshort?: boolean;\n\t\tpath?: string;\n\t\tpattern?: string;\n\t\tstats?: boolean;\n\t\ttype?: string;\n\t\tignore?: string[];\n\t\tprintMode?: string;\n\t\tignoreGitIgnore?: boolean;\n\t}) {\n\t\tthis.path = path;\n\t\tthis.rePattern = pattern\n\t\t\t? new RegExp(pattern, ignoreCase ? \"i\" : \"\")\n\t\t\t: undefined;\n\t\tthis.type = type || STR_TYPE_BOTH;\n\t\tthis.boring = boring;\n\t\tkleur.enabled = !boring;\n\t\tthis.displayLongListing = !short;\n\t\tthis.displayStats = stats;\n\t\tthis.displayHiddenFilesAndFolders = dot;\n\t\tthis.nodesList = [];\n\t\tthis.foldersBlacklist = foldersBlacklist;\n\t\tthis.totalDirScanned = 0;\n\t\tthis.totalFileScanned = 0;\n\t\tthis.totalDirFound = 0;\n\t\tthis.totalFileFound = 0;\n\t\tthis.command = command ? command.trim() : undefined;\n\t\tthis.ignoreExtensions = ignore.map((ext) => ext.toLowerCase());\n\t\tthis.printMode = printMode;\n\t\tthis.ignoreGitIgnore = ignoreGitIgnore;\n\t\tthis.gitIgnoreHandler = new GitIgnoreHandler();\n\t\ttry {\n\t\t\tthis.grep = grep ? new RegExp(grep, ignoreCase ? \"gi\" : \"g\") : undefined;\n\t\t} catch (error) {\n\t\t\tlogger.error(error);\n\t\t\t// eslint-disable-next-line unicorn/no-process-exit\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tignoreFolders(directory: string) {\n\t\tthis.foldersBlacklist.lastIndex = 0;\n\t\treturn this.foldersBlacklist.test(basename(directory));\n\t}\n\n\tshouldIgnoreFile(filePath: string) {\n\t\tif (!this.ignoreExtensions || this.ignoreExtensions.length === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst extension = extname(filePath).toLowerCase().replace(/^\\./, \"\");\n\t\treturn this.ignoreExtensions.includes(extension);\n\t}\n\n\tfilterHidden(value: string[] | string) {\n\t\tif (this.displayHiddenFilesAndFolders) {\n\t\t\treturn true;\n\t\t}\n\t\treturn value[0] !== \".\";\n\t}\n\n\tasync start() {\n\t\tif (this.displayStats) {\n\t\t\tperf.start();\n\t\t}\n\t\tawait this.scanFileSystem([this.path]);\n\t\tawait this.postProcessResults();\n\n\t\tif (this.displayStats) {\n\t\t\tperf.stop();\n\t\t\tprintStatistics({\n\t\t\t\tduration: perf.results.duration,\n\t\t\t\tgrep: this.grep,\n\t\t\t\tpattern: this.rePattern,\n\t\t\t\ttotalDirScanned: this.totalDirScanned,\n\t\t\t\ttotalDirsFound: this.totalDirFound,\n\t\t\t\ttotalFileScanned: this.totalFileScanned,\n\t\t\t\ttotalFilesFound: this.totalFileFound,\n\t\t\t\ttype: this.type,\n\t\t\t});\n\t\t}\n\t}\n\n\tasync scanFileSystem(nodes: string[]) {\n\t\tfor (const node of nodes) {\n\t\t\tlet result: boolean | RegExpExecArray,\n\t\t\t\tfiles: string[],\n\t\t\t\tshortname: string,\n\t\t\t\tstat: fs.Stats;\n\t\t\ttry {\n\t\t\t\tstat = await lstatAsync(node);\n\t\t\t} catch {\n\t\t\t\t// ignore read permission denied errors silently...\n\t\t\t}\n\n\t\t\tconst isDirectory = stat && stat.isDirectory();\n\t\t\tconst isFile = stat && stat.isFile();\n\n\t\t\t// Add this check to respect .gitignore patterns\n\t\t\tif (await this.shouldIgnoreByGitIgnore(node, isDirectory)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isDirectory && !this.ignoreFolders(node)) {\n\t\t\t\tthis.totalDirScanned++;\n\n\t\t\t\tresult = checkPattern(this.rePattern, node);\n\t\t\t\tif (result) {\n\t\t\t\t\tthis.totalDirFound++;\n\t\t\t\t\tthis.nodesList.push({\n\t\t\t\t\t\tcommand: this.command,\n\t\t\t\t\t\tmatch: result,\n\t\t\t\t\t\tname: node,\n\t\t\t\t\t\tstat,\n\t\t\t\t\t\ttype: STR_TYPE_DIRECTORY,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tfiles = await readdirAsync(node);\n\t\t\t\t\tawait this.scanFileSystem(\n\t\t\t\t\t\tfiles\n\t\t\t\t\t\t\t.filter((element) => this.filterHidden(element))\n\t\t\t\t\t\t\t.map(function (file) {\n\t\t\t\t\t\t\t\treturn join(node, file);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t} catch {\n\t\t\t\t\t// nothing to declare\n\t\t\t\t}\n\t\t\t} else if (isFile) {\n\t\t\t\t// Skip files with ignored extensions\n\t\t\t\tif (this.shouldIgnoreFile(node)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthis.totalFileScanned++;\n\t\t\t\tshortname = basename(node);\n\t\t\t\tconst patternResult = checkPattern(this.rePattern, shortname);\n\t\t\t\tif (patternResult) {\n\t\t\t\t\tthis.totalFileFound++;\n\t\t\t\t\tthis.nodesList.push({\n\t\t\t\t\t\tcommand: this.command,\n\t\t\t\t\t\tmatch: patternResult[0],\n\t\t\t\t\t\tname: node,\n\t\t\t\t\t\tstat,\n\t\t\t\t\t\ttype: STR_TYPE_FILE,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tasync readFileContent(filePath: string): Promise<string> {\n\t\ttry {\n\t\t\tconst content = await readFileAsync(filePath, \"utf8\");\n\t\t\treturn content;\n\t\t} catch (error) {\n\t\t\t/* istanbul ignore next */\n\t\t\treturn `Error reading file: ${error.message}`;\n\t\t}\n\t}\n\n\tasync printFilesContent() {\n\t\tconst fileNodes = this.nodesList.filter(\n\t\t\t(node) => node.type === STR_TYPE_FILE,\n\t\t);\n\n\t\tif (this.printMode === \"simple\") {\n\t\t\tfor (const node of fileNodes) {\n\t\t\t\tconst relativePath = relative(process.cwd(), node.name);\n\t\t\t\tlogger.log(`---\\n./${relativePath}\\n---`);\n\t\t\t\tconst content = await this.readFileContent(node.name);\n\t\t\t\tlogger.log(content);\n\t\t\t\t// adding a new line after each file content except the last one\n\t\t\t\tif (node !== fileNodes[fileNodes.length - 1]) {\n\t\t\t\t\tlogger.log(\"\");\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.printMode === \"xml\") {\n\t\t\tlogger.log(\"<documents>\");\n\n\t\t\tfor (let i = 0; i < fileNodes.length; i++) {\n\t\t\t\tconst node = fileNodes[i];\n\t\t\t\tconst relativePath = relative(process.cwd(), node.name);\n\t\t\t\tconst content = await this.readFileContent(node.name);\n\n\t\t\t\tlogger.log(`<document index=\"${i + 1}\">`);\n\t\t\t\tlogger.log(`<source>./${relativePath}</source>`);\n\t\t\t\tlogger.log(\"<document_content>\");\n\t\t\t\tlogger.log(content);\n\t\t\t\tlogger.log(\"</document_content>\");\n\t\t\t\tlogger.log(\"</document>\");\n\t\t\t}\n\n\t\t\tlogger.log(\"</documents>\");\n\t\t}\n\t}\n\n\tasync shouldIgnoreByGitIgnore(\n\t\tnodePath: string,\n\t\tisDirectory: boolean,\n\t): Promise<boolean> {\n\t\t/* istanbul ignore if */\n\t\tif (this.ignoreGitIgnore) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.gitIgnoreHandler.isIgnored(nodePath, isDirectory);\n\t}\n\n\tasync postProcessResults() {\n\t\t/* istanbul ignore if */\n\t\tif (!this.boring) {\n\t\t\tlogger.log();\n\t\t}\n\n\t\tif (this.grep) {\n\t\t\t/**\n\t\t\t * Resetting the number of files found, since we want to\n\t\t\t * show how many matched the grep, not how many matched the\n\t\t\t * pattern (in the file name).\n\t\t\t */\n\t\t\tthis.totalFileFound = 0;\n\t\t}\n\n\t\t// If printMode is enabled, handle file content printing and return\n\t\tif (this.printMode && [\"simple\", \"xml\"].includes(this.printMode)) {\n\t\t\tawait this.printFilesContent();\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const node of this.nodesList) {\n\t\t\tif (\n\t\t\t\t(this.type === STR_TYPE_FILE && node.type === STR_TYPE_FILE) ||\n\t\t\t\t(this.type === STR_TYPE_DIRECTORY &&\n\t\t\t\t\tnode.type === STR_TYPE_DIRECTORY) ||\n\t\t\t\tthis.type === STR_TYPE_BOTH\n\t\t\t) {\n\t\t\t\tlet list: {\n\t\t\t\t\t\tgroup?: string;\n\t\t\t\t\t\tmdate?: string;\n\t\t\t\t\t\tmode?: string;\n\t\t\t\t\t\towner?: string;\n\t\t\t\t\t\tsize?: string;\n\t\t\t\t\t} = {\n\t\t\t\t\t\tgroup: \"\",\n\t\t\t\t\t\tmdate: \"\",\n\t\t\t\t\t\tmode: \"\",\n\t\t\t\t\t\towner: \"\",\n\t\t\t\t\t\tsize: \"\",\n\t\t\t\t\t},\n\t\t\t\t\tname: string,\n\t\t\t\t\tseparator: string = \"\";\n\n\t\t\t\t/* istanbul ignore if */\n\t\t\t\tif (this.displayLongListing) {\n\t\t\t\t\tlist = await formatLongListings(node.stat, node.type);\n\t\t\t\t\tseparator = \"\\t\";\n\t\t\t\t}\n\n\t\t\t\tconst color = node.type === STR_TYPE_FILE ? kleur.gray : kleur.blue;\n\t\t\t\tname = relative(process.cwd(), node.name);\n\n\t\t\t\tif (node.match) {\n\t\t\t\t\tconst matchStr = String(node.match); // Ensure match is a string\n\t\t\t\t\tconst match = new RegExp(matchStr, \"g\");\n\t\t\t\t\tconst highlightedMatch = kleur.black().bgYellow(matchStr);\n\t\t\t\t\tname = color(name.replace(match, highlightedMatch));\n\t\t\t\t} else {\n\t\t\t\t\tname = color(name);\n\t\t\t\t}\n\n\t\t\t\tif (this.grep && node.type === STR_TYPE_FILE) {\n\t\t\t\t\tconst { totalMatchingLines, results } = await runGrepOnNode(\n\t\t\t\t\t\tnode.name,\n\t\t\t\t\t\tthis.grep,\n\t\t\t\t\t);\n\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\tif (totalMatchingLines) {\n\t\t\t\t\t\tthis.totalFileFound++;\n\t\t\t\t\t\tconst occurrences = plur(\"occurrence\", totalMatchingLines);\n\t\t\t\t\t\tlogger.log(\n\t\t\t\t\t\t\t` %s${separator}%s${separator}%s${separator}%s${separator}%s`,\n\t\t\t\t\t\t\tlist.mode.trim(),\n\t\t\t\t\t\t\tlist.owner.trim(),\n\t\t\t\t\t\t\tlist.size.trim(),\n\t\t\t\t\t\t\tlist.mdate,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t`(${kleur.white(totalMatchingLines)} ${occurrences})`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlogger.log(`${results.join(\"\\n\")}\\n`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t/* istanbul ignore next */\n\t\t\t\t\tif (!this.grep) {\n\t\t\t\t\t\tlogger.log(\n\t\t\t\t\t\t\t` %s${separator}%s${separator}%s${separator}%s${separator}%s`,\n\t\t\t\t\t\t\tlist.mode.trim(),\n\t\t\t\t\t\t\tlist.owner.trim(),\n\t\t\t\t\t\t\tlist.size.trim(),\n\t\t\t\t\t\t\tlist.mdate,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (node.command) {\n\t\t\t\t\t\t\tawait runCommandOnNode(node.name, node.command);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["basename","extname","join","relative","GitIgnoreHandler","STR_TYPE_BOTH","STR_TYPE_DIRECTORY","STR_TYPE_FILE","checkPattern","formatLongListings","printStatistics","runCommandOnNode","runGrepOnNode","promisify","Logger","Performance","fs","kleur","plur","lstatAsync","lstat","readdirAsync","readdir","readFileAsync","readFile","perf","logger","boring","process","env","NODE_ENV","Search","command","displayHiddenFilesAndFolders","displayLongListing","displayStats","foldersBlacklist","grep","nodesList","path","rePattern","totalDirFound","totalDirScanned","totalFileFound","totalFileScanned","type","ignoreExtensions","printMode","gitIgnoreHandler","ignoreGitIgnore","constructor","dot","ignoreCase","short","pattern","stats","ignore","RegExp","undefined","enabled","trim","map","ext","toLowerCase","error","exit","ignoreFolders","directory","lastIndex","test","shouldIgnoreFile","filePath","length","extension","replace","includes","filterHidden","value","start","scanFileSystem","postProcessResults","stop","duration","results","totalDirsFound","totalFilesFound","nodes","node","result","files","shortname","stat","isDirectory","isFile","shouldIgnoreByGitIgnore","push","match","name","filter","element","file","patternResult","readFileContent","content","message","printFilesContent","fileNodes","relativePath","cwd","log","i","nodePath","isIgnored","list","group","mdate","mode","owner","size","separator","color","gray","blue","matchStr","String","highlightedMatch","black","bgYellow","totalMatchingLines","occurrences","white"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,YAAY;AAC9D,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SACCC,aAAa,EACbC,kBAAkB,EAClBC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,QACP,iBAAiB;AAExB,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,UAAU,OAAO;AAExB,MAAMC,aAAaN,UAAUG,GAAGI,KAAK;AACrC,MAAMC,eAAeR,UAAUG,GAAGM,OAAO;AACzC,MAAMC,gBAAgBV,UAAUG,GAAGQ,QAAQ;AAC3C,MAAMC,OAAO,IAAIV;AACjB,MAAMW,SAAS,IAAIZ,OAAO;IACzBa,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK;AAClC;AAEA,OAAO,MAAMC;IACZJ,OAAiB;IACjBK,QAAiB;IACjBC,6BAAuC;IACvCC,mBAA6B;IAC7BC,aAAuB;IACvBC,iBAA0B;IAC1BC,KAAc;IACdC,UAAkB;IAClBC,KAAc;IACdC,UAAmB;IACnBC,cAAuB;IACvBC,gBAAyB;IACzBC,eAAwB;IACxBC,iBAA0B;IAC1BC,KAAc;IACdC,iBAA4B;IAC5BC,UAAmB;IACnBC,iBAAmC;IACnCC,gBAA0B;IAE1BC,YAAY,EACXvB,MAAM,EACNK,OAAO,EACPmB,GAAG,EACHf,gBAAgB,EAChBC,IAAI,EACJe,UAAU,EACVC,KAAK,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AACzD,IAAI,IACfqD,KAAKK,IAAI,CAAC1D,IAAI,IACdqD,KAAKE,KAAK,EACVlB;wBAED,IAAIV,KAAKvD,OAAO,EAAE;4BACjB,MAAMrB,iBAAiB4E,KAAKU,IAAI,EAAEV,KAAKvD,OAAO;wBAC/C;oBACD;gBACD;YACD;QACD;IACD;AACD"}
|
package/dist/defaults.d.ts
CHANGED
package/dist/defaults.js
CHANGED
package/dist/defaults.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const defaultFlags = {\n\tboring: false,\n\tdot: false,\n\tignoreCase: false,\n\tshort: false,\n\tstats: false,\n};\n\nexport const defaultParameters = {\n\t\"0\": process.cwd(),\n};\n"],"names":["defaultFlags","boring","dot","ignoreCase","short","stats","defaultParameters","process","cwd"],"mappings":"AAAA,OAAO,MAAMA,eAAe;IAC3BC,QAAQ;IACRC,KAAK;IACLC,YAAY;IACZC,OAAO;IACPC,OAAO;
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const defaultFlags = {\n\tboring: false,\n\tdot: false,\n\tignoreCase: false,\n\tshort: false,\n\tstats: false,\n\tignore: [],\n\tignoreGitIgnore: false,\n};\n\nexport const defaultParameters = {\n\t\"0\": process.cwd(),\n};\n"],"names":["defaultFlags","boring","dot","ignoreCase","short","stats","ignore","ignoreGitIgnore","defaultParameters","process","cwd"],"mappings":"AAAA,OAAO,MAAMA,eAAe;IAC3BC,QAAQ;IACRC,KAAK;IACLC,YAAY;IACZC,OAAO;IACPC,OAAO;IACPC,QAAQ,EAAE;IACVC,iBAAiB;AAClB,EAAE;AAEF,OAAO,MAAMC,oBAAoB;IAChC,KAAKC,QAAQC,GAAG;AACjB,EAAE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a pattern from a .gitignore file
|
|
3
|
+
*/
|
|
4
|
+
interface GitIgnorePattern {
|
|
5
|
+
/** The actual pattern string */
|
|
6
|
+
pattern: string;
|
|
7
|
+
/** Whether this is a negated pattern (starts with !) */
|
|
8
|
+
isNegated: boolean;
|
|
9
|
+
/** Whether this pattern is specific to directories (ends with /) */
|
|
10
|
+
isDirectory: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Handles parsing and matching of .gitignore patterns
|
|
14
|
+
*/
|
|
15
|
+
export declare class GitIgnoreHandler {
|
|
16
|
+
/** Map to store ignore patterns by directory */
|
|
17
|
+
private ignorePatterns;
|
|
18
|
+
/** Cache to store already processed paths */
|
|
19
|
+
private ignoredPathsCache;
|
|
20
|
+
constructor();
|
|
21
|
+
/**
|
|
22
|
+
* Parse a .gitignore file and return the patterns
|
|
23
|
+
* @param filePath Path to the .gitignore file
|
|
24
|
+
* @returns Array of parsed patterns
|
|
25
|
+
*/
|
|
26
|
+
parseGitIgnoreFile(filePath: string): Promise<GitIgnorePattern[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Load .gitignore files from a directory and its parents
|
|
29
|
+
* @param directory Directory to load .gitignore from
|
|
30
|
+
*/
|
|
31
|
+
loadGitIgnorePatterns(directory: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Check if a path should be ignored based on .gitignore rules
|
|
34
|
+
* @param path Path to check
|
|
35
|
+
* @param isDirectory Whether the path is a directory
|
|
36
|
+
* @returns True if the path should be ignored, false otherwise
|
|
37
|
+
*/
|
|
38
|
+
isIgnored(path: string, isDirectory?: boolean): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Clear the cache of ignored paths
|
|
41
|
+
*/
|
|
42
|
+
clearCache(): void;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/* istanbul ignore file */ import { basename, dirname, join, relative } from "node:path";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import micromatch from "micromatch";
|
|
5
|
+
const readFileAsync = promisify(fs.readFile);
|
|
6
|
+
/**
|
|
7
|
+
* Handles parsing and matching of .gitignore patterns
|
|
8
|
+
*/ export class GitIgnoreHandler {
|
|
9
|
+
/** Map to store ignore patterns by directory */ ignorePatterns;
|
|
10
|
+
/** Cache to store already processed paths */ ignoredPathsCache;
|
|
11
|
+
constructor(){
|
|
12
|
+
this.ignorePatterns = new Map();
|
|
13
|
+
this.ignoredPathsCache = new Map();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse a .gitignore file and return the patterns
|
|
17
|
+
* @param filePath Path to the .gitignore file
|
|
18
|
+
* @returns Array of parsed patterns
|
|
19
|
+
*/ async parseGitIgnoreFile(filePath) {
|
|
20
|
+
try {
|
|
21
|
+
const content = await readFileAsync(filePath, "utf8");
|
|
22
|
+
return content.split("\n").filter((line)=>{
|
|
23
|
+
// Remove comments and empty lines
|
|
24
|
+
const trimmedLine = line.trim();
|
|
25
|
+
return trimmedLine && !trimmedLine.startsWith("#");
|
|
26
|
+
}).map((pattern)=>{
|
|
27
|
+
// Handle negated patterns (those starting with !)
|
|
28
|
+
const isNegated = pattern.startsWith("!");
|
|
29
|
+
// Remove leading ! for negated patterns
|
|
30
|
+
const cleanPattern = isNegated ? pattern.slice(1) : pattern;
|
|
31
|
+
// Handle directory-specific patterns (those ending with /)
|
|
32
|
+
const isDirectory = cleanPattern.endsWith("/");
|
|
33
|
+
// Remove trailing / for directory patterns
|
|
34
|
+
const finalPattern = isDirectory ? cleanPattern.slice(0, -1) : cleanPattern;
|
|
35
|
+
return {
|
|
36
|
+
pattern: finalPattern,
|
|
37
|
+
isNegated,
|
|
38
|
+
isDirectory
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
} catch (_error) {
|
|
42
|
+
// If file doesn't exist or can't be read, return empty array
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Load .gitignore files from a directory and its parents
|
|
48
|
+
* @param directory Directory to load .gitignore from
|
|
49
|
+
*/ async loadGitIgnorePatterns(directory) {
|
|
50
|
+
// If we've already loaded patterns for this directory, return
|
|
51
|
+
if (this.ignorePatterns.has(directory)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Load .gitignore from current directory
|
|
55
|
+
const gitIgnorePath = join(directory, ".gitignore");
|
|
56
|
+
const patterns = await this.parseGitIgnoreFile(gitIgnorePath);
|
|
57
|
+
this.ignorePatterns.set(directory, patterns);
|
|
58
|
+
// Load patterns from parent directories (if not at root)
|
|
59
|
+
const parentDir = dirname(directory);
|
|
60
|
+
if (parentDir !== directory) {
|
|
61
|
+
await this.loadGitIgnorePatterns(parentDir);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check if a path should be ignored based on .gitignore rules
|
|
66
|
+
* @param path Path to check
|
|
67
|
+
* @param isDirectory Whether the path is a directory
|
|
68
|
+
* @returns True if the path should be ignored, false otherwise
|
|
69
|
+
*/ async isIgnored(path, isDirectory = false) {
|
|
70
|
+
// Check cache first
|
|
71
|
+
const cacheKey = `${path}:${isDirectory}`;
|
|
72
|
+
if (this.ignoredPathsCache.has(cacheKey)) {
|
|
73
|
+
return this.ignoredPathsCache.get(cacheKey);
|
|
74
|
+
}
|
|
75
|
+
// Get the directory containing the path
|
|
76
|
+
const directory = isDirectory ? path : dirname(path);
|
|
77
|
+
// Load .gitignore patterns if not already loaded
|
|
78
|
+
await this.loadGitIgnorePatterns(directory);
|
|
79
|
+
// Get the relative path from the containing directory
|
|
80
|
+
const filename = basename(path);
|
|
81
|
+
// Start with not ignored
|
|
82
|
+
let ignored = false;
|
|
83
|
+
// Check patterns from current directory up to root
|
|
84
|
+
let currentDir = directory;
|
|
85
|
+
while(true){
|
|
86
|
+
const patterns = this.ignorePatterns.get(currentDir) || [];
|
|
87
|
+
// Calculate relative path from this directory to the file
|
|
88
|
+
const relPath = relative(currentDir, path);
|
|
89
|
+
for (const { pattern, isNegated, isDirectory: isPatternForDir } of patterns){
|
|
90
|
+
// Skip directory-specific patterns if checking a file
|
|
91
|
+
if (isPatternForDir && !isDirectory) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
// Check if pattern matches
|
|
95
|
+
const matches = micromatch.isMatch(relPath, pattern) || micromatch.isMatch(filename, pattern);
|
|
96
|
+
if (matches) {
|
|
97
|
+
// Negated patterns override previous ignores
|
|
98
|
+
ignored = !isNegated;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Move to parent directory
|
|
102
|
+
const parentDir = dirname(currentDir);
|
|
103
|
+
if (parentDir === currentDir) {
|
|
104
|
+
break; // We've reached the root
|
|
105
|
+
}
|
|
106
|
+
currentDir = parentDir;
|
|
107
|
+
}
|
|
108
|
+
// Cache the result
|
|
109
|
+
this.ignoredPathsCache.set(cacheKey, ignored);
|
|
110
|
+
return ignored;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Clear the cache of ignored paths
|
|
114
|
+
*/ clearCache() {
|
|
115
|
+
this.ignoredPathsCache.clear();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=gitIgnoreHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/gitIgnoreHandler.ts"],"sourcesContent":["/* istanbul ignore file */\nimport { basename, dirname, join, relative } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport fs from \"fs-extra\";\nimport micromatch from \"micromatch\";\n\nconst readFileAsync = promisify(fs.readFile);\n\n/**\n * Represents a pattern from a .gitignore file\n */\ninterface GitIgnorePattern {\n\t/** The actual pattern string */\n\tpattern: string;\n\t/** Whether this is a negated pattern (starts with !) */\n\tisNegated: boolean;\n\t/** Whether this pattern is specific to directories (ends with /) */\n\tisDirectory: boolean;\n}\n\n/**\n * Handles parsing and matching of .gitignore patterns\n */\nexport class GitIgnoreHandler {\n\t/** Map to store ignore patterns by directory */\n\tprivate ignorePatterns: Map<string, GitIgnorePattern[]>;\n\t/** Cache to store already processed paths */\n\tprivate ignoredPathsCache: Map<string, boolean>;\n\n\tconstructor() {\n\t\tthis.ignorePatterns = new Map<string, GitIgnorePattern[]>();\n\t\tthis.ignoredPathsCache = new Map<string, boolean>();\n\t}\n\n\t/**\n\t * Parse a .gitignore file and return the patterns\n\t * @param filePath Path to the .gitignore file\n\t * @returns Array of parsed patterns\n\t */\n\tasync parseGitIgnoreFile(filePath: string): Promise<GitIgnorePattern[]> {\n\t\ttry {\n\t\t\tconst content = await readFileAsync(filePath, \"utf8\");\n\t\t\treturn content\n\t\t\t\t.split(\"\\n\")\n\t\t\t\t.filter((line) => {\n\t\t\t\t\t// Remove comments and empty lines\n\t\t\t\t\tconst trimmedLine = line.trim();\n\t\t\t\t\treturn trimmedLine && !trimmedLine.startsWith(\"#\");\n\t\t\t\t})\n\t\t\t\t.map((pattern) => {\n\t\t\t\t\t// Handle negated patterns (those starting with !)\n\t\t\t\t\tconst isNegated = pattern.startsWith(\"!\");\n\t\t\t\t\t// Remove leading ! for negated patterns\n\t\t\t\t\tconst cleanPattern = isNegated ? pattern.slice(1) : pattern;\n\t\t\t\t\t// Handle directory-specific patterns (those ending with /)\n\t\t\t\t\tconst isDirectory = cleanPattern.endsWith(\"/\");\n\t\t\t\t\t// Remove trailing / for directory patterns\n\t\t\t\t\tconst finalPattern = isDirectory\n\t\t\t\t\t\t? cleanPattern.slice(0, -1)\n\t\t\t\t\t\t: cleanPattern;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpattern: finalPattern,\n\t\t\t\t\t\tisNegated,\n\t\t\t\t\t\tisDirectory,\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t} catch (_error) {\n\t\t\t// If file doesn't exist or can't be read, return empty array\n\t\t\treturn [];\n\t\t}\n\t}\n\n\t/**\n\t * Load .gitignore files from a directory and its parents\n\t * @param directory Directory to load .gitignore from\n\t */\n\tasync loadGitIgnorePatterns(directory: string): Promise<void> {\n\t\t// If we've already loaded patterns for this directory, return\n\t\tif (this.ignorePatterns.has(directory)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Load .gitignore from current directory\n\t\tconst gitIgnorePath = join(directory, \".gitignore\");\n\t\tconst patterns = await this.parseGitIgnoreFile(gitIgnorePath);\n\t\tthis.ignorePatterns.set(directory, patterns);\n\n\t\t// Load patterns from parent directories (if not at root)\n\t\tconst parentDir = dirname(directory);\n\t\tif (parentDir !== directory) {\n\t\t\tawait this.loadGitIgnorePatterns(parentDir);\n\t\t}\n\t}\n\n\t/**\n\t * Check if a path should be ignored based on .gitignore rules\n\t * @param path Path to check\n\t * @param isDirectory Whether the path is a directory\n\t * @returns True if the path should be ignored, false otherwise\n\t */\n\tasync isIgnored(\n\t\tpath: string,\n\t\tisDirectory: boolean = false,\n\t): Promise<boolean> {\n\t\t// Check cache first\n\t\tconst cacheKey = `${path}:${isDirectory}`;\n\t\tif (this.ignoredPathsCache.has(cacheKey)) {\n\t\t\treturn this.ignoredPathsCache.get(cacheKey)!;\n\t\t}\n\n\t\t// Get the directory containing the path\n\t\tconst directory = isDirectory ? path : dirname(path);\n\n\t\t// Load .gitignore patterns if not already loaded\n\t\tawait this.loadGitIgnorePatterns(directory);\n\n\t\t// Get the relative path from the containing directory\n\t\tconst filename = basename(path);\n\n\t\t// Start with not ignored\n\t\tlet ignored = false;\n\n\t\t// Check patterns from current directory up to root\n\t\tlet currentDir = directory;\n\t\twhile (true) {\n\t\t\tconst patterns = this.ignorePatterns.get(currentDir) || [];\n\n\t\t\t// Calculate relative path from this directory to the file\n\t\t\tconst relPath = relative(currentDir, path);\n\n\t\t\tfor (const {\n\t\t\t\tpattern,\n\t\t\t\tisNegated,\n\t\t\t\tisDirectory: isPatternForDir,\n\t\t\t} of patterns) {\n\t\t\t\t// Skip directory-specific patterns if checking a file\n\t\t\t\tif (isPatternForDir && !isDirectory) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Check if pattern matches\n\t\t\t\tconst matches =\n\t\t\t\t\tmicromatch.isMatch(relPath, pattern) ||\n\t\t\t\t\tmicromatch.isMatch(filename, pattern);\n\n\t\t\t\tif (matches) {\n\t\t\t\t\t// Negated patterns override previous ignores\n\t\t\t\t\tignored = !isNegated;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Move to parent directory\n\t\t\tconst parentDir = dirname(currentDir);\n\t\t\tif (parentDir === currentDir) {\n\t\t\t\tbreak; // We've reached the root\n\t\t\t}\n\t\t\tcurrentDir = parentDir;\n\t\t}\n\n\t\t// Cache the result\n\t\tthis.ignoredPathsCache.set(cacheKey, ignored);\n\t\treturn ignored;\n\t}\n\n\t/**\n\t * Clear the cache of ignored paths\n\t */\n\tclearCache(): void {\n\t\tthis.ignoredPathsCache.clear();\n\t}\n}\n"],"names":["basename","dirname","join","relative","promisify","fs","micromatch","readFileAsync","readFile","GitIgnoreHandler","ignorePatterns","ignoredPathsCache","constructor","Map","parseGitIgnoreFile","filePath","content","split","filter","line","trimmedLine","trim","startsWith","map","pattern","isNegated","cleanPattern","slice","isDirectory","endsWith","finalPattern","_error","loadGitIgnorePatterns","directory","has","gitIgnorePath","patterns","set","parentDir","isIgnored","path","cacheKey","get","filename","ignored","currentDir","relPath","isPatternForDir","matches","isMatch","clearCache","clear"],"mappings":"AAAA,wBAAwB,GACxB,SAASA,QAAQ,EAAEC,OAAO,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,YAAY;AAC9D,SAASC,SAAS,QAAQ,YAAY;AACtC,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,gBAAgB,aAAa;AAEpC,MAAMC,gBAAgBH,UAAUC,GAAGG,QAAQ;AAc3C;;CAEC,GACD,OAAO,MAAMC;IACZ,8CAA8C,GAC9C,AAAQC,eAAgD;IACxD,2CAA2C,GAC3C,AAAQC,kBAAwC;IAEhDC,aAAc;QACb,IAAI,CAACF,cAAc,GAAG,IAAIG;QAC1B,IAAI,CAACF,iBAAiB,GAAG,IAAIE;IAC9B;IAEA;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AAI,IAAI,CAACjB,iBAAiB,CAACuB,GAAG,CAACO,WAAW;YACzC,OAAO,IAAI,CAAC9B,iBAAiB,CAAC+B,GAAG,CAACD;QACnC;QAEA,wCAAwC;QACxC,MAAMR,YAAYL,cAAcY,OAAOvC,QAAQuC;QAE/C,iDAAiD;QACjD,MAAM,IAAI,CAACR,qBAAqB,CAACC;QAEjC,sDAAsD;QACtD,MAAMU,WAAW3C,SAASwC;QAE1B,yBAAyB;QACzB,IAAII,UAAU;QAEd,mDAAmD;QACnD,IAAIC,aAAaZ;QACjB,MAAO,KAAM;YACZ,MAAMG,WAAW,IAAI,CAAC1B,cAAc,CAACgC,GAAG,CAACG,eAAe,EAAE;YAE1D,0DAA0D;YAC1D,MAAMC,UAAU3C,SAAS0C,YAAYL;YAErC,KAAK,MAAM,EACVhB,OAAO,EACPC,SAAS,EACTG,aAAamB,eAAe,EAC5B,IAAIX,SAAU;gBACd,sDAAsD;gBACtD,IAAIW,mBAAmB,CAACnB,aAAa;oBACpC;gBACD;gBAEA,2BAA2B;gBAC3B,MAAMoB,UACL1C,WAAW2C,OAAO,CAACH,SAAStB,YAC5BlB,WAAW2C,OAAO,CAACN,UAAUnB;gBAE9B,IAAIwB,SAAS;oBACZ,6CAA6C;oBAC7CJ,UAAU,CAACnB;gBACZ;YACD;YAEA,2BAA2B;YAC3B,MAAMa,YAAYrC,QAAQ4C;YAC1B,IAAIP,cAAcO,YAAY;gBAC7B,OAAO,yBAAyB;YACjC;YACAA,aAAaP;QACd;QAEA,mBAAmB;QACnB,IAAI,CAAC3B,iBAAiB,CAAC0B,GAAG,CAACI,UAAUG;QACrC,OAAOA;IACR;IAEA;;EAEC,GACDM,aAAmB;QAClB,IAAI,CAACvC,iBAAiB,CAACwC,KAAK;IAC7B;AACD"}
|
package/dist/index.d.ts
CHANGED
package/dist/parse.d.ts
CHANGED
package/dist/parse.js
CHANGED
|
@@ -75,6 +75,22 @@ import { parser } from "@node-cli/parser";
|
|
|
75
75
|
shortFlag: "v",
|
|
76
76
|
description: "Output the current version",
|
|
77
77
|
type: "boolean"
|
|
78
|
+
},
|
|
79
|
+
ignore: {
|
|
80
|
+
shortFlag: "I",
|
|
81
|
+
description: "Ignore files extensions",
|
|
82
|
+
type: "string",
|
|
83
|
+
isMultiple: true
|
|
84
|
+
},
|
|
85
|
+
printMode: {
|
|
86
|
+
shortFlag: "P",
|
|
87
|
+
description: "Print mode (simple or xml)",
|
|
88
|
+
type: "string"
|
|
89
|
+
},
|
|
90
|
+
ignoreGitIgnore: {
|
|
91
|
+
description: "Ignore .gitignore files",
|
|
92
|
+
default: defaultFlags.ignoreGitIgnore,
|
|
93
|
+
type: "boolean"
|
|
78
94
|
}
|
|
79
95
|
},
|
|
80
96
|
parameters: {
|
package/dist/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parse.ts"],"sourcesContent":["import { defaultFlags, defaultParameters } from \"./defaults.js\";\n\nimport { parser } from \"@node-cli/parser\";\n\nexport type Flags = {\n\tboring?: boolean;\n\tdot?: boolean;\n\tignoreCase?: boolean;\n\tshort?: boolean;\n\tstats?: boolean;\n\tgrep?: string;\n\ttype?: string;\n};\n\nexport type Parameters = {\n\tpath?: string;\n};\n\nexport type Configuration = {\n\tflags?: Flags;\n\tparameters?: Parameters;\n};\n\n/* istanbul ignore next */\nexport const config: Configuration = parser({\n\tmeta: import.meta,\n\texamples: [\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".jsx$\" src/',\n\t\t\tcomment:\n\t\t\t\t'## Find all files with the extension \".jsx\" in the \"src\" folder',\n\t\t},\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".sh$\" --command \"chmod +x\" bin/',\n\t\t\tcomment: `## Change the permissions to executable for all the files with\\n ## the extension \".sh\" found under the \"bin\" folder`,\n\t\t},\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".md$\" --grep \"Table of Content\"',\n\t\t\tcomment: `## Search in all the markdown files under the \"src\" folder for\\n ## the keywords \"Table of Content\"`,\n\t\t},\n\t],\n\tflags: {\n\t\tboring: {\n\t\t\tshortFlag: \"b\",\n\t\t\tdefault: defaultFlags.boring,\n\t\t\tdescription: \"Do not use color output\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tcommand: {\n\t\t\tshortFlag: \"c\",\n\t\t\tdescription: \"Command to execute over each node (ex: chmod +x)\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tdot: {\n\t\t\tdefault: defaultFlags.dot,\n\t\t\tdescription: \"Show hidden files and directories\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tgrep: {\n\t\t\tshortFlag: \"g\",\n\t\t\tdescription: \"A RegExp to match the content of the files found\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\thelp: {\n\t\t\tshortFlag: \"h\",\n\t\t\tdescription: \"Display help instructions\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tignoreCase: {\n\t\t\tshortFlag: \"i\",\n\t\t\tdefault: defaultFlags.ignoreCase,\n\t\t\tdescription: \"Ignore case when searching\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tpattern: {\n\t\t\tshortFlag: \"p\",\n\t\t\tdescription: \"A regular expression to match file or folder names\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tshort: {\n\t\t\tdefault: defaultFlags.short,\n\t\t\tdescription: \"Short listing format (equivalent to ls)\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tstats: {\n\t\t\tshortFlag: \"s\",\n\t\t\tdefault: defaultFlags.stats,\n\t\t\tdescription: \"Display some statistics\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\ttype: {\n\t\t\tshortFlag: \"t\",\n\t\t\tdefault: \"both\",\n\t\t\tdescription: \"Search for files (f) or directories (d)\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tversion: {\n\t\t\tshortFlag: \"v\",\n\t\t\tdescription: \"Output the current version\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t},\n\tparameters: {\n\t\tpath: {\n\t\t\tdefault: \"current folder\",\n\t\t\tdescription: \"the path where to start the search\",\n\t\t},\n\t},\n\tusage: \"search [options] [path]\",\n\tdefaultFlags,\n\tdefaultParameters,\n});\n"],"names":["defaultFlags","defaultParameters","parser","config","meta","examples","command","comment","flags","boring","shortFlag","default","description","type","dot","grep","help","ignoreCase","pattern","short","stats","version","parameters","path","usage"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/parse.ts"],"sourcesContent":["import { print } from \"kleur/colors\";\nimport { defaultFlags, defaultParameters } from \"./defaults.js\";\n\nimport { parser } from \"@node-cli/parser\";\n\nexport type Flags = {\n\tboring?: boolean;\n\tdot?: boolean;\n\tignoreCase?: boolean;\n\tshort?: boolean;\n\tstats?: boolean;\n\tgrep?: string;\n\ttype?: string;\n\tignore?: string[];\n\tprintMode?: string;\n};\n\nexport type Parameters = {\n\tpath?: string;\n};\n\nexport type Configuration = {\n\tflags?: Flags;\n\tparameters?: Parameters;\n};\n\n/* istanbul ignore next */\nexport const config: Configuration = parser({\n\tmeta: import.meta,\n\texamples: [\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".jsx$\" src/',\n\t\t\tcomment:\n\t\t\t\t'## Find all files with the extension \".jsx\" in the \"src\" folder',\n\t\t},\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".sh$\" --command \"chmod +x\" bin/',\n\t\t\tcomment: `## Change the permissions to executable for all the files with\\n ## the extension \".sh\" found under the \"bin\" folder`,\n\t\t},\n\t\t{\n\t\t\tcommand: 'search --type f --pattern \".md$\" --grep \"Table of Content\"',\n\t\t\tcomment: `## Search in all the markdown files under the \"src\" folder for\\n ## the keywords \"Table of Content\"`,\n\t\t},\n\t],\n\tflags: {\n\t\tboring: {\n\t\t\tshortFlag: \"b\",\n\t\t\tdefault: defaultFlags.boring,\n\t\t\tdescription: \"Do not use color output\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tcommand: {\n\t\t\tshortFlag: \"c\",\n\t\t\tdescription: \"Command to execute over each node (ex: chmod +x)\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tdot: {\n\t\t\tdefault: defaultFlags.dot,\n\t\t\tdescription: \"Show hidden files and directories\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tgrep: {\n\t\t\tshortFlag: \"g\",\n\t\t\tdescription: \"A RegExp to match the content of the files found\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\thelp: {\n\t\t\tshortFlag: \"h\",\n\t\t\tdescription: \"Display help instructions\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tignoreCase: {\n\t\t\tshortFlag: \"i\",\n\t\t\tdefault: defaultFlags.ignoreCase,\n\t\t\tdescription: \"Ignore case when searching\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tpattern: {\n\t\t\tshortFlag: \"p\",\n\t\t\tdescription: \"A regular expression to match file or folder names\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tshort: {\n\t\t\tdefault: defaultFlags.short,\n\t\t\tdescription: \"Short listing format (equivalent to ls)\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tstats: {\n\t\t\tshortFlag: \"s\",\n\t\t\tdefault: defaultFlags.stats,\n\t\t\tdescription: \"Display some statistics\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\ttype: {\n\t\t\tshortFlag: \"t\",\n\t\t\tdefault: \"both\",\n\t\t\tdescription: \"Search for files (f) or directories (d)\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tversion: {\n\t\t\tshortFlag: \"v\",\n\t\t\tdescription: \"Output the current version\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tignore: {\n\t\t\tshortFlag: \"I\",\n\t\t\tdescription: \"Ignore files extensions\",\n\t\t\ttype: \"string\",\n\t\t\tisMultiple: true,\n\t\t},\n\t\tprintMode: {\n\t\t\tshortFlag: \"P\",\n\t\t\tdescription: \"Print mode (simple or xml)\",\n\t\t\ttype: \"string\",\n\t\t},\n\t\tignoreGitIgnore: {\n\t\t\tdescription: \"Ignore .gitignore files\",\n\t\t\tdefault: defaultFlags.ignoreGitIgnore,\n\t\t\ttype: \"boolean\",\n\t\t},\n\t},\n\tparameters: {\n\t\tpath: {\n\t\t\tdefault: \"current folder\",\n\t\t\tdescription: \"the path where to start the search\",\n\t\t},\n\t},\n\tusage: \"search [options] [path]\",\n\tdefaultFlags,\n\tdefaultParameters,\n});\n"],"names":["defaultFlags","defaultParameters","parser","config","meta","examples","command","comment","flags","boring","shortFlag","default","description","type","dot","grep","help","ignoreCase","pattern","short","stats","version","ignore","isMultiple","printMode","ignoreGitIgnore","parameters","path","usage"],"mappings":"AACA,SAASA,YAAY,EAAEC,iBAAiB,QAAQ,gBAAgB;AAEhE,SAASC,MAAM,QAAQ,mBAAmB;AAuB1C,wBAAwB,GACxB,OAAO,MAAMC,SAAwBD,OAAO;IAC3CE,MAAM;IACNC,UAAU;QACT;YACCC,SAAS;YACTC,SACC;QACF;QACA;YACCD,SAAS;YACTC,SAAS,CAAC,uHAAuH,CAAC;QACnI;QACA;YACCD,SAAS;YACTC,SAAS,CAAC,sGAAsG,CAAC;QAClH;KACA;IACDC,OAAO;QACNC,QAAQ;YACPC,WAAW;YACXC,SAASX,aAAaS,MAAM;YAC5BG,aAAa;YACbC,MAAM;QACP;QACAP,SAAS;YACRI,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAC,KAAK;YACJH,SAASX,aAAac,GAAG;YACzBF,aAAa;YACbC,MAAM;QACP;QACAE,MAAM;YACLL,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAG,MAAM;YACLN,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAI,YAAY;YACXP,WAAW;YACXC,SAASX,aAAaiB,UAAU;YAChCL,aAAa;YACbC,MAAM;QACP;QACAK,SAAS;YACRR,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAM,OAAO;YACNR,SAASX,aAAamB,KAAK;YAC3BP,aAAa;YACbC,MAAM;QACP;QACAO,OAAO;YACNV,WAAW;YACXC,SAASX,aAAaoB,KAAK;YAC3BR,aAAa;YACbC,MAAM;QACP;QACAA,MAAM;YACLH,WAAW;YACXC,SAAS;YACTC,aAAa;YACbC,MAAM;QACP;QACAQ,SAAS;YACRX,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAS,QAAQ;YACPZ,WAAW;YACXE,aAAa;YACbC,MAAM;YACNU,YAAY;QACb;QACAC,WAAW;YACVd,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAY,iBAAiB;YAChBb,aAAa;YACbD,SAASX,aAAayB,eAAe;YACrCZ,MAAM;QACP;IACD;IACAa,YAAY;QACXC,MAAM;YACLhB,SAAS;YACTC,aAAa;QACd;IACD;IACAgB,OAAO;IACP5B;IACAC;AACD,GAAG"}
|
package/dist/utilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utilities.ts"],"sourcesContent":["import { RunResult, run } from \"@node-cli/run\";\n\nimport fs from \"node:fs\";\nimport { Logger } from \"@node-cli/logger\";\nimport kleur from \"kleur\";\nimport prettyMilliseconds from \"pretty-ms\";\n\nconst BYTE_CHUNKS = 1000;\nconst DECIMAL = 10;\nconst LAST_THREE_ENTRIES = -3;\nconst MODE_GROUP_POS = 1;\nconst MODE_OWNER_POS = 0;\nconst MODE_WORD_POS = 2;\nconst OCTAL = 8;\nexport const STR_TYPE_DIRECTORY = \"d\";\nexport const STR_TYPE_FILE = \"f\";\nexport const STR_TYPE_BOTH = \"both\";\nconst PERMISSIONS_PREFIX = {\n\t[STR_TYPE_DIRECTORY]: \"d\",\n\t[STR_TYPE_FILE]: \"-\",\n};\n\nconst ownerNames = {\n\t0: \"root\",\n};\n\nconst MONTHS = {\n\t0: \"Jan\",\n\t1: \"Feb\",\n\t2: \"Mar\",\n\t3: \"Apr\",\n\t4: \"May\",\n\t5: \"Jun\",\n\t6: \"Jul\",\n\t7: \"Aug\",\n\t8: \"Sep\",\n\t9: \"Oct\",\n\t10: \"Nov\",\n\t11: \"Dec\",\n};\n\nconst logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nexport const extractMode = (mode: number): string => {\n\tconst modeDec = Number.parseInt(mode.toString(OCTAL), DECIMAL)\n\t\t.toString()\n\t\t.slice(LAST_THREE_ENTRIES);\n\tconst modeOwner = modeDec.charAt(MODE_OWNER_POS);\n\tconst modeGroup = modeDec.charAt(MODE_GROUP_POS);\n\tconst modeWorld = modeDec.charAt(MODE_WORD_POS);\n\tconst modes = {\n\t\t0: \"---\",\n\t\t1: \"--x\",\n\t\t2: \"-w-\",\n\t\t3: \"-wx\",\n\t\t4: \"r--\",\n\t\t5: \"r-x\",\n\t\t6: \"rw-\",\n\t\t7: \"rwx\",\n\t};\n\treturn modes[modeOwner] + modes[modeGroup] + modes[modeWorld];\n};\n\nexport const convertSize = (bytes: number): string => {\n\tconst sizes = [\"B\", \"K\", \"M\", \"G\", \"T\"];\n\tconst length = 5;\n\tlet posttxt = 0;\n\n\twhile (bytes >= BYTE_CHUNKS) {\n\t\tposttxt = posttxt + 1;\n\t\tbytes = bytes / BYTE_CHUNKS;\n\t}\n\tconst string_ =\n\t\tNumber.parseInt(bytes.toString(), DECIMAL).toFixed(0) + sizes[posttxt];\n\treturn (\n\t\tArray.from({ length: length + 1 - string_.length }).join(\" \") + string_\n\t);\n};\n\nexport const convertDate = (mtime: Date): string => {\n\tconst month = MONTHS[mtime.getMonth()];\n\tconst date = `${mtime.getDate()}`.padStart(2, \"0\");\n\tconst hours = `${mtime.getHours()}`.padStart(2, \"0\");\n\tconst minutes = `${mtime.getMinutes()}`.padStart(2, \"0\");\n\treturn `${month} ${date} ${hours}:${minutes}`;\n};\n\nexport const getOwnerNameFromId = async (\n\tuid: string | number,\n): Promise<string | number> => {\n\tlet result: RunResult;\n\n\t/* istanbul ignore else */\n\tif (ownerNames[uid]) {\n\t\treturn ownerNames[uid];\n\t} else {\n\t\ttry {\n\t\t\tresult = await run(`id -nu ${uid}`);\n\t\t\townerNames[uid] = result.stdout;\n\t\t\treturn result.stdout;\n\t\t} catch {\n\t\t\t// nothing to declare officer\n\t\t\treturn `${uid}`;\n\t\t}\n\t}\n};\n\nexport const formatLongListings = async (\n\tstat: { mtime: Date; mode: number; uid: string | number; size: number },\n\ttype: string,\n): Promise<{\n\tmdate: string;\n\tmode: string;\n\towner: string;\n\tsize: string;\n}> => ({\n\tmdate: `${convertDate(stat.mtime)}`,\n\tmode: PERMISSIONS_PREFIX[type] + extractMode(stat.mode),\n\towner: `${await getOwnerNameFromId(stat.uid)}`,\n\tsize: `${convertSize(stat.size)}`,\n});\n\nexport type Statistics = {\n\tduration?: number;\n\ttotalDirScanned?: number;\n\ttotalDirsFound?: number;\n\ttotalFileScanned?: number;\n\ttotalFilesFound?: number;\n\ttype?: string;\n\tpattern?: boolean | RegExp;\n\tgrep?: boolean | RegExp | string;\n};\nexport const printStatistics = ({\n\tduration,\n\ttotalDirScanned,\n\ttotalDirsFound,\n\ttotalFileScanned,\n\ttotalFilesFound,\n\ttype,\n\tpattern,\n\tgrep,\n}: Statistics) => {\n\tlet message = `Total folders scanned: ${kleur.yellow(totalDirScanned)}\\n`;\n\tmessage += `Total files scanned: ${kleur.yellow(totalFileScanned)}\\n`;\n\tswitch (type) {\n\t\tcase STR_TYPE_DIRECTORY: {\n\t\t\tmessage += `Total folders matching: ${kleur.green(totalDirsFound)}\\n`;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase STR_TYPE_FILE: {\n\t\t\tmessage += `Total files matching: ${kleur.green(totalFilesFound)}\\n`;\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tif (pattern) {\n\t\t\t\tmessage += `Total folders matching: ${kleur.green(totalDirsFound)}\\n`;\n\t\t\t\tmessage += `Total files matching: ${kleur.green(totalFilesFound)}\\n`;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tmessage += `Duration: ${kleur.yellow(`${prettyMilliseconds(duration)}`)}`;\n\tif (!grep) {\n\t\tlogger.log();\n\t}\n\tlogger.printBox(message);\n};\n\nexport const checkPattern = (\n\trePattern: RegExp | undefined,\n\tstring_: string,\n): boolean | RegExpExecArray => {\n\tif (rePattern) {\n\t\trePattern.lastIndex = 0;\n\t\treturn rePattern.exec(string_);\n\t}\n\treturn true;\n};\n\nexport const runCommandOnNode = async (node: string, command: string) => {\n\ttry {\n\t\tconst { stdout } = await run(`${command} ${node}`);\n\t\tif (stdout) {\n\t\t\tlogger.log(stdout);\n\t\t}\n\t} catch {\n\t\t// nothing to declare officer\n\t}\n};\n\nexport type RunGrepOnNode = {\n\tresults: (string | number)[];\n\ttotalMatchingLines: number;\n};\nexport const runGrepOnNode = async (\n\tnode?: string,\n\trePattern?: RegExp,\n): Promise<RunGrepOnNode> => {\n\ttry {\n\t\tconst lines = [];\n\t\tlet totalMatchingLines = 0;\n\t\tconst buffer = fs.readFileSync(node, \"utf8\").split(\"\\n\");\n\n\t\tfor (const [lineNumber, line] of buffer.entries()) {\n\t\t\trePattern.lastIndex = 0;\n\t\t\tconst result: (string | number)[] = rePattern.exec(line);\n\t\t\tif (!result) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttotalMatchingLines++;\n\t\t\tif (lineNumber > 0) {\n\t\t\t\tlines.push(`${lineNumber}: ${kleur.grey(buffer[lineNumber - 1])}`);\n\t\t\t}\n\t\t\tlines.push(\n\t\t\t\t`${lineNumber + 1}: ${kleur.grey(\n\t\t\t\t\tline.replace(rePattern, kleur.black().bgYellow(result[0])),\n\t\t\t\t)}`,\n\t\t\t\t`${lineNumber + 2}: ${kleur.grey(buffer[lineNumber + 1])}`,\n\t\t\t\t\"\",\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tresults: lines.length > 0 ? lines : [],\n\t\t\ttotalMatchingLines,\n\t\t};\n\t} catch (error) {\n\t\t/* istanbul ignore next */\n\t\tlogger.error(error);\n\t}\n};\n"],"names":["run","fs","Logger","kleur","prettyMilliseconds","BYTE_CHUNKS","DECIMAL","LAST_THREE_ENTRIES","MODE_GROUP_POS","MODE_OWNER_POS","MODE_WORD_POS","OCTAL","STR_TYPE_DIRECTORY","STR_TYPE_FILE","STR_TYPE_BOTH","PERMISSIONS_PREFIX","ownerNames","MONTHS","logger","boring","process","env","NODE_ENV","extractMode","mode","modeDec","Number","parseInt","toString","slice","modeOwner","charAt","modeGroup","modeWorld","modes","convertSize","bytes","sizes","length","posttxt","string_","toFixed","Array","from","join","convertDate","mtime","month","getMonth","date","getDate","padStart","hours","getHours","minutes","getMinutes","getOwnerNameFromId","uid","result","stdout","formatLongListings","stat","type","mdate","owner","size","printStatistics","duration","totalDirScanned","totalDirsFound","totalFileScanned","totalFilesFound","pattern","grep","message","yellow","green","log","printBox","checkPattern","rePattern","lastIndex","exec","runCommandOnNode","node","command","runGrepOnNode","lines","totalMatchingLines","buffer","readFileSync","split","lineNumber","line","entries","push","grey","replace","black","bgYellow","results","error"],"mappings":"AAAA,SAAoBA,GAAG,QAAQ,gBAAgB;AAE/C,OAAOC,QAAQ,UAAU;AACzB,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,wBAAwB,YAAY;AAE3C,MAAMC,cAAc;AACpB,MAAMC,UAAU;AAChB,MAAMC,qBAAqB,CAAC;AAC5B,MAAMC,iBAAiB;AACvB,MAAMC,iBAAiB;AACvB,MAAMC,gBAAgB;AACtB,MAAMC,QAAQ;AACd,OAAO,MAAMC,qBAAqB,IAAI;AACtC,OAAO,MAAMC,gBAAgB,IAAI;AACjC,OAAO,MAAMC,gBAAgB,OAAO;AACpC,MAAMC,qBAAqB;IAC1B,CAACH,mBAAmB,EAAE;IACtB,CAACC,cAAc,EAAE;AAClB;AAEA,MAAMG,aAAa;IAClB,GAAG;AACJ;AAEA,MAAMC,SAAS;IACd,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GA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QAAQO,KAAK,CAAC;QAEnD,KAAK,MAAM,CAACC,YAAYC,KAAK,IAAIJ,OAAOK,OAAO,GAAI;YAClDd,UAAUC,SAAS,GAAG;YACtB,MAAMvB,SAA8BsB,UAAUE,IAAI,CAACW;YACnD,IAAI,CAACnC,QAAQ;gBACZ;YACD;YACA8B;YACA,IAAII,aAAa,GAAG;gBACnBL,MAAMQ,IAAI,CAAC,CAAC,EAAEH,WAAW,EAAE,EAAEzF,MAAM6F,IAAI,CAACP,MAAM,CAACG,aAAa,EAAE,EAAE,CAAC;YAClE;YACAL,MAAMQ,IAAI,CACT,CAAC,EAAEH,aAAa,EAAE,EAAE,EAAEzF,MAAM6F,IAAI,CAC/BH,KAAKI,OAAO,CAACjB,WAAW7E,MAAM+F,KAAK,GAAGC,QAAQ,CAACzC,MAAM,CAAC,EAAE,IACvD,CAAC,EACH,CAAC,EAAEkC,aAAa,EAAE,EAAE,EAAEzF,MAAM6F,IAAI,CAACP,MAAM,CAACG,aAAa,EAAE,EAAE,CAAC,EAC1D;QAEF;QACA,OAAO;YACNQ,SAASb,MAAMjD,MAAM,GAAG,IAAIiD,QAAQ,EAAE;YACtCC;QACD;IACD,EAAE,OAAOa,OAAO;QACf,wBAAwB,GACxBnF,OAAOmF,KAAK,CAACA;IACd;AACD,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/utilities.ts"],"sourcesContent":["import { RunResult, run } from \"@node-cli/run\";\n\nimport fs from \"node:fs\";\nimport { Logger } from \"@node-cli/logger\";\nimport kleur from \"kleur\";\nimport prettyMilliseconds from \"pretty-ms\";\n\nconst BYTE_CHUNKS = 1000;\nconst DECIMAL = 10;\nconst LAST_THREE_ENTRIES = -3;\nconst MODE_GROUP_POS = 1;\nconst MODE_OWNER_POS = 0;\nconst MODE_WORD_POS = 2;\nconst OCTAL = 8;\nexport const STR_TYPE_DIRECTORY = \"d\";\nexport const STR_TYPE_FILE = \"f\";\nexport const STR_TYPE_BOTH = \"both\";\nconst PERMISSIONS_PREFIX = {\n\t[STR_TYPE_DIRECTORY]: \"d\",\n\t[STR_TYPE_FILE]: \"-\",\n};\n\nconst ownerNames = {\n\t0: \"root\",\n};\n\nconst MONTHS = {\n\t0: \"Jan\",\n\t1: \"Feb\",\n\t2: \"Mar\",\n\t3: \"Apr\",\n\t4: \"May\",\n\t5: \"Jun\",\n\t6: \"Jul\",\n\t7: \"Aug\",\n\t8: \"Sep\",\n\t9: \"Oct\",\n\t10: \"Nov\",\n\t11: \"Dec\",\n};\n\nconst logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nexport const extractMode = (mode: number): string => {\n\tconst modeDec = Number.parseInt(mode.toString(OCTAL), DECIMAL)\n\t\t.toString()\n\t\t.slice(LAST_THREE_ENTRIES);\n\tconst modeOwner = modeDec.charAt(MODE_OWNER_POS);\n\tconst modeGroup = modeDec.charAt(MODE_GROUP_POS);\n\tconst modeWorld = modeDec.charAt(MODE_WORD_POS);\n\tconst modes = {\n\t\t0: \"---\",\n\t\t1: \"--x\",\n\t\t2: \"-w-\",\n\t\t3: \"-wx\",\n\t\t4: \"r--\",\n\t\t5: \"r-x\",\n\t\t6: \"rw-\",\n\t\t7: \"rwx\",\n\t};\n\treturn modes[modeOwner] + modes[modeGroup] + modes[modeWorld];\n};\n\nexport const convertSize = (bytes: number): string => {\n\tconst sizes = [\"B\", \"K\", \"M\", \"G\", \"T\"];\n\tconst length = 5;\n\tlet posttxt = 0;\n\n\twhile (bytes >= BYTE_CHUNKS) {\n\t\tposttxt = posttxt + 1;\n\t\tbytes = bytes / BYTE_CHUNKS;\n\t}\n\tconst string_ =\n\t\tNumber.parseInt(bytes.toString(), DECIMAL).toFixed(0) + sizes[posttxt];\n\treturn (\n\t\tArray.from({ length: length + 1 - string_.length }).join(\" \") + string_\n\t);\n};\n\nexport const convertDate = (mtime: Date): string => {\n\tconst month = MONTHS[mtime.getMonth()];\n\tconst date = `${mtime.getDate()}`.padStart(2, \"0\");\n\tconst hours = `${mtime.getHours()}`.padStart(2, \"0\");\n\tconst minutes = `${mtime.getMinutes()}`.padStart(2, \"0\");\n\treturn `${month} ${date} ${hours}:${minutes}`;\n};\n\nexport const getOwnerNameFromId = async (\n\tuid: string | number,\n): Promise<string | number> => {\n\tlet result: RunResult;\n\n\t/* istanbul ignore else */\n\tif (ownerNames[uid]) {\n\t\treturn ownerNames[uid];\n\t} else {\n\t\ttry {\n\t\t\tresult = await run(`id -nu ${uid}`);\n\t\t\townerNames[uid] = result.stdout;\n\t\t\treturn result.stdout;\n\t\t} catch {\n\t\t\t// nothing to declare officer\n\t\t\treturn `${uid}`;\n\t\t}\n\t}\n};\n\nexport const formatLongListings = async (\n\tstat: { mtime: Date; mode: number; uid: string | number; size: number },\n\ttype: string,\n): Promise<{\n\tmdate: string;\n\tmode: string;\n\towner: string;\n\tsize: string;\n}> => ({\n\tmdate: `${convertDate(stat.mtime)}`,\n\tmode: PERMISSIONS_PREFIX[type] + extractMode(stat.mode),\n\towner: `${await getOwnerNameFromId(stat.uid)}`,\n\tsize: `${convertSize(stat.size)}`,\n});\n\nexport type Statistics = {\n\tduration?: number;\n\ttotalDirScanned?: number;\n\ttotalDirsFound?: number;\n\ttotalFileScanned?: number;\n\ttotalFilesFound?: number;\n\ttype?: string;\n\tpattern?: boolean | RegExp;\n\tgrep?: boolean | RegExp | string;\n};\nexport const printStatistics = ({\n\tduration,\n\ttotalDirScanned,\n\ttotalDirsFound,\n\ttotalFileScanned,\n\ttotalFilesFound,\n\ttype,\n\tpattern,\n\tgrep,\n}: Statistics) => {\n\tlet message = `Total folders scanned: ${kleur.yellow(totalDirScanned)}\\n`;\n\tmessage += `Total files scanned: ${kleur.yellow(totalFileScanned)}\\n`;\n\tswitch (type) {\n\t\tcase STR_TYPE_DIRECTORY: {\n\t\t\tmessage += `Total folders matching: ${kleur.green(totalDirsFound)}\\n`;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase STR_TYPE_FILE: {\n\t\t\tmessage += `Total files matching: ${kleur.green(totalFilesFound)}\\n`;\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tif (pattern) {\n\t\t\t\tmessage += `Total folders matching: ${kleur.green(totalDirsFound)}\\n`;\n\t\t\t\tmessage += `Total files matching: ${kleur.green(totalFilesFound)}\\n`;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tmessage += `Duration: ${kleur.yellow(`${prettyMilliseconds(duration)}`)}`;\n\tif (!grep) {\n\t\tlogger.log();\n\t}\n\tlogger.printBox(message);\n};\n\nexport const checkPattern = (\n\trePattern: RegExp | undefined,\n\tstring_: string,\n): boolean | RegExpExecArray => {\n\tif (rePattern) {\n\t\trePattern.lastIndex = 0;\n\t\treturn rePattern.exec(string_);\n\t}\n\treturn true;\n};\n\nexport const runCommandOnNode = async (node: string, command: string) => {\n\ttry {\n\t\tconst { stdout } = await run(`${command} ${node}`);\n\t\tif (stdout) {\n\t\t\tlogger.log(stdout);\n\t\t}\n\t} catch {\n\t\t// nothing to declare officer\n\t}\n};\n\nexport type RunGrepOnNode = {\n\tresults: (string | number)[];\n\ttotalMatchingLines: number;\n};\nexport const runGrepOnNode = async (\n\tnode?: string,\n\trePattern?: RegExp,\n): Promise<RunGrepOnNode> => {\n\ttry {\n\t\tconst lines = [];\n\t\tlet totalMatchingLines = 0;\n\t\tconst buffer = fs.readFileSync(node, \"utf8\").split(\"\\n\");\n\n\t\tfor (const [lineNumber, line] of buffer.entries()) {\n\t\t\trePattern.lastIndex = 0;\n\t\t\tconst result: (string | number)[] = rePattern.exec(line);\n\t\t\tif (!result) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttotalMatchingLines++;\n\t\t\tif (lineNumber > 0) {\n\t\t\t\tlines.push(`${lineNumber}: ${kleur.grey(buffer[lineNumber - 1])}`);\n\t\t\t}\n\t\t\tlines.push(\n\t\t\t\t`${lineNumber + 1}: ${kleur.grey(\n\t\t\t\t\tline.replace(rePattern, kleur.black().bgYellow(result[0])),\n\t\t\t\t)}`,\n\t\t\t\t`${lineNumber + 2}: ${kleur.grey(buffer[lineNumber + 1])}`,\n\t\t\t\t\"\",\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tresults: lines.length > 0 ? lines : [],\n\t\t\ttotalMatchingLines,\n\t\t};\n\t} catch (error) {\n\t\t/* istanbul ignore next */\n\t\tlogger.error(error);\n\t}\n};\n"],"names":["run","fs","Logger","kleur","prettyMilliseconds","BYTE_CHUNKS","DECIMAL","LAST_THREE_ENTRIES","MODE_GROUP_POS","MODE_OWNER_POS","MODE_WORD_POS","OCTAL","STR_TYPE_DIRECTORY","STR_TYPE_FILE","STR_TYPE_BOTH","PERMISSIONS_PREFIX","ownerNames","MONTHS","logger","boring","process","env","NODE_ENV","extractMode","mode","modeDec","Number","parseInt","toString","slice","modeOwner","charAt","modeGroup","modeWorld","modes","convertSize","bytes","sizes","length","posttxt","string_","toFixed","Array","from","join","convertDate","mtime","month","getMonth","date","getDate","padStart","hours","getHours","minutes","getMinutes","getOwnerNameFromId","uid","result","stdout","formatLongListings","stat","type","mdate","owner","size","printStatistics","duration","totalDirScanned","totalDirsFound","totalFileScanned","totalFilesFound","pattern","grep","message","yellow","green","log","printBox","checkPattern","rePattern","lastIndex","exec","runCommandOnNode","node","command","runGrepOnNode","lines","totalMatchingLines","buffer","readFileSync","split","lineNumber","line","entries","push","grey","replace","black","bgYellow","results","error"],"mappings":"AAAA,SAAoBA,GAAG,QAAQ,gBAAgB;AAE/C,OAAOC,QAAQ,UAAU;AACzB,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,wBAAwB,YAAY;AAE3C,MAAMC,cAAc;AACpB,MAAMC,UAAU;AAChB,MAAMC,qBAAqB,CAAC;AAC5B,MAAMC,iBAAiB;AACvB,MAAMC,iBAAiB;AACvB,MAAMC,gBAAgB;AACtB,MAAMC,QAAQ;AACd,OAAO,MAAMC,qBAAqB,IAAI;AACtC,OAAO,MAAMC,gBAAg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;AAMF,OAAO,MAAM2B,gBAAgB,OAC5BF,MACAJ;IAEA,IAAI;QACH,MAAMO,QAAQ,EAAE;QAChB,IAAIC,qBAAqB;QACzB,MAAMC,SAASxF,GAAGyF,YAAY,CAACN,MAAM,QAAQO,KAAK,CAAC;QAEnD,KAAK,MAAM,CAACC,YAAYC,KAAK,IAAIJ,OAAOK,OAAO,GAAI;YAClDd,UAAUC,SAAS,GAAG;YACtB,MAAMvB,SAA8BsB,UAAUE,IAAI,CAACW;YACnD,IAAI,CAACnC,QAAQ;gBACZ;YACD;YACA8B;YACA,IAAII,aAAa,GAAG;gBACnBL,MAAMQ,IAAI,CAAC,GAAGH,WAAW,EAAE,EAAEzF,MAAM6F,IAAI,CAACP,MAAM,CAACG,aAAa,EAAE,GAAG;YAClE;YACAL,MAAMQ,IAAI,CACT,GAAGH,aAAa,EAAE,EAAE,EAAEzF,MAAM6F,IAAI,CAC/BH,KAAKI,OAAO,CAACjB,WAAW7E,MAAM+F,KAAK,GAAGC,QAAQ,CAACzC,MAAM,CAAC,EAAE,KACtD,EACH,GAAGkC,aAAa,EAAE,EAAE,EAAEzF,MAAM6F,IAAI,CAACP,MAAM,CAACG,aAAa,EAAE,GAAG,EAC1D;QAEF;QACA,OAAO;YACNQ,SAASb,MAAMjD,MAAM,GAAG,IAAIiD,QAAQ,EAAE;YACtCC;QACD;IACD,EAAE,OAAOa,OAAO;QACf,wBAAwB,GACxBnF,OAAOmF,KAAK,CAACA;IACd;AACD,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-cli/search",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"description": "Search for files in a directory",
|
|
@@ -21,20 +21,22 @@
|
|
|
21
21
|
"lint": "biome lint src",
|
|
22
22
|
"test": "cross-env-shell NODE_OPTIONS=--experimental-vm-modules TZ=UTC jest",
|
|
23
23
|
"test:coverage": "npm run test -- --coverage",
|
|
24
|
+
"test:watch": "npm run test -- --watch",
|
|
24
25
|
"watch": "swc --strip-leading-paths --watch --out-dir dist src"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@node-cli/logger": "1.2.
|
|
28
|
-
"@node-cli/parser": "2.
|
|
28
|
+
"@node-cli/logger": "1.2.6",
|
|
29
|
+
"@node-cli/parser": "2.4.0",
|
|
29
30
|
"@node-cli/perf": "1.0.6",
|
|
30
|
-
"@node-cli/run": "1.1.
|
|
31
|
-
"fs-extra": "11.
|
|
31
|
+
"@node-cli/run": "1.1.2",
|
|
32
|
+
"fs-extra": "11.3.0",
|
|
32
33
|
"kleur": "4.1.5",
|
|
34
|
+
"micromatch": "4.0.8",
|
|
33
35
|
"plur": "5.1.0",
|
|
34
|
-
"pretty-ms": "9.
|
|
36
|
+
"pretty-ms": "9.2.0"
|
|
35
37
|
},
|
|
36
38
|
"publishConfig": {
|
|
37
39
|
"access": "public"
|
|
38
40
|
},
|
|
39
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "ee678925a3a2d06a9f32d6279b4df37a131d4fab"
|
|
40
42
|
}
|