diff --git a/changelog.md b/changelog.md index cebadb1..754c529 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 2025-10-27 - 1.3.0 - feat(cli) +Add automatic update command and documentation updates + +- Add 'update' CLI command that checks the latest Gitea release and runs the install script to perform a self-update +- Implements release fetch/compare logic and executes the repository install.sh via curl +- Update README to document the one-line installer and the new 'moxytool update' usage +- Update changelog to note the new update command and installation clarifications + ## 2025-10-27 - 1.2.0 - feat(scripts) Add community scripts subsystem: script index, runner, and CLI commands with background refresh; update docs and paths @@ -19,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.1.0] - 2025-01-27 ### Added +- `update` command for automatic self-updating from Gitea releases - `scripts` command for Proxmox community scripts management - Access to 400+ community-maintained installation scripts - Automatic daily index updates with local caching @@ -26,8 +35,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Interactive script execution with full stdin/stdout/stderr passthrough - Support for both LXC containers and VM templates - Script metadata display (requirements, ports, credentials) +- One-line installation script as primary installation method ### Features +- `moxytool update` - Update MOXYTOOL to the latest version automatically - `moxytool scripts list` - List all available scripts - `moxytool scripts search ` - Search scripts by keyword - `moxytool scripts info ` - View detailed script information diff --git a/readme.md b/readme.md index 81d545b..9b5f7bd 100644 --- a/readme.md +++ b/readme.md @@ -19,7 +19,22 @@ MOXYTOOL is a comprehensive command-line tool for managing Proxmox servers, with ## Installation -### Global Installation (Recommended) +### One-Line Installation (Recommended) + +```bash +# Download and install MOXYTOOL automatically +curl -sSL https://code.foss.global/serve.zone/moxytool/raw/branch/main/install.sh | sudo bash +``` + +This will: +- Detect your platform automatically (Linux x64/ARM64, macOS Intel/Apple Silicon, Windows) +- Download the latest binary from Gitea releases (~400-500KB) +- Install to `/usr/local/bin/moxytool` +- Make it available system-wide + +### Via npm (Alternative) + +Install globally using npm: ```bash npm install -g @serve.zone/moxytool @@ -31,14 +46,28 @@ or with pnpm: pnpm install -g @serve.zone/moxytool ``` -### Local Installation - -```bash -npm install @serve.zone/moxytool -``` +**Benefits:** +- Automatic platform detection and binary download +- Easy updates via `npm update -g @serve.zone/moxytool` +- Version management with npm +- Works with Node.js >=14 ## Usage +### Updating MOXYTOOL + +Update to the latest version from the repository: + +```bash +moxytool update +``` + +This command will: +- Check the current version +- Fetch the latest release from Gitea +- Automatically download and install the update if available +- Preserve your existing configuration + ### vGPU Setup Install and configure NVIDIA vGPU support on your Proxmox host: diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 0fd0aaa..85b0a43 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@serve.zone/moxytool', - version: '1.2.0', + version: '1.3.0', description: 'Proxmox administration tool for vGPU setup, VM management, and cluster configuration' } diff --git a/ts/moxytool.cli.ts b/ts/moxytool.cli.ts index 8c17f86..48d8190 100644 --- a/ts/moxytool.cli.ts +++ b/ts/moxytool.cli.ts @@ -36,6 +36,7 @@ export const runCli = async () => { logger.log('info', 'Available commands:'); logger.log('info', '* vgpu-setup - Install and configure Proxmox vGPU support'); logger.log('info', '* scripts - Manage Proxmox community scripts'); + logger.log('info', '* update - Update MOXYTOOL to the latest version'); logger.log('info', ''); logger.log('info', 'Usage: moxytool [options]'); }); @@ -129,6 +130,78 @@ export const runCli = async () => { } }); + // Update command + smartcliInstance.addCommand('update').subscribe(async (argvArg) => { + logger.log('info', 'Checking for updates...'); + logger.log('info', ''); + + try { + // Get current version from deno.json + const denoJsonPath = plugins.path.join(paths.packageDir, 'deno.json'); + let currentVersion = '1.1.0'; // fallback + + try { + const denoJsonContent = await Deno.readTextFile(denoJsonPath); + const denoJson = JSON.parse(denoJsonContent); + currentVersion = denoJson.version || currentVersion; + } catch { + // Use fallback version + } + + // Fetch latest version from Gitea API + const apiUrl = 'https://code.foss.global/api/v1/repos/serve.zone/moxytool/releases/latest'; + const response = await fetch(apiUrl); + + if (!response.ok) { + logger.log('error', 'Failed to check for updates'); + logger.log('error', `HTTP ${response.status}: ${response.statusText}`); + Deno.exit(1); + } + + const release = await response.json(); + const latestVersion = release.tag_name; // e.g., "v1.1.0" + + // Normalize versions for comparison (ensure both have "v" prefix) + const normalizedCurrent = currentVersion.startsWith('v') ? currentVersion : `v${currentVersion}`; + const normalizedLatest = latestVersion.startsWith('v') ? latestVersion : `v${latestVersion}`; + + logger.log('info', `Current version: ${normalizedCurrent}`); + logger.log('info', `Latest version: ${normalizedLatest}`); + logger.log('info', ''); + + // Compare normalized versions + if (normalizedCurrent === normalizedLatest) { + logger.log('success', 'Already up to date!'); + logger.log('info', ''); + return; + } + + logger.log('ok', `New version available: ${latestVersion}`); + logger.log('info', 'Downloading and installing...'); + logger.log('info', ''); + + // Download and run the install script + const installUrl = 'https://code.foss.global/serve.zone/moxytool/raw/branch/main/install.sh'; + + const updateResult = await smartshellInstance.exec( + `curl -sSL ${installUrl} | bash` + ); + + if (updateResult.exitCode !== 0) { + logger.log('error', 'Update failed'); + logger.log('error', updateResult.stderr || 'Unknown error'); + Deno.exit(1); + } + + logger.log('info', ''); + logger.log('success', `Updated to ${latestVersion}`); + logger.log('info', ''); + } catch (error) { + logger.log('error', `Update failed: ${error instanceof Error ? error.message : String(error)}`); + Deno.exit(1); + } + }); + // Scripts management commands smartcliInstance.addCommand('scripts').subscribe(async (argvArg) => { const subcommand = argvArg._[0];