MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / normalizeInstallSpec

Function normalizeInstallSpec

src/cm/lsp/serverLauncher.ts:327–401  ·  view source on GitHub ↗
(server: LspServerDefinition)

Source from the content-addressed store, hash-verified

325}
326
327function normalizeInstallSpec(server: LspServerDefinition) {
328 const install = server.launcher?.install;
329 if (!install) return null;
330
331 const packages = Array.isArray(install.packages)
332 ? install.packages
333 .map((entry) => String(entry || "").trim())
334 .filter(Boolean)
335 : [];
336 const kind =
337 install.kind ||
338 (install.binaryPath ? "manual" : null) ||
339 (install.source === "apk" ? "apk" : null) ||
340 (install.source === "npm" ? "npm" : null) ||
341 (install.source === "pip" ? "pip" : null) ||
342 (install.source === "cargo" ? "cargo" : null) ||
343 (install.command ? "shell" : null) ||
344 "shell";
345
346 return {
347 ...install,
348 kind,
349 packages,
350 command:
351 typeof install.command === "string" && install.command.trim()
352 ? install.command.trim()
353 : undefined,
354 updateCommand:
355 typeof install.updateCommand === "string" && install.updateCommand.trim()
356 ? install.updateCommand.trim()
357 : undefined,
358 source:
359 install.source ||
360 (kind === "shell" ? "custom" : kind === "manual" ? "manual" : kind),
361 executable:
362 typeof install.executable === "string" && install.executable.trim()
363 ? install.executable.trim()
364 : undefined,
365 binaryPath:
366 typeof install.binaryPath === "string" && install.binaryPath.trim()
367 ? install.binaryPath.trim()
368 : undefined,
369 repo:
370 typeof install.repo === "string" && install.repo.trim()
371 ? install.repo.trim()
372 : undefined,
373 assetNames:
374 install.assetNames && typeof install.assetNames === "object"
375 ? Object.fromEntries(
376 Object.entries(install.assetNames)
377 .map(([key, value]) => [String(key), String(value || "").trim()])
378 .filter(([, value]) => Boolean(value)),
379 )
380 : {},
381 archiveType: install.archiveType === "binary" ? "binary" : "zip",
382 extractFile:
383 typeof install.extractFile === "string" && install.extractFile.trim()
384 ? install.extractFile.trim()

Callers 6

getInstallerExecutableFunction · 0.85
getInstallLabelFunction · 0.85
buildUninstallCommandFunction · 0.85
buildInstallCommandFunction · 0.85
buildDerivedCheckCommandFunction · 0.85
getInstallSourceFunction · 0.85

Calls 1

StringInterface · 0.85

Tested by

no test coverage detected