()
| 125 | * If any tool does not exist, download it. |
| 126 | */ |
| 127 | export 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. |
no test coverage detected