feat: add choco and scoop to opencode upgrade methods
What does this PR do?
Adds support for opencode upgrade to work with Chocolatey and Scoop installations. This works by adding choco and scoop commands to the relevant methods in the Installation namespace -
Installation.method: addchoco listandscoop listcommandsInstallation.upgrade: addchoco upgrade --version=<target>andscoop install opencode@<target>commandsInstallation.latest: fetch the latest version number of thechocoandscoopopencode packages from public manifest URLs
How did you verify your code works?
Chocolatey
PS C:\Users\Mani\repos\opencode\dev--win-auto-update> opencode -v
1.1.17
PS C:\Users\Mani\repos\opencode\dev--win-auto-update> bun dev upgrade
$ bun run --cwd packages/opencode --conditions=browser src/index.ts upgrade
▄
█▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
█░░█ █░░█ █▀▀▀ █░░█ █░░░ █░░█ █░░█ █▀▀▀
▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀ ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀
┌ Upgrade
│
● Using method: choco
│
● From v1.1.17 → 1.1.18
│
◇ Upgrade complete
│
└ Done
PS C:\Users\Mani\repos\opencode\dev--win-auto-update> opencode -v
1.1.18
Scoop
PS C:\Users\Mani\repos\opencode\dev--win-auto-update> opencode -v
1.1.17
PS C:\Users\Mani\repos\opencode\dev--win-auto-update> bun dev upgrade
$ bun run --cwd packages/opencode --conditions=browser src/index.ts upgrade
▄
█▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
█░░█ █░░█ █▀▀▀ █░░█ █░░░ █░░█ █░░█ █▀▀▀
▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀ ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀
┌ Upgrade
│
● Using method: scoop
│
● From v1.1.17 → 1.1.18
│
◇ Upgrade complete
│
└ Done
PS C:\Users\Mani\repos\opencode\dev--win-auto-update> opencode -v
1.1.18
Notify Update
latest() pulls in the right version for our chocolatey based install (1.1.18 at the time of this PR whereas latest release is on 1.1.19
Not an Elevated Command Shell
Chocolatey has an annoying issue where it doesn't allow installation or upgrading a package if you're not in an elevated command shell. This "error" also passes to stdout and not stderr so we pass a custom error message to the UpgradeFailedError so we can capture it in the upgrade.ts and communicate this to the user.
Output of upgrade w/ a non-elevated command shell (this has been tested on cmd and non-elevated powershell.
PS C:\Users\Mani\repos\opencode\dev--win-auto-update> bun dev upgrade
$ bun run --cwd packages/opencode --conditions=browser src/index.ts upgrade
▄
█▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
█░░█ █░░█ █▀▀▀ █░░█ █░░░ █░░█ █░░█ █▀▀▀
▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀ ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀
┌ Upgrade
│
● Using method: choco
│
● From v1.1.17 → 1.1.18
│
■ Upgrade failed
│
■ Please run the terminal as Administrator and try again
│
└ Done