@sdsrs/code-graph 0.5.31 → 0.5.33
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.
|
@@ -8,6 +8,23 @@ const os = require('os');
|
|
|
8
8
|
const { CACHE_DIR, PLUGIN_ID, MARKETPLACE_NAME, readManifest, readJson, writeJsonAtomic } = require('./lifecycle');
|
|
9
9
|
const { clearCache: clearBinaryCache } = require('./find-binary');
|
|
10
10
|
|
|
11
|
+
// ── Environment Checks ────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if a command-line tool is available on the system PATH.
|
|
15
|
+
* @param {string} cmd - Command name (e.g., 'curl', 'tar')
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
*/
|
|
18
|
+
function commandExists(cmd) {
|
|
19
|
+
try {
|
|
20
|
+
const whichCmd = process.platform === 'win32' ? 'where' : 'which';
|
|
21
|
+
execFileSync(whichCmd, [cmd], { stdio: 'ignore' });
|
|
22
|
+
return true;
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
11
28
|
// ── Configuration ──────────────────────────────────────────
|
|
12
29
|
const GITHUB_REPO = 'sdsrss/code-graph-mcp';
|
|
13
30
|
const STATE_FILE = path.join(CACHE_DIR, 'update-state.json');
|
|
@@ -207,6 +224,13 @@ function promoteVerifiedBinary(binaryTmp, binaryDst, expectedVersion) {
|
|
|
207
224
|
// ── Download & Install ─────────────────────────────────────
|
|
208
225
|
|
|
209
226
|
async function downloadAndInstall(latest) {
|
|
227
|
+
// Pre-flight: check required CLI tools before attempting any download
|
|
228
|
+
const missingTools = ['curl', 'tar'].filter(cmd => !commandExists(cmd));
|
|
229
|
+
if (missingTools.length > 0) {
|
|
230
|
+
console.error(`[code-graph] Auto-update skipped: missing required tools: ${missingTools.join(', ')}. Install them to enable auto-updates.`);
|
|
231
|
+
return { pluginUpdated: false, binaryUpdated: false };
|
|
232
|
+
}
|
|
233
|
+
|
|
210
234
|
const tmpDir = path.join(os.tmpdir(), `code-graph-update-${Date.now()}`);
|
|
211
235
|
let pluginUpdated = false;
|
|
212
236
|
let binaryUpdated = false;
|
|
@@ -273,13 +297,15 @@ async function downloadAndInstall(latest) {
|
|
|
273
297
|
if (promoteVerifiedBinary(binaryTmp, binaryDst, latest.version)) {
|
|
274
298
|
binaryUpdated = true;
|
|
275
299
|
}
|
|
276
|
-
} catch {
|
|
300
|
+
} catch (e) {
|
|
277
301
|
// Binary download failed — plugin update still counts as success
|
|
302
|
+
console.error(`[code-graph] Binary download failed: ${e.message}`);
|
|
278
303
|
}
|
|
279
304
|
}
|
|
280
305
|
|
|
281
306
|
return { pluginUpdated, binaryUpdated };
|
|
282
|
-
} catch {
|
|
307
|
+
} catch (e) {
|
|
308
|
+
console.error(`[code-graph] Plugin download/extract failed: ${e.message}`);
|
|
283
309
|
return { pluginUpdated: false, binaryUpdated: false };
|
|
284
310
|
} finally {
|
|
285
311
|
try { fs.rmSync(tmpDir, { recursive: true, force: true }); } catch { /* ok */ }
|
|
@@ -354,7 +380,7 @@ async function checkForUpdate() {
|
|
|
354
380
|
}
|
|
355
381
|
|
|
356
382
|
module.exports = {
|
|
357
|
-
checkForUpdate, isDevMode, readState, compareVersions,
|
|
383
|
+
checkForUpdate, commandExists, isDevMode, readState, compareVersions,
|
|
358
384
|
getExtractedPluginVersion, readBinaryVersion, promoteVerifiedBinary, isSilentMode,
|
|
359
385
|
requestJson, parseLatestRelease, fetchLatestRelease,
|
|
360
386
|
};
|
|
@@ -6,6 +6,7 @@ const os = require('os');
|
|
|
6
6
|
const path = require('path');
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
|
+
commandExists,
|
|
9
10
|
fetchLatestRelease,
|
|
10
11
|
getExtractedPluginVersion,
|
|
11
12
|
parseLatestRelease,
|
|
@@ -80,6 +81,16 @@ test('parseLatestRelease selects the matching platform asset', () => {
|
|
|
80
81
|
});
|
|
81
82
|
});
|
|
82
83
|
|
|
84
|
+
// ── commandExists ──────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
test('commandExists returns true for a known command (node)', () => {
|
|
87
|
+
assert.equal(commandExists('node'), true);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('commandExists returns false for a non-existent command', () => {
|
|
91
|
+
assert.equal(commandExists('__nonexistent_cmd_xyz_12345__'), false);
|
|
92
|
+
});
|
|
93
|
+
|
|
83
94
|
test('fetchLatestRelease parses JSON without relying on global fetch', async () => {
|
|
84
95
|
const latest = await fetchLatestRelease(async () => ({
|
|
85
96
|
statusCode: 200,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdsrs/code-graph",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.33",
|
|
4
4
|
"description": "MCP server that indexes codebases into an AST knowledge graph with semantic search, call graph traversal, and HTTP route tracing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"node": ">=16"
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@sdsrs/code-graph-linux-x64": "0.5.
|
|
37
|
-
"@sdsrs/code-graph-linux-arm64": "0.5.
|
|
38
|
-
"@sdsrs/code-graph-darwin-x64": "0.5.
|
|
39
|
-
"@sdsrs/code-graph-darwin-arm64": "0.5.
|
|
40
|
-
"@sdsrs/code-graph-win32-x64": "0.5.
|
|
36
|
+
"@sdsrs/code-graph-linux-x64": "0.5.33",
|
|
37
|
+
"@sdsrs/code-graph-linux-arm64": "0.5.33",
|
|
38
|
+
"@sdsrs/code-graph-darwin-x64": "0.5.33",
|
|
39
|
+
"@sdsrs/code-graph-darwin-arm64": "0.5.33",
|
|
40
|
+
"@sdsrs/code-graph-win32-x64": "0.5.33"
|
|
41
41
|
}
|
|
42
42
|
}
|