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

Function checkPluginsUpdate

src/lib/checkPluginsUpdate.js:5–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import config from "./config";
4
5export default async function checkPluginsUpdate() {
6 const plugins = await fsOperation(PLUGIN_DIR).lsDir();
7 const promises = [];
8 const updates = [];
9
10 plugins.forEach((pluginDir) => {
11 promises.push(
12 (async () => {
13 const plugin = await fsOperation(
14 Url.join(pluginDir.url, "plugin.json"),
15 ).readFile("json");
16
17 const res = await fetch(
18 `${config.API_BASE}/plugin/check-update/${plugin.id}/${plugin.version}`,
19 );
20
21 if (res.ok) {
22 const json = await res.json();
23 if (json.update) {
24 updates.push(plugin.id);
25 }
26 }
27 })(),
28 );
29 });
30
31 await Promise.allSettled(promises);
32 return updates;
33}

Callers 1

onDeviceReadyFunction · 0.85

Calls 3

fsOperationFunction · 0.85
lsDirMethod · 0.45
readFileMethod · 0.45

Tested by

no test coverage detected