scip-query 0.3.5 → 0.4.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/README.md +2 -1
- package/dist/{chunk-VMM4SYV4.js → chunk-24LF6IZB.js} +17 -4
- package/dist/{chunk-EPWLXXBL.js → chunk-3NJSJ7TE.js} +28 -30
- package/dist/{chunk-SMDCNPMK.js → chunk-43A4UCS7.js} +3 -3
- package/dist/{chunk-CHDJXYBG.js → chunk-5GCORUNV.js} +3 -3
- package/dist/{chunk-OIDHN6GD.js → chunk-6CH23IAS.js} +148 -7
- package/dist/chunk-6ECR2FLR.js +60 -0
- package/dist/{chunk-C7H5WBTJ.js → chunk-6UZU7DFL.js} +3 -3
- package/dist/chunk-7BS4CPJX.js +162 -0
- package/dist/{chunk-UGQKAVCD.js → chunk-A6XLXV6W.js} +3 -3
- package/dist/chunk-ALUFWH3U.js +2695 -0
- package/dist/{chunk-F7XU27LU.js → chunk-CBIWNZZZ.js} +27 -3
- package/dist/{chunk-26DOJ63W.js → chunk-DUJNJQPO.js} +14 -3
- package/dist/{chunk-GSH2FPKV.js → chunk-EAGKJFDX.js} +3 -3
- package/dist/{chunk-VIYSWZCO.js → chunk-ELFGD5EW.js} +32 -4
- package/dist/chunk-FVJE4MQL.js +37 -0
- package/dist/{chunk-NFS5W3PP.js → chunk-GNAMV3JC.js} +3 -3
- package/dist/{chunk-TRESG7OB.js → chunk-J47VSL6I.js} +3 -3
- package/dist/chunk-J6QXMYAQ.js +115 -0
- package/dist/{chunk-6FKIA6EI.js → chunk-JHVQB4Y5.js} +12 -12
- package/dist/{chunk-YY4QGUQ5.js → chunk-JKXHHV4B.js} +2 -2
- package/dist/{chunk-EN2Z2CLO.js → chunk-KG4OFQEN.js} +17 -20
- package/dist/chunk-KLNKDX6A.js +110 -0
- package/dist/{chunk-5OMVSV6E.js → chunk-KYPXKV64.js} +3 -3
- package/dist/chunk-NXUIWD6K.js +87 -0
- package/dist/{chunk-LFJQVJYJ.js → chunk-OXX3QF24.js} +2 -2
- package/dist/{chunk-NG5F43OU.js → chunk-P3VCDYMJ.js} +70 -1
- package/dist/{chunk-7HK5ZLOE.js → chunk-PCU455MX.js} +2 -2
- package/dist/{chunk-O7Q7FDUJ.js → chunk-POLELLNM.js} +3 -3
- package/dist/chunk-PU2254N2.js +115 -0
- package/dist/{chunk-WGAD3GNR.js → chunk-QMXSLHZP.js} +5 -5
- package/dist/{chunk-YDBXNPYU.js → chunk-R7HPHMRZ.js} +3 -3
- package/dist/{chunk-HLUS2HEB.js → chunk-RE7POFGI.js} +5 -4
- package/dist/{chunk-VT4JBH6L.js → chunk-RJ5GULL6.js} +2 -2
- package/dist/{chunk-7KIMF5PV.js → chunk-RL74LF47.js} +2 -2
- package/dist/chunk-SVLUJSY7.js +75 -0
- package/dist/chunk-SYQR4QGK.js +38 -0
- package/dist/{chunk-QIXNAB5K.js → chunk-TO3L4YNK.js} +1 -2
- package/dist/{chunk-P3E6L7KW.js → chunk-TWVXFKJA.js} +84 -4
- package/dist/chunk-UJWI5CBB.js +75 -0
- package/dist/{chunk-J3JSOSUO.js → chunk-VKBOLNYN.js} +3 -3
- package/dist/{chunk-KBOQX573.js → chunk-VY2L4TP6.js} +20 -3
- package/dist/{chunk-KKCHYLVI.js → chunk-W46L2BXT.js} +2 -2
- package/dist/chunk-XUVPQDXW.js +34 -0
- package/dist/{chunk-DH7G3DDV.js → chunk-Z5VSUOEE.js} +2 -2
- package/dist/{chunk-GEXE2T6I.js → chunk-ZVZAIIB5.js} +23 -15
- package/dist/cli.js +2838 -870
- package/dist/{db-viWlyVtv.d.ts → db-C4rPbKkI.d.ts} +6 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +376 -142
- package/dist/postinstall.js +9 -3
- package/dist/queries/affected.d.ts +1 -1
- package/dist/queries/affected.js +3 -3
- package/dist/queries/bottlenecks.d.ts +1 -1
- package/dist/queries/bottlenecks.js +3 -2
- package/dist/queries/by-kind.d.ts +1 -1
- package/dist/queries/by-kind.js +3 -2
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +3 -3
- package/dist/queries/change-surface.d.ts +1 -1
- package/dist/queries/change-surface.js +3 -3
- package/dist/queries/code.d.ts +1 -1
- package/dist/queries/code.js +3 -3
- package/dist/queries/complexity-hotspots.d.ts +1 -1
- package/dist/queries/complexity-hotspots.js +3 -3
- package/dist/queries/complexity.d.ts +1 -1
- package/dist/queries/complexity.js +3 -3
- package/dist/queries/convergence.d.ts +1 -1
- package/dist/queries/convergence.js +3 -3
- package/dist/queries/coupling.d.ts +1 -1
- package/dist/queries/coupling.js +3 -3
- package/dist/queries/cycles.d.ts +1 -1
- package/dist/queries/cycles.js +3 -3
- package/dist/queries/dataflow.d.ts +1 -1
- package/dist/queries/dataflow.js +3 -3
- package/dist/queries/dead.d.ts +1 -1
- package/dist/queries/dead.js +4 -4
- package/dist/queries/deep-chains.d.ts +1 -1
- package/dist/queries/deep-chains.js +3 -3
- package/dist/queries/deps.d.ts +1 -1
- package/dist/queries/deps.js +3 -3
- package/dist/queries/diff-impact.d.ts +1 -1
- package/dist/queries/diff-impact.js +2 -2
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +3 -3
- package/dist/queries/extract-candidates.d.ts +1 -1
- package/dist/queries/extract-candidates.js +3 -3
- package/dist/queries/fan.d.ts +1 -1
- package/dist/queries/fan.js +3 -3
- package/dist/queries/files.d.ts +1 -1
- package/dist/queries/health.d.ts +1 -1
- package/dist/queries/health.js +14 -14
- package/dist/queries/hierarchy.d.ts +1 -1
- package/dist/queries/hierarchy.js +3 -3
- package/dist/queries/hotspots.d.ts +1 -1
- package/dist/queries/hotspots.js +3 -2
- package/dist/queries/imports.d.ts +1 -1
- package/dist/queries/imports.js +3 -3
- package/dist/queries/index.d.ts +1 -1
- package/dist/queries/index.js +44 -44
- package/dist/queries/isolated.d.ts +3 -4
- package/dist/queries/isolated.js +4 -4
- package/dist/queries/members.d.ts +1 -1
- package/dist/queries/members.js +3 -3
- package/dist/queries/methods.d.ts +1 -1
- package/dist/queries/methods.js +3 -2
- package/dist/queries/outline.d.ts +1 -1
- package/dist/queries/outline.js +3 -3
- package/dist/queries/passthrough-candidates.d.ts +1 -1
- package/dist/queries/passthrough-candidates.js +3 -3
- package/dist/queries/redundant-reexports.d.ts +1 -1
- package/dist/queries/redundant-reexports.js +4 -4
- package/dist/queries/refs.d.ts +1 -1
- package/dist/queries/refs.js +3 -3
- package/dist/queries/similar-chains.d.ts +1 -1
- package/dist/queries/similar-chains.js +3 -3
- package/dist/queries/similar-files.d.ts +1 -1
- package/dist/queries/similar-files.js +3 -3
- package/dist/queries/similar-signatures.d.ts +5 -3
- package/dist/queries/similar-signatures.js +3 -2
- package/dist/queries/similar.d.ts +1 -1
- package/dist/queries/similar.js +3 -3
- package/dist/queries/slice.d.ts +1 -1
- package/dist/queries/slice.js +3 -3
- package/dist/queries/stale-abstractions.d.ts +1 -1
- package/dist/queries/stale-abstractions.js +3 -3
- package/dist/queries/stats.d.ts +1 -1
- package/dist/queries/surface.d.ts +1 -1
- package/dist/queries/surface.js +3 -3
- package/dist/queries/symbols.d.ts +1 -1
- package/dist/queries/symbols.js +3 -3
- package/dist/queries/system.d.ts +1 -1
- package/dist/queries/system.js +3 -3
- package/dist/queries/trace.d.ts +1 -1
- package/dist/queries/trace.js +3 -3
- package/dist/queries/wrapper-candidates.d.ts +1 -1
- package/dist/queries/wrapper-candidates.js +3 -3
- package/dist/reindex-worker.js +216 -64
- package/package.json +5 -1
- package/skills/scip-language-playbook/SKILL.md +371 -0
- package/dist/chunk-4JCSOF2O.js +0 -97
- package/dist/chunk-AXQKUYKF.js +0 -1442
- package/dist/chunk-CPVAQJEC.js +0 -46
- package/dist/chunk-EOROMIFO.js +0 -41
- package/dist/chunk-GU2H5QRN.js +0 -28
- package/dist/chunk-LQJUPXQY.js +0 -109
- package/dist/chunk-MPGIHELS.js +0 -39
- package/dist/chunk-TOIEB3LG.js +0 -78
- package/dist/chunk-UQEQ6AHX.js +0 -60
- package/dist/chunk-VJJKSGIX.js +0 -121
- package/dist/chunk-YGGFLMTM.js +0 -83
- package/dist/chunk-ZEUCXQBN.js +0 -71
package/dist/reindex-worker.js
CHANGED
|
@@ -1,58 +1,165 @@
|
|
|
1
1
|
import {
|
|
2
2
|
describeIndexerBinary,
|
|
3
|
+
getIndexerExecutionEnv,
|
|
3
4
|
isBinaryAvailable,
|
|
4
5
|
isIndexerInstalled,
|
|
5
6
|
resolveIndexerBinary,
|
|
7
|
+
resolveProjectLocalIndexerBinary,
|
|
6
8
|
tryInstallIndexer,
|
|
7
9
|
tryInstallScipCli
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-P3VCDYMJ.js";
|
|
9
11
|
|
|
10
12
|
// src/reindex/index.ts
|
|
11
13
|
import { execFileSync } from "child_process";
|
|
12
|
-
import { existsSync as
|
|
13
|
-
import { join as
|
|
14
|
+
import { existsSync as existsSync3, renameSync } from "fs";
|
|
15
|
+
import { join as join3 } from "path";
|
|
14
16
|
|
|
15
17
|
// src/reindex/detect.ts
|
|
16
|
-
import { existsSync } from "fs";
|
|
17
|
-
import { join } from "path";
|
|
18
|
+
import { existsSync, readdirSync } from "fs";
|
|
19
|
+
import { extname, join } from "path";
|
|
20
|
+
var IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
21
|
+
".git",
|
|
22
|
+
".hg",
|
|
23
|
+
".svn",
|
|
24
|
+
".idea",
|
|
25
|
+
".vscode",
|
|
26
|
+
"node_modules",
|
|
27
|
+
"vendor",
|
|
28
|
+
"dist",
|
|
29
|
+
"build",
|
|
30
|
+
"target",
|
|
31
|
+
"bin",
|
|
32
|
+
"obj",
|
|
33
|
+
".dart_tool",
|
|
34
|
+
".gradle",
|
|
35
|
+
".next",
|
|
36
|
+
".venv",
|
|
37
|
+
"venv",
|
|
38
|
+
"__pycache__"
|
|
39
|
+
]);
|
|
18
40
|
var LANGUAGE_MARKERS = [
|
|
19
|
-
{ language: "typescript", files: ["tsconfig.json", "tsconfig.base.json"] },
|
|
20
|
-
{ language: "rust", files: ["Cargo.toml"] },
|
|
21
|
-
{ language: "go", files: ["go.mod"] },
|
|
22
|
-
{ language: "java", files: ["pom.xml", "build.gradle", "build.gradle.kts"] },
|
|
23
|
-
{ language: "kotlin", files: ["build.gradle.kts"] },
|
|
24
|
-
{ language: "scala", files: ["build.sbt"] },
|
|
25
|
-
{ language: "python", files: ["pyproject.toml", "setup.py", "setup.cfg", "Pipfile"] },
|
|
26
|
-
{ language: "ruby", files: ["Gemfile"] },
|
|
27
|
-
{ language: "
|
|
28
|
-
{ language: "
|
|
29
|
-
{ language: "
|
|
30
|
-
{ language: "
|
|
31
|
-
|
|
41
|
+
{ language: "typescript", files: ["tsconfig.json", "tsconfig.base.json"], extensions: [".ts", ".tsx", ".mts", ".cts"] },
|
|
42
|
+
{ language: "rust", files: ["Cargo.toml"], extensions: [".rs"] },
|
|
43
|
+
{ language: "go", files: ["go.mod"], extensions: [".go"] },
|
|
44
|
+
{ language: "java", files: ["pom.xml", "build.gradle", "build.gradle.kts"], extensions: [".java"] },
|
|
45
|
+
{ language: "kotlin", files: ["build.gradle.kts"], extensions: [".kt", ".kts"] },
|
|
46
|
+
{ language: "scala", files: ["build.sbt"], extensions: [".scala"] },
|
|
47
|
+
{ language: "python", files: ["pyproject.toml", "setup.py", "setup.cfg", "Pipfile"], extensions: [".py", ".pyi"] },
|
|
48
|
+
{ language: "ruby", files: ["Gemfile"], extensions: [".rb"] },
|
|
49
|
+
{ language: "cpp", files: ["compile_commands.json", "CMakeLists.txt", "Makefile"], extensions: [".cc", ".cpp", ".cxx", ".hpp", ".hh", ".hxx"] },
|
|
50
|
+
{ language: "c", files: ["compile_commands.json", "CMakeLists.txt", "Makefile"], extensions: [".c", ".h"] },
|
|
51
|
+
{ language: "csharp", globs: ["*.csproj", "*.sln"], extensions: [".cs"] },
|
|
52
|
+
{ language: "vb", globs: ["*.vbproj"], extensions: [".vb"] },
|
|
53
|
+
{ language: "dart", files: ["pubspec.yaml"], extensions: [".dart"] },
|
|
54
|
+
{ language: "php", files: ["composer.json"], extensions: [".php"] },
|
|
55
|
+
{ language: "javascript", files: ["package.json"], extensions: [".js", ".jsx", ".mjs", ".cjs"] }
|
|
56
|
+
// Last — very common
|
|
32
57
|
];
|
|
33
58
|
function detectLanguages(projectRoot2) {
|
|
34
59
|
const detected = [];
|
|
60
|
+
const rootEntries = safeReadDir(projectRoot2);
|
|
61
|
+
const extensionSet = collectExtensions(projectRoot2);
|
|
35
62
|
for (const marker of LANGUAGE_MARKERS) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
63
|
+
if (hasMarkerFile(projectRoot2, marker.files)) {
|
|
64
|
+
detected.push(marker.language);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (matchesRootGlob(rootEntries, marker.globs)) {
|
|
68
|
+
detected.push(marker.language);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (hasExtension(extensionSet, marker.extensions)) {
|
|
72
|
+
detected.push(marker.language);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (detected.includes("typescript")) {
|
|
76
|
+
removeLanguage(detected, "javascript");
|
|
77
|
+
}
|
|
78
|
+
if (detected.includes("cpp") && !extensionSet.has(".c")) {
|
|
79
|
+
removeLanguage(detected, "c");
|
|
80
|
+
}
|
|
81
|
+
return detected;
|
|
82
|
+
}
|
|
83
|
+
function safeReadDir(projectRoot2) {
|
|
84
|
+
try {
|
|
85
|
+
return readdirSync(projectRoot2);
|
|
86
|
+
} catch {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function hasMarkerFile(projectRoot2, files) {
|
|
91
|
+
if (!files?.length) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
return files.some((file) => existsSync(join(projectRoot2, file)));
|
|
95
|
+
}
|
|
96
|
+
function matchesRootGlob(entries, globs) {
|
|
97
|
+
if (!globs?.length) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return entries.some((entry) => globs.some((glob) => matchesSimpleGlob(entry, glob)));
|
|
101
|
+
}
|
|
102
|
+
function matchesSimpleGlob(entry, pattern) {
|
|
103
|
+
if (pattern === "*") {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (!pattern.includes("*")) {
|
|
107
|
+
return entry === pattern;
|
|
108
|
+
}
|
|
109
|
+
const [prefix, suffix] = pattern.split("*");
|
|
110
|
+
return entry.startsWith(prefix ?? "") && entry.endsWith(suffix ?? "");
|
|
111
|
+
}
|
|
112
|
+
function collectExtensions(projectRoot2) {
|
|
113
|
+
const found = /* @__PURE__ */ new Set();
|
|
114
|
+
const stack = [projectRoot2];
|
|
115
|
+
while (stack.length > 0) {
|
|
116
|
+
const current = stack.pop();
|
|
117
|
+
if (!current) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
let entries;
|
|
121
|
+
try {
|
|
122
|
+
entries = readdirSync(current, { withFileTypes: true });
|
|
123
|
+
} catch {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
for (const entry of entries) {
|
|
127
|
+
if (entry.name.startsWith(".") && !entry.name.endsWith("proj") && !entry.name.endsWith("sln")) {
|
|
128
|
+
if (entry.isDirectory()) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
39
131
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
132
|
+
const fullPath = join(current, entry.name);
|
|
133
|
+
if (entry.isDirectory()) {
|
|
134
|
+
if (!IGNORED_DIRS.has(entry.name)) {
|
|
135
|
+
stack.push(fullPath);
|
|
43
136
|
}
|
|
44
|
-
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const extension = extname(entry.name).toLowerCase();
|
|
140
|
+
if (extension) {
|
|
141
|
+
found.add(extension);
|
|
45
142
|
}
|
|
46
143
|
}
|
|
47
144
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
145
|
+
return found;
|
|
146
|
+
}
|
|
147
|
+
function hasExtension(extensionSet, extensions) {
|
|
148
|
+
if (!extensions?.length) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
return extensions.some((extension) => extensionSet.has(extension));
|
|
152
|
+
}
|
|
153
|
+
function removeLanguage(detected, language) {
|
|
154
|
+
const index = detected.indexOf(language);
|
|
155
|
+
if (index !== -1) {
|
|
156
|
+
detected.splice(index, 1);
|
|
51
157
|
}
|
|
52
|
-
return detected;
|
|
53
158
|
}
|
|
54
159
|
|
|
55
160
|
// src/reindex/indexers.ts
|
|
161
|
+
import { existsSync as existsSync2, readdirSync as readdirSync2 } from "fs";
|
|
162
|
+
import { join as join2 } from "path";
|
|
56
163
|
var INDEXER_CONFIGS = {
|
|
57
164
|
typescript: {
|
|
58
165
|
language: "typescript",
|
|
@@ -92,9 +199,7 @@ var INDEXER_CONFIGS = {
|
|
|
92
199
|
args: ["index", "--output", outputPath]
|
|
93
200
|
}),
|
|
94
201
|
markerFiles: ["pom.xml", "build.gradle"],
|
|
95
|
-
installMethods: [
|
|
96
|
-
{ label: "coursier", prerequisite: "cs", binary: "cs", args: ["install", "scip-java"] }
|
|
97
|
-
],
|
|
202
|
+
installMethods: [],
|
|
98
203
|
installUrl: "https://github.com/sourcegraph/scip-java/releases"
|
|
99
204
|
},
|
|
100
205
|
scala: {
|
|
@@ -106,9 +211,7 @@ var INDEXER_CONFIGS = {
|
|
|
106
211
|
args: ["index", "--output", outputPath]
|
|
107
212
|
}),
|
|
108
213
|
markerFiles: ["build.sbt"],
|
|
109
|
-
installMethods: [
|
|
110
|
-
{ label: "coursier", prerequisite: "cs", binary: "cs", args: ["install", "scip-java"] }
|
|
111
|
-
],
|
|
214
|
+
installMethods: [],
|
|
112
215
|
installUrl: "https://github.com/sourcegraph/scip-java/releases"
|
|
113
216
|
},
|
|
114
217
|
kotlin: {
|
|
@@ -120,9 +223,7 @@ var INDEXER_CONFIGS = {
|
|
|
120
223
|
args: ["index", "--output", outputPath]
|
|
121
224
|
}),
|
|
122
225
|
markerFiles: ["build.gradle.kts"],
|
|
123
|
-
installMethods: [
|
|
124
|
-
{ label: "coursier", prerequisite: "cs", binary: "cs", args: ["install", "scip-java"] }
|
|
125
|
-
],
|
|
226
|
+
installMethods: [],
|
|
126
227
|
installUrl: "https://github.com/sourcegraph/scip-java/releases"
|
|
127
228
|
},
|
|
128
229
|
rust: {
|
|
@@ -158,10 +259,11 @@ var INDEXER_CONFIGS = {
|
|
|
158
259
|
language: "ruby",
|
|
159
260
|
indexerBinary: "scip-ruby",
|
|
160
261
|
checkCommand: "scip-ruby --version",
|
|
161
|
-
indexArgs: ({
|
|
162
|
-
binary:
|
|
163
|
-
args: ["--
|
|
262
|
+
indexArgs: ({ indexerBinary }) => ({
|
|
263
|
+
binary: indexerBinary,
|
|
264
|
+
args: ["--dir", "."]
|
|
164
265
|
}),
|
|
266
|
+
defaultOutputPath: "index.scip",
|
|
165
267
|
markerFiles: ["Gemfile"],
|
|
166
268
|
installMethods: [],
|
|
167
269
|
installUrl: "https://github.com/sourcegraph/scip-ruby/releases"
|
|
@@ -186,7 +288,7 @@ var INDEXER_CONFIGS = {
|
|
|
186
288
|
checkCommand: "scip-clang --version",
|
|
187
289
|
indexArgs: ({ outputPath }) => ({
|
|
188
290
|
binary: "scip-clang",
|
|
189
|
-
args: ["--output", outputPath]
|
|
291
|
+
args: ["--compdb-path", "compile_commands.json", "--index-output-path", outputPath]
|
|
190
292
|
}),
|
|
191
293
|
markerFiles: ["CMakeLists.txt", "Makefile"],
|
|
192
294
|
installMethods: [],
|
|
@@ -198,7 +300,7 @@ var INDEXER_CONFIGS = {
|
|
|
198
300
|
checkCommand: "scip-clang --version",
|
|
199
301
|
indexArgs: ({ outputPath }) => ({
|
|
200
302
|
binary: "scip-clang",
|
|
201
|
-
args: ["--output", outputPath]
|
|
303
|
+
args: ["--compdb-path", "compile_commands.json", "--index-output-path", outputPath]
|
|
202
304
|
}),
|
|
203
305
|
markerFiles: ["CMakeLists.txt", "Makefile"],
|
|
204
306
|
installMethods: [],
|
|
@@ -208,11 +310,25 @@ var INDEXER_CONFIGS = {
|
|
|
208
310
|
language: "csharp",
|
|
209
311
|
indexerBinary: "scip-dotnet",
|
|
210
312
|
checkCommand: "scip-dotnet --version",
|
|
211
|
-
indexArgs: ({ outputPath }) => ({
|
|
313
|
+
indexArgs: ({ projectRoot: projectRoot2, outputPath }) => ({
|
|
212
314
|
binary: "scip-dotnet",
|
|
213
|
-
args: ["index", "--output", outputPath]
|
|
315
|
+
args: ["index", resolveDotnetProject(projectRoot2, [".sln", ".csproj"]) ?? projectRoot2, "--output", outputPath, "--working-directory", projectRoot2]
|
|
316
|
+
}),
|
|
317
|
+
markerFiles: ["*.csproj", "*.sln"],
|
|
318
|
+
installMethods: [
|
|
319
|
+
{ label: "dotnet", prerequisite: "dotnet", binary: "dotnet", args: ["tool", "install", "--global", "scip-dotnet"] }
|
|
320
|
+
],
|
|
321
|
+
installUrl: "https://github.com/sourcegraph/scip-dotnet/releases"
|
|
322
|
+
},
|
|
323
|
+
vb: {
|
|
324
|
+
language: "vb",
|
|
325
|
+
indexerBinary: "scip-dotnet",
|
|
326
|
+
checkCommand: "scip-dotnet --version",
|
|
327
|
+
indexArgs: ({ projectRoot: projectRoot2, outputPath }) => ({
|
|
328
|
+
binary: "scip-dotnet",
|
|
329
|
+
args: ["index", resolveDotnetProject(projectRoot2, [".sln", ".vbproj"]) ?? projectRoot2, "--output", outputPath, "--working-directory", projectRoot2]
|
|
214
330
|
}),
|
|
215
|
-
markerFiles: [],
|
|
331
|
+
markerFiles: ["*.vbproj", "*.sln"],
|
|
216
332
|
installMethods: [
|
|
217
333
|
{ label: "dotnet", prerequisite: "dotnet", binary: "dotnet", args: ["tool", "install", "--global", "scip-dotnet"] }
|
|
218
334
|
],
|
|
@@ -222,9 +338,9 @@ var INDEXER_CONFIGS = {
|
|
|
222
338
|
language: "dart",
|
|
223
339
|
indexerBinary: "scip-dart",
|
|
224
340
|
checkCommand: "scip-dart --version",
|
|
225
|
-
indexArgs: ({ outputPath }) => ({
|
|
226
|
-
binary:
|
|
227
|
-
args: ["
|
|
341
|
+
indexArgs: ({ indexerBinary, outputPath }) => ({
|
|
342
|
+
binary: indexerBinary,
|
|
343
|
+
args: ["--output", outputPath]
|
|
228
344
|
}),
|
|
229
345
|
markerFiles: ["pubspec.yaml"],
|
|
230
346
|
installMethods: [
|
|
@@ -235,21 +351,44 @@ var INDEXER_CONFIGS = {
|
|
|
235
351
|
php: {
|
|
236
352
|
language: "php",
|
|
237
353
|
indexerBinary: "scip-php",
|
|
354
|
+
projectLocalBinaries: ["vendor/davidrjenni/scip-php/bin/scip-php", "vendor/bin/scip-php"],
|
|
238
355
|
checkCommand: "scip-php --version",
|
|
239
|
-
indexArgs: ({
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
356
|
+
indexArgs: ({ projectRoot: projectRoot2, indexerBinary }) => {
|
|
357
|
+
const localBinary = join2(projectRoot2, "vendor", "bin", "scip-php");
|
|
358
|
+
const nestedLocalBinary = join2(projectRoot2, "vendor", "davidrjenni", "scip-php", "bin", "scip-php");
|
|
359
|
+
const targetBinary = existsSync2(nestedLocalBinary) ? nestedLocalBinary : existsSync2(localBinary) ? localBinary : indexerBinary;
|
|
360
|
+
return {
|
|
361
|
+
binary: "php",
|
|
362
|
+
args: [
|
|
363
|
+
"-d",
|
|
364
|
+
"error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",
|
|
365
|
+
targetBinary
|
|
366
|
+
]
|
|
367
|
+
};
|
|
368
|
+
},
|
|
369
|
+
defaultOutputPath: "index.scip",
|
|
243
370
|
markerFiles: ["composer.json"],
|
|
244
|
-
installMethods: [
|
|
245
|
-
{ label: "composer", prerequisite: "composer", binary: "composer", args: ["global", "require", "davidrjenni/scip-php"] }
|
|
246
|
-
],
|
|
371
|
+
installMethods: [],
|
|
247
372
|
installUrl: "https://github.com/davidrjenni/scip-php/releases"
|
|
248
373
|
}
|
|
249
374
|
};
|
|
250
375
|
function getIndexerConfig(language) {
|
|
251
376
|
return INDEXER_CONFIGS[language];
|
|
252
377
|
}
|
|
378
|
+
function resolveDotnetProject(projectRoot2, suffixes) {
|
|
379
|
+
let entries;
|
|
380
|
+
try {
|
|
381
|
+
entries = readdirSync2(projectRoot2);
|
|
382
|
+
} catch {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
for (const entry of entries) {
|
|
386
|
+
if (suffixes.some((suffix) => entry.endsWith(suffix))) {
|
|
387
|
+
return join2(projectRoot2, entry);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
253
392
|
|
|
254
393
|
// src/reindex/index.ts
|
|
255
394
|
async function reindex(opts) {
|
|
@@ -259,8 +398,8 @@ async function reindex(opts) {
|
|
|
259
398
|
onStatus = console.log,
|
|
260
399
|
skipAutoInstall = false
|
|
261
400
|
} = opts;
|
|
262
|
-
const outputScip2 = opts.outputScip ??
|
|
263
|
-
const outputDb2 = opts.outputDb ??
|
|
401
|
+
const outputScip2 = opts.outputScip ?? join3(projectRoot2, "index.scip");
|
|
402
|
+
const outputDb2 = opts.outputDb ?? join3(projectRoot2, "index.db");
|
|
264
403
|
const start = Date.now();
|
|
265
404
|
const languages2 = opts.languages ?? detectLanguages(projectRoot2);
|
|
266
405
|
if (languages2.length === 0) {
|
|
@@ -289,7 +428,8 @@ async function reindex(opts) {
|
|
|
289
428
|
for (const lang of languages2) {
|
|
290
429
|
const config = getIndexerConfig(lang);
|
|
291
430
|
const binaryLabel = describeIndexerBinary(config);
|
|
292
|
-
|
|
431
|
+
const projectLocalBinary = resolveProjectLocalIndexerBinary(config, projectRoot2);
|
|
432
|
+
if (!projectLocalBinary && !isIndexerInstalled(config)) {
|
|
293
433
|
if (skipAutoInstall) {
|
|
294
434
|
throw new Error(
|
|
295
435
|
`${binaryLabel} is required to index ${lang} but not found on PATH.
|
|
@@ -304,7 +444,7 @@ async function reindex(opts) {
|
|
|
304
444
|
);
|
|
305
445
|
}
|
|
306
446
|
}
|
|
307
|
-
const resolvedBinary = resolveIndexerBinary(config);
|
|
447
|
+
const resolvedBinary = projectLocalBinary ?? resolveIndexerBinary(config);
|
|
308
448
|
if (!resolvedBinary) {
|
|
309
449
|
throw new Error(
|
|
310
450
|
`${binaryLabel} is required to index ${lang} but was not found on PATH after installation checks.
|
|
@@ -312,6 +452,7 @@ async function reindex(opts) {
|
|
|
312
452
|
);
|
|
313
453
|
}
|
|
314
454
|
onStatus(`Indexing ${lang} with ${resolvedBinary}...`);
|
|
455
|
+
const indexerEnv = getIndexerExecutionEnv(config, env, resolvedBinary);
|
|
315
456
|
const { binary, args } = config.indexArgs({
|
|
316
457
|
projectRoot: projectRoot2,
|
|
317
458
|
outputPath: outputScip2,
|
|
@@ -321,7 +462,7 @@ async function reindex(opts) {
|
|
|
321
462
|
try {
|
|
322
463
|
execFileSync(binary, args, {
|
|
323
464
|
cwd: projectRoot2,
|
|
324
|
-
env,
|
|
465
|
+
env: indexerEnv,
|
|
325
466
|
stdio: "pipe",
|
|
326
467
|
maxBuffer: 50 * 1024 * 1024
|
|
327
468
|
});
|
|
@@ -329,12 +470,14 @@ async function reindex(opts) {
|
|
|
329
470
|
const msg = err instanceof Error ? err.message : String(err);
|
|
330
471
|
throw new Error(
|
|
331
472
|
`Failed to index ${lang} with ${resolvedBinary}: ${msg}
|
|
332
|
-
Make sure ${binaryLabel} is installed and available on PATH
|
|
473
|
+
Make sure ${binaryLabel} is installed and available on PATH.`,
|
|
474
|
+
{ cause: err }
|
|
333
475
|
);
|
|
334
476
|
}
|
|
477
|
+
moveDefaultOutputIfNeeded(config, projectRoot2, outputScip2);
|
|
335
478
|
}
|
|
336
479
|
onStatus("Converting to SQLite...");
|
|
337
|
-
if (!
|
|
480
|
+
if (!existsSync3(outputScip2)) {
|
|
338
481
|
throw new Error(`SCIP index not found at ${outputScip2} after indexing`);
|
|
339
482
|
}
|
|
340
483
|
try {
|
|
@@ -345,12 +488,21 @@ Make sure ${binaryLabel} is installed and available on PATH.`
|
|
|
345
488
|
});
|
|
346
489
|
} catch (err) {
|
|
347
490
|
const msg = err instanceof Error ? err.message : String(err);
|
|
348
|
-
throw new Error(`Failed to convert SCIP index to SQLite: ${msg}
|
|
491
|
+
throw new Error(`Failed to convert SCIP index to SQLite: ${msg}`, { cause: err });
|
|
349
492
|
}
|
|
350
493
|
const durationMs = Date.now() - start;
|
|
351
494
|
onStatus(`Done in ${(durationMs / 1e3).toFixed(1)}s`);
|
|
352
495
|
return { languages: languages2, indexPath: outputScip2, dbPath: outputDb2, durationMs };
|
|
353
496
|
}
|
|
497
|
+
function moveDefaultOutputIfNeeded(config, projectRoot2, outputScip2) {
|
|
498
|
+
if (!config.defaultOutputPath) {
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
const defaultOutputPath = join3(projectRoot2, config.defaultOutputPath);
|
|
502
|
+
if (outputScip2 !== defaultOutputPath && existsSync3(defaultOutputPath)) {
|
|
503
|
+
renameSync(defaultOutputPath, outputScip2);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
354
506
|
|
|
355
507
|
// src/reindex-worker.ts
|
|
356
508
|
var projectRoot = process.env["SCIP_REINDEX_PROJECT_ROOT"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scip-query",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Language-agnostic code intelligence CLI powered by SCIP indexes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -65,11 +65,15 @@
|
|
|
65
65
|
"ignore": "^7.0.3"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
+
"@eslint/js": "^10.0.1",
|
|
68
69
|
"@sourcegraph/scip-typescript": "^0.4.0",
|
|
69
70
|
"@types/better-sqlite3": "^7.6.12",
|
|
70
71
|
"@types/node": "^22.10.0",
|
|
72
|
+
"eslint": "^10.2.0",
|
|
73
|
+
"globals": "^17.5.0",
|
|
71
74
|
"tsup": "^8.3.0",
|
|
72
75
|
"typescript": "^5.7.0",
|
|
76
|
+
"typescript-eslint": "^8.58.1",
|
|
73
77
|
"vitest": "^3.0.0"
|
|
74
78
|
}
|
|
75
79
|
}
|