Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (wukong-deploy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
๐ฆ wukong-deploy
โก๏ธ A lightweight Node.js CLI for remote server deployment โ run any command queue with a single line.
English | ็ฎไฝไธญๆ
๐ Table of Contents
- ๐ฆ
wukong-deploy - ๐ Table of Contents
- โจ Features
- ๐งฑ Requirements
- ๐ฆ Installation
- ๐ Usage
- โ๏ธ Configuration
- โ Adding Multiple Servers
- ๐ฑ Environment Variables
- ๐ท Demo
- ๐ฅ Supported Platforms
- ๐ฆ Upgrade
- ๐ Multi-language Support
- ๐ Changelog
- ๐ Troubleshooting
- ๐ License
- ๐ Keywords
โจ Features
- ๐ One-command deployment to remote servers
- ๐ Secure SSH + SCP support
- ๐ Custom file/folder inclusion
- ๐ฆ Easily configurable with
config.mjsand.env - ๐ Multilingual CLI: English / ็ฎไฝไธญๆ
- ๐งช Robust stderr error matching
๐งฑ Requirements
- Node.js >= 18.0.0
- Linux / macOS (recommended)
- Windows
๐ฆ Installation
npm install -g wukong-deploy
# or
yarn global add wukong-deploy๐ Usage
CLI Commands
wukong-deploy init # Generate .env and config/config.mjs
wukong-deploy deploy # Interactive deployment
wukong-deploy deploy dev # Deploy using specific server keySet environment variables on the fly:
WUKONG_LANG=en WUKONG_DEBUG=1 wukong-deploy deployโ๏ธ Configuration
config/config.mjs
export default {
showCommandLog: true,
servers: {
dev: {
name: 'Dev Server',
host: '192.168.0.123',
username: 'root',
passwordEnv: 'SERVER_DEV_PASSWORD',
commands: [
{
cmd: 'git pull',
cwd: '/your/project',
description: 'Update code',
exitOnStdErr: false,
errorMatch: /Permission denied/
},
{
cmd: 'npm run build',
cwd: '/your/project',
description: 'Build project',
exitOnStdErr: false,
errorMatch: /Permission denied/
}
],
finishMsg: '๐ Deployment completed'
}
}
}version >=1.2.8
you can run local commands:
export default {
showCommandLog: true,
servers: {
dev: {
name: 'Dev Server',
host: '192.168.0.123',
username: 'root',
passwordEnv: 'SERVER_DEV_PASSWORD',
commands: [
{
cmd: 'git pull',
cwd: '/your/project',
description: 'Update code',
exitOnStdErr: false,
errorMatch: /Permission denied/
},
{
cmd: 'npm run build',
cwd: '/your/project',
description: 'Build project',
exitOnStdErr: false,
errorMatch: /Permission denied/
},
{
cmd: 'curl http://www.google.com/',
description: 'curl url',
isLocal: true
},
{
cmd: 'yarn -v',
description: 'show yarn version',
isLocal: true
},
{
cmd: 'open http://www.google.com/',
description: 'open url',
isLocal: true
}
],
finishMsg: '๐ Deployment completed'
}
}
}โ Adding Multiple Servers
To deploy to more environments, simply add more entries in the servers field:
export default {
servers: {
dev: {
/* ... */
},
staging: {
name: 'Staging Server',
host: '123.45.67.89',
username: 'deploy',
passwordEnv: 'SERVER_STAGING_PASSWORD',
commands: [
{
cmd: 'npm run build',
cwd: '/srv/app',
description: 'Build app',
exitOnStdErr: false,
errorMatch: /Permission denied/
}
],
finishMsg: '๐ Staging deployment done'
},
prod: {
/* ... */
}
}
}Then, define each server's password (or other secrets) in your .env file:
SERVER_DEV_PASSWORD=your_dev_password
SERVER_STAGING_PASSWORD=your_staging_password
SERVER_PROD_PASSWORD=your_prod_passwordTo deploy to a specific server:
wukong-deploy deploy staging๐ฑ Environment Variables
You can define these variables in .env, or export them in .bashrc / .zshrc:
| Variable | Description | Example |
|---|---|---|
WUKONG_DEV_MODE |
Enable verbose/dev mode | 1 |
WUKONG_LANG |
CLI language (zh or en) |
zh |
WUKONG_NO_EMOJI |
Disable emoji output | 1 |
WUKONG_DEBUG |
Enable internal debug logs | 1 |
๐ก WUKONG_NO_EMOJI: ๆไบ Windows ็ป็ซฏ๏ผๅฆๆง็ CMD๏ผๅฏน emoji ๆพ็คบไธๅๅฅฝ๏ผๅปบ่ฎฎ่ฎพ็ฝฎไธบ 1 ็ฆ็จใ
Example .env
WUKONG_DEV_MODE=1
WUKONG_LANG=zh
WUKONG_NO_EMOJI=1
WUKONG_DEBUG=1
# Server login credentials
SERVER_DEV_PASSWORD=your_password
SERVER_STAGING_PASSWORD=your_password๐ท Demo
wukong-deploy deploy๐ฅ Supported Platforms
- macOS
- Linux
- Windows (Windows Terminal or Git Bash recommended to avoid encoding and emoji problems in CMD)
๐ฆ Upgrade
npm update -g wukong-deploy
# or
yarn global upgrade wukong-deploy๐ Multi-language Support
Automatically switches between Chinese and English based on your terminal's system language, no extra configuration needed.
| Language Environment Variable | Language |
|---|---|
LANG=zh_CN.UTF-8 |
Chinese |
LANG=en_US.UTF-8 |
English |
You can also force the language via command-line argument:
wukong-deploy --lang=zh # ๅผบๅถไธญๆ
wukong-deploy --lang=en # Force EnglishOr configure it in your .env file similarly:
WUKONG_LANG=zh # ๅผบๅถไธญๆ
WUKONG_LANG=en # Force English๐ Changelog
See CHANGELOG.md for release history.
๐ Troubleshooting
Garbled characters in Windows terminal: It is recommended to use a UTF-8 capable terminal, such as Windows Terminal.
Emoji not displaying: Set
WUKONG_NO_EMOJI=1Server login failure:
- Please verify that the password in
.envand the username inconfig/config.mjsare correct.
- Please verify that the password in
PowerShell Error: Cannot load file
wukong-deploy.ps1(execution policy restriction):Cause: By default, PowerShell blocks the execution of
.ps1script files. When installing global packages vianpm install -g, a.ps1launcher is created, which may be blocked on your system.Solution 1 (recommended): Set a more permissive execution policy for the current user:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUserโ Run PowerShell as Administrator when executing this command.
Solution 2: Use
yarnfor global installation (no.ps1script generated):npm uninstall -g wukong-deploy yarn global add wukong-deploy
Solution 3: Manually delete the
.ps1launcher script. PowerShell will then use the.cmdfile instead.Default global path:
C:\Users\<YourUsername>\AppData\Roaming\npm\wukong-deploy.ps1โ ๏ธ This file may be regenerated if you reinstall the package via npm.
Solution 4: Run the CLI directly via Node.js (bypasses shell script entirely):
node "$(npm root -g)/wukong-deploy/bin/cli.js"