Commit graph

808 commits

Author SHA1 Message Date
Jake Runzer
53a3d40e5d chore: Release railwayapp version 4.16.0 2025-12-19 18:49:44 -05:00
Jake Runzer
a1d7ce67f6
Add TUI log viewer for dev command (#714)
* Add TUI log viewer for dev command

- ratatui-based interface with tabs: Local, Image, per-service
- 100k line scrollback, follow mode, vim-style navigation
- Docker logs streamed alongside code services
- Opt-out via --no-tui flag (TUI is default)
- Auto-disables when stdout is not a terminal

* Fix TUI scroll behavior and filter railway-proxy logs

- Enable mouse capture for native scroll support
- Fix scroll jump when exiting follow mode by syncing scroll_offset
- Filter out railway-proxy infrastructure logs from docker output

* Batch scroll events to eliminate momentum lag

Drain queued events before rendering to prevent macOS trackpad
inertia from causing gradual scroll movement across render cycles.

* Add service info pane and improve TUI tab visibility

- Change tab colors from DarkGray to Gray (unselected) and Cyan (selected)
- Add info pane showing service URLs and var counts
- Display both private and public URLs separated by pipe when HTTPS enabled
- Info pane content changes based on current tab (Local/Image/Service)

* Skip service summary output in TUI mode and fix terminal cleanup

- Only print service summaries in non-TUI mode (info now shown in TUI pane)
- Fix terminal cleanup order: restore before disabling mouse capture

* Fix --no-tui to only stream code service logs

* Kill process groups on shutdown and fix panic terminal cleanup

- Use process_group(0) to create new process groups for spawned processes
- Use killpg instead of kill to terminate entire process groups
- Add panic hook to restore terminal on panic
- Extract setup_terminal/restore_terminal helpers for consistent cleanup

* Fix terminal corruption on TUI exit by isolating child stdin

Child processes were inheriting stdin from the terminal. When receiving
SIGTERM during shutdown, they could write escape sequences directly to
the terminal, bypassing piped stdout/stderr and corrupting cursor state.

* Improve post-TUI shutdown output

Clear terminal after TUI exits to remove confusing scrollback,
suppress docker compose output, show clean service count summary

* Refactor dev up command with DevSession struct

Extract TUI/service execution logic from up_command() into DevSession
struct with focused methods: start(), run(), shutdown()

* Move DevSession to controllers/develop/session.rs

- Move DevSession struct and impl to session.rs alongside DevelopSessionLock
- Move print_code_service_summary to output.rs
- Update imports in dev.rs

* Remove test script and unnecessary comments
2025-12-19 17:59:40 -05:00
Jake Runzer
7e1beb9fb4 chore: Release railwayapp version 4.15.1 2025-12-17 12:45:54 -05:00
Jake Runzer
a7f4a4ab56
Fix public domain replacement in --no-https mode (#713)
In --no-https mode, resolve_public_domain() was returning None which
caused public domain mapping to be empty. Now returns localhost:{port}
so cross-service domain replacement works without HTTPS.
2025-12-17 02:28:20 -05:00
Jake Runzer
b0fb27f06e
Inject mkcert CA env vars for code services when HTTPS enabled (#712)
Node, Python, and other runtimes bundle their own CA stores and don't
trust the system CA. This injects NODE_EXTRA_CA_CERTS, REQUESTS_CA_BUNDLE,
SSL_CERT_FILE, CURL_CA_BUNDLE, and SSL_CERT_DIR when HTTPS is enabled
and mkcert is installed. Silently falls back if mkcert unavailable.
2025-12-17 01:41:05 -05:00
Jake Runzer
37aa6ead7d
Refactor variable replacement with LocalDevelopContext struct (#711)
* Refactor variable replacement with LocalDevelopContext struct

Simplify variable replacement API by consolidating scattered parameters
into structured types. Adds --verbose flag to dev and run commands.

* Fix port 443 conflict when another project's proxy is running

Check if this project's railway-proxy container owns port 443 before
falling back to per-service ports. Prevents false conflicts when
re-running dev up on the same project.

* Consolidate HTTPS config fields into HttpsDomainConfig struct

Replace 3 separate fields (https_enabled, https_base_domain, use_port_443)
with single Option<HttpsDomainConfig> field. https_enabled() is now a
method returning .is_some().

* Clean up code slop in dev command flow

- Remove unnecessary comments explaining obvious code
- Replace defensive unwrap_or_else fallbacks with expect() where service is guaranteed in context
- Fix empty string fallback for slug to use slugify(service_id)
- Simplify path display logic from nested chain to match
- Remove redundant doc comments

* Fix HTTPS proxy port in variable replacement for fallback mode

When port 443 is unavailable and HTTPS falls back to per-service ports,
variable replacement was using the internal port (e.g., 4567) instead
of the HTTPS proxy port (e.g., 41191).

Add https_proxy_port field to ServiceDomainConfig and use it in
resolve_public_domain when use_port_443 is false.

* Add DEFAULT_PORT constant (8080), remove dead code in local_override

* Fix cross-service domain replacement in railway run

- Consolidate build_local_override_context functions into one that
  auto-loads LocalDevConfig
- Make override_railway_vars accept Option<&ServiceLocalDomains> so
  cross-service replacements work even when current service isn't
  in context
- Add code service handling to local override context builder
2025-12-17 00:32:25 -05:00
Jake Runzer
a41ebe76ef chore: Release railwayapp version 4.15.0 2025-12-12 18:34:21 -05:00
Jake Runzer
17c97f4b9c chore: Release railwayapp version 4.14.0 2025-12-12 18:23:19 -05:00
Jake Runzer
0e60a613f6 chore: Release railwayapp version 4.13.0 2025-12-12 18:22:59 -05:00
Jake Runzer
c65c909420
Add dev command for local development with Docker Compose (#710)
* init develop command

* develop: use service names, random ports, project-specific dir

- extract environment config types to controllers/environment_config.rs
- use slugified service names instead of IDs in compose
- generate deterministic external ports (10000-60000) to avoid conflicts
- save compose to ~/.railway/develop/<project_id>/
- always run detached

* develop: show service names and URLs in output

* develop: resolve variables and override Railway networking vars

- Fetch resolved variables via VariablesForServiceDeployment API
- Override RAILWAY_PRIVATE_DOMAIN with docker-compose service slug
- Override RAILWAY_PUBLIC_DOMAIN and RAILWAY_TCP_PROXY_DOMAIN with localhost
- Override RAILWAY_TCP_PROXY_PORT with mapped local port
- Replace *.railway.internal refs in values with service slugs
- Filter deprecated vars (RAILWAY_STATIC_URL, RAILWAY_SERVICE_*_URL)
- Add docker-compose networking for inter-container communication
- Escape $ as $$ in commands for docker-compose interpolation

* develop: add volume support and down subcommand

- Add volumes field to docker-compose output (persist through up/down)
- Add `develop down` subcommand to stop containers
- Use environment ID for compose dir and volume names
- Show volume mount paths in service summary

* run: use local services when develop is active

Add --no-local flag to skip. Extracts shared variable override logic
into controllers/local_override.rs for reuse between run and develop.

* develop down: add --clean flag to remove volumes and files

* restart services on failure

* develop: add local HTTPS with mkcert and pretty URLs

- auto-generate TLS certs via mkcert for {project}.railway.dev
- add Caddy reverse proxy for HTTPS termination
- set RAILWAY_PUBLIC_DOMAIN to https://{domain}:{port}
- auto-add /etc/hosts entry on develop up
- remove hosts entry on develop down --clean
- skip cert generation if already exists

* develop: use .localhost TLD instead of .railway.dev

.localhost resolves to 127.0.0.1 per RFC 6761, eliminating need for
/etc/hosts manipulation and sudo prompts

* process manager

* develop: support port 443 for prettier public URLs

- Try binding to port 443 at startup for cleaner URLs
- Port 443 mode: https://{service}.{project}.railway.localhost
- Fallback mode: https://{project}.railway.localhost:{port}
- Generate wildcard certs (*.project.railway.localhost) for port 443
- SNI-based routing in Caddy when using port 443
- Add http:// prefix to private domain display

* develop: add session lock to prevent concurrent code service runs

- Add DevelopSessionLock using fs2 file locking to prevent multiple
  develop sessions running code services for the same environment
- Check existing https_mode before falling back from port 443
- Lock auto-releases on drop or process crash

* develop: refactor into testable module structure

- Extract shared types to controllers/config/ (EnvironmentConfig)
- Create controllers/develop/ with submodules:
  - ports.rs: slugify, generate_port + tests
  - variables.rs: override_railway_vars + tests
  - session.rs: DevelopSessionLock + tests
  - traits.rs: EnvironmentDataProvider, CommandRunner + mocks
  - compose.rs: DockerCompose types, build_port_infos
  - https_proxy.rs: HttpsConfig, certs, Caddyfile gen
  - code_runner.rs: ProcessManager
  - local_config.rs: LocalDevConfig
- Add async-trait dependency for trait abstractions
- Old controller files re-export for backward compat

* develop: remove unused traits and cleanup backward compat stubs

- Delete unused EnvironmentDataProvider and CommandRunner traits (371 lines)
- Add fetch_environment_config() function to controllers/config
- Update develop.rs to use centralized fetch function
- Delete empty stub files: process_manager.rs, develop_lock.rs,
  local_https.rs, local_dev_config.rs
- Update local_override.rs to import directly from develop module

* develop: remove unused get_env_vars, cleanup dead_code attributes

- Remove unused get_env_vars method from ServiceInstance
- Remove unnecessary #![allow(dead_code)] from compose.rs and output.rs
- Add explanatory comment for dead_code allow in environment.rs
  (needed for API deserialization struct fields)

* dev: rename develop to dev, add clean subcommand

- rename command from `develop` to `dev` (with `develop` alias)
- extract `--clean` flag from `down` into separate `clean` subcommand
- update output: remove "Using port 443" msg, add checkmark to "Started X image services"

* dev: store data in ~/.railway/develop/{projectId} instead of environmentId

* remove unnecessary comments

* dev: add unit tests for compose, https_proxy, local_config

Tests for port building, caddyfile generation, cert existence, and config operations.

* dev: fix cross-platform compatibility for Linux/Windows

- Add extra_hosts to Caddy service for host.docker.internal on Linux
- Use shell execution (sh -c / cmd /C) for proper command parsing
- Replace path unwraps with to_string_lossy()

* dev: check docker compose availability before running

* fix: handle Windows error kind for file lock conflicts

* dev configure: add service menu and --remove <name> support

* dev: clarify comments in up_command

* fix: use fs2 lock_contended_error for cross-platform lock check

* fix: use privateNetworkEndpoint for private domain resolution

Previously used slugified service name which may not match the actual
private network endpoint configured in the environment.

* refactor: extract build_service_endpoints helper for privateNetworkEndpoint

DRYs up duplicate logic between dev.rs and local_override.rs.
Fixes run command using environment_id instead of project_id for
is_local_develop_active check.

* dev: improve empty state messages

Distinguish "no services at all" from "no code services" so users
get actionable guidance (railway add vs railway develop configure)

* fix: only show networking for code services when port configured

* fix: skip canonicalize on windows to avoid UNC path prefix

canonicalize() returns \\?\C:\... paths on Windows which cmd.exe rejects

* dev: improve empty state messages with color

* dev: show command as first log line for code services

* dev: add port selection to configure and detect port conflicts

- prompt for port during service configuration (default: inferred from Railway)
- skip port prompt if service has no networking config
- detect and warn about port conflicts during configure
- force reconfigure conflicting ports during `railway dev up`
- only set PORT env var for services with networking configured

* dev: allow configuring multiple services on first-time setup

Use multi-select prompt instead of single-select, with summary at end

* dev: show OS-specific Docker install URL

* dev: format Docker not found message

* remove test dir

* remove test and to gitignore

* dev: fix cross-service public domain replacement

When service A references service B's RAILWAY_PUBLIC_DOMAIN via variable
interpolation, the production domain wasn't being replaced with the local
equivalent. Now builds a mapping of production -> local public domains
and replaces them in all variable values.

* dev: show next steps when only image services running

* dev: extract constants and refactor up_command

- Add port range constants (PORT_RANGE_MIN, PORT_RANGE_SIZE, RANDOM_PORT_MIN, RANDOM_PORT_MAX)
- Add resolve_path() for cross-platform path canonicalization
- Move generate_random_port() to ports.rs
- Extract helper functions from up_command:
  - print_image_service_summary()
  - print_code_service_summary()
  - build_public_domain_mapping()
  - build_image_service_compose()
  - setup_caddy_proxy()
2025-12-12 18:18:58 -05:00
Jake Runzer
4e830ff507
Fix deprecated GraphQL field usage (#709)
* Fix deprecated GraphQL field usage

Migrate from deprecated service.serviceInstances and volume.volumeInstances
to environment.serviceInstances and environment.volumeInstances. Also removes
deprecated team field usage in favor of workspace id.

* Extract common service/environment lookup helpers

- Add get_service_ids_in_env() and find_service_instance() to controllers/project.rs
- Add build_service_env_map! macro in link.rs
- Replace duplicated lookup patterns across commands
2025-12-09 17:19:52 -05:00
Paulo Cabral Sanz
e1af2a4071
Stop using rustls-pemfile, it's unmaintained (#708)
Fixes #707

Turns out we never used it anyway
2025-12-08 17:13:20 -03:00
Paulo Cabral Sanz
42d51b13d9 chore: Release railwayapp version 4.12.0 2025-11-28 17:57:13 -03:00
Paulo Cabral Sanz
29bfbbf9a3
Hide environments user can't access (#704)
* Hide environments user can't access

Makes env level RBAC experience better in CLI
2025-11-28 17:09:41 -03:00
Milo
407c5ac511
Verbose logging for the add command (#692)
* very basic verbose logging

* Update src/commands/deploy.rs

Co-authored-by: Jake Runzer <jakerunzer@gmail.com>

* make more descriptive

---------

Co-authored-by: Jake Runzer <jakerunzer@gmail.com>
2025-11-28 11:10:03 -05:00
Paulo Cabral Sanz
a493459cd2
Dont hard error on no services (#703)
It makes the error handling think it's a auth issue.
2025-11-26 14:35:40 -03:00
Jake Runzer
45fd9afde1 chore: Release railwayapp version 4.11.2 2025-11-25 23:54:25 -05:00
Jake Runzer
9d69041b93
retry log streaming on mid-connection failures (#701)
Previously retry only covered initial connection establishment. Now
retries the entire stream consumption, with timestamp-based dedup to
skip already-seen logs on reconnect.
2025-11-25 23:50:31 -05:00
jez
53f70de101
Fix security vulnerabilities (#694) 2025-11-25 23:48:52 -05:00
Brody Over
d1f2108d24
don't check for a linked project when the project, environment, and service flags are provided (#700) 2025-11-25 14:42:30 -05:00
Mihovil Ilakovac
490e11e2a8
Fixes some typos (#691) 2025-11-24 22:58:38 -05:00
Kyle Rose
e02555ce03
feat(service.rs): add service management features (#680)
* feat(service.rs): add service management features

This commit introduces significant enhancements to the service management capabilities of the application. It includes the ability to link a service to the current project, show the deployment status for services, and handle legacy direct service link. The changes also introduce new commands, arguments, and structures for managing services more effectively.

* feat(service.rs): remove DateTime usage and tweak command handling

This commit removes the usage of the DateTime from the `service.rs` file. Additionally, it refines the command handling logic to maintain backward compatibility. It also removes the display of creation time in the status command output.

* feat(service.rs): streamline print statements and simplify status display formatting

This commit simplifies the print statements in the `link_command` and `status_command` functions, removing unnecessary line breaks and redundant code. It also streamlines the `format_status_display` function, making the status formatting more efficient and readable.
2025-11-21 20:20:04 -05:00
echohack
3f6f980240
improve error message for invalid token (#698)
* improve error message for invalid token

Signed-off-by: echohack <git@echohack.app>

* cargo fmt

Signed-off-by: echohack <git@echohack.app>

---------

Signed-off-by: echohack <git@echohack.app>
2025-11-20 14:39:04 -08:00
Milo
6a1329b312
Consistent variable parsing (#689)
* introduce Variable struct

* refactor variable handling/parsing

uses the new Variable struct wherever possible

* feat(environment): Simplify variable mapping in service metadata

Reduce boilerplate by directly using the variable instead of
constructing a new Variable struct. This change maintains the
same functionality while making the code more concise and
readable.

* edition 2024 + rust-version 1.85.0 + cargo fmt

includes lots of formatting changes.

* fix formatting

* downgrade temporarily to fix formatting and conflicts

* edition 2024 and formatting
2025-11-18 08:37:23 -05:00
Paulo Cabral Sanz
7f4f300cfd chore: Release railwayapp version 4.11.1 2025-11-14 13:11:20 -03:00
Paulo Cabral Sanz
c6815ee035
Emit on failures if RAILWAY_TOKEN is set (#690)
Some user was mixing railway login with RAILWAY_TOKEN and getting strage errors. This should explain it further.

https://discord.com/channels/713503345364697088/1438513376677331136
2025-11-14 13:04:32 -03:00
jez
6e470eedad
Address RUSTSEC-2025-0057 (#677) 2025-11-13 01:00:02 -05:00
jez
97d269ee7d
Fix the behavior of the railway completion command (#685)
* Fix behavior of `railway completion` command

* cargo fmt
2025-11-08 07:26:25 -05:00
Jeremy Hoon
0c90d27875
Split variable definitions passed to railway environment new --service-name into at most two parts (#682) 2025-10-28 18:31:53 -04:00
Jake Runzer
5769fecab8 chore: Release railwayapp version 4.11.0 2025-10-21 15:55:30 -04:00
Jake Runzer
22a8779daf Merge branch 'master' of github.com:railwayapp/cli 2025-10-21 15:55:17 -04:00
Jake Runzer
b1b8679cd9 chore: Release railwayapp version 4.10.1 2025-10-21 15:53:29 -04:00
Malthe Jørgensen
eb6f8912e8
ssh-command: Allow passing one or two of -p, -e and -s (#679)
* ssh-command: Allow passing one or two of `-p`, `-e` and `-s`

Previously, `railway ssh` required you to either be in a linked
directory or pass all three `-p/--project`, `-e/--environment` and
`-s/--service` arguments.

Now, if only one or two arguments are passed the ones that aren't passed
will default to what was linked.

This allows more easily connecting to e.g. the production environment if
you linked to the staging one, by simply passing:

    railway ssh -e <PRODUCTION_ENV_ID>

similarly if you want to connect to a service that wasn't linked to the
current directory but is in the same project and environment you can now
do:

    railway ssh -s <SERVICE_ID>

* ssh-command: Allow passing service name on top of service ID
2025-10-21 15:53:19 -04:00
Jake Runzer
e7d2660cf8
Fix cronSchedule being unset during function push operations (#681)
The graphql-client crate v0.14.0 has a bug where skip_serializing_none
doesn't work for root-level variables. This caused None values to serialize
as null instead of being omitted, which told the API to unset cron schedules.

Added post_graphql_skip_none helper that strips null values from the variables
object before sending, ensuring the API receives undefined and preserves
existing settings.
2025-10-21 15:48:25 -04:00
jez
418f600903
Replace paste with pastey (#674) 2025-09-30 11:09:00 -05:00
Milo
7309ad4176
Fix environment tokens not working (#668)
* testing

* authentication fixes
2025-09-30 10:58:13 -05:00
Michael Hadley
9f581e2273 chore: Release railwayapp version 4.10.0 2025-09-26 16:07:36 -05:00
Michael Hadley
280f2d74ff
Add deployment command with subcommands for list, up and redeploy (#673)
* Fix

* Fix

* Add env arg

* local time
2025-09-26 14:22:46 -05:00
Michael Hadley
f71df85dc5
Improving railway log --help docs for users and LLMs (#672)
* Fix

* Fix

* Fix

* Fix

* fix

* Fix

* Fix

* Fix
2025-09-26 10:44:12 -05:00
Michael Hadley
252920ea16
Fix for railway logs: allow using deployment ID to look up failed build logs (#671)
* Fix

* Fix

* Fix

* Fix
2025-09-26 09:12:09 -05:00
Michael Hadley
e0c7638862 chore: Release railwayapp version 4.9.0 2025-09-25 12:11:17 -05:00
Michael Hadley
d7fae6b209
Improve logs --help (#670)
* Fix

* WIP

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* add test

* add rustfmt which is missing in ci

* add tail alias

* Fix

* Fix

* Fix

* Update logs.rs
2025-09-25 11:58:14 -05:00
Michael Hadley
30a8a9c524
Add logs --tail alias + examples in the logs --help output (#669)
* Fix

* WIP

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* add test

* add rustfmt which is missing in ci

* add tail alias

* Fix

* Fix

* Update logs.rs
2025-09-25 11:38:40 -05:00
Michael Hadley
538e5a7a5a
Add --lines / -n and -f / --filter options to log command (#667)
* Fix

* WIP

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* add test

* add rustfmt which is missing in ci
2025-09-24 16:05:09 -05:00
Michael Hadley
eedd94067c
Fix osx compilation (#666)
* Fix

* Fix
2025-09-24 10:30:03 -05:00
Jake Runzer
2b3cd24897
longer log retry (#665) 2025-09-16 16:32:44 -04:00
Jake Runzer
8708ebf4de chore: Release railwayapp version 4.8.0 2025-09-11 20:26:09 -04:00
Paulo Cabral Sanz
a4984de90f
Use workspace based queries/mutations (#664)
Team concept is being removed from the platform
2025-09-11 19:59:51 -03:00
Jake Runzer
00f7ed24a0 chore: Release railwayapp version 4.7.3 2025-09-10 13:23:20 -04:00
Jake Runzer
38276dfcc5 chore: Release railwayapp version 4.7.2 2025-09-10 13:21:44 -04:00