feat: plugin install/uninstall lifecycle + UI buttons
- AppConfig: add InstalledPlugins []string - Manager.Discover(): no config dependency, all plugins start inactive - Manager.SyncConfig(): apply installed/enabled state from AppConfig - Manager.Enable(): works for plugins without on_install hook - Manager.Install/Uninstall(): run on_install/on_uninstall hooks - ActivatePlugin: skip if HasInstall && !Installed - ReloadPlugins: Discover → SyncConfig → InitRuntimes - Bindings: InstallPlugin, UninstallPlugin - SettingsPlugins: install/uninstall buttons, toggle only after install - Calendar: migration moved from on_init to on_install, on_uninstall drops tables - Tests: all 12 pass (manager + runtime + calendar)
This commit is contained in:
@@ -649,10 +649,9 @@ end
|
||||
-- Hooks
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
function on_init()
|
||||
print("Calendar: on_init — running migration")
|
||||
function on_install()
|
||||
print("Calendar: on_install — creating tables")
|
||||
|
||||
-- Run migration SQL
|
||||
local ok, err = pcall(function()
|
||||
verstak.db.exec([[
|
||||
CREATE TABLE IF NOT EXISTS categories (
|
||||
@@ -696,13 +695,40 @@ function on_init()
|
||||
|
||||
if not ok then
|
||||
print("Calendar: migration error: " .. tostring(err))
|
||||
error(err)
|
||||
else
|
||||
print("Calendar: migration complete")
|
||||
end
|
||||
|
||||
-- Ensure default categories
|
||||
-- Insert default categories
|
||||
M.ensure_categories()
|
||||
|
||||
print("Calendar: install complete")
|
||||
end
|
||||
|
||||
function on_uninstall()
|
||||
print("Calendar: on_uninstall — dropping tables")
|
||||
|
||||
local ok, err = pcall(function()
|
||||
verstak.db.exec("DROP TABLE IF EXISTS events")
|
||||
verstak.db.exec("DROP TABLE IF EXISTS categories")
|
||||
end)
|
||||
|
||||
if not ok then
|
||||
print("Calendar: uninstall error: " .. tostring(err))
|
||||
else
|
||||
print("Calendar: tables dropped")
|
||||
end
|
||||
|
||||
-- Clean up config
|
||||
pcall(verstak.config.set, "categories", nil)
|
||||
|
||||
print("Calendar: uninstall complete")
|
||||
end
|
||||
|
||||
function on_init()
|
||||
print("Calendar: on_init — registering API")
|
||||
|
||||
-- Register global API for panel access
|
||||
_G.calendar = M
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,9 @@
|
||||
|
||||
"hooks": {
|
||||
"on_init": "on_init",
|
||||
"on_shutdown": "on_shutdown"
|
||||
"on_shutdown": "on_shutdown",
|
||||
"on_install": "on_install",
|
||||
"on_uninstall": "on_uninstall"
|
||||
},
|
||||
|
||||
"ui": {
|
||||
|
||||
Reference in New Issue
Block a user