web-pub 一款ssh上传命令行工具

443 阅读1分钟

Welcome to web-pub 👋

一款用于发布静态资源到服务器的脚本。

🏠 Homepage

Prerequisites

  • node >= 18.0.0

  • npm >= 9.8.1

  • yarn >= 1.22.0

Author

👤 Smilydes

起步

  • npm install web-pub -g

ssh 操作

  • 查看 ssh 配置 web-pub ssh list

  • 添加 ssh 配置 web-pub ssh add <名称> <host@port> <user> <password>

    • web-pub ssh add test 127.0.0.1@22 root 123456
  • 删除指定 ssh 配置 web-pub ssh del test

    • web-pub ssh del <name>
  • 局部配置 ssh

    • web-pub run -S <ip@port@user@pass> -R <remotePath> -L [localPath 默认./ 用于指定本地路径]
      • web-pub run -S 127.0.0.1@22@root@123456. -R /mnt/test

      • 可使用web-pub run --help 查看配置描述

部署

    - web-pub use <ssh名称> <远程服务器部署路径>

示例


# 进入web/dist打包好的目录将dist目录内的文件上传到指定服务器的 /mnt/statics/test目录中

  


cd /web/dist

web-pub use test /mnt/statics/test

配合项目使用

   // package.json
   {
       ...
       "script"{
           ...
           "publish": yarn build && cd dist && web-pub use test /mnt/statics/test-dev,
           "publish2": yarn build && npx web-pub run -S 127.0.0.1@22@root@123456 -R /mnt/statics/test-dev -L ./dist
           
       }
       ...
   
   }

Give a ⭐️ if this project helped you!

这款小工具可以自己用来玩玩,上传资源到自己的服务器啥的,目前大部分项目都是用的流水线自动部署方案