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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cpillar/quick-deploy

v0.0.0

Published

快速部署项目脚本

Readme

nginx-deploy 部署工具

这是一个用于自动化部署前端项目到 Nginx 服务器的工具。

功能特点

  • 自动构建前端项目
  • 通过 SSH 将构建产物部署到远程服务器
  • 支持自定义配置文件
  • 提供友好的命令行界面和彩色输出

安装

# 本地安装
npm install nginx-deploy -D

# 全局安装【建议】
npm install -g nginx-deploy

使用方法

1. 创建配置文件

在前端项目根目录下创建一个名为 .deploy 的配置文件,包含以下内容:

npm run build
dist
[email protected]
/ssdata/server/nginx/html/x-chain2
22

配置文件各行的含义:

  • 第一行:构建命令(例如:npm run build
  • 第二行:构建后的 dist 目录路径(相对于项目根目录)
  • 第三行:远程服务器的 SSH 用户和主机地址(例如:[email protected]
  • 第四行:远程服务器上的部署路径(例如:/ssdata/server/nginx/html
  • 第五行:SSH 端口号(例如:22

2. 执行部署

在项目根目录下运行:

nginx-deploy

3. 使用自定义配置文件

如果您想使用不同的配置文件,可以通过 -c 参数指定:

nginx-deploy -c .deploy2

4. 查看帮助

nginx-deploy -h

使用示例

示例 1:使用默认配置文件

  1. 在项目根目录创建 .deploy 文件:
npm run build
dist
[email protected]
/ssdata/server/nginx/html
22
  1. 执行部署:
nginx-deploy

示例 2:使用自定义配置文件

  1. 在项目根目录创建 .deploy-production 文件:
npm run build:prod
dist
[email protected]
/ssdata/server/nginx/html-prod
22
  1. 执行部署:
nginx-deploy -c .deploy-production

工作流程

  1. 读取配置文件
  2. 执行构建命令
  3. 验证构建产物是否存在
  4. 建立 SSH 连接
  5. 在远程服务器创建目标目录
  6. 通过 SCP 传输构建产物到远程服务器
  7. 关闭 SSH 连接

注意事项

  • 确保本地可以正常执行构建命令
  • 确保有权限访问远程服务器
  • 确保远程服务器上的目标路径有写入权限
  • 首次连接可能需要确认 SSH 主机密钥
  • 在上传代码时,需要录入 SSH 服务密码,请确保您知道远程服务器的 SSH 登录密码
  • 如果使用 SSH 密钥认证,请确保本地已正确配置 SSH 密钥

错误处理

脚本会在以下情况下报错并退出:

  • 配置文件不存在
  • 配置文件内容不完整
  • 构建命令执行失败
  • 构建产物目录不存在
  • SSH 连接失败
  • 文件传输失败

技术细节

  • 使用 SSH 连接复用技术提高传输效率
  • 支持彩色输出,便于区分信息类型
  • 使用 set -e 确保脚本在遇到错误时立即退出