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

bt-vite-deploy

v1.5.3

Published

Deploy Vite/Vue projects to BT Panel (宝塔面板) with a single command

Readme

bt-vite-deploy

Deploy Vite/Vue projects to BT Panel (宝塔面板) with a single command.

在当前目录查找 dist.zip(不存在则自动打包 dist/ 目录)→ 上传到宝塔 → 远程解压 → 清理。

安装

pnpm add -D bt-vite-deploy

快速开始

1. 一键初始化

安装后,在项目根目录执行:

npx bt-deploy init

这会自动:

  • 创建 bt-deploy.config.ts 配置模板
  • 向 package.json 添加 "deploy": "bt-deploy" 脚本

2. 编辑配置

打开 bt-deploy.config.ts,填写你的宝塔面板信息:

import { defineConfig } from 'bt-vite-deploy';

export default defineConfig({
  panel: 'https://tx.example.com:12345',
  remoteDir: '/www/wwwroot/example.com',
  // localDir: '.',         // 查找 dist.zip 的目录,默认当前目录
  // timeout: 120,          // 请求超时(秒),默认 120
  // cleanRemote: true,     // 部署前清理远程目录,默认 true
});

也支持 .js、.mjs、.cjs、.json 格式,或在 package.json 中添加 btDeploy 字段。

3. 设置 API 密钥

# Windows
set BT_KEY=你的宝塔API密钥

# Linux / macOS
export BT_KEY=你的宝塔API密钥

也可在配置文件中直接设置 key 字段(不推荐提交到版本控制)。

4. 构建并部署

# 构建项目(生成 dist/ 目录)
pnpm run build

# 执行部署(自动查找 dist.zip,不存在则从 dist/ 打包)
pnpm run deploy

部署流程

固定 4 步,上传 dist.zip 一个文件:

  1. 在 localDir(默认当前目录)中查找 dist.zip
    • 存在 → 直接使用
    • 不存在 → 查找 dist/ 目录,自动打包为 dist.zip
    • 两者都不存在 → 报错中止
  2. 列出远程目录文件
  3. 批量删除远程所有文件(移入回收站)
  4. 上传 dist.zip → 远程解压 → 删除远程 dist.zip(自动生成的本地 dist.zip 也会清理)

配置选项

| 选项 | 类型 | 默认值 | 说明 | |------|------|--------|------| | panel | string | (必填) | 宝塔面板地址(不带末尾斜杠) | | remoteDir | string | (必填) | 服务器端目标目录 | | key | string | process.env.BT_KEY | API 密钥 | | localDir | string | '.' | 查找 dist.zip 的目录 | | timeout | number | 120 | 请求超时时间(秒) | | cleanRemote | boolean | true | 部署前是否清理远程目录 |

CLI 用法

bt-deploy init              # 创建配置文件 + 添加 deploy 脚本
bt-deploy                   # 执行部署
bt-deploy --no-clean        # 不清理远程目录
bt-deploy --local-dir build # 指定查找 dist.zip 的目录
bt-deploy --help            # 查看帮助
bt-deploy --version         # 查看版本

配置文件中的所有选项都可通过 CLI 参数覆盖:

bt-deploy --panel https://panel.example.com:8888 --remote-dir /www/wwwroot/site.com

API 密钥获取

  1. 登录宝塔面板
  2. 进入 面板设置 → API 接口
  3. 复制 API 密钥
  4. 确保 API 接口已开启,且你的 IP 在白名单中

认证机制

request_time  = 当前 Unix 时间戳(秒)
request_token = MD5(request_time + MD5(API_KEY))

每次请求将 request_time 和 request_token 作为表单参数发送。

编程式使用

除了 CLI,也可以在代码中直接调用:

import { deploy, loadConfig, initConfig } from 'bt-vite-deploy';

// 初始化配置文件
await initConfig();

// 执行部署
const config = await loadConfig();
await deploy(config);

宝塔Linux面板入门【人人都能上手的服务器运维面板】

https://www.bilibili.com/cheese/play/ss22181

License

MIT