@appland/search 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +7 -0
- package/built/build-file-index.js +4 -0
- package/built/file-type.d.ts +1 -1
- package/built/file-type.js +12 -2
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# [@appland/search-v1.0.1](https://github.com/getappmap/appmap-js/compare/@appland/search-v1.0.0...@appland/search-v1.0.1) (2024-12-01)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Detect and skip binary files when indexing ([b42fedf](https://github.com/getappmap/appmap-js/commit/b42fedf258e42539243f3aea2727115846b8f19b))
|
7
|
+
|
1
8
|
# @appland/search-v1.0.0 (2024-11-06)
|
2
9
|
|
3
10
|
|
@@ -9,13 +9,17 @@ const path_1 = require("path");
|
|
9
9
|
const console_1 = require("console");
|
10
10
|
const debug = (0, debug_1.default)('appmap:search:build-index');
|
11
11
|
async function indexFile(context, filePath) {
|
12
|
+
debug('Indexing file: %s', filePath);
|
12
13
|
const fileContents = await context.contentReader(filePath);
|
13
14
|
if (!fileContents)
|
14
15
|
return;
|
16
|
+
debug('Read file: %s, length: %d (%s...)', filePath, fileContents.length, fileContents.slice(0, 40));
|
15
17
|
const tokens = context.tokenizer(fileContents, filePath);
|
16
18
|
const symbols = tokens.symbols.join(' ');
|
17
19
|
const words = tokens.words.join(' ');
|
20
|
+
debug('Tokenized file: %s', filePath);
|
18
21
|
context.fileIndex.indexFile(context.baseDirectory, filePath, symbols, words);
|
22
|
+
debug('Wrote file to index: %s', filePath);
|
19
23
|
}
|
20
24
|
async function indexDirectory(context, directory) {
|
21
25
|
const dirContents = await context.listDirectory(directory);
|
package/built/file-type.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
export declare const isLargeFile: (fileName: string) => Promise<boolean>;
|
2
|
-
export declare const isBinaryFile: (
|
2
|
+
export declare const isBinaryFile: (filePath: string) => boolean;
|
3
3
|
export declare const isDataFile: (fileName: string) => boolean;
|
package/built/file-type.js
CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isDataFile = exports.isBinaryFile = exports.isLargeFile = void 0;
|
7
7
|
const promises_1 = require("fs/promises");
|
8
8
|
const debug_1 = __importDefault(require("debug"));
|
9
|
+
const isbinaryfile_1 = require("isbinaryfile");
|
9
10
|
const debug = (0, debug_1.default)('appmap:search:file-type');
|
10
11
|
const BINARY_FILE_EXTENSIONS = [
|
11
12
|
'7z',
|
@@ -107,8 +108,17 @@ const isLargeFile = async (fileName) => {
|
|
107
108
|
return fileSize > largeFileThreshold();
|
108
109
|
};
|
109
110
|
exports.isLargeFile = isLargeFile;
|
110
|
-
const isBinaryFile = (
|
111
|
-
|
111
|
+
const isBinaryFile = (filePath) => {
|
112
|
+
if (BINARY_FILE_EXTENSIONS.some((ext) => filePath.endsWith(ext)))
|
113
|
+
return true;
|
114
|
+
try {
|
115
|
+
return (0, isbinaryfile_1.isBinaryFileSync)(filePath);
|
116
|
+
}
|
117
|
+
catch (error) {
|
118
|
+
debug(`Error reading file: %s`, filePath);
|
119
|
+
debug(error);
|
120
|
+
return false;
|
121
|
+
}
|
112
122
|
};
|
113
123
|
exports.isBinaryFile = isBinaryFile;
|
114
124
|
const isDataFile = (fileName) => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@appland/search",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.1",
|
4
4
|
"description": "",
|
5
5
|
"bin": "built/cli.js",
|
6
6
|
"publishConfig": {
|
@@ -40,6 +40,7 @@
|
|
40
40
|
},
|
41
41
|
"dependencies": {
|
42
42
|
"better-sqlite3": "^11.5.0",
|
43
|
+
"isbinaryfile": "^5.0.4",
|
43
44
|
"yargs": "^17.7.2"
|
44
45
|
}
|
45
46
|
}
|