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

Function installServer

src/cm/lsp/serverLauncher.ts:719–810  ·  view source on GitHub ↗
(
  server: LspServerDefinition,
  mode: InstallActionMode = "install",
  options: { promptConfirm?: boolean } = {},
)

Source from the content-addressed store, hash-verified

717type InstallActionMode = "install" | "update" | "reinstall";
718
719export async function installServer(
720 server: LspServerDefinition,
721 mode: InstallActionMode = "install",
722 options: { promptConfirm?: boolean } = {},
723): Promise<boolean> {
724 const bundle = getServerBundle(server.id);
725 if (bundle?.installServer) {
726 return bundle.installServer(server.id, server, mode, options);
727 }
728
729 const { promptConfirm = false } = options;
730 const cacheKey = getInstallCacheKey(server);
731 const displayLabel = getInstallLabel(server);
732 const isUpdate = mode === "update";
733 const actionLabel = isUpdate ? "Update" : "Install";
734 const command =
735 mode === "install"
736 ? getInstallCommand(server, "install")
737 : getUpdateCommand(server);
738
739 if (!command) {
740 throw new Error(
741 `${displayLabel} has no ${actionLabel.toLowerCase()} command.`,
742 );
743 }
744
745 if (promptConfirm) {
746 let resolveThis: (val: boolean) => void;
747 let rejectThis: (err: Error) => void;
748 notificationManager.pushNotification({
749 icon: "zap",
750 title: displayLabel,
751 message: strings["lsp-install-notification"].replace(
752 "{server}",
753 displayLabel,
754 ),
755 type: "warning",
756 action: async (notification) => {
757 notificationManager.closeNotification(notification);
758 try {
759 resolveThis(await installServer(server, mode));
760 } catch (error) {
761 rejectThis(error as Error);
762 }
763 },
764 onDismiss: () => {
765 resolveThis(false);
766 if (cacheKey) {
767 checkedCommands.set(cacheKey, STATUS_DECLINED);
768 }
769 },
770 });
771
772 return new Promise((resolve, reject) => {
773 resolveThis = resolve;
774 rejectThis = reject;
775 });
776 }

Callers 2

installFunction · 0.90
performInstallCheckFunction · 0.70

Calls 11

getServerBundleFunction · 0.90
runForegroundCommandFunction · 0.90
getInstallCacheKeyFunction · 0.85
getInstallLabelFunction · 0.85
getUpdateCommandFunction · 0.85
resetInstallStateFunction · 0.85
checkServerInstallationFunction · 0.85
pushNotificationMethod · 0.80
setMethod · 0.80
getInstallCommandFunction · 0.70
errorMethod · 0.45

Tested by

no test coverage detected