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

@postar/deploy-cli

v0.1.0

Published

一个支持自动上传、备份、监听和回滚的部署命令行工具,助力前端/静态资源项目实现标准化部署流程

Downloads

15

Readme

Deploy CLI

npm version license

一个轻量级的前端项目自动化部署工具,支持文件上传、备份、监听和回滚,让部署更简单、更安全。

✨ 特性

  • 🚀 自动部署 - 一键完成打包上传,告别手动操作
  • 📦 文件备份 - 自动备份原文件,支持快速回滚
  • 👀 实时监听 - 监听文件变化,自动触发部署
  • 🔒 安全可靠 - 完整的备份机制,部署更有保障
  • 🎯 开箱即用 - 简单配置即可使用,无需复杂设置
  • 🔄 支持回滚 - 一键回滚到上一版本,快速止损

🎯 功能

  • 自动上传部署
  • 文件自动备份
  • 文件变化监听
  • 版本快速回滚
  • 支持多环境配置
  • 支持自定义部署流程

📦 安装

npm install @postar/deploy-cli --save-dev
# 或者
pnpm install @postar/deploy-cli --save-dev
# 或者
yarn add @postar/deploy-cli -D

🚀 快速开始

  1. 在项目根目录创建 deploy-cli.js 文件

  2. package.json 中添加部署命令:

{
  "scripts": {
    "build": "vite build",
    "deploy": "vite build --mode=test && node deploy-cli.js deploy",
    "deploy:backup": "vite build && node deploy-cli.js deployBackup",
    "rollback": "node deploy-cli.js rollback"
  }
}
  1. 配置 deploy-cli.js
const { 
  deploy, 
  deployBackup, 
  watchDeploy,
  watchDeployBackup,
  rollback 
} = require('@postar/deploy-cli')

const config = {
  // 服务器配置
  sftpConfig: {
    host: 'xxx.xxx.xxx.xxx',
    port: '22',
    username: 'xxx',
    password: 'xxx'
  },
  // 本地配置
  watchFolder: './unpackage/dist/build',
  uploadFile: './unpackage/dist/build/h5',
  // 远程配置
  remotePath: `/home/www/h5-project/dist`,
  backupFolder: `/home/www/h5-project/backup`,
  // 其他配置
  author: 'yourname'
}

// 命令映射
const COMMANDS = {
  deploy: () => deploy(config),
  deployBackup: () => deployBackup(config),
  watchDeploy: () => watchDeploy(config),
  watchDeployBackup: () => watchDeployBackup(config),
  rollback: () => rollback(config)
};

// 执行命令
const command = process.argv[2];
if (command in COMMANDS) {
  COMMANDS[command]();
} else {
  console.log(`可用命令:${Object.keys(COMMANDS).join('、')}`);
}

📚 API 文档

deploy(config)

执行部署操作,将本地文件上传至服务器。

deployBackup(config)

执行部署操作并备份原文件,保障部署安全。

watchDeploy(config)

监听文件变化并自动部署,适用于开发环境。

watchDeployBackup(config)

监听文件变化并自动部署(带备份),适用于测试环境。

rollback(config)

回滚到上一个版本,快速恢复服务。

⚠️ 注意事项

  • watchDeploywatchDeployBackup 主要用于需要监听文件变化的项目(如 uni-app H5)
  • 建议在生产环境部署时总是使用 deployBackup 以确保安全
  • 确保服务器目录具有正确的读写权限
  • 建议在 .gitignore 中忽略 deploy-cli.js 以保护服务器信息

📝 配置说明

| 配置项 | 说明 | 类型 | 必填 | |-------|------|------|-----| | sftpConfig | 服务器连接配置 | Object | 是 | | watchFolder | 监听的文件夹路径 | String | 否 | | uploadFile | 需要上传的文件路径 | String | 是 | | remotePath | 服务器部署路径 | String | 是 | | backupFolder | 服务器备份路径 | String | 否 | | author | 部署作者 | String | 否 |