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

@zrhsh/wukong-cli

v0.4.20

Published

Wukong CLI - TypeScript with auto token refresh

Downloads

1,703

Readme

Wukong CLI

用于 Oceanet/NRP 系统的 TypeScript CLI 工具,支持 OAuth Device PKCE Flow 认证和自动 token 刷新。

功能特性

  • 🔐 安全认证 - OAuth Device PKCE Flow,无需输入密码
  • 🔄 自动刷新 - Token 过期前自动刷新
  • 🌍 多环境支持 - 支持 dev、beta、uat 和 prod 环境
  • 🐛 调试模式 - 使用 --debug 标志显示 HTTP 请求和响应
  • 💾 安全存储 - 使用平台原生凭据管理器,支持文件回退
  • 🛠️ HTTP 客户端 - 内置 HTTP 客户端,自动处理认证
  • ⚙️ 智能配置 - 内置默认配置,支持用户自定义
  • 🔍 结构化错误 - 清晰的错误消息和可操作的修复建议

快速开始

# 安装
npm install -g @zrhsh/wukong-cli

# 初始化配置
wukong-cli init

# 登录
wukong-cli auth login

# 查看状态
wukong-cli auth status

# 发送 API 请求
wukong-cli http get "/oceanet-auth/web/userInfo"

开发

# 克隆仓库
git clone <repository-url>
cd wukong-ts-cli

# 安装依赖(自动构建项目)
npm install

# 开发模式(直接运行 TypeScript)
npm run dev <args>

# 生产环境构建
npm run build

# 全局链接用于测试
npm run link

# 运行测试
npm test

# 发布前验证
npm run verify

注意:项目配置了自动构建脚本(prepareprepack),在 npm installnpm publish 时会自动构建。如果遇到 MODULE_NOT_FOUND 错误,请运行 npm run build 手动构建。

命令

配置命令

wukong-cli init          # 初始化配置文件

更新命令

wukong-cli update       # 更新到 npm latest 版本

认证命令

wukong-cli auth login     # OAuth Device PKCE Flow 登录
wukong-cli auth status    # 显示认证状态
wukong-cli auth refresh   # 刷新访问令牌
wukong-cli auth logout    # 登出并清除令牌

HTTP 命令

wukong-cli http get "/endpoint"              # GET 请求
wukong-cli http post "/endpoint" -d '{"key":"value"}'  # POST 请求
wukong-cli http put "/endpoint" -d '{"key":"value"}'   # PUT 请求
wukong-cli http delete "/endpoint"           # DELETE 请求

全局选项

--debug         # 启用调试模式(显示 HTTP 请求)
-V, --version   # 显示版本号
-h, --help      # 显示帮助信息

环境切换

# PowerShell
$env:WUKONG_CLI_ENV="beta"
wukong-cli auth login

# Bash/Zsh
export WUKONG_CLI_ENV="beta"
wukong-cli auth login

# CMD
set WUKONG_CLI_ENV=beta
wukong-cli auth login

配置

Wukong CLI 使用智能配置,内置默认值:

  • 无需配置:CLI 开箱即用,使用内置的环境默认配置
  • 自定义配置:可选的 wukong-cli.json 用于自定义端点
  • 智能回退:环境未配置时使用内置默认值
  • 清晰错误:结构化错误消息指导您修复配置问题

配置文件位置

~/wukong-cli.json  # 用户主目录

初始化配置

wukong-cli init  # 创建或重置配置文件

配置示例

{
  "defaultEnv": "prod",
  "environments": {
    "prod": {
      "authBaseUrl": "https://portal.zrhsh.com",
      "apiBaseUrl": "https://nrp.zrhsh.com",
      "clientId": "wukong-cli-prod"
    },
    "dev": {
      "authBaseUrl": "https://portal-dev.zrhsh.com",
      "apiBaseUrl": "https://nrp-dev.zrhsh.com",
      "clientId": "wukong-cli-dev"
    }
  }
}

配置错误

如果配置不完整,您会看到结构化错误消息:

[ERROR] Configuration Error

Incomplete configuration for environment 'prod'
Environment: prod
Missing fields: apiBaseUrl, clientId

Edit your wukong-cli.json or run 'wukong-cli init' to reset

文档

入门指南

用户指南

开发指南

架构设计

发布管理

项目信息

  • 版本: 0.3.0
  • 包名: @zrhsh/wukong-cli
  • 组织: @zrhsh
  • 许可证: MIT
  • Node.js: v18+
  • TypeScript: 5.x+

贡献

欢迎贡献!请参阅:

许可证

MIT License - 详见 LICENSE 文件

支持

  • 问题反馈: (GitHub Issues URL)
  • 文档: (docs/ 目录)
  • 调试模式: 使用 --debug 标志查看详细日志

版本历史

详见 发布说明


当前版本: 0.3.0 | 包名: @zrhsh/wukong-cli | 组织: @zrhsh