demand
Now many projects, such as simple front-end H5, the fastest way to publish or test is through SFTP upload, there are good upload tools, such as FileZilla, but this tool is not coupled to the project, every new start needs to constantly find folders.
In order to publish one command at a time, easy-SFTP is a tool. You can visit easy-SFTP to download the trial.
If you execute NPM run upload, you can upload it.
use
Now our project, such as packaging, service are all NPM script, for unification and better operation, release project also use NPM script.
Perform:
(sudo) npm install easy-sftp -g
Copy the code
Easy-sftp provides three commands:
Chaos create <file.json> // Create an uploaded configuration item chaos send -c <file.json> // Start uploading chaoslog// Check the chaos of uploads in the last 3 dayslog-t // Displays logs of the current day chaoslog-r // Displays all existing logsCopy the code
Now let’s start building a set of upload configuration items in the project.
CD to the project directory, run:
Chaos Create server.json // Any name will do, just in JSON formatCopy the code
A server.json file is created in the root directory as follows:
{
"host": ""."port": 22."username": "root"."password": ""."pathMap": [{"localPath": ""."remotePath": ""}}]Copy the code
Multiple folders can be uploaded at the same time. Add the local folder or file address to pathMap and fill in the mapping remotePath address.
Ok, the basic configuration file is ready. Json script: package.json
"scripts": {
"upload": "chaos send -c server.json"
}
Copy the code
Everything is ready, now just execute:
npm run upload
Copy the code
You can upload local static resources to the server.
logging
The tool also provides a logging function, which records the git address and branch, time, local IP and remote IP of each upload.
Execute the following at any location:
chaos log// All logs chaoslog-t // Logs of the day chaoslog// Check the chaos of uploads in the last 3 dayslog-r // Clears all upload logsCopy the code
conclusion
Good use, everybody. Can YOU give me a star? Hahaha, thanks.