local-memory-mcp 1.0.5 → 1.0.7
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/bin/local-memory-macos-arm +0 -0
- package/package.json +1 -1
- package/scripts/install.js +69 -15
- package/scripts/test.js +1 -1
|
Binary file
|
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -13,10 +13,15 @@ const https = require('https');
|
|
|
13
13
|
const fs = require('fs');
|
|
14
14
|
const path = require('path');
|
|
15
15
|
const os = require('os');
|
|
16
|
+
const { execSync } = require('child_process');
|
|
16
17
|
|
|
17
18
|
// Configuration
|
|
18
19
|
const GITHUB_RELEASES_BASE = 'https://github.com/danieleugenewilliams/local-memory-releases/releases/latest/download';
|
|
19
|
-
|
|
20
|
+
|
|
21
|
+
// Get expected version from package.json
|
|
22
|
+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
23
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
24
|
+
const EXPECTED_VERSION = packageJson.version;
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
27
|
* Logging that works reliably with npm
|
|
@@ -78,10 +83,6 @@ function generateDownloadUrls(binaryName) {
|
|
|
78
83
|
// Primary: GitHub releases (public repository)
|
|
79
84
|
urls.push(`${GITHUB_RELEASES_BASE}/${binaryName}`);
|
|
80
85
|
|
|
81
|
-
// Fallback: S3 backup paths (if GitHub is down)
|
|
82
|
-
urls.push(`${S3_BACKUP_URL}/platform-binaries/${binaryName}`);
|
|
83
|
-
urls.push(`${S3_BACKUP_URL}/npm-binaries/${binaryName}`);
|
|
84
|
-
|
|
85
86
|
return urls;
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -215,6 +216,50 @@ async function downloadBinary(binaryName, destination) {
|
|
|
215
216
|
throw new Error(`All ${attempts} download attempts failed. Last error: ${lastError?.message || 'Unknown error'}`);
|
|
216
217
|
}
|
|
217
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Get the version of an installed binary
|
|
221
|
+
*/
|
|
222
|
+
function getBinaryVersion(binaryPath) {
|
|
223
|
+
try {
|
|
224
|
+
const output = execSync(`"${binaryPath}" --version`, {
|
|
225
|
+
encoding: 'utf8',
|
|
226
|
+
timeout: 5000,
|
|
227
|
+
stdio: ['pipe', 'pipe', 'ignore'] // Suppress stderr
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// Parse version from output like "local-memory version 1.0.5"
|
|
231
|
+
const match = output.match(/version\s+(\d+\.\d+\.\d+)/);
|
|
232
|
+
return match ? match[1] : null;
|
|
233
|
+
} catch (error) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Check if installed binary matches expected version
|
|
240
|
+
*/
|
|
241
|
+
function isVersionMatch(binaryPath) {
|
|
242
|
+
if (!fs.existsSync(binaryPath)) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Check file size first (basic validation)
|
|
247
|
+
const stats = fs.statSync(binaryPath);
|
|
248
|
+
if (stats.size < 1024 * 1024) { // Less than 1MB is invalid
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Check actual version
|
|
253
|
+
const installedVersion = getBinaryVersion(binaryPath);
|
|
254
|
+
if (!installedVersion) {
|
|
255
|
+
log(`⚠️ Could not determine binary version`, true);
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
log(`📋 Installed version: ${installedVersion}, Expected: ${EXPECTED_VERSION}`);
|
|
260
|
+
return installedVersion === EXPECTED_VERSION;
|
|
261
|
+
}
|
|
262
|
+
|
|
218
263
|
/**
|
|
219
264
|
* Set executable permissions (Unix-like systems)
|
|
220
265
|
*/
|
|
@@ -256,19 +301,22 @@ async function install() {
|
|
|
256
301
|
|
|
257
302
|
const binaryPath = path.join(binDir, binaryName);
|
|
258
303
|
|
|
259
|
-
// Check if binary already exists and
|
|
260
|
-
if (
|
|
304
|
+
// Check if binary already exists and matches expected version
|
|
305
|
+
if (isVersionMatch(binaryPath)) {
|
|
306
|
+
log('✅ Correct version already installed, skipping download');
|
|
307
|
+
setExecutablePermissions(binaryPath);
|
|
261
308
|
const stats = fs.statSync(binaryPath);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
309
|
+
log(`✅ Binary verified (${(stats.size / 1024 / 1024).toFixed(1)}MB)`);
|
|
310
|
+
log('✅ Local Memory Server installation complete!');
|
|
311
|
+
return;
|
|
312
|
+
} else if (fs.existsSync(binaryPath)) {
|
|
313
|
+
const installedVersion = getBinaryVersion(binaryPath);
|
|
314
|
+
if (installedVersion) {
|
|
315
|
+
log(`🔄 Upgrading from v${installedVersion} to v${EXPECTED_VERSION}`);
|
|
268
316
|
} else {
|
|
269
317
|
log('🗑️ Removing invalid existing binary...');
|
|
270
|
-
fs.unlinkSync(binaryPath);
|
|
271
318
|
}
|
|
319
|
+
fs.unlinkSync(binaryPath);
|
|
272
320
|
}
|
|
273
321
|
|
|
274
322
|
// Download binary
|
|
@@ -278,10 +326,16 @@ async function install() {
|
|
|
278
326
|
log('🔐 Setting executable permissions...');
|
|
279
327
|
setExecutablePermissions(binaryPath);
|
|
280
328
|
|
|
329
|
+
// Verify downloaded version matches expected
|
|
330
|
+
const downloadedVersion = getBinaryVersion(binaryPath);
|
|
331
|
+
if (downloadedVersion !== EXPECTED_VERSION) {
|
|
332
|
+
throw new Error(`Downloaded binary version mismatch: got v${downloadedVersion}, expected v${EXPECTED_VERSION}`);
|
|
333
|
+
}
|
|
334
|
+
|
|
281
335
|
// Final verification
|
|
282
336
|
const finalStats = fs.statSync(binaryPath);
|
|
283
337
|
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
284
|
-
log(`✅ Installation verified (${(finalStats.size / 1024 / 1024).toFixed(1)}MB in ${duration}s)`);
|
|
338
|
+
log(`✅ Installation verified v${downloadedVersion} (${(finalStats.size / 1024 / 1024).toFixed(1)}MB in ${duration}s)`);
|
|
285
339
|
|
|
286
340
|
log('🎉 Local Memory Server installed successfully!');
|
|
287
341
|
log('📚 Next steps:');
|
package/scripts/test.js
CHANGED
|
@@ -79,7 +79,7 @@ async function testBinaryExecution(binaryPath) {
|
|
|
79
79
|
throw new Error(`Version command failed with code ${result.code}: ${result.stderr}`);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
if (!result.stdout.includes('
|
|
82
|
+
if (!result.stdout.includes('local-memory version')) {
|
|
83
83
|
throw new Error(`Unexpected version output: ${result.stdout}`);
|
|
84
84
|
}
|
|
85
85
|
|