An open API service indexing awesome lists of open source software.

https://github.com/reandimo/wp-dev-sync

Sync your local environment with your remote Wordpress
https://github.com/reandimo/wp-dev-sync

ftp ftp-sync remote sync wordpress

Last synced: 11 days ago
JSON representation

Sync your local environment with your remote Wordpress

Awesome Lists containing this project

README

          


WP Dev Sync


Version
License
Platform
Protocols


CLI for syncing WordPress themes to remote servers.

The same workflow Shopify devs get with shopify theme dev, but for WordPress.


Install ยท
Quick Start ยท
Commands ยท
Configuration ยท
Wiki

---

## The Problem

```
๐Ÿ˜ฉ The Old Way โœจ The WP Dev Sync Way
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
1. Edit theme file locally 1. Edit theme file locally
2. Open FileZilla 2. That's it. It's already
3. Navigate to remote dir on your server.
4. Upload file manually
5. Refresh browser
6. Repeat 500 times a day
```

**No more FTP clients. No more manual uploads.** Save a file locally and it's on your server in seconds.

---

## ๐Ÿ“ฆ Install

```bash
npm install -g wp-dev-sync
```

Other install methods

```bash
# Manual install (clone + link)
git clone https://github.com/reandimo/wp-dev-sync.git
cd wp-dev-sync && npm link
```

> **Requirements:** Bash (Git Bash on Windows) + `rsync` (SSH) or `lftp` (FTP)

---

## ๐Ÿš€ Quick Start

```bash
cd /path/to/my-wordpress-site # 1. Go to your project

npx wp-dev-sync init # 2. Creates .env config file

nano .env # 3. Set your server credentials

npx wp-dev-sync setup # 4. Verify everything works

npx wp-dev-sync watch # 5. Start syncing! ๐ŸŽ‰
```

That's it. Every file you save now appears on your server automatically.

---

## ๐Ÿ“‹ Commands

```
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ โ”‚
โ”‚ โŸณ watch Watch + auto-sync on file changes โ”‚
โ”‚ โ†‘ push One-time upload to remote โ”‚
โ”‚ โ†“ pull One-time download from remote โ”‚
โ”‚ โ—‡ diff Compare local vs remote (dry-run) โ”‚
โ”‚ โ—ˆ env Manage multiple environments โ”‚
โ”‚ โ˜… tunnel Public URL for client previews โ”‚
โ”‚ โ—† setup Preflight check (deps + connection) โ”‚
โ”‚ โ—‡ init Create .env from template โ”‚
โ”‚ โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
```

---

## โš™๏ธ Configuration

All config lives in a `.env` file in your project root:

```bash
# โ”€โ”€ What to sync โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
LOCAL_PATH=./wp-content/themes/my-theme # Local dir
REMOTE_PATH=/var/www/html/wp-content/themes/my-theme # Remote dir

# โ”€โ”€ Connection โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
SYNC_PROTOCOL=ssh # ssh or ftp
REMOTE_USER=deploy
REMOTE_HOST=myserver.com
REMOTE_PORT=22 # 22 for SSH, 21 for FTP
REMOTE_PASSWORD= # FTP only

# โ”€โ”€ Behavior โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
SYNC_EXCLUDE=.git,node_modules,.DS_Store,*.log,.env
SYNC_DELETE=false # true = mirror exact state
```

### .syncignore

For more control, create a `.syncignore` file in your project root (or run `npx wp-dev-sync init`). One pattern per line, like `.gitignore`:

```bash
# .syncignore
node_modules
vendor
.git
.env
*.log
*.map
public/hot
public/.vite
.idea
.vscode
```

Both `.syncignore` and `SYNC_EXCLUDE` work together โ€” patterns from both are merged.

### Example Setups

๐Ÿ  WordPress Classic (cPanel / Shared Hosting)

```bash
LOCAL_PATH=./wp-content/themes/my-theme
REMOTE_PATH=/home/user/public_html/wp-content/themes/my-theme
SYNC_PROTOCOL=ftp
REMOTE_USER=cpanel-user@domain.com
REMOTE_HOST=ftp.domain.com
REMOTE_PORT=21
REMOTE_PASSWORD=your-ftp-password
```

๐Ÿชจ WordPress Bedrock

```bash
LOCAL_PATH=./web/app/themes/my-theme
REMOTE_PATH=/var/www/mysite/current/web/app/themes/my-theme
SYNC_PROTOCOL=ssh
REMOTE_USER=deploy
REMOTE_HOST=myserver.com
REMOTE_PORT=22
```

๐Ÿ–ฅ๏ธ VPS (DigitalOcean, Linode, Vultr)

```bash
LOCAL_PATH=./wp-content/themes/my-theme
REMOTE_PATH=/var/www/html/wp-content/themes/my-theme
SYNC_PROTOCOL=ssh
REMOTE_USER=root
REMOTE_HOST=203.0.113.10
REMOTE_PORT=22
SYNC_DELETE=true
```

โšก WP Engine

```bash
LOCAL_PATH=./wp-content/themes/my-theme
REMOTE_PATH=/sites/mysite/wp-content/themes/my-theme
SYNC_PROTOCOL=ssh
REMOTE_USER=mysite
REMOTE_HOST=mysite.ssh.wpengine.net
REMOTE_PORT=22
```

๐Ÿ”Œ Plugin Development

```bash
LOCAL_PATH=./wp-content/plugins/my-plugin
REMOTE_PATH=/var/www/html/wp-content/plugins/my-plugin
SYNC_PROTOCOL=ssh
REMOTE_USER=deploy
REMOTE_HOST=myserver.com
REMOTE_PORT=22
SYNC_EXCLUDE=.git,node_modules,tests,vendor
```

---

## ๐Ÿ”„ Protocols

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ SSH (rsync) โ”‚ FTP (lftp) โ”‚
โ”‚ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• โ”‚ โ•โ•โ•โ•โ•โ•โ•โ•โ• โ”‚
โ”‚ โœ” Delta transfer โ”‚ โœ” Universal access โ”‚
โ”‚ โœ” Encrypted โ”‚ โœ” No server setup โ”‚
โ”‚ โœ” Passwordless โ”‚ โœ” Works everywhere โ”‚
โ”‚ โœ” ~200 bytes/edit โ”‚ โœ˜ Full file upload โ”‚
โ”‚ โ”‚ โœ˜ Unencrypted โ”‚
โ”‚ โ˜… Recommended โ”‚ โ—‹ Fallback option โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

Install rsync (SSH)

```bash
choco install rsync # Windows
brew install rsync # macOS
sudo apt install rsync # Linux
```

**SSH key setup (one-time):**
```bash
ssh-keygen -t ed25519
ssh-copy-id -p 22 user@myserver.com
```

Install lftp (FTP)

```bash
choco install lftp # Windows
brew install lftp # macOS
sudo apt install lftp # Linux
```

---

## ๐Ÿ‘€ Watch Mode

`npx wp-dev-sync watch` starts with a smart reconciliation that compares local and remote files before syncing:

```
โ•ญโ”€โ”€ info โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ โ”‚
โ”‚ The files listed below differ between the local and โ”‚
โ”‚ remote versions. What would you like to do? โ”‚
โ”‚ โ— assets/style.css โ”‚
โ”‚ โ— templates/page.json โ”‚
โ”‚ โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

? Reconciliation Strategy:
โ–ธ Keep the local version
Keep the remote version
```

Each category gets its own prompt: **local-only** (upload or delete), **remote-only** (download or delete), and **differing** (keep local or keep remote). Then syncs with a gradient progress bar and starts watching for changes.

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ OS โ”‚ Watcher โ”‚ Latency โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ macOS โ”‚ fswatch โ”‚ ~0.5s โ”‚
โ”‚ Linux โ”‚ inotifywait โ”‚ ~0.5s โ”‚
โ”‚ Windows โ”‚ Polling โ”‚ ~2s โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

**Pro tip:** Pair with Vite HMR for the ultimate WordPress dev experience:

```bash
# Terminal 1 # Terminal 2
npm run dev npx wp-dev-sync watch
# Vite handles CSS/JS HMR # WP Dev Sync handles PHP uploads
```

---

## ๐Ÿš‡ Tunnels

Share your staging site with clients via a public URL:

```bash
# .env
TUNNEL_TOOL=cloudflared # or: ngrok
TUNNEL_DOMAIN=staging.mysite.com
```

```bash
npx wp-dev-sync tunnel
# โ†’ https://random-words.trycloudflare.com
```

---

## ๐Ÿ” Diff

Compare local and remote without syncing โ€” like `git status` for your server:

```bash
npx wp-dev-sync diff
```

```
Local only (1 files) โ€” present locally, missing on remote
+ index.php

Remote only (3 files) โ€” present on remote, missing locally
- .editorconfig
- README.md
- setup.js

Modified (2 files) โ€” differ between local and remote
~ assets/style.css
~ templates/page.json

1 local only 3 remote only 2 modified
```

---

## ๐ŸŒ Environments

Manage multiple server configs without editing `.env` manually:

```bash
npx wp-dev-sync env create staging # Create from current .env
npx wp-dev-sync env create production # Create another

# Edit each: .env.staging, .env.production

npx wp-dev-sync env switch staging # Activate staging
npx wp-dev-sync env switch # Interactive picker
npx wp-dev-sync env list # Show all environments
```

```
โ–ธ staging ssh@deploy@staging.mysite.com:/themes/my-theme
production ftp@user@ftp.mysite.com:/public_html/themes/my-theme
```

---

## ๐Ÿ”ฅ SYNC_DELETE

| Value | What happens | Safety |
|:------|:-------------|:------:|
| `false` | Only uploads new/changed files. Never deletes remotely. | โœ… Safe |
| `true` | Mirrors local state exactly. Remote-only files get deleted. | โš ๏ธ Careful |

---

## ๐Ÿ”ง Troubleshooting

rsync: command not found (Windows)

The CLI auto-adds Chocolatey/Scoop paths. If it still fails:
```bash
export PATH="/c/ProgramData/chocolatey/bin:$PATH"
```

SSH: Connection refused

- Check SSH is enabled on your server
- Try alternative ports: `2222`, `7822`, `18765`
- SSH hostname may differ from FTP (`ssh.host.com` vs `ftp.host.com`)

FTP: Login incorrect

- Some hosts require full email as username (`user@domain.com`)
- Check IP whitelisting in your hosting panel
- Test with FileZilla first to isolate the issue

Sync is slow

- Switch from FTP to SSH if possible (10x faster)
- Exclude large dirs: `SYNC_EXCLUDE=.git,node_modules,vendor,public/fonts`
- Windows polling (2s) is normal behavior

---

## ๐Ÿ—๏ธ Architecture

```
wp-dev-sync/
โ”œโ”€โ”€ bin/wp-dev-sync # CLI entry point
โ”œโ”€โ”€ lib/
โ”‚ โ”œโ”€โ”€ _env.sh # .env loader + Windows PATH fix
โ”‚ โ”œโ”€โ”€ _ui.sh # Terminal UI (colors, banners, spinners)
โ”‚ โ””โ”€โ”€ _sync.sh # Core sync engine (rsync + lftp)
โ”œโ”€โ”€ commands/
โ”‚ โ”œโ”€โ”€ watch.sh # File watcher + auto-sync
โ”‚ โ”œโ”€โ”€ push.sh # One-time upload
โ”‚ โ”œโ”€โ”€ pull.sh # One-time download
โ”‚ โ”œโ”€โ”€ diff.sh # Compare local vs remote
โ”‚ โ”œโ”€โ”€ env.sh # Multi-environment manager
โ”‚ โ”œโ”€โ”€ tunnel.sh # Cloudflare / ngrok tunnel
โ”‚ โ””โ”€โ”€ setup.sh # Preflight dependency check
โ””โ”€โ”€ docs/ # Full wiki documentation
```

---

## ๐Ÿ’ก Not just WordPress

While wp-dev-sync is built for WordPress theme development, it works with **any directory** you need to sync remotely. Just set `LOCAL_PATH` and `REMOTE_PATH` to whatever you need.

```bash
# Sync a React app
LOCAL_PATH=./build
REMOTE_PATH=/var/www/html/myapp

# Sync a Jekyll site
LOCAL_PATH=./_site
REMOTE_PATH=/var/www/html/blog
```

---


๐Ÿ“– Full Documentation
ย ยทย 
๐Ÿ› Report Bug
ย ยทย 
๐Ÿ’ก Request Feature


Built by Renan Diaz