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

@via-cli/cache-command

v0.0.2

Published

via-cli cache command - 缓存管理命令

Readme

@via-cli/cache

Via CLI 缓存管理命令 - 支持旧版依赖缓存和统一包缓存的统一管理。

功能特性

🎯 双缓存系统支持

同时管理两种类型的缓存:

  • 📦 旧版依赖缓存: 项目特定的依赖缓存目录
  • 🚀 统一包缓存: pkg-manager v2.0+ 使用的共享缓存 (~/.via-cli/npm-cache)

📋 主要命令

查看缓存列表

via-cli cache list
# 或
via-cli cache ls

分类显示所有缓存包:

  • 旧版依赖缓存列表
  • 统一包缓存列表
  • 总缓存统计

清理缓存

via-cli cache clear
# 或
via-cli cache clean

灵活选择清理范围:

  • 仅清理旧版依赖缓存
  • 仅清理统一包缓存
  • 清理所有缓存
  • 取消操作

删除指定包

via-cli cache remove
# 或
via-cli cache rm

从统一列表中选择性删除:

  • 显示所有缓存包(带类型标识)
  • 支持多选删除
  • 显示将释放的空间

查看缓存信息

via-cli cache info
# 或
via-cli cache status

详细的缓存统计:

  • 缓存配置路径
  • 分类统计两种缓存
  • 最近缓存的包列表

安装

pnpm install @via-cli/cache

使用示例

查看所有缓存

$ via-cli cache list

📦 旧版依赖缓存 (/path/to/dependencies/cache):
   1. [email protected]
   2. [email protected]

🚀 统一包缓存 (~/.via-cli/npm-cache):
   1. [email protected]
   2. [email protected]

总缓存包数: 4 个
总缓存大小: 125.67 MB

选择性删除缓存包

$ via-cli cache remove

? 选择要删除的缓存包:
  ◯ 📦 [旧版] [email protected] (12.5 MB)
  ◉ 🚀 [统一] [email protected] (45.2 MB)
  ◯ 🚀 [统一] [email protected] (8.3 MB)

? 确定要删除选中的 1 个包吗?将释放 45.2 MB 空间 (y/N)

查看详细缓存信息

$ via-cli cache info

📋 缓存配置:
   用户主目录: C:\Users\YourName
   CLI主目录:  C:\Users\YourName\.via-cli
   环境变量:   CLI_HOME_PATH=未设置

📦 旧版依赖缓存:
   路径: /path/to/dependencies/cache
   状态: 正常
   包数量: 2 个
   总大小: 20.5 MB

🚀 统一包缓存:
   路径: C:\Users\YourName\.via-cli\npm-cache
   状态: 正常
   包数量: 3 个
   总大小: 105.2 MB

📊 总计:
   总包数: 5 个
   总大小: 125.7 MB

🕒 最近缓存的包 (最多显示5个):
   1. 🚀 [email protected] - 2024/1/15 14:30:25
   2. 🚀 [email protected] - 2024/1/15 10:15:00
   3. 📦 [email protected] - 2024/1/14 16:45:30

缓存目录说明

旧版依赖缓存

  • 路径由 getDependenciesCacheDir() 确定
  • 通常在项目相关目录
  • 用于旧版项目的依赖缓存

统一包缓存

  • 路径: ~/.via-cli/npm-cache/{packageName}/{version}
  • pkg-manager v2.0+ 使用
  • 跨项目共享,节省磁盘空间
  • 结构: {packageName}/{version}/node_modules/{packageName}

API

CacheCommand

class CacheCommand {
  // 查看缓存列表
  async listCache(): Promise<void>
  
  // 清理缓存
  async clearCache(): Promise<void>
  
  // 删除指定包
  async removePackage(): Promise<void>
  
  // 显示缓存信息
  async showCacheInfo(): Promise<void>
  
  // 获取所有缓存包
  async getAllPackages(): Promise<PackageInfo[]>
  
  // 按类型获取缓存包
  async getAllPackagesByType(type: 'legacy' | 'unified'): Promise<PackageInfo[]>
}

PackageInfo 接口

interface PackageInfo {
  name: string;           // 包名
  version: string;        // 版本号
  path: string;           // 缓存路径
  size: number;           // 大小(字节)
  modifiedTime: Date;     // 修改时间
  type: 'legacy' | 'unified';  // 缓存类型
}

命令行参数

用法: via-cli cache [command]

命令:
  list, ls          查看所有缓存列表
  clear, clean      清理缓存
  remove, rm        选择删除缓存包
  info, status      查看缓存信息

选项:
  --help           显示帮助信息

开发

构建

pnpm build

测试

查看 TEST_GUIDE.md 获取详细测试指南。

版本历史

查看 CHANGELOG.md 获取详细变更记录。

相关包

License

MIT