@appland/search 1.2.2 → 1.2.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # [@appland/search-v1.2.3](https://github.com/getappmap/appmap-js/compare/@appland/search-v1.2.2...@appland/search-v1.2.3) (2025-07-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Improve worst case performance of file indexing ([3a8baa1](https://github.com/getappmap/appmap-js/commit/3a8baa18f7fdb7b4ecf8df91ce2f4ff27ea13d18))
7
+ * Optimize file indexing by caching binary content by file extension ([e402f68](https://github.com/getappmap/appmap-js/commit/e402f6872ce041bab0e5b4124ff9fa059bc5b321))
8
+ * Prevent file index from being re-created ([d59717f](https://github.com/getappmap/appmap-js/commit/d59717fd7b09d60608625d0b3ecd14cbe82b975f))
9
+
1
10
  # [@appland/search-v1.2.2](https://github.com/getappmap/appmap-js/compare/@appland/search-v1.2.1...@appland/search-v1.2.2) (2025-05-01)
2
11
 
3
12
 
package/LICENSE.txt ADDED
@@ -0,0 +1,25 @@
1
+ The Software is provided to you by the Licensor under the License, as defined below, subject to the following condition.
2
+
3
+ Without limiting other conditions in the License, the grant of rights under the License will not include,
4
+ and the License does not grant to you, the right to Sell the Software.
5
+
6
+ For purposes of the foregoing, “Sell” means practicing any or all of the rights granted to you under the License to provide to third parties,
7
+ for a fee or other consideration (including without limitation fees for hosting or consulting/ support services related to the Software),
8
+ a product or service whose value derives, entirely or substantially, from the functionality of the Software.
9
+ Any license notice or attribution required by the License must also include this Commons Clause License Condition notice.
10
+
11
+ Software: @appland/search
12
+
13
+ License: MIT License
14
+
15
+ Copyright 2025, AppLand Inc
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
18
+ to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
19
+ and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/built/cli.js CHANGED
@@ -48,7 +48,7 @@ const cli = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
48
48
  filterRE = new RegExp(argv.fileFilter);
49
49
  const fileFilter = async (path) => {
50
50
  debug('Filtering: %s', path);
51
- if ((0, file_type_1.isBinaryFile)(path)) {
51
+ if (await (0, file_type_1.isBinaryFile)(path)) {
52
52
  debug('Skipping binary file: %s', path);
53
53
  return false;
54
54
  }
@@ -77,9 +77,9 @@ class FileIndex {
77
77
  const version = this.database
78
78
  .prepare("SELECT value FROM metadata WHERE key = 'schema_version'")
79
79
  .get();
80
- if (!version?.version)
80
+ if (!version?.value)
81
81
  return undefined;
82
- return String(version.version);
82
+ return String(version.value);
83
83
  }
84
84
  catch (error) {
85
85
  debug('Error retrieving schema version: %s', error);
@@ -1,3 +1,4 @@
1
1
  export declare const isLargeFile: (fileName: string) => Promise<boolean>;
2
- export declare const isBinaryFile: (filePath: string) => boolean;
2
+ export declare const getFileExtensions: (filePath: string) => string[];
3
+ export declare const isBinaryFile: (filePath: string) => Promise<boolean>;
3
4
  export declare const isDataFile: (fileName: string) => boolean;
@@ -3,78 +3,123 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isDataFile = exports.isBinaryFile = exports.isLargeFile = void 0;
6
+ exports.isDataFile = exports.isBinaryFile = exports.getFileExtensions = exports.isLargeFile = void 0;
7
7
  const promises_1 = require("fs/promises");
8
8
  const debug_1 = __importDefault(require("debug"));
9
9
  const isbinaryfile_1 = require("isbinaryfile");
10
+ const path_1 = require("path");
10
11
  const debug = (0, debug_1.default)('appmap:search:file-type');
11
- const BINARY_FILE_EXTENSIONS = [
12
- '7z',
13
- 'aac',
14
- 'avi',
15
- 'bmp',
16
- 'bz2',
17
- 'class',
18
- 'dll',
19
- 'doc',
20
- 'docx',
21
- 'dylib',
22
- 'ear',
23
- 'exe',
24
- 'eot',
25
- 'flac',
26
- 'flv',
27
- 'gif',
28
- 'gz',
29
- 'ico',
30
- 'jar',
31
- 'jpeg',
32
- 'jpg',
33
- 'js.map',
34
- 'min.js',
35
- 'min.css',
36
- 'mkv',
37
- 'mo',
38
- 'mov',
39
- 'mp3',
40
- 'mp4',
41
- 'mpg',
42
- 'odt',
43
- 'odp',
44
- 'ods',
45
- 'ogg',
46
- 'otf',
47
- 'pdf',
48
- 'po',
49
- 'png',
50
- 'ppt',
51
- 'pptx',
52
- 'pyc',
53
- 'rar',
54
- 'rtf',
55
- 'so',
56
- 'svg',
57
- 'tar',
58
- 'tiff',
59
- 'ttf',
60
- 'wav',
61
- 'webm',
62
- 'webp',
63
- 'woff',
64
- 'woff2',
65
- 'wmv',
66
- 'xls',
67
- 'xlsx',
68
- 'xz',
69
- 'yarn.lock',
70
- 'zip',
71
- ].map((ext) => '.' + ext);
12
+ const BINARY_FILE_MEMO = new Map([
13
+ // Binary files
14
+ ['.7z', true],
15
+ ['.aac', true],
16
+ ['.avi', true],
17
+ ['.bin', true],
18
+ ['.bmp', true],
19
+ ['.bz2', true],
20
+ ['.class', true],
21
+ ['.data', true],
22
+ ['.dat', true],
23
+ ['.dll', true],
24
+ ['.doc', true],
25
+ ['.docx', true],
26
+ ['.dylib', true],
27
+ ['.ear', true],
28
+ ['.exe', true],
29
+ ['.eot', true],
30
+ ['.flac', true],
31
+ ['.flv', true],
32
+ ['.gif', true],
33
+ ['.gz', true],
34
+ ['.ico', true],
35
+ ['.jar', true],
36
+ ['.jpeg', true],
37
+ ['.jpg', true],
38
+ ['.js.map', true],
39
+ ['.min.js', true],
40
+ ['.min.css', true],
41
+ ['.mkv', true],
42
+ ['.mo', true],
43
+ ['.mov', true],
44
+ ['.mp3', true],
45
+ ['.mp4', true],
46
+ ['.mpg', true],
47
+ ['.odt', true],
48
+ ['.odp', true],
49
+ ['.ods', true],
50
+ ['.ogg', true],
51
+ ['.otf', true],
52
+ ['.pdf', true],
53
+ ['.po', true],
54
+ ['.png', true],
55
+ ['.ppt', true],
56
+ ['.pptx', true],
57
+ ['.pyc', true],
58
+ ['.rar', true],
59
+ ['.rtf', true],
60
+ ['.so', true],
61
+ ['.svg', true],
62
+ ['.tar', true],
63
+ ['.tiff', true],
64
+ ['.ttf', true],
65
+ ['.wav', true],
66
+ ['.webm', true],
67
+ ['.webp', true],
68
+ ['.woff', true],
69
+ ['.woff2', true],
70
+ ['.wmv', true],
71
+ ['.xls', true],
72
+ ['.xlsx', true],
73
+ ['.xz', true],
74
+ ['.yarn.lock', true],
75
+ ['.zip', true],
76
+ // Source code files
77
+ ['.cjs', false],
78
+ ['.mjs', false],
79
+ ['.coffee', false],
80
+ ['.dart', false],
81
+ ['.el', false],
82
+ ['.elm', false],
83
+ ['.js', false],
84
+ ['.ts', false],
85
+ ['.jsx', false],
86
+ ['.tsx', false],
87
+ ['.py', false],
88
+ ['.java', false],
89
+ ['.rb', false],
90
+ ['.php', false],
91
+ ['.go', false],
92
+ ['.rs', false],
93
+ ['.cpp', false],
94
+ ['.cc', false],
95
+ ['.cxx', false],
96
+ ['.h', false],
97
+ ['.hpp', false],
98
+ ['.cs', false],
99
+ ['.swift', false],
100
+ ['.kt', false],
101
+ ['.kts', false],
102
+ ['.scala', false],
103
+ ['.lua', false],
104
+ ['.sh', false],
105
+ ['.bat', false],
106
+ ['.pl', false],
107
+ ['.sql', false],
108
+ ['.html', false],
109
+ ['.htm', false],
110
+ ['.css', false],
111
+ ['.scss', false],
112
+ ['.sass', false],
113
+ ['.less', false],
114
+ ['.vue', false],
115
+ ]);
72
116
  const DATA_FILE_EXTENSIONS = [
73
117
  'cjs',
74
118
  'csv',
75
119
  'dat',
76
120
  'log',
77
121
  'json',
122
+ 'toml',
78
123
  'tsv',
79
124
  'yaml',
80
125
  'yml',
@@ -108,11 +153,35 @@ const isLargeFile = async (fileName) => {
108
153
  return fileSize > largeFileThreshold();
109
154
  };
110
155
  exports.isLargeFile = isLargeFile;
111
- const isBinaryFile = (filePath) => {
112
- if (BINARY_FILE_EXTENSIONS.some((ext) => filePath.endsWith(ext)))
113
- return true;
156
+ /* Returns unique file extensions for the given file path.
157
+ * E.g., for 'example.tar.gz', it returns [ '.tar.gz', '.gz'].
158
+ */
159
+ const getFileExtensions = (filePath) => {
160
+ const fileName = (0, path_1.basename)(filePath).toLowerCase();
161
+ const parts = fileName.split('.');
162
+ if (parts.length <= 1)
163
+ return [];
164
+ const extensions = [];
165
+ for (let i = 1; i < parts.length; i++) {
166
+ const ext = '.' + parts.slice(i).join('.');
167
+ extensions.push(ext);
168
+ }
169
+ return extensions;
170
+ };
171
+ exports.getFileExtensions = getFileExtensions;
172
+ const isBinaryFile = async (filePath) => {
173
+ const fileExtensions = (0, exports.getFileExtensions)(filePath);
174
+ for (const ext of fileExtensions) {
175
+ if (BINARY_FILE_MEMO.has(ext)) {
176
+ return BINARY_FILE_MEMO.get(ext) === true;
177
+ }
178
+ }
114
179
  try {
115
- return (0, isbinaryfile_1.isBinaryFileSync)(filePath);
180
+ const isBinary = await (0, isbinaryfile_1.isBinaryFile)(filePath);
181
+ fileExtensions.forEach((ext) => {
182
+ BINARY_FILE_MEMO.set(ext, isBinary);
183
+ });
184
+ return isBinary;
116
185
  }
117
186
  catch (error) {
118
187
  debug(`Error reading file: %s`, filePath);
package/built/git.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Git = exports.GitCommitEnvKeys = exports.GitBranchEnvKeys = exports.GitRepositoryEnvKeys = exports.GitState = void 0;
4
- const child_process_1 = require("child_process");
4
+ const node_child_process_1 = require("node:child_process");
5
5
  const util_1 = require("util");
6
- const exec = (0, util_1.promisify)(child_process_1.exec);
6
+ const exec = (0, util_1.promisify)(node_child_process_1.exec);
7
7
  var GitState;
8
8
  (function (GitState) {
9
9
  GitState[GitState["NotInstalled"] = 0] = "NotInstalled";
@@ -102,7 +102,7 @@ class GitProperties {
102
102
  static async state(cwd) {
103
103
  return new Promise((resolve) => {
104
104
  try {
105
- const commandProcess = (0, child_process_1.spawn)('git', ['status', '--porcelain'], {
105
+ const commandProcess = (0, node_child_process_1.spawn)('git', ['status', '--porcelain'], {
106
106
  shell: true,
107
107
  cwd: cwd?.toString(),
108
108
  stdio: 'ignore',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appland/search",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "",
5
5
  "bin": "built/cli.js",
6
6
  "publishConfig": {