A package updater module for CC-Misc utilities that checks for and installs updates programmatically using the GitHub API. Features: Check for available updates, programmatic package installation and updates, version comparison, dependency resolution, batch update operations, and JSON API integration.
Recommended: Install via installer (handles dependencies automatically):
This pattern downloads and runs libraries at runtime, automatically installing any that are missing:
-- Auto-install and require libraries
local libs = {"updater"} -- Add more libraries as needed
local libDir = (fs.exists("disk") and "disk/lib/" or "/lib/")
local allExist = true
for _, lib in ipairs(libs) do
if not fs.exists(libDir .. lib .. ".lua") then
allExist = false
break
end
end
if not allExist then
shell.run("wget", "run", "https://raw.githubusercontent.com/Twijn/cc-misc/main/util/installer.lua", table.unpack(libs))
end
local updater = require(libDir .. "updater")
-- Use the library
-- (your code here)
Alternative: Direct download via wget:
This example shows how to download and use libraries with automatic installation:
-- Auto-install and require libraries
local libs = {"updater"} -- Add more libraries as needed
local libDir = (fs.exists("disk") and "disk/lib/" or "/lib/")
local allExist = true
for _, lib in ipairs(libs) do
if not fs.exists(libDir .. lib .. ".lua") then
allExist = false
break
end
end
if not allExist then
shell.run("wget", "run", "https://raw.githubusercontent.com/Twijn/cc-misc/main/util/installer.lua", table.unpack(libs))
end
local updater = require(libDir .. "updater")
-- Use the library
local updater = require("updater")
-- Check for updates
local updates = updater.checkUpdates()
for _, update in ipairs(updates) do
print(update.name .. ": " .. update.current .. " -> " .. update.latest)
end
-- Update a specific package
updater.update("s")
-- Update all packages
updater.updateAll()
module.getLibraries()Get information about all available libraries
module.getLibraryInfo(name)Get information about a specific library
name (string): Library namemodule.checkUpdates()Check for updates to installed libraries
module.hasUpdate(name)Check if a specific library has an update available
name (string): Library namemodule.update(name, silent?)Install or update a library
name (string): Library namesilent? (boolean): Suppress output messagesmodule.updateAll(silent?)Update all installed libraries that have updates available
silent? (boolean): Suppress output messagesmodule.listInstalled()List all installed libraries with their versions
module.install(name, silent?)Install a new library with its dependencies
name (string): Library namesilent? (boolean): Suppress output messages