MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / main

Function main

pkg/npm/install.js:710–832  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

708}
709
710async function main() {
711 const platform = getPlatform();
712 const arch = getArch();
713 const ext = platform === 'windows' ? 'zip' : 'tar.gz';
714 // Package-manager shims are portable one-shot instances: one cached binary
715 // per platform, entered directly.
716 const binName = platform === 'windows'
717 ? WINDOWS_BINARY_NAME
718 : 'codebase-memory-mcp';
719 const binPath = path.join(BIN_DIR, binName);
720 const cacheNames = platform === 'windows'
721 ? [WINDOWS_BINARY_NAME]
722 : [binName];
723 const extractedNames = platform === 'windows'
724 ? [WINDOWS_BINARY_NAME]
725 : [binName];
726 const archiveNames = platform === 'windows'
727 ? WINDOWS_ARCHIVE_NAMES
728 : UNIX_ARCHIVE_NAMES;
729 const cachePaths = cacheNames.map((name) => path.join(BIN_DIR, name));
730
731 if (platform === 'windows' && windowsBinaryReady(BIN_DIR)) return;
732 if (platform !== 'windows' &&
733 cachePaths.every((candidate) => fs.existsSync(candidate))) {
734 try {
735 verifyCandidate(binPath);
736 return; // already installed and runnable, nothing to do
737 } catch (_) {
738 // Fall through and atomically replace the invalid binary.
739 }
740 }
741
742 const source = resolveDownloadBase();
743 fs.mkdirSync(BIN_DIR, { recursive: true });
744
745 // Linux ships a fully-static "-portable" build; the standard linux binary
746 // dynamically links glibc 2.38+ and fails on older distros. macOS/Windows
747 // have no such variant. Keep in sync with install.sh / pypi _cli.py / cli.c.
748 const variant = platform === 'linux' ? '-portable' : '';
749 // No UI/standard split since v0.10.0: one archive per platform, graph UI
750 // always embedded. The old CBM_VARIANT=ui opt-in pointed at ui-* archives
751 // that no longer exist, so honoring it could only 404 (#1538).
752 const archive = `codebase-memory-mcp-${platform}-${arch}${variant}.${ext}`;
753 const url = `${source.base}/${archive}`;
754
755 process.stdout.write(`codebase-memory-mcp: downloading v${VERSION} for ${platform}/${arch}...\n`);
756
757 const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'cbm-install-'));
758 const tmpArchive = path.join(tmpDir, `cbm.${ext}`);
759
760 try {
761 await download(url, tmpArchive, source.loopback);
762 await verifyChecksum(tmpArchive, archive, source);
763
764 // Validate the complete archive namespace, then extract only executables.
765 if (ext === 'tar.gz') {
766 await extractExactTarArchive(
767 tmpArchive, tmpDir, archiveNames, binName,

Callers 1

install.jsFile · 0.70

Calls 13

getPlatformFunction · 0.85
getArchFunction · 0.85
windowsBinaryReadyFunction · 0.85
resolveDownloadBaseFunction · 0.85
extractExactTarArchiveFunction · 0.85
extractZipOnWindowsFunction · 0.85
filesEqualSha256Function · 0.85
verifyCandidateFunction · 0.70
downloadFunction · 0.70
verifyChecksumFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected