Skip to content

Add a self-update command for the standalone PHAR - #65

Merged
joetannenbaum merged 12 commits into
2.xfrom
feat/self-update
Aug 13, 2026
Merged

Add a self-update command for the standalone PHAR#65
joetannenbaum merged 12 commits into
2.xfrom
feat/self-update

Conversation

@WendellAdriel

Copy link
Copy Markdown
Member

Overview

Standalone PHAR users have no way to update cpx short of manually downloading the latest release, while Composer-managed installs already have composer global update. This brings the standard self-update experience every PHAR-distributed CLI ships (Composer, Laravel Zero apps) to cpx.

Solution

cpx self-update fetches the latest GitHub release, verifies the downloaded PHAR against the sha256 digest the release API publishes, smoke-runs it with --version, and then swaps the running binary in place — an atomic rename on POSIX and a copy-over on Windows, with a backup restored if the swap fails. It follows the house conventions (--json envelope, Prompts output, streams-based HTTP with GITHUB_TOKEN support) and adds zero runtime dependencies. Composer-managed installs are updated too, with a note that composer global update cpx/cpx makes it stick.

Examples

$ cpx self-update

 ┌ cpx updated ─────────────────────────────────────┐
 │ Updated cpx from v1.9.9 to v2.0.0.               │
 └──────────────────────────────────────────────────┘

$ cpx self-update --json
{"success":true,"errors":[],"summary":{"updated":true,"from":"v1.9.9","to":"v2.0.0","path":"/usr/local/bin/cpx"}}

@WendellAdriel
WendellAdriel marked this pull request as ready for review August 11, 2026 11:45
@joetannenbaum
joetannenbaum merged commit 59a5d64 into 2.x Aug 13, 2026
22 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants