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

@vergil/tools

v4.0.15

Published

> 🚀 一个强大的前端开发工具集,支持国际化文件生成和 API 接口代码生成

Downloads

6

Readme

@tarsiidae/tools

🚀 一个强大的前端开发工具集,支持国际化文件生成和 API 接口代码生成

npm version License

✨ 功能特性

  • 🌍 国际化文件生成: 从 Google Sheets 读取数据,生成多种格式的国际化文件
  • 🔌 API 接口生成: 从 Torna 文档和 Swagger 文档自动生成 TypeScript 接口文件和类型定义
  • 📦 多格式支持: 支持 XML、JSON、Strings、Dart 等多种国际化文件格式
  • 🎯 类型安全: 自动生成完整的 TypeScript 类型定义
  • 快速配置: 简单易用的配置文件,快速上手

📦 安装

# 使用 npm
npm install @tarsiidae/tools

# 使用 yarn
yarn add @tarsiidae/tools

# 使用 pnpm
pnpm add @tarsiidae/tools

🚀 快速开始

1. 国际化文件生成

创建配置文件

在项目根目录创建 i18n-tools.config.mjs 配置文件:

/** @type {import('@tarsiidae/tools').Config} */
export default {
  // Google Sheets 地址
  googleSheetsUrl: "https://docs.google.com/spreadsheets/d/your-sheet-id",
  
  // 语言配置
  langConfig: [
    {
      lang: "en",
      file: "en.xml",
    },
    {
      lang: "zh",
      file: "zh.json",
    },
    {
      lang: "ph",
      file: "ph.strings",
    },
    {
      lang: "vi",
      file: "vi.dart",
    },
  ],
  
  // 要使用的表格名称列表
  sheets: ['XX_Production'],
  
  // 存放国际化文件的路径
  localesPath: './src/i18n',
  
  // 自定义语言目录和文件生成规则
  // 示例: public/locales/en/common.json
  // 示例: src/i18n/en/index.json
  localeStructure: (localesPath, locale, file) =>
    `${localesPath}/${locale}/${file}`,
};

添加脚本命令

package.json 中添加脚本:

{
  "scripts": {
    "xlsx2i18n": "xlsx2i18n",
    "api": "api"
  }
}

运行命令

# 生成国际化文件
yarn run xlsx2i18n
# 或
npm run xlsx2i18n

2. API 接口生成

创建 API 配置文件

在项目根目录创建 api.config.mjs 配置文件:

export default {
  // 输出目录
  dist: './src/api',
  
  // 生成的文件名
  dtsFileName: 'api.d.ts',
  apiFileName: 'index.ts',
  
  // 忽略的 API 接口
  ignoreApi: ['/api/ping'],
  
  // 需要注入 token 的接口
  injectTokenUrls: ['/api/user/info'],
  
  // token 字段名
  tokenName: 'Authorization',
  
  // 是否启用 Torna 文档
  enableTorna: true,
  
  // 自定义导入前缀
  prefixStr: "import { request, requestList } from '@/utils/request'"
};

运行命令

# 生成 API 接口文件
yarn api

📁 生成的文件结构

src/
├── i18n/                    # 国际化文件
│   ├── en/
│   │   └── en.xml
│   ├── zh/
│   │   └── zh.json
│   ├── ph/
│   │   └── ph.strings
│   └── vi/
│       └── vi.dart
└── api/                     # API 接口文件
    ├── index.ts            # API 方法
    └── api.d.ts            # 类型定义

🔧 配置选项

国际化配置

| 选项 | 类型 | 描述 | |------|------|------| | googleSheetsUrl | string | Google Sheets 文档地址 | | langConfig | Array | 语言配置数组 | | sheets | Array | 要处理的表格名称列表 | | localesPath | string | 国际化文件输出路径 | | localeStructure | function | 自定义文件路径生成函数 |

API 配置

| 选项 | 类型 | 默认值 | 描述 | |------|------|--------|------| | dist | string | './src/api' | 输出目录 | | dtsFileName | string | 'api.d.ts' | 类型定义文件名 | | apiFileName | string | 'index.ts' | API 文件名 | | ignoreApi | Array | [] | 忽略的 API 接口 | | injectTokenUrls | Array | [] | 需要注入 token 的接口 | | tokenName | string | '' | token 字段名 | | enableTorna | boolean | true | 是否启用 Torna 文档 |

📄 许可证

MIT License