up is a command-line tool, which can upload your files to sftp with simple commands.
npm install -g upuse yarn/pnpm whatever you like.
up will read configuration file from up.config.json in your working directory.
You can use up --init to create a configuration file.
Below is a complete example of up.config.json:
{
"host": "your-sftp-host",
"port": 22,
"username": "your-username",
"password": "your-password",
"remotePath": "/your/remote/path",
"localPath": "/your/local/path",
"exclude": []
}host(required): the sftp hostport: the sftp port, default is22username(required): the sftp usernamepassword(required): the sftp passwordremotePath(required): the remote dir path you want to upload to, should be an absolute path.localPath(required): the local file path you want to upload, can be relative or absolute, finally this path will be resolved to an absolute pathexclude: the files you want to exclude, should be an array of string, the string should be a glob pattern, like['**/*.log', 'node_modules']priority: the files you want to upload first, should be an array of glob patterns. Files are uploaded in the order of the patterns, for example["**/*.js", "**/*.css"]uploads JS and CSS files before other files.priorityLast: the files you want to upload last, should be an array of glob patterns. Defaults to["**/*.html"]so HTML entry files are uploaded after all static assets. Set it to[]to disable this default behavior.
if localPath is a directory, up will upload all files in the directory, for example:
/your/local/path is a directory, and it contains files like: /your/local/path/example.txt, remotePath is /var/www/project, when upload finished, the remote file url will be /var/www/project/example.txt
if localPath is a file, up will directly upload the file to the remotePath, for example
/your/local/example.txt is a file, remotePath is /var/www/project, when upload finished, the remote file url will be /var/www/project/example.txt
By default, all .html files are uploaded last. This is useful when deploying a frontend project: visitors won't request the new HTML before its static assets (JS, CSS, images, etc.) are already in place.
You can customize the order with priority and priorityLast:
{
"host": "your-sftp-host",
"port": 22,
"username": "your-username",
"password": "your-password",
"remotePath": "/var/www/project",
"localPath": "./dist",
"exclude": [],
"priority": ["**/*.js", "**/*.css", "**/*.{png,jpg,jpeg,svg,webp,gif}"],
"priorityLast": ["**/*.html"]
}With this configuration, files are uploaded in the following order:
priorityfiles: JS, CSS, and image files (in the order listed)- All other files
priorityLastfiles: HTML files (by default)
up: upload files to sftp, use the working directory'sup.config.jsonas configuration file.-h, --help: output usage information-v, --version: output the version number-i, --init: create a template of configuration file in the working directory
MIT