muti-ports-manager
v1.1.2
Published
一个可以管理多个项目所占用端口的 npm cli 工具
Readme
Multi Ports Manager
An npm CLI tool for managing ports occupied by multiple projects, with TypeScript support.
About The Project

Current Version: 1.1.0 | Changelog | Report Bug
There are many great port management tools available; however, I didn't find one that really suited my needs for managing multiple projects with named ports and environment variable integration. So I created this enhanced one.
Here's why Multi Ports Manager is special:
- Your time should be focused on creating something amazing. A project that solves port conflicts and helps manage development environments efficiently
- You shouldn't be doing the same tasks over and over like manually checking port availability and updating .env files
- Smart port management with automatic detection, naming, and environment variable integration
- Cross-platform support for Windows, macOS, and Linux
Features
- 🚀 Multi-Project Management: Allocate and manage ports for different projects
- 🔧 Port Naming: Each port has a customizable name
- 📝 Environment Variable Management: Automatically add port information to .env files
- 🖥️ Cross-Platform Support: Supports Windows, macOS, and Linux
- 💻 Process Management: View and terminate processes occupying ports
- 🎯 Smart Detection: Automatically detect port occupancy
- 🌍 Internationalization: Support for English and Chinese languages
- ⚡ Enhanced CLI: Improved error handling and user experience
- 🔒 Data Persistence: Reliable project and port data storage
- 📊 Real-time Status: Live port occupancy information
Built With
This section lists the major frameworks/libraries used to bootstrap this project.
Getting Started
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
Prerequisites
This is an example of how to list things you need to use the software and how to install them.
- npm
npm install npm@latest -gQuick Installation
# Install globally from npm
npm install -g muti-ports-manager
# Start using immediately
muti-ports --helpDevelopment Installation
Clone the repo
git clone https://github.com/AHappyAtlas/muti_ports_manager.gitInstall NPM packages
npm installBuild the project
npm run buildInstall globally (optional)
npm install -g muti-ports-managerChange git remote url to avoid accidental pushes to base project
git remote set-url origin AHappyAtlas/muti-ports-manager git remote -v # confirm the changes
Usage
Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space.
Basic Commands
# Add a project
muti-ports add-project
# Add a port to a project
muti-ports add-port
# List all projects and ports
muti-ports list
# Check port occupancy
muti-ports check-port 3000
# Terminate process occupying a port
muti-ports kill-port 3000Language Management
# Set language to English
muti-ports set-language en
# Set language to Chinese
muti-ports set-language zh
# Show current language
muti-ports languagePort Name Management
# Add a port with a name
muti-ports add-port -p myproject -P 3000 -N API_PORT
# Update port name
muti-ports update-port-name -p myproject -P 3000 -N NEW_API_PORT
# Remove a port
muti-ports remove-port -p myproject -P 3000Environment Variable Management
# Add a port to .env file
muti-ports add-to-env -n API_PORT
# Specify project and .env file path
muti-ports add-to-env -p myproject -e .env.local -n API_PORT
# Remove a port from .env file
muti-ports remove-from-env -n API_PORT
# List port variables in .env file
muti-ports list-env
# Specify .env file path
muti-ports list-env -e .env.productionCommand Options
add-project
-n, --name <name>: Project name
add-port
-p, --project <name>: Project name-P, --port <port>: Port number-N, --name <name>: Port name
update-port-name
-p, --project <name>: Project name-P, --port <port>: Port number-N, --name <name>: New port name
add-to-env
-p, --project <name>: Project name-e, --env-file <path>: .env file path-n, --name <name>: Port name
remove-from-env
-e, --env-file <path>: .env file path-n, --name <name>: Port name
list-env
-e, --env-file <path>: .env file path
set-language
<language>: Language code (en/zh)
Environment Variable Format
Port names are automatically converted to uppercase format when added to .env files:
# If port name is "API_PORT" and port number is 3000
API_PORT=3000
# If port name is "db_port" and port number is 5432
DB_PORT=5432For more examples, please refer to the Documentation
Roadmap
- [x] Multi-project port management
- [x] Port naming system
- [x] Environment variable integration
- [x] Cross-platform support
- [x] Internationalization (English/Chinese)
- [x] Enhanced CLI interface and error handling
- [ ] Web dashboard for port management
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Top contributors:
License
Distributed under the MIT License. See LICENSE for more information.
Contact
Email - [email protected]
Project Link: https://github.com/AHappyAtlas/muti_ports_manager
Acknowledgments
Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!
- Choose an Open Source License
- GitHub Emoji Cheat Sheet
- Malven's Flexbox Cheatsheet
- Malven's Grid Cheatsheet
- Img Shields
- GitHub Pages
- Font Awesome
- React Icons
Version History
- v1.1.0 (Current) - Enhanced CLI interface, improved error handling, and better user experience
- v1.0.0 - Initial release with core functionality
For detailed changes, see CHANGELOG.md.
Development
# Install dependencies
npm install
# Build project
npm run build
# Run in development mode
npm run dev
# Run built version
npm startProject Structure
src/
├── types.ts # TypeScript type definitions
├── project-manager.ts # Project manager
├── port-manager.ts # Port manager
├── env-manager.ts # Environment variable manager
├── manager.ts # Main manager
├── i18n/
│ └── index.ts # Internationalization manager
├── index.ts # Entry file
└── bin/
└── muti-ports.ts # CLI entryData Storage
Project data is stored in the .muti-ports-manager/projects.json file in the user's home directory.
Internationalization
The tool supports multiple languages:
- English (en): Default language
- Chinese (zh): Full Chinese localization
Language can be changed at runtime using the set-language command.
