Contributing
How Rift is built
Rift is two programs that ship as one binary: rift, a PHP console application, and rift-dash, the Go program that draws rift dash.
rift
rift is a Laravel Zero (opens in a new tab) application. Laravel Zero is a framework for console applications built from Laravel's components, so Rift's commands get Laravel's service container, its process and HTTP clients and their test fakes, without a web layer or a database.
Every command, every rule about checkouts, domains, ports and .env values, and every call to Docker, Git and the Caddy (opens in a new tab) router lives here, in app/.
rift-dash
rift-dash draws rift dash. It is a Go (opens in a new tab) program in dash/, built with Bubble Tea (opens in a new tab) and Lip Gloss (opens in a new tab), because a terminal interface needs a fast event loop that PHP has no maintained library for.
It only draws, reads keys and runs commands:
- it keeps one
rift dash:watchrunning, which prints a JSON snapshot of every project every two seconds, - it runs
riftitself for every action.
Rift's rules are never repeated in Go, so the two cannot disagree.
The contract between them
SnapshotJson writes that JSON, and dash/testdata/snapshot.json is the contract between the two programs:
SnapshotJsonmust produce the fixture exactly,rift-dashis tested against the same file.
A change one side has not caught up with fails a test. Change both, and bump SnapshotJson::VERSION and Go's snapshot.Version when a field is renamed or removed.
One binary, no runtime to install
Users need neither PHP nor Go. A release binary is rift packed into a PHAR, carrying the rift-dash built for its platform, and appended to a static PHP runtime from static-php-cli (opens in a new tab). rift dash unpacks rift-dash to ~/.cache/rift on first use.
Building binaries explains how a binary is put together.