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.3.0

Published

Wukong CLI - TypeScript with auto token refresh

Readme

Wukong CLI

TypeScript CLI tool for Oceanet/NRP system with OAuth Device PKCE Flow authentication and automatic token refresh.

Features

  • 🔐 Secure Authentication - OAuth Device PKCE Flow without password input
  • 🔄 Auto Token Refresh - Automatic token refresh before expiration
  • 🌍 Multi-Environment - Support for dev, beta, uat, and prod environments
  • 🐛 Debug Mode - Show HTTP requests and responses with --debug flag
  • 💾 Secure Storage - Platform native credential managers with file fallback
  • 🛠️ HTTP Client - Built-in HTTP client with automatic authentication
  • ⚙️ Smart Configuration - Built-in defaults with fallback to user configuration
  • 🔍 Structured Errors - Clear error messages with actionable fix suggestions

Quick Start

# Install
npm install -g @zrhsh/wukong-cli

# Initialize configuration
wukong-cli init

# Login
wukong-cli auth login

# Check status
wukong-cli auth status

# Make API request
wukong-cli http get "/oceanet-auth/web/userInfo"

Development

# Clone repository
git clone <repository-url>
cd wukong-ts-cli

# Install dependencies (自动构建项目)
npm install

# Development mode (直接运行 TypeScript)
npm run dev <args>

# Build for production
npm run build

# Link globally for testing
npm run link

# Run tests
npm test

# Verify before publishing
npm run verify

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

Deprecation Notices

⚠️ Device Flow API: 某些内部 API 已标记为弃用,将在 v1.0.0 中移除。这不会影响终端用户的使用。详见 弃用文档

Commands

Configuration Commands

wukong-cli init          # Initialize configuration file

Authentication Commands

wukong-cli auth login     # OAuth Device PKCE Flow login
wukong-cli auth status    # Show authentication status
wukong-cli auth refresh   # Refresh access token
wukong-cli auth logout    # Logout and clear tokens

HTTP Commands

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

Global Options

--debug         # Enable debug mode (show HTTP requests)
-V, --version   # Show version number
-h, --help      # Show help information

Environment Switching

# 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

Configuration

Wukong CLI uses intelligent configuration with built-in defaults:

  • No Configuration Required: CLI works out of the box with built-in environment defaults
  • Custom Configuration: Optional wukong-cli.json for custom endpoints
  • Smart Fallback: Uses built-in defaults when environments are not configured
  • Clear Errors: Structured error messages guide you to fix configuration issues

Configuration File Location

~/wukong-cli.json  # User home directory

Initialize Configuration

wukong-cli init  # Creates or resets configuration file

Example Configuration

{
  "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"
    }
  }
}

Configuration Errors

If your configuration is incomplete, you'll see structured error messages:

[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

Documentation

Getting Started

User Guide

Development

Architecture

Publishing

Project Information

  • Version: 0.1.12
  • Package: @zrhsh/wukong-cli
  • Organization: @zrhsh
  • License: MIT
  • Node.js: v18+
  • TypeScript: 5.x+

Installation

# Global installation from npm
npm install -g @zzhsh/wukong-cli

# Development installation from source
git clone <repository-url>
cd wukong-ts-cli
npm install
npm run build
npm run link

Development

# Clone repository
git clone <repository-url>
cd wukong-ts-cli

# Install dependencies
npm install

# Development mode
npm run dev auth login

# Build
npm run build

# Test
npm run link
wukong-cli --version

# Unit tests
npm test

# E2E tests - Automated (无需用户交互,CI/CD 推荐)
npm run test:e2e:automated      # 默认环境自动化测试
npm run test:e2e:automated:dev  # 开发环境自动化测试
npm run test:e2e:automated:beta # 测试环境自动化测试
npm run test:e2e:automated:prod # 生产环境自动化测试

# E2E tests - Interactive (需要用户OAuth授权)
npm run test:e2e:interactive      # 默认环境交互式测试
npm run test:e2e:interactive:dev  # 开发环境交互式测试
npm run test:e2e:interactive:beta # 测试环境交互式测试
npm run test:e2e:interactive:prod # 生产环境交互式测试
npm run test:e2e:interactive:run  # 带用户引导的交互式测试

Contributing

Contributions are welcome! Please see:

License

MIT License - see LICENSE file for details

Support

  • Issues: (GitHub Issues URL)
  • Documentation: (in docs/ directory)
  • Debug Mode: Use --debug flag for detailed logs

Version History

See Release Notes for version history and changes.


Current Version: 0.1.12 | Package: @zrhsh/wukong-cli | Organization: @zrhsh