raggrep 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/main.js +50 -2
- package/dist/cli/main.js.map +5 -5
- package/dist/index.js +49 -1
- package/dist/index.js.map +5 -5
- package/dist/infrastructure/storage/literalIndex.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3183,6 +3183,11 @@ var init_symbolicIndex = __esm(() => {
|
|
|
3183
3183
|
});
|
|
3184
3184
|
|
|
3185
3185
|
// src/infrastructure/storage/literalIndex.ts
|
|
3186
|
+
var exports_literalIndex = {};
|
|
3187
|
+
__export(exports_literalIndex, {
|
|
3188
|
+
getLiteralIndexPath: () => getLiteralIndexPath,
|
|
3189
|
+
LiteralIndex: () => LiteralIndex
|
|
3190
|
+
});
|
|
3186
3191
|
import * as fs4 from "fs/promises";
|
|
3187
3192
|
import * as path9 from "path";
|
|
3188
3193
|
|
|
@@ -3235,6 +3240,22 @@ class LiteralIndex {
|
|
|
3235
3240
|
}
|
|
3236
3241
|
}
|
|
3237
3242
|
}
|
|
3243
|
+
removeFile(filepath) {
|
|
3244
|
+
let removed = 0;
|
|
3245
|
+
for (const [key, entries] of this.entries) {
|
|
3246
|
+
const filtered = entries.filter((e) => e.filepath !== filepath);
|
|
3247
|
+
const removedCount = entries.length - filtered.length;
|
|
3248
|
+
if (removedCount > 0) {
|
|
3249
|
+
removed += removedCount;
|
|
3250
|
+
if (filtered.length === 0) {
|
|
3251
|
+
this.entries.delete(key);
|
|
3252
|
+
} else {
|
|
3253
|
+
this.entries.set(key, filtered);
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
return removed;
|
|
3258
|
+
}
|
|
3238
3259
|
findMatches(queryLiterals) {
|
|
3239
3260
|
const matches = [];
|
|
3240
3261
|
for (const queryLiteral of queryLiterals) {
|
|
@@ -3327,6 +3348,9 @@ function shouldReplaceMatchType(existing, incoming) {
|
|
|
3327
3348
|
};
|
|
3328
3349
|
return priority[incoming] > priority[existing];
|
|
3329
3350
|
}
|
|
3351
|
+
function getLiteralIndexPath(rootDir, moduleId, indexDir = ".raggrep") {
|
|
3352
|
+
return path9.join(rootDir, indexDir, "index", moduleId, "literals");
|
|
3353
|
+
}
|
|
3330
3354
|
var init_literalIndex = () => {};
|
|
3331
3355
|
|
|
3332
3356
|
// src/infrastructure/storage/index.ts
|
|
@@ -3489,6 +3513,16 @@ class TypeScriptModule {
|
|
|
3489
3513
|
await this.symbolicIndex.save();
|
|
3490
3514
|
this.literalIndex = new LiteralIndex(indexDir, this.id);
|
|
3491
3515
|
await this.literalIndex.initialize();
|
|
3516
|
+
const indexedFilepaths = new Set;
|
|
3517
|
+
for (const filepath of this.pendingSummaries.keys()) {
|
|
3518
|
+
indexedFilepaths.add(filepath);
|
|
3519
|
+
}
|
|
3520
|
+
for (const { filepath } of this.pendingLiterals.values()) {
|
|
3521
|
+
indexedFilepaths.add(filepath);
|
|
3522
|
+
}
|
|
3523
|
+
for (const filepath of indexedFilepaths) {
|
|
3524
|
+
this.literalIndex.removeFile(filepath);
|
|
3525
|
+
}
|
|
3492
3526
|
for (const [chunkId, { filepath, literals }] of this.pendingLiterals) {
|
|
3493
3527
|
this.literalIndex.addLiterals(chunkId, filepath, literals);
|
|
3494
3528
|
}
|
|
@@ -4846,6 +4880,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
4846
4880
|
filesToRemove.push(filepath);
|
|
4847
4881
|
}
|
|
4848
4882
|
}
|
|
4883
|
+
const removedFilepaths = [];
|
|
4849
4884
|
for (const filepath of filesToRemove) {
|
|
4850
4885
|
logger.debug(` Removing stale: ${filepath}`);
|
|
4851
4886
|
const indexFilePath = path15.join(indexPath, filepath.replace(/\.[^.]+$/, ".json"));
|
|
@@ -4857,8 +4892,21 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
4857
4892
|
await fs7.unlink(symbolicFilePath);
|
|
4858
4893
|
} catch {}
|
|
4859
4894
|
delete manifest.files[filepath];
|
|
4895
|
+
removedFilepaths.push(filepath);
|
|
4860
4896
|
totalRemoved++;
|
|
4861
4897
|
}
|
|
4898
|
+
if (removedFilepaths.length > 0) {
|
|
4899
|
+
try {
|
|
4900
|
+
const { LiteralIndex: LiteralIndex2 } = await Promise.resolve().then(() => (init_literalIndex(), exports_literalIndex));
|
|
4901
|
+
const raggrepDir = getRaggrepDir(rootDir, config);
|
|
4902
|
+
const literalIndex = new LiteralIndex2(raggrepDir, module.id);
|
|
4903
|
+
await literalIndex.initialize();
|
|
4904
|
+
for (const filepath of removedFilepaths) {
|
|
4905
|
+
literalIndex.removeFile(filepath);
|
|
4906
|
+
}
|
|
4907
|
+
await literalIndex.save();
|
|
4908
|
+
} catch {}
|
|
4909
|
+
}
|
|
4862
4910
|
const ctx = {
|
|
4863
4911
|
rootDir,
|
|
4864
4912
|
config,
|
|
@@ -5406,4 +5454,4 @@ export {
|
|
|
5406
5454
|
ConsoleLogger
|
|
5407
5455
|
};
|
|
5408
5456
|
|
|
5409
|
-
//# debugId=
|
|
5457
|
+
//# debugId=F5160C7762E8AC7864756E2164756E21
|