npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pfan/tq-simple-deploy

v0.0.3

Published

a sample deploy tool

Downloads

3

Readme

tq-simple-deploy 介绍

主要利用node 的 node-ssh 库 实现自动连接服务器 并将本地打包完成的 dist目录自动上传到指定服务器目录,在没有安装云效,需要多次发布远程的场景下可快速发布。

在需要堡垒机发布的场景下 可快速提升发布效率

命令解释

tq-simple-deploy init --config xxx.js

init 命令 主要 用于下载config模板 及 help.md 到执行命令的目录
--config 指定 config 文件名称 默认 deploy.config.js

tq-simple-deploy ng-init --config xxx.js

ng-init 命令 nginx 配置初始化 主要通过 配置文件中选项 生成nginx配置文件,上传至服务器 比重启nginx
--config 指定 config 文件名称 默认 deploy.config.js

tq-simple-deploy deploy --config xxx.js -z -c

deploy 命令主要用于发布
--config 指定 config 文件名称 默认 deploy.config.js
-z 是否开启压缩 默认不压缩 直接dist 目录上传 dist较小时可直接文件夹上传
-c 是否拷贝原有文件夹 默认不拷贝 直接删除 服务器上原有文件 如果开启 会先将原有文件夹复制为 xxx202107011109009 格式

属性解释 deploy.config.js

  • local 本地目录 例如:path.resolve(__dirname, './dist')
  • remote 远程服务器目录 例如:/mnt/fe-projects/fe-demo/dist
  • clientConfig 连接服务器所需参数
    • port ssh 端口 默认22
    • host 服务器地址 xxx.xx.xx.xx
    • username 用户名 root admin
    • password 密码 xxxxxx
  • nginx nginx远程 动态配置文件路径 例如: /etc/nginx/conf.d
  • confName 动态配置文件名称 xxxx.cong 例如:test.conf
  • port 部署的静态文件所用的端口
  • isHistory 是否history 模式 history 模式下.cong文件下会添加 try_files $uri $uri/ /index.html;
  • nginxComd nginx relaod 命令 例如: nginx -s reload 或者 /etc/nginx/sbin/nginx -s reload
  • beforeDeploy 发布前钩子函数
  • afterDeploy 发布后钩子函数

简单nginx 配置使用 示例

安装依赖

npm i @pfan/tq-simple-deploy -D  

初始化指令

yarn  tq-simple-deploy  init 
或
npx   tq-simple-deploy  init

会下载 deploy.config.js 模板
我们以 服务器 47.96.94.154 端口 8478 为模板填写如下

//发布部署相关配置
const path = require('path')
module.exports = {
  local: path.resolve(__dirname, './dist'), //本地目录
  remote: '/mnt/fe-projects/fe-demo5/dist',//远程服务器 目录  /mnt/fe-projects/fe-demo/dist
  clientConfig: {
    port: 22,//ssh 端口  默认22
    host: '47.96.94.154',//服务器地址 xxx.xx.xx.xx
    username: 'root',//用户名   root admin
    password: 'Mm123456',//密码  xxxxxx
  },
  nginx:'/etc/nginx/conf.d',//nginx 动态配置文件路径
  confName:'test5.conf',//动态配置文件名称
  port:'8478',//静态文件 端口
  isHistory:false,//是否history 模式
  nginxComd:'nginx -s reload',//nginx relaod 命令 nginx 没有 配置到全局   类似   /etc/nginx/sbin/nginx -s reload
  beforeDeploy: async (clint) => {
     console.log("发布前钩子函数,这里可以暂时不写")
  },
  afterDeploy: async (clint) => {
    console.log("发布后钩子函数,这里可以暂时不写")
  }
}

执行

yarn  tq-simple-deploy  ng-init  
或
npx   tq-simple-deploy  ng-init 

简单发布使用示例

堡垒机发布使用示例