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

snan-cli

v1.0.4

Published

CLI tool to expose backend HTTP interfaces as command-line commands

Downloads

236

Readme

Astro CLI

Astro 数据查询命令行工具。通过统一的 astro <module> <action> 命令调用 Astro OpenAPI。

安装

需要 Node.js 16 或更高版本。

npm install -g snan-cli
astro --version

npm 包名是 snan-cli,安装后的可执行命令是 astro。

配置

推荐使用交互式配置:

astro setup

也可以使用环境变量:

export ASTRO_BASE_URL=https://data.snanai.com
export ASTRO_TOKEN=your-bearer-token
export ASTRO_TIMEOUT=30000

或写入 ~/.astrorc:

{
  "baseUrl": "https://data.snanai.com",
  "token": "your-bearer-token",
  "timeout": 30000
}

配置优先级为环境变量、~/.astrorc、默认配置。默认服务地址是 https://data.snanai.com。

命令

查看帮助:

astro --help
astro metadata --help
astro metadata tables --help

元数据

# 获取数据来源;结果包含 serviceName、dsCode、sourceType 和 dbType
astro metadata sources

# serviceName 必须来自 metadata sources
astro metadata tables --serviceName=tenant-doris_prod --keyword="订单|order"

# fqn 为 serviceName.database.schema.table
astro metadata tableDetail --fqn=tenant-doris_prod.default.prod_dwi.dwi_order

数据资产

# 查询 L3 业务模型;结果包含所属业务域、业务阶段及关联资产概要
astro asset businessModels --keyword="销售|订单"

# name 必须来自 businessModels 返回结果
astro asset businessModelDetail --name="销售订单处理"

astro asset dataModels --keyword="销售|订单"
astro asset dataModelDetail --nameEn=SalesOrder
astro asset indicators --keyword="GMV|成交额"

数仓数据

astro data queryDw --body="{\"sql\":\"SELECT order_date, COUNT(*) AS order_count FROM prod_dwi.dwi_order GROUP BY order_date LIMIT 100\",\"env\":\"prod\"}"

请求体字段:

  • sql:必填,只读 SQL。
  • env:可选,支持 dev 或 prod,默认 prod。

组织查询

# 获取部门清单
astro org departments --raw

# 按关键字、部门筛选人员
astro org users --keyword '张三' --dept-code D001 --page 1 --page-size 100 --raw

# 按角色名称筛选角色
astro org roles --keyword '销售' --page 1 --page-size 1000 --raw

数据标准

astro standard dataStandard --body='{"nameCn":"客户编码"}'
astro standard nameRoot --body='{"nameCn":"客户"}'

具体请求字段以服务端 DataStandardRequestDTO 和 StandardDictRequestDTO 为准。

输出

默认输出格式化 JSON。添加 --raw 输出紧凑 JSON:

astro metadata sources --raw

Shell 补全

astro --setup-completion

执行后重新打开终端,或重新加载对应的 shell 配置文件。

请求地址

各模块请求当前版本的 Astro OpenAPI:

{baseUrl}/astro-server/openapi/v1/{module}/{action}

所有请求使用 Authorization: Bearer <token> 认证。