Every other railyard command (deploy, rollback, deploys, domains) follows
a deploy with no way to see the Worker's own logs afterward -- the CLI's
README promises "one command" deploys but left debugging a bad deploy to
a separate `wrangler tail` invocation the user has to assemble by hand
(right worker name, right account). That's a real gap in the deploy/ops
loop this CLI exists to close for every consumer product that ships
through Railyard.
Add `railyard logs [--app NAME] [--branch B] [--format pretty|json]
[--status ok|error|canceled]`: resolves the same Worker name deploy uses
(workerName(app, branch)) and runs `wrangler tail` against it with the
user's own Cloudflare login, same as deploy/rollback/domains. Requires
`railyard login` first, for the same identity consistency as every other
command.
Also fix a latent bug in run.mjs surfaced by this feature: a child
process stopped by a signal (e.g. Ctrl+C on a long-running tail) resolved
with `code: 1` (a false failure) because `code ?? 1` treated a null exit
code as an error even when the process was cleanly killed by signal.
Now `close` also captures `signal`, and a signal-stopped child resolves
`code: 0` -- a Ctrl+C on `railyard logs` reports success, not "Could not
stream logs."
Verified manually (no new test files, per instructions): ran the
existing `node --test test/*.test.mjs` suite (23/23 still green, 0
regressions), then drove `main()` from a scratch script against a
throwaway fake `wrangler` binary (deleted after, not committed): logs
without login is refused, an unknown --format is rejected, `railyard
logs` in a project on main resolves and tails the same worker name
`railyard deploy` would use, `--app`/`--status` on a feature branch
resolve to the branch-preview worker name with --status passed through,
and --help lists the new command. Separately confirmed in a standalone
repro that a SIGINT-killed child now resolves `{ code: 0, signal:
"SIGINT" }` instead of the old `code: 1`.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
85 lines
4.0 KiB
Markdown
85 lines
4.0 KiB
Markdown
# railyard
|
|
|
|
Deploy a Next.js, Vite, Astro or static site to your own Cloudflare account with
|
|
one command. Every git branch gets its own preview, every deploy is listed in
|
|
your Railyard console, and a bad deploy is one command away from the version
|
|
before it.
|
|
|
|
```sh
|
|
npx railyard login # opens a code page; approve it in the browser
|
|
npx railyard deploy # builds and deploys the folder you are in
|
|
```
|
|
|
|
## What it does
|
|
|
|
- Finds your framework: Next.js (built for Cloudflare Workers), Vite, Astro
|
|
(static output) or a plain `index.html`. Anything else stops with one line
|
|
that says what to change.
|
|
- Uses Cloudflare's own login on your machine. The first deploy opens
|
|
Cloudflare in your browser; Railyard never sees that login and never asks
|
|
for a key.
|
|
- Names the Worker after your app on `main`, and `<app>-<branch>` on any other
|
|
branch, so each branch has its own URL.
|
|
- Records each deploy in the console: URL, commit, branch, framework, how long
|
|
it took and whether it worked.
|
|
- `railyard rollback` puts the previous version of the same branch back live.
|
|
|
|
## Commands
|
|
|
|
| Command | What it does |
|
|
|---|---|
|
|
| `railyard login` | Signs this machine in to your Railyard org |
|
|
| `railyard deploy [--app NAME] [--branch B] [--dir PATH]` | Builds and deploys |
|
|
| `railyard rollback [--app NAME] [--branch B]` | Goes back one version |
|
|
| `railyard deploys [--app NAME]` | Lists recent deploys |
|
|
| `railyard logs [--app NAME] [--branch B] [--format pretty\|json] [--status ok\|error\|canceled]` | Streams the app's Worker logs until you stop it with Ctrl+C |
|
|
| `railyard link [--app NAME]` | Deploys this GitHub repository on every push |
|
|
| `railyard ci` | The deploy step inside GitHub Actions (the workflow `link` adds runs it) |
|
|
| `railyard domains [--app NAME]` | Lists the app's own domains and whether their certificate is issued |
|
|
| `railyard domains add HOSTNAME [--app NAME]` | Serves the app's production deploy on your domain (the domain must be in your Cloudflare account; Cloudflare issues the certificate) |
|
|
| `railyard domains remove HOSTNAME [--app NAME]` | Takes the domain off the app; running it again changes nothing |
|
|
|
|
Domains use your organization's Cloudflare connection from `railyard link` when
|
|
there is one; otherwise your local Cloudflare login (`wrangler login`, or
|
|
`CLOUDFLARE_API_TOKEN` with `CLOUDFLARE_ACCOUNT_ID` when it reaches several
|
|
accounts). The token is never printed or sent to Railyard.
|
|
|
|
Your Railyard sign-in is saved in `~/.config/railyard/credentials.json`, readable
|
|
only by you. There is no option that takes a key or a token.
|
|
|
|
## Ship from GitHub (arriving)
|
|
|
|
This is switched on per console with `RAILYARD_SHIP_ON_PUSH_LIVE`; until then
|
|
`railyard link` answers that it is not on yet.
|
|
|
|
```sh
|
|
npx railyard link
|
|
```
|
|
|
|
`link` prints one page to open. There you install the Railyard GitHub app on
|
|
the repository and allow Cloudflare access on Cloudflare's own screen; either
|
|
step is skipped when you did it before. Railyard then opens one pull request
|
|
that adds `.github/workflows/railyard.yml`. Once you merge it, each push to your
|
|
default branch goes live, and each other branch gets its own preview; Railyard
|
|
writes the preview URL on that branch's pull request.
|
|
|
|
The workflow holds no key. Each run proves which repository and branch it is
|
|
with GitHub's own identity token, and Railyard answers with a short-lived
|
|
Cloudflare token that is hidden in the log. Builds use your GitHub Actions
|
|
minutes and deploy to your Cloudflare account.
|
|
|
|
## In a Scribase project
|
|
|
|
Run `railyard deploy` in a folder where Scribase wrote the app's env file. The
|
|
project's URL and anon key (both public, they ship in the app) are set for the
|
|
build and on the Worker, so nothing is pasted and neither is printed; only
|
|
their names are shown. Anything secret in the same file, such as the service
|
|
role key, is left out and named. A git branch with its own Scribase branch
|
|
settings (`.scribase/branches/<branch>.env`) deploys its preview against that
|
|
branch.
|
|
|
|
## Where it runs
|
|
|
|
Deploys go to your own Cloudflare account. Railyard hosts nothing; it keeps the
|
|
deploy history and the console.
|