updater v1.0.1

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.

Installation

Recommended: Install via installer (handles dependencies automatically):

wget run https://raw.githubusercontent.com/Twijn/cc-misc/main/util/installer.lua updater
View on GitHub →

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:

wget https://raw.githubusercontent.com/Twijn/cc-misc/main/util/updater.lua

Examples

Using with Runtime Installation

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

Usage Examples

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()

Functions

module.getLibraries()

View source on GitHub

Get information about all available libraries

Returns: table|nil List of library info or nil on error

module.getLibraryInfo(name)

View source on GitHub

Get information about a specific library

Parameters:
Returns: table|nil Library info or nil on error

module.checkUpdates()

View source on GitHub

Check for updates to installed libraries

Returns: table List of libraries with available updates

module.hasUpdate(name)

View source on GitHub

Check if a specific library has an update available

Parameters:
Returns: boolean, string|nil, string|nil Has update, current version, latest version

module.update(name, silent?)

View source on GitHub

Install or update a library

Parameters:
Returns: boolean Success

module.updateAll(silent?)

View source on GitHub

Update all installed libraries that have updates available

Parameters:
Returns: number Number of successful updates

module.listInstalled()

View source on GitHub

List all installed libraries with their versions

Returns: table List of {name, version, path} for installed libraries

module.install(name, silent?)

View source on GitHub

Install a new library with its dependencies

Parameters:
Returns: boolean Success