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

bhpan-cli

v0.3.0

Published

Unofficial BUAA AnyShare cloud drive CLI and interactive shell

Downloads

666

Readme

bhpan-cli

npm version npm downloads GitHub release License

bhpan-cli 是一个面向北航云盘(AnyShare)的非官方命令行工具,提供:

  • 单次 CLI:适合脚本、SSH、自动化任务
  • 交互式 shell:适合日常手工浏览和文件操作

它基于早期的 dist_bhpanPanCLI 思路重写,目标不是简单移植,而是做一个结构更清晰、能直接安装、并且已经对当前北航线上站点做过真实联调的 TypeScript 版本。

项目链接

为什么用它

  • 直接安装:npm install -g bhpan-cli
  • 直接使用:安装后命令就是 bhpan
  • 同时支持脚本化调用和交互式 shell
  • 已适配北航当前 OAuth2 / Hydra 登录链路
  • 已完成真实账号联调,不是只在本地做静态实现

当前版本

  • 版本:0.2.1
  • 运行时:Node >= 22
  • npm 包名:bhpan-cli
  • CLI 命令:bhpan

功能概览

当前已实现:

  • 登录、登出、身份查看
  • 路径解析与 /home 别名
  • lstreestat(支持 -R 递归列出、-L 深度限制、--regex 正则过滤)
  • mkdirrm
  • mvcp
  • catheadtail
  • touch
  • 上传、下载
  • 匿名分享与实名分享
  • 单次 CLI 与交互式 shell

当前已经用真实北航账号做过联调的主链包括:

  • OAuth2 登录与 token 刷新
  • /home 路径解析
  • ls / stat / mkdir / rm
  • cat / head / tail
  • touch
  • 小文件上传与下载
  • tree -L/--depth--sort--desc
  • 匿名分享 link create/show/delete
  • 实名分享 link create/show/delete
  • 同一路径下多分享并存时的 link showlink delete --type all

安装

全局安装:

npm install -g bhpan-cli

临时执行:

npx bhpan-cli --help

安装完成后:

bhpan --help
bhpan --version

快速开始

首次登录:

bhpan login --username <你的学号>

查看主页目录:

bhpan ls /home

上传文件:

bhpan upload ./report.pdf /home/code

下载文件:

bhpan download /home/code/report.pdf .

进入交互式 shell:

bhpan

或:

bhpan shell

常用命令

bhpan shell
bhpan login [--username <name>] [--no-store-password]
bhpan logout
bhpan whoami
bhpan ls [remote_path] [-R] [-L depth] [--regex pattern]
bhpan tree [remote_path] [-L depth] [--sort name|mtime|size] [--desc] [--regex pattern]
bhpan stat <remote_path>
bhpan mkdir <remote_path>
bhpan rm <remote_path> [-r]
bhpan mv <src> <dst> [-f]
bhpan cp <src> <dst> [-f]
bhpan cat <remote_file>
bhpan head <remote_file> [-n lines]
bhpan tail <remote_file> [-n lines]
bhpan touch <remote_file>
bhpan link <show|create|delete> <remote_path> [--type anonymous|realname|all] [--expires days] [-p] [--allow-upload] [--no-download]
bhpan upload <local_path> <remote_dir>
bhpan download <remote_path> [local_dir]

完整说明请直接运行:

bhpan --help

示例

列目录:

bhpan ls /home
bhpan ls /home/code

查看目录树:

bhpan tree /home/code -L 2
bhpan tree /home/code --sort size --desc

创建空文件:

bhpan touch /home/code/hello.txt

查看文件头尾:

bhpan head /home/code/readme.txt -n 20
bhpan tail /home/code/readme.txt -n 20

创建匿名分享:

bhpan link create /home/code/report.pdf -p

创建实名分享:

bhpan link create /home/code/report.pdf --type realname

查看或关闭分享:

bhpan link show /home/code/report.pdf
bhpan link delete /home/code/report.pdf --type all

递归列出目录:

bhpan ls /home -R
bhpan ls /home -R -L 2

使用正则表达式过滤:

bhpan ls /home -R --regex '.*\\.pdf$'
bhpan tree /home -L 4 --regex '.*report.*'

说明:

  • ls -R 递归列出所有文件和目录,显示完整逻辑路径
  • --regex 使用 JavaScript 正则表达式匹配完整路径
  • tree --regex 显示匹配项及其祖先目录(保持上下文)

已知边界

当前仍建议继续补实盘回归的部分:

  • mv / cp
  • 大文件上传下载
  • 递归目录传输
  • 异常中断恢复

体验层面仍待继续增强的部分:

  • tree 的更细过滤与统计输出
  • 更丰富的分享参数
  • shell 命令补全与更强的错误提示

配置与数据位置

Linux:

  • 配置:~/.config/bhpan/config.json
  • 数据:~/.local/share/bhpan/

macOS:

  • 配置:~/Library/Application Support/bhpan/config.json
  • 数据:~/Library/Application Support/bhpan/

Windows:

  • 配置:%APPDATA%\\bhpan\\config.json
  • 数据:%LOCALAPPDATA%\\bhpan\\

隐私与说明

  • 这是非官方工具,不代表北航或 AnyShare 官方
  • 仅适用于本身就拥有北航云盘访问权限的用户
  • 登录后会把配置写到本地配置目录
  • 如选择保存密码,保存的是加密后的本地凭据与缓存 token

反馈与状态

开发

安装依赖:

npm install

类型检查:

npm run typecheck

构建发布产物:

npm run build

本地打包预览:

npm pack

致谢

本项目的设计与协议适配过程中参考了以下上游项目: