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

excel2mock

v1.0.2

Published

从 Excel 接口文档生成 mock 数据提示词的 CLI 工具。

Readme

Excel2Mock

从 Excel 接口文档生成 mock 数据提示词的 CLI 工具。

安装

# 全局安装
npm install -g excel2mock

使用方法

excel2mock [excel文件路径] [输出文件路径] [选项]

如果不指定 Excel 文件路径,将自动读取当前目录下的第一个 .xlsx 文件。

选项

| 选项 | 说明 | 默认值 | | ---------------- | -------------- | ---------- | | --sheet <name> | 指定工作表名称 | 交易接口 | | --verbose | 打印解析日志 | - | | -V, --version | 查看版本号 | - | | -h, --help | 查看帮助 | - |

示例

# 自动读取当前目录下的第一个 xlsx 文件
excel2mock

# 指定 Excel 文件
excel2mock worksheet.xlsx

# 指定输出路径
excel2mock worksheet.xlsx output.txt

# 指定工作表
excel2mock worksheet.xlsx --sheet 交易接口

# 打印解析日志
excel2mock worksheet.xlsx --verbose

Excel 格式要求

工具期望 Excel 文件具有以下结构:

服务定义块

每个服务定义包含以下部分:

| 行内容 | 说明 | | -------------- | -------------------------------------------- | | 服务中文名 | 服务头标识,第3列为服务英文名称 | | 服务ID | 服务唯一标识,行中搜索"服务ID"关键字取后一列 | | 响应报文 | 标记响应数据区域开始 | | 栏位项目名称 | 字段表头行 |

字段定义

| 列索引 | 字段 | | ------ | --------------------------- | | 0 | 栏位项目名称(字段英文名) | | 1 | 中文名称 | | 6 | XML属性补充说明(类型信息) | | 9 | 数据项说明 |

嵌套层级

| 前缀 | 含义 | | ------ | ----------------------------------- | | 无前缀 | 顶层字段 | | LIST | 数组类型 | | .. | 一层嵌套(LIST 内的字段) | | .... | 两层嵌套(LIST 内嵌套 LIST 的字段) |

输出格式

生成的提示词文件结构如下:

  1. 服务总览 - JSON 文件总数
  2. 公共规则 - 生成要求、类型规则、字段命名规则(只出现一次)
  3. 示例参考 - mock 数据格式示例
  4. 各服务定义 - 每个服务包含服务ID、输出文件名和 JSON 结构

项目结构

excel2mock/
├── cli.js                    # CLI 主入口
├── package.json              # 项目配置
├── src/
│   ├── constants.js          # 常量配置
│   ├── logger.js             # 日志模块
│   ├── parser.js             # Excel 解析模块
│   ├── structure.js          # 字段结构构建模块
│   └── generator.js          # 提示词生成模块
└── README.md

代码架构

| 模块 | 文件 | 职责 | | ----------------------- | ------------ | ---------------------------------- | | CONSTANTS | constants.js | 常量配置(标记、列索引、输出配置) | | Logger | logger.js | 日志输出,支持 verbose 模式 | | ServiceParser | parser.js | Excel 解析,提取服务和字段信息 | | FieldStructureBuilder | structure.js | 构建字段树结构 | | PromptGenerator | generator.js | 生成提示词文本 |