diff --git a/src/main/index.js b/src/main/index.js index b66b299..8b06669 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -29,7 +29,7 @@ class ElectronApp { this.pkgManager.update(manifest_id) }, "bundle:exec": (event, manifest_id) => { - this.pkgManager.exec(manifest_id) + this.pkgManager.execute(manifest_id) }, "bundle:install": async (event, manifest) => { this.pkgManager.install(manifest) diff --git a/src/main/pkgManager.js b/src/main/pkgManager.js index 237f168..504a943 100644 --- a/src/main/pkgManager.js +++ b/src/main/pkgManager.js @@ -594,4 +594,67 @@ export default class PkgManager { console.error(error) } } + + async execute(manifest_id) { + console.log(`Executing ${manifest_id}...`) + + sendToRenderer("installation:status", { + status: "starting", + id: manifest_id, + statusText: `Executing ${manifest_id}...`, + }) + + const db = await this.readDb() + + let manifest = db.installations.find((i) => i.id === manifest_id) + + if (!manifest) { + sendToRenderer("runtime:error", "Manifest not found") + return false + } + + const packPath = path.resolve(INSTALLERS_PATH, manifest.id) + + if (manifest.remote_url) { + manifest = await readManifest(manifest.remote_url, { just_read: true }) + } + + if (typeof manifest.init === "function") { + const init_result = await manifest.init({ + pack_dir: packPath, + tmp_dir: TMP_PATH + }) + + manifest = { + ...manifest, + ...init_result, + } + + delete manifest.init + } + + if (typeof manifest.execute !== "function") { + sendToRenderer("installation:status", { + status: "execution_failed", + ...manifest, + }) + + return false + } + + await manifest.execute({ + manifest, + pack_dir: packPath, + tmp_dir: TMP_PATH + }) + + sendToRenderer("installation:status", { + status: "installed", + ...manifest, + }) + + console.log(`Successfully executed ${manifest_id}!`) + + return true + } } \ No newline at end of file diff --git a/src/main/setup.js b/src/main/setup.js index ce24f2a..f55015a 100644 --- a/src/main/setup.js +++ b/src/main/setup.js @@ -6,8 +6,6 @@ import { pipeline as streamPipeline } from "node:stream/promises" import unzipper from "unzipper" -import { extractFull } from "node-7z" - import got from "got" function resolveDestBin(pre, post) { diff --git a/src/renderer/src/pages/manager/index.jsx b/src/renderer/src/pages/manager/index.jsx index 7891c6c..dede8e3 100644 --- a/src/renderer/src/pages/manager/index.jsx +++ b/src/renderer/src/pages/manager/index.jsx @@ -92,6 +92,14 @@ const InstallationItem = (props) => {
+ { + isInstalled && manifest.executable && } + onClick={onClickPlay} + /> + } + { isFailed && { /> } - { - isInstalled && manifest.exec_path && } - onClick={onClickPlay} - /> - } - { isInstalled &&