diff --git a/src/main/pkg_mng/commands/apply.js b/src/main/pkg_mng/commands/apply.js index 2326393..ae7fcb9 100644 --- a/src/main/pkg_mng/commands/apply.js +++ b/src/main/pkg_mng/commands/apply.js @@ -119,8 +119,13 @@ export default async function apply(pkg_id, changes) { await updateInstalledPackage(pkg) + sendToRender(`new:notification`, { + type: "success", + message: "Changes applied!", + }) + sendToRender(`pkg:update:status`, { - id: pkg_id, + ...pkg, status: "installed", statusText: "Changes applied!", }) diff --git a/src/main/pkg_mng/commands/execute.js b/src/main/pkg_mng/commands/execute.js index 341d2f4..00ee91e 100644 --- a/src/main/pkg_mng/commands/execute.js +++ b/src/main/pkg_mng/commands/execute.js @@ -7,7 +7,7 @@ import initManifest from "../../utils/initManifest" import parseStringVars from "../../utils/parseStringVars" import sendToRender from "../../utils/sendToRender" -export default async function execute(pkg_id) { +export default async function execute(pkg_id, { force = false } = {}) { let pkg = await getInstalledPackages(pkg_id) if (!pkg) { @@ -26,12 +26,38 @@ export default async function execute(pkg_id) { if (pkg.remote_url) { pkg = { ...pkg, - ...await readManifest(pkg.remote_url, { just_read: true }), + ...await readManifest(pkg, { just_read: true }), } } pkg = await initManifest(pkg) + if (pkg.check_updates_after_execute === true) { + if (pkg._original_manifest) { + if ((pkg._original_manifest.version !== pkg.version) && !force) { + console.log(`[${pkg_id}] execute() | Update available (${pkg._original_manifest.version} -> ${pkg.version}). Aborting...`,) + console.log(pkg._original_manifest) + + sendToRender("pkg:update_available", { + manifest: pkg._original_manifest, + current_version: pkg._original_manifest.version, + new_version: pkg.version, + }) + + sendToRender("pkg:update:status", { + id: pkg_id, + status: "installed", + }) + + return false + } + } + } + + if (typeof pkg.after_execute === "function") { + await pkg.after_execute(pkg) + } + if (typeof pkg.execute === "string") { pkg.execute = parseStringVars(pkg.execute, pkg) diff --git a/src/main/pkg_mng/commands/update.js b/src/main/pkg_mng/commands/update.js index 0444260..0437592 100644 --- a/src/main/pkg_mng/commands/update.js +++ b/src/main/pkg_mng/commands/update.js @@ -84,7 +84,7 @@ export default async function update(pkg_id) { // update render sendToRender(`pkg:update:status`, { - id: pkg_id, + ...pkg, status: "installed", }) @@ -97,7 +97,7 @@ export default async function update(pkg_id) { } catch (error) { // update render sendToRender(`pkg:update:status`, { - id: pkg_id, + ...pkg, status: "error", statusText: error.toString(), })