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

ai-yuca

v1.6.5

Published

一个用AI生成的开发辅助工具

Downloads

930

Readme

AI-Yuca

AI-Yuca 是一个面向前端发布、静态资源处理和国际化同步的 Node.js CLI 工具。它支持 GCP 存储桶上传/下载、配置化部署、图片压缩、SVG 修复、icon font 生成、favicon 生成、翻译 key 提取与 Crowdin 资源同步。

安装

npm install -g ai-yuca

验证安装:

ai-yuca --version
ai-yuca --help

环境要求

  • Node.js >=14.0.0
  • npm
  • GCP 认证:服务账号 key 文件、vs.config.json 中的 aws.FileKey,或本机 Application Default Credentials
  • 代理图片上传:接口域名优先读取 --url,其次读取 vs.config.jsondeploy.host,默认使用 https://decom.valleysound.xyz
  • 可选:Tinify API Key,用于 tinifyzip-anim
  • 可选:expectssh,用于 lg 登录脚本

快速开始

# 交互生成 vs.config.json
ai-yuca init

# 查看配置解析结果
ai-yuca upload-config --show-config

# 上传配置中声明的静态资源
ai-yuca upload-config

# 部署到测试环境
ai-yuca deploy -e test

# 通过 PM2 发布当前项目
ai-yuca pm2-release deploy prod

# 压缩图片
ai-yuca sharp -s ./assets -o ./assets-compressed -q 80

# 生成 favicon.ico
ai-yuca ico -f ./logo.svg -o ./public/favicon.ico -s 16,32,48,64,128,256

# 通过代理服务上传图片并输出可直接使用的链接
ai-yuca proxy-upload-image -f ./logo.png --raw

命令列表

| 命令 | 说明 | | --- | --- | | analyze | 分析文本内容,统计字符数、单词数、行数并提取关键词 | | upload | 上传文件或目录到 GCP 存储桶 | | proxy-upload-image | 通过代理服务上传本地图片到 GCP 并返回图片链接 | | download | 从 GCP 存储桶下载文件或目录 | | upload-config | 基于 vs.config.json 批量上传 | | deploy | 一键部署到指定环境 | | pm2-release | 读取项目配置并通过 PM2 远程发布 | | init | 交互生成或更新 vs.config.json | | sharp | 使用 sharp 本地压缩 jpg/png/webp | | tinify | 使用 Tinify API 压缩 jpg/png/webp | | zip-anim | 压缩 AE JSON 动画文件中的 base64 图片 | | svg-fix | 修复 SVG 路径并去色,输出到 fixed 子目录 | | font | 将 SVG 图标目录转换为字体库 | | ico | 将单个图片转换为 .ico 文件 | | gkeys | 扫描页面入口和依赖,生成页面级翻译 key 映射 | | transKey | 从项目代码提取翻译 key 并生成多语言源文件 | | useTrans | 将 un-trans.json 中已翻译内容合并回 source 文件 | | cr-pull | 从 GCP 或 AWS 存储桶下载 Crowdin JSON 资源 | | cr-push | 将本地 keys 翻译源文件推送到 Crowdin 存储路径 | | lg | 执行 JumpServer 登录脚本 |

上传与下载

直接上传

# 上传单个文件
ai-yuca upload -s ./dist/index.html -b my-bucket -d static/app/

# 递归上传目录
ai-yuca upload -s ./dist -b my-bucket -d static/app/ -r

# 上传多个路径
ai-yuca upload -s ./dist ./assets -b my-bucket -d static/app/ -r

# 指定 GCP 服务账号 key
ai-yuca upload -s ./dist -b my-bucket -d static/app/ -k ./service-account.json

# 禁用 GZIP
ai-yuca upload -s ./dist -b my-bucket -d static/app/ -r --no-compression

配置化上传

# 使用当前目录的 vs.config.json
ai-yuca upload-config

# 指定配置文件
ai-yuca upload-config -c ./custom.config.json

# 覆盖源路径或目标路径
ai-yuca upload-config -s ./build -d fed/static/my-app

# 强制全量上传
ai-yuca upload-config --no-cache

# 只显示配置,不执行上传
ai-yuca upload-config --show-config

upload-config 默认读取:

  • upload.uploadPath:本地上传目录
  • upload.s3Static:静态资源子路径
  • aws.Bucket:GCP 存储桶
  • aws.prefix:远端路径前缀

最终默认上传路径为:

{aws.prefix}/{upload.s3Static}

代理图片上传

proxy-upload-image 会调用项目代理接口 POST /proxy-upload/gcp-image,以 multipart/form-data 上传本地文件,文件字段名固定为 file。命令成功后默认输出 fullUrl,适合在 AI 工作流中把本地图片转换成可直接使用的远程链接。

接口域名读取优先级:

  1. 命令参数 --url
  2. vs.config.json 中的 deploy.host
  3. 默认域名 https://decom.valleysound.xyz
# 传站点 origin,命令会自动拼接 /proxy-upload/gcp-image
ai-yuca proxy-upload-image -f ./assets/logo.png -u https://your-domain.com

# 未传 --url 时读取当前目录 vs.config.json 的 deploy.host
ai-yuca proxy-upload-image -f ./assets/logo.png --raw

# 指定配置文件
ai-yuca proxy-upload-image -f ./assets/logo.png -c ./custom.config.json --raw

# 仅输出图片 URL,适合脚本或 AI 读取
ai-yuca proxy-upload-image -f ./assets/logo.png -u https://your-domain.com --raw

# 上传到 own 目录,对应接口参数 staticPath=true
ai-yuca proxy-upload-image -f ./assets/logo.png -u https://your-domain.com --static-path

下载

# 下载单个文件或指定前缀下文件
ai-yuca download -s static/app/index.html -b my-bucket -d ./downloads/

# 递归下载目录
ai-yuca download -s static/app/ -b my-bucket -d ./downloads/ -r

部署

# 部署到测试环境
ai-yuca deploy -e test

# 部署到生产环境
ai-yuca deploy -e production

# 跳过交互确认
ai-yuca deploy -e test -f

# 查看部署配置
ai-yuca deploy -e test --show-config

# 上传环境 config.json 时,将匹配项目的 name 替换为 package.json.name
ai-yuca deploy -e test --replace-config-name-with-package

PM2 远程发布

pm2-release 读取当前项目 package.jsonai-yuca.pm2Release 配置,用于把多个前端项目统一到一套 PM2 发布命令。命令会先检查本机 SSH alias 是否配置了有效 HostName,再运行时生成临时 PM2 ecosystem 配置并复用 SSH master 连接执行 PM2;项目内不需要保留 ecosystem.config.cjs

# 初始化 test 和 prod 远端目录
ai-yuca pm2-release setup

# 发布测试环境
ai-yuca pm2-release deploy test

# 发布生产环境
ai-yuca pm2-release deploy prod

# 指定分支或 ref
ai-yuca pm2-release deploy test --ref feat_xxx
ai-yuca pm2-release deploy prod --ref origin/main

package.json 配置示例:

{
  "scripts": {
    "pm2:setup": "ai-yuca pm2-release setup",
    "pm2:deploy": "ai-yuca pm2-release deploy prod",
    "pm2:deploy:test": "ai-yuca pm2-release deploy test"
  },
  "ai-yuca": {
      "pm2Release": {
      "repo": "[email protected]:HEchooo/project.git",
      "packageManager": "pnpm",
      "pm2Command": "pnpm exec pm2",
      "allowNoPnpmLockfile": false,
      "deployName": "server",
      "environments": {
        "test": {
          "hosts": "test",
          "path": "/home/echooo/fed/project-test",
          "ref": "origin/main",
          "script": "ai:test"
        },
        "prod": {
          "hosts": "test",
          "path": "/home/echooo/fed/project",
          "ref": "origin/main",
          "script": "ai"
        }
      }
    }
  }
}

pnpm 项目默认优先使用 pnpm install --frozen-lockfile。如果本地没有 pnpm-lock.yamlpm2-release deploy 会先询问是否继续;如果远端目标分支没有 lockfile,会自动降级为 pnpm install --no-frozen-lockfile。如果项目明确不提交 lockfile,可设置 "allowNoPnpmLockfile": true

资源处理

sharp 本地压缩

ai-yuca sharp -s ./assets -o ./assets-zip -q 80
ai-yuca sharp -s ./assets -o ./assets-zip -q 75 -f

Tinify 压缩

# 压缩目录,默认输出到 source/zip
ai-yuca tinify -s ./assets -k "$TINIFY_API_KEY"

# 压缩单个文件并覆盖原文件
ai-yuca tinify -f ./assets/logo.png -k "$TINIFY_API_KEY"

# 压缩单个文件到指定目录或文件
ai-yuca tinify -f ./assets/logo.png -o ./assets-zip/

Tinify API Key 读取优先级:

  1. -k, --key
  2. vs.config.jsonapiKeys.tinifytinify
  3. ~/.yuca/.env 中的 tinifyTINIFY_KEYTINIFY_API_KEYapiKeys.tinify

AE 动画 JSON 压缩

ai-yuca zip-anim -s ./animation/data.json -k "$TINIFY_API_KEY"

SVG 修复

ai-yuca svg-fix -s ./icons

图标工具

生成 icon font

# 从命令参数读取输入输出
ai-yuca font -s ./icons -o ./dist/iconfont -n ai-icons -p ai

# 从 vs.config.json 的 font 字段读取
ai-yuca font

可在 vs.config.json 中通过 font.styleTypes 控制生成哪些样式文件:

{
  "font": {
    "source": "src/icons",
    "output": "dist/iconfont",
    "name": "iconfont",
    "prefix": "iconfont",
    "styleTypes": ["css", "less", "scss"]
  }
}

支持的样式类型:csslessmodule.lessscsssassstylstylusall。其中 sass 会按当前 svgtofont 模板生成 .scss 文件。

生成 .ico

# 默认同目录同名输出 .ico
ai-yuca ico -f ./public/logo.png

# 指定完整输出路径和尺寸
ai-yuca ico -f ./public/logo.svg -o ./public/favicon.ico -s 16,32,48,64,128,256

支持输入格式:pngjpgjpegsvgwebp

国际化与 Crowdin

提取翻译 key

ai-yuca transKey
ai-yuca transKey -c ./vs.config.json

合并未翻译文件

ai-yuca useTrans

生成页面级 key 映射

ai-yuca gkeys -s ./src/pages
ai-yuca gkeys -s ./src/pages -r "\\{#(.+?)#\\}"

Crowdin 资源同步

# 拉取远端 Crowdin JSON 资源
ai-yuca cr-pull

# 排除匹配资源
ai-yuca cr-pull --exclude draft

# 使用 AWS 存储模式
ai-yuca cr-pull --aws

# 推送本地 keys 到配置的存储路径
ai-yuca cr-push

其他命令

文本分析

ai-yuca analyze -f ./example.txt
ai-yuca analyze -t "这是一段需要分析的文本"

JumpServer 登录

ai-yuca lg -s 192.168.1.1
ai-yuca lg -s web-server -u username

vs.config.json

可以通过 ai-yuca init 交互生成配置。常用结构如下:

{
  "upload": {
    "uploadPath": "out",
    "s3Static": "static/projectName"
  },
  "deploy": {
    "baseUrl": ["/", "en-us/"],
    "host": "",
    "testHost": ""
  },
  "aws": {
    "Bucket": "cdn",
    "prefix": "fed",
    "Region": "us-east-1",
    "HostName": "",
    "FileKey": "./service-account.json"
  },
  "apiKeys": {
    "tinify": ""
  },
  "font": {
    "source": "src/icons",
    "output": "dist/iconfont",
    "name": "iconfont",
    "prefix": "iconfont",
    "styleTypes": ["css", "less", "scss"]
  },
  "crowdin": {
    "project": "fed-project-name",
    "langMap": ["zh-cn", "en-us"],
    "workDir": "src",
    "reg": "{#(.+?)#}",
    "keysDir": "src/_i18n",
    "Bucket": "cdn",
    "prefix": "fed",
    "Region": "us-east-1",
    "FromIni": "mall",
    "HostName": ""
  }
}

更多文档

许可证

MIT