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

Function installServer

src/cm/lsp/servers/luau.ts:136–186  ·  view source on GitHub ↗
(_, manifest, mode, options = {})

Source from the content-addressed store, hash-verified

134 }
135 },
136 async installServer(_, manifest, mode, options = {}): Promise<boolean> {
137 const { promptConfirm = true } = options;
138 const install = manifest.launcher?.install;
139 const assetCases = buildShellArchCase(install?.assetNames, quoteArg);
140 const binaryPath = install?.binaryPath;
141 const repo = install?.repo;
142 if (!assetCases || !binaryPath || !repo) {
143 throw new Error("Luau bundle is missing release metadata");
144 }
145
146 const label = manifest.label || "Luau";
147 const actionLabel = mode === "update" ? "Update" : "Install";
148
149 if (promptConfirm) {
150 const shouldContinue = await confirm(
151 label,
152 `${actionLabel} ${label} language server?`,
153 );
154 if (!shouldContinue) {
155 return false;
156 }
157 }
158
159 const downloadUrl = `https://github.com/${repo}/releases/latest/download/$ASSET`;
160 const command = `apk add --no-cache curl unzip && ARCH="$(uname -m)" && case "$ARCH" in
161${assetCases}
162\t*) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;;
163esac && apk add --no-cache gcompat libstdc++ && TMP_DIR="$(mktemp -d)" && cleanup() { rm -rf "$TMP_DIR"; } && trap cleanup EXIT && curl -fsSL "${downloadUrl}" -o "$TMP_DIR/$ASSET" && unzip -oq "$TMP_DIR/$ASSET" -d "$TMP_DIR" && chmod +x "$TMP_DIR/luau-lsp" && if ! "$TMP_DIR/luau-lsp" --help >/dev/null 2>&1 && ! "$TMP_DIR/luau-lsp" lsp --help >/dev/null 2>&1; then command -v ldd >/dev/null 2>&1 && ldd "$TMP_DIR/luau-lsp" >&2 || true; echo "Luau release binary is not runnable in this environment." >&2; exit 1; fi && install -Dm755 "$TMP_DIR/luau-lsp" ${quoteArg(binaryPath)}`;
164
165 const loadingDialog = loader.create(
166 label,
167 `${actionLabel}ing ${label}...`,
168 );
169 try {
170 loadingDialog.show();
171 await runForegroundCommand(command);
172 const runtimeFailure = await readLuauRuntimeFailure(binaryPath);
173 if (runtimeFailure) {
174 await runQuickCommand(`rm -f ${quoteArg(binaryPath)}`);
175 throw new Error(getLuauRuntimeFailureMessage(runtimeFailure));
176 }
177 toast(`${label} ${mode === "update" ? "updated" : "installed"}`);
178 return true;
179 } catch (error) {
180 console.error(`Failed to ${actionLabel.toLowerCase()} ${label}`, error);
181 toast(strings?.error ?? "Error");
182 throw error;
183 } finally {
184 loadingDialog.destroy();
185 }
186 },
187 },
188});

Callers

nothing calls this directly

Calls 11

buildShellArchCaseFunction · 0.90
quoteArgFunction · 0.90
runForegroundCommandFunction · 0.90
runQuickCommandFunction · 0.90
confirmFunction · 0.85
readLuauRuntimeFailureFunction · 0.85
createMethod · 0.65
showMethod · 0.45
errorMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected