This is a deployment utility written in node.js that leverages rsync to deploy the files from your local file system to a drive that is mounted with sshfs. This project exists because it is not always possible to use deployment tools such as Capistrano in order to deploy sites to shared or managed hosting accounts.
The logic that the deployment script follows is to upload only new files or directories, as well as overwrite the files on the server when the files on your computer are newer.
This is a recursive file copy from one place to another.
- Node JS
This requires the rsyncwrapper package for Node.js, which has a dependency that "a reasonably modern version of rsync (>=2.6.9) in your PATH."
Windows users will need to install the cwRsync package. See the installation section for more info.
This script also relies on sshfs to mount the remote server as a network drive. Some options for mounting a remote server as a network drive include:
- Install the package as a global module by running
npm install -g emadfrom the command line
- Set up your config files (
- Mount remote directory using sshfs.
- Deploy using
Makes the sync operation non-recursive. default: false
The target environment of the deployment. default: staging
The deploys only the index specified in the target environment. The index is zero-based. A value of false will deploy all locations in the environment. default: false
Limits the scope of the deployment to the contents of the file provided in the command
line option. Must be used with the
--only flag. default: false
Will do a fresh copy of the source into the target and ignore the last modified time. This is not a full mirror. Files that do not exist in the source will be kept intact in the target directory. default: false
Outputs a list of files to be copied without actually copying them. default: false
Writes data to the destination file directly instead of using a temporary file. default: false
Attempts to swap the source and destination directories provided in the config file. default: false
Displays the version number.
Displays help information.
This file contains the project-level includes and excludes, environment definitions, and deployment locations for each. This is to avoid having items such as config files advertently deployed to a server. These excludes can be shared with other developers and this file IS meant to be checked in to version control.
Every object in the deployment environment is required to have a
target property values must always use POSIX style paths, regardless of
the OS of your development machine.
Also, note that to copy the contents of the source directory into the target directory, the
source directory should end in a trailing slash but the
target directory should not.
"exclude": "*.komodoproject" "test.txt""include": "smiley.gif""configversion": 3"env":"production":"source": "./path-1/""target": "/public_html/path-1""source": "./path-2/""target": "/public_html/path-2""staging":"source": "./path-1/""target": "/public_html/path-1""source": "./path-2/""target": "/public_html/path-2"
It's likely that each developer that works on the project will have drives mapped differently. The emad-config.json file adds prefixes to each path that are specific to each development machine. This file is specific to your dev environment and should not be checked in to version control.
"env":"production":"source":"prefix": """target":"prefix": "/cygdrive/p/""staging":"source":"prefix": """target":"prefix": "/cygdrive/s/"
In the example above, the
/cygdrive prefix is needed because the development machine is Windows,
and cwRsync which is used on Windows requires the
/cygdrive prefix in order for absolute paths
to be used. The
/s in the staging environment's target prefix value means that the developer
has the target destination of the deployment mapped to his or her "s" drive.
This is a log of previous deploys. Note that it is specific to the machine that the deployment is being triggered from and not a true log every developer's releases to a specific server. This file is specific to your dev environment and should not be checked in to version control.
The following files and directories are not included in the deployment: 'emad-project.json', 'emad-local/', 'node_modules/', '.sass-cache/', '*.scssc', '.DS_Store'
Additionally, the command uses rsync's --cvs-exclude flag, which will ignore common directories that
are used for source control such as
See the rsync manual for more information.