MCPcopy
hub / github.com/APKLab/APKLab / checkAndInstallTools

Function checkAndInstallTools

src/utils/updater.ts:127–164  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

125 * If any tool does not exist, download it.
126 */
127export async function checkAndInstallTools(): Promise<void> {
128 try {
129 const extensionConfig =
130 vscode.workspace.getConfiguration(extensionConfigName);
131 const config = await getUpdateConfig();
132
133 const results = await Promise.allSettled(
134 config.tools.map(async (tool) => {
135 const toolPath = extensionConfig.get(tool.configName);
136 if (!toolPath || !fs.existsSync(String(toolPath))) {
137 const filepath = await downloadTool(tool);
138 if (!filepath) {
139 throw new Error(
140 `Failed to download tool: ${tool.name}`,
141 );
142 }
143 if (tool.name === "apktool") {
144 // remove old res framework on apktool install
145 await apktool.emptyFrameworkDir();
146 }
147 }
148 }),
149 );
150
151 // Check if any downloads failed
152 const failures = results.filter(
153 (result) => result.status === "rejected",
154 );
155 if (failures.length > 0) {
156 const errors = failures
157 .map((f) => (f as PromiseRejectedResult).reason)
158 .join(", ");
159 outputChannel.appendLine(`Failed to install some tools: ${errors}`);
160 }
161 } catch (err) {
162 outputChannel.appendLine(`Can't download/update dependencies: ${err}`);
163 }
164}
165
166/**
167 * download the dynamic update data and save it locally.

Callers 8

activateFunction · 0.90
apktool.test.tsFile · 0.90
apk-mitm.test.tsFile · 0.90
smali-lsp.test.tsFile · 0.90
git.test.tsFile · 0.90
quark.test.tsFile · 0.90
jadx.test.tsFile · 0.90

Calls 2

downloadToolFunction · 0.90
getUpdateConfigFunction · 0.85

Tested by

no test coverage detected