@yang0/iconfont-cli
v0.1.0
Published
API-first CLI for authenticated iconfont.cn workflows
Maintainers
Readme
iconfont-cli
通过命令行使用 iconfont.cn。
iconfont-cli 是一个 API-first 的 iconfont.cn 命令行工具,支持登录态校验、素材搜索、素材集查看、SVG 下载、项目查看、CDN 查询和 ZIP 导出。
安装
1. 先安装 Bun
这个包会通过 npm 分发,但运行时仍然依赖 Bun。
先安装 Bun:
powershell -c "irm bun.sh/install.ps1 | iex"或者查看官方安装文档:https://bun.sh/docs/installation
2. 通过 npm 安装 CLI
计划使用的包名:
npm install -g @yang0/iconfont-cli安装完成后运行:
iconfont --help能做什么
- 校验 cookie 登录态
- 搜索插画和贴纸类素材集
- 用
--free-only过滤 collection 搜索结果 - 查看素材集详情与素材列表
- 下载单个 SVG
- 批量下载整个素材集的 SVG
- 查看项目详情
- 查询项目 CDN 信息
- 下载项目 ZIP 包
快速开始
校验登录态
iconfont auth --cookie-file "G:\cookies\iconfont.txt" --format json搜索免费素材
iconfont search 电商 贴纸 彩色 --cookie-file "G:\cookies\iconfont.txt" --free-only查看素材集
iconfont collection inspect 33904 --cookie-file "G:\cookies\iconfont.txt"下载单个 SVG
iconfont collection download 33904 220319 --cookie-file "G:\cookies\iconfont.txt"批量下载素材集 SVG
iconfont collection download-all 33904 --cookie-file "G:\cookies\iconfont.txt"查看项目
iconfont project inspect 2935321 --cookie-file "G:\cookies\iconfont.txt"命令说明
auth
iconfont auth --cookie-file <path> [--ctoken <token>] [--format text|json]search
iconfont search <query> --cookie-file <path> [--scope collections|items] [--collection-type illustration|illustration_3d] [--page <n>] [--page-size <n>] [--sort <value>] [--free-only] [--ctoken <token>] [--format text|json]说明:
- 多个位置参数会自动拼成一个搜索词
--free-only目前只对 collection 搜索生效- collection 结果会在本地做多关键词聚合、去重和排序
collection inspect
iconfont collection inspect <collectionId> --cookie-file <path> [--type illustration|illustration_3d] [--ctoken <token>] [--format text|json]collection download
iconfont collection download <collectionId> <assetId> --cookie-file <path> [--type illustration|illustration_3d] [--out <svg>] [--force] [--ctoken <token>] [--format text|json]会使用素材的 origin_file 下载 SVG。
collection download-all
iconfont collection download-all <collectionId> --cookie-file <path> [--type illustration|illustration_3d] [--out-dir <dir>] [--force] [--ctoken <token>] [--format text|json]会下载素材集中所有带 origin_file 的 SVG。
project inspect
iconfont project inspect <projectId> --cookie-file <path> [--ctoken <token>] [--format text|json]project cdn
iconfont project cdn <projectId> --cookie-file <path> [--ctoken <token>] [--format text|json]project download
iconfont project download <projectId> --cookie-file <path> [--ctoken <token>] [--out <zip>] [--force] [--format text|json]Cookie 文件格式
认证依赖 Netscape cookie jar 格式文件。
典型流程:
- 在浏览器中登录
iconfont.cn - 导出 Netscape 格式 cookies
- 将文件路径传给
--cookie-file
运行说明
- npm 负责安装包并暴露
iconfont命令 - 命令启动器会再调用 Bun 执行 CLI
- 因此 Bun 必须已经在
PATH中可用 - 如果没有安装 Bun,启动器会给出安装提示并退出
开发
bun install
bun run check
bun run index.ts --help
node ./bin/iconfont.js --help发布
当前按以下方式准备:
npm publish --access public发布前请确认:
- 已执行
npm login - 目标包名可用
- 本机已安装 Bun
