mirror of
https://github.com/ragestudio/relic.git
synced 2025-06-09 02:24:18 +00:00
support execution
This commit is contained in:
parent
c8aa3d7cba
commit
ad2d9cc4b3
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
@ -92,6 +92,14 @@ const InstallationItem = (props) => {
|
||||
</div>
|
||||
|
||||
<div className="installation_item_actions">
|
||||
{
|
||||
isInstalled && manifest.executable && <antd.Button
|
||||
type="primary"
|
||||
icon={<MdPlayArrow />}
|
||||
onClick={onClickPlay}
|
||||
/>
|
||||
}
|
||||
|
||||
{
|
||||
isFailed && <antd.Button
|
||||
type="primary"
|
||||
@ -108,14 +116,6 @@ const InstallationItem = (props) => {
|
||||
/>
|
||||
}
|
||||
|
||||
{
|
||||
isInstalled && manifest.exec_path && <antd.Button
|
||||
type="primary"
|
||||
icon={<MdPlayArrow />}
|
||||
onClick={onClickPlay}
|
||||
/>
|
||||
}
|
||||
|
||||
{
|
||||
isInstalled && <antd.Button
|
||||
type="primary"
|
||||
|
Loading…
x
Reference in New Issue
Block a user