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

zipx-cli

v0.0.3

Published

zipx

Downloads

8

Readme

zipx-cli

npm version npm downloads bundle License

一个简单、快速、支持 include / exclude Glob 过滤的目录压缩 CLI / 库。

底层基于 tinyglobby + JSZip:极速文件匹配 + 高压缩率。开箱即用:默认把 dist 打成 archive.zip

✨ 特性

  • 🔍 支持 Glob 包含 / 排除(含隐藏文件)
  • 🗂 保留相对目录结构
  • 💨 tinyglobby 极速匹配
  • 🧪 ESM 为主,TypeScript 类型完善
  • 🧰 同时支持命令行与程序调用

📦 安装

全局(仅 CLI):

pnpm add -g zipx-cli
# 或
npm i -g zipx-cli

项目内(CLI + 代码调用):

pnpm add -D zipx-cli

🖥️ 命令行使用

zipx [options]

| 选项 | 别名 | 默认值 | 说明 | |------|------|--------|------| | --target <dir> | -t | dist | 要压缩的目录;可重复或用逗号分隔以指定多个目录(会一起打包) | | --no-namespace | | false | 多目录时不加前缀(默认会加前缀:按目录相对 cwd 的路径),可能造成同名文件覆盖 | | --output <file> | -o | archive | 输出文件名(可不带 .zip) | | --include <patterns...> | -i | **/* | 仅包含的 Glob 模式 | | --exclude <patterns...> | -e | - | 需要排除的 Glob 模式 | | --help | | | 查看帮助 |

示例:

# 压缩 dist -> archive.zip
zipx

# 指定目录与输出名
zipx -t build -o release

# 多目录一起打包
# 重复传参
zipx -t dist -t public -o release
# 逗号分隔
zipx -t dist,public -o release

# 多目录但不加前缀(平铺合并)
zipx -t dist,public --no-namespace -o release

# 只包含 js 与 map
zipx -i "**/*.js" "**/*.js.map"

# 排除测试与 map 文件
zipx -e "**/*.test.*" "**/*.map"

# 组合示例
zipx -t dist -o artifacts/app -i "**/*" -e "**/*.log" "**/*.md"

结果:当前工作目录生成 archive.zip(或你指定的名称)。

⚙️ 配置文件

在项目根目录创建 zipx.config.(ts|js|mjs|cjs)

import { defineConfig } from 'zipx-cli'

export default defineConfig({
  // 单目录
  target: 'dist',
  output: 'artifacts/app',
  include: ['**/*'],
  exclude: ['**/*.log', '**/*.map'],
})

// 或:多目录
export default defineConfig({
  target: ['dist', 'public'],
  output: 'artifacts/app',
  // 关闭命名空间(默认 true)
  namespace: false,
})

命令行参数优先级高于配置文件。

🧩 编程式调用

import { compress } from 'zipx-cli'

await compress({
  // 单目录
  target: 'dist',
  output: 'release', // 生成 release.zip
  include: ['**/*.js'],
  exclude: ['**/*.test.js'],
})

// 多目录
await compress({
  target: ['dist', 'public'],
  output: 'release',
  // 关闭命名空间(默认 true)
  namespace: false,
})

类型定义

interface ZipxOptions {
  cwd?: string
  target?: string | string[] // 默认: dist;数组则代表多个目录一起压缩
  output?: string // 默认: archive (若无 .zip 自动补全)
  include?: string[] // 默认: ['**/*']
  exclude?: string[]
  namespace?: boolean // 多目录时是否加前缀,默认 true;false 则平铺合并(可能覆盖同名文件)
}

🤝 贡献

欢迎 PR,本地开发:

pnpm i
pnpm dev
pnpm test

📄 许可证

MIT License © hackycy