locport
- Standardizes keeping track of local development ports.
- See which ports are listening.
- Automatically assign unused ports.
- See conflicts.
- Proxy and daemon free.
Introducing the .localhost file convention
A project can define within it's root, the .localhost file, that lists local hosts with ports that the project uses.
Format of this file is a simple list of <host>:<port> separated by newlines. For example:
hello.localhost:3001
another.service.localhost:3002A single project can have multiple addresses associated to it.
To add the project to locport, simply locport index [PATH1] [PATH2]. Now you can overview hosts and ports with
locport and easily discover conflicts across any number of projects.
You can also add projects recursively, like so: locport index ~/projects -r. This will look for directories that contain .localhost file and indexes those.
Installation
Ruby is required.
gem install locportUsage
Adding hosts
You've got several options to create or add to .localhost file,
from within your project directory:
# Creates .localhost file in the current directory, with randomly assigned unused port,
# and hostname based on the current directory name suffixed with .localhost
locport add
# Adding a custom hostname and letting locport find a port
locport add myapp.localhost
# Example with a user specified port
locport add myapp.localhost:30000All of the above action ensure the project is also indexed by locport.
Listing projects and hosts
locport
# OR
locport listIf any conflicts are detected, they will be displayed and program exits with error code 1.
Adding existing projects to the index
# Add specific projects that contain .localhost file
locport index ~/projects/a ~/projects/b
# Recursively find and index .localhost files
locport index -r ~/projectsYou can view the location of the projects index, which is a single text file, containing project paths, separated by a newline.
locport infoScreenshots
Development
PRs are welcome. To set up locally from within the checked out repo:
# Install dependencies
bundle
# Run commands with dev code
ruby -Ilib/ bin/locportRunning tests
bin/rake