Skip to content

feat: add {PORT}, {HOST}, {PORTLESS_URL} placeholders for command args#167

Open
oosawy wants to merge 1 commit intovercel-labs:mainfrom
oosawy:oosawy/host-port-args-placeholder
Open

feat: add {PORT}, {HOST}, {PORTLESS_URL} placeholders for command args#167
oosawy wants to merge 1 commit intovercel-labs:mainfrom
oosawy:oosawy/host-port-args-placeholder

Conversation

@oosawy
Copy link
Copy Markdown

@oosawy oosawy commented Mar 28, 2026

Summary

  • Many tools ignore the PORT env var and require CLI flags instead, with no standard flag name across tools
  • The existing injectFrameworkFlags whitelist can't cover all tools, and Vite-based tools with their own CLI keep growing
  • Users can't use $PORT in command args because the shell expands it before portless assigns a port; sh -c "..." works but is awkward
  • {PORT}, {HOST}, and {PORTLESS_URL} placeholders in command args are now replaced with the assigned values before the command runs:
    portless run my-server --port {PORT} --host {HOST}
    
  • When placeholders are present, automatic --port/--host injection is skipped
  • {...} syntax has no special meaning in bash, zsh, fish, PowerShell, or cmd.exe, so it passes through to portless as-is

Implementation Details

  • hasPlaceholders() and replacePlaceholders() added to cli-utils.ts; exact-match only, uppercase only, unknown tokens ignored
  • In runApp(), placeholders are replaced after port assignment and before injectFrameworkFlags; if any placeholder was present, framework injection is skipped entirely
  • PORT/HOST/PORTLESS_URL env vars are still set regardless of placeholder usage

Test plan

  • pnpm exec vitest run src/cli-utils.test.ts -- 92 tests pass (16 new for hasPlaceholders/replacePlaceholders)
  • portless run my-server --port {PORT} -- confirm port is replaced and server starts on the assigned port
  • portless run vite dev -- confirm auto-injection still works when no placeholders are used
  • Verify --help output includes the new Placeholders section

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 28, 2026

@oosawy is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant