Skip to content

Cloudflare Worker

install.dotfiles.wiki is a Cloudflare Worker in the cloudflare/ directory. It returns an installation script for whatever chezmoi repository the query string names, defaulting to this one.

  1. The request arrives with optional username, provider, repo, branch, and os parameters.

  2. os decides the script type. Without it, a PowerShell user agent gets PowerShell and everything else gets a POSIX shell script.

  3. The provider and names become a repository URL. github, gitlab, and bitbucket map to their hosts; any other value is treated as a bare domain.

  4. Inputs are stripped of shell metacharacters and the branch is capped at fifty characters.

  5. The script is returned inline. Nothing is fetched from GitHub at request time.

The shell script installs the Xcode Command Line Tools on macOS or git and curl through the distro package manager on Linux, installs chezmoi into ~/.local/bin, and runs chezmoi init --apply <url> --branch <branch>.

The worker-deploy.yml workflow runs bun test on every pull request that touches cloudflare/ and deploys with wrangler-action on push to main. Tests cover both script generators, URL generation per provider, and input sanitising.

Terminal window
cd cloudflare
bun install
bun test
bun run dev # local worker on wrangler

The Worker stays generic on purpose. It serves Linux and Windows users of other repositories even though this repository is macOS only.