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

@sunshine-monorepo/deploy

v1.0.4

Published

一个快捷部署项目的小工具

Readme

@sunshine-monorepo/deploy

一个快捷部署项目到远程服务器的 CLI 工具。

安装

npm install -g @sunshine-monorepo/deploy
# 或
pnpm add -g @sunshine-monorepo/deploy

快速开始

1. 初始化配置文件

在你的项目根目录或全局配置目录创建 .env.local 文件:

# 在项目根目录创建
touch .env.local

2. 配置环境变量

编辑 .env.local 文件,添加以下内容:

# SSH 私钥路径(必填)
PRIVATE_KEY_PATH=/Users/your-username/.ssh/id_rsa

# 项目目录前缀(必填)
TARGET_DIR_PREFIX=/Users/your-username/Desktop/your-project

3. 运行部署命令

# 交互式选择项目部署
deploy choice

# 直接指定项目部署
deploy choice anshu_admin_uat

环境变量配置

必填环境变量

| 变量名 | 说明 | 示例 | |--------|------|------| | PRIVATE_KEY_PATH | SSH 私钥路径 | /Users/john/.ssh/id_rsa | | TARGET_DIR_PREFIX | 项目目录前缀 | /Users/john/Desktop/projects |

环境变量查找顺序

工具会按以下顺序查找环境变量:

  1. 项目根目录的 .env.local - 优先级最高
  2. 全局 .env.local - 如果项目目录没有找到
  3. 系统环境变量 - 如果上述都没有找到

项目配置

项目配置定义在 src/config/index.ts 中,包含以下信息:

{
  projectDescription: '项目描述',      // 用户选择时显示
  projectName: 'project_name',         // 命令行参数
  env: 'test',                         // 构建环境
  ssh: {
    host: '139.224.202.65',           // 服务器 IP
    port: 22,                         // SSH 端口
    username: 'root',                 // SSH 用户名
    password: '',                     // SSH 密码(可选)
    passphrase: '',                   // 秘钥密码(可选)
    privateKeyPath: string,           // 从 .env.local 读取
  },
  targetDir: string,                  // 从 .env.local 读取
  targetFile: 'dist.zip',             // 压缩文件名
  deployDir: '/var/www/html/...',     // 服务器部署目录
}

工作流程

1. 选择项目
   ↓
2. 读取 .env.local 配置
   ↓
3. 打包项目 (pnpm build:${env})
   ↓
4. 压缩文件 (dist.zip)
   ↓
5. 连接 SSH
   ↓
6. 删除旧文件
   ↓
7. 上传压缩包
   ↓
8. 解压文件
   ↓
9. 移动文件到部署目录
   ↓
10. 删除临时文件
   ↓
11. 断开 SSH 连接

常见问题

Q: 如何添加新的项目配置?

A: 编辑 src/config/index.ts,在 deployList 数组中添加新的项目配置对象。

Q: 如何修改 SSH 连接信息?

A: 编辑 src/config/index.ts 中的 ssh 配置,或直接修改 PRIVATE_KEY_PATH 环境变量。

Q: 部署失败怎么办?

A: 查看控制台输出的错误信息,常见原因:

  • SSH 私钥路径错误
  • 目标目录权限不足
  • 网络连接问题
  • 服务器磁盘空间不足

Q: 如何在 CI/CD 中使用?

A: 在 CI/CD 环境中设置环境变量:

export PRIVATE_KEY_PATH=/path/to/private/key
export TARGET_DIR_PREFIX=/path/to/projects
deploy choice project_name

开发

本地开发

pnpm install
pnpm dev

构建

pnpm build

发布到 npm

pnpm publish

许可证

ISC