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

@laofan666/prd-generator

v2.1.0

Published

PRD文档生成工具 - 支持自动截图并生成Word格式需求文档

Readme

@laofan666/prd-generator

PRD文档生成工具 - 支持自动截图并生成Word格式需求文档。

功能特性

  • 📸 自动截图 - 使用Puppeteer自动登录系统并截取页面
  • 📝 Word生成 - 生成标准格式的PRD需求文档(.docx)
  • 🎨 专业排版 - 遵循标准PRD文档格式(封面、修订记录、需求说明、验收标准)
  • ⚙️ 配置驱动 - 通过JSON配置文件定义截图步骤和文档内容
  • 🖼️ 图片嵌入 - 自动将截图嵌入Word文档指定位置

安装

全局安装(推荐)

npm install -g @laofan666/prd-generator

项目本地安装

npm install --save-dev @laofan666/prd-generator

快速开始

1. 初始化配置文件

prd-gen init -n v2.1.0-my-feature

2. 编辑配置文件

编辑生成的 prd-configs/v2.1.0-my-feature.json

{
  "name": "新增XX需求",
  "version": "v2.1.0",
  "system": "XX系统",
  "author": "老范",
  "baseConfig": {
    "baseUrl": "http://localhost:3000",
    "viewport": { "width": 1440, "height": 900 },
    "username": "admin",
    "password": "admin123"
  },
  "screenshotConfig": {
    "screenshotDir": "prototype",
    "steps": [
      {
        "id": 1,
        "name": "首次进入页面",
        "filename": "screenshot-1.png",
        "actions": [
          { "type": "navigate", "target": "idcard-verify", "waitFor": "#queryIdCard" },
          { "type": "delay", "ms": 1000 }
        ]
      }
    ]
  }
}

3. 生成PRD文档

# 完整流程:截图 + 生成文档
prd-gen generate -c v2.1.0-my-feature

# 或简写
prd-gen gen -c v2.1.0-my-feature

命令说明

generate / gen - 生成PRD文档

prd-gen generate [选项]

选项:

  • -c, --config <name> - 配置文件名(默认:v1.1.0-idcard-verify)
  • -o, --output <dir> - 输出目录(默认:./prd)
  • -s, --screenshot-dir <dir> - 截图保存目录(默认:./prototype)
  • --config-dir <dir> - 配置文件目录(默认:./prd-configs)
  • --no-screenshot - 跳过截图步骤
  • --use-existing - 截图失败时使用已有截图

screenshot / shot - 仅执行截图

prd-gen screenshot -c v2.1.0-my-feature

list - 列出可用配置

prd-gen list

init - 初始化示例配置

prd-gen init -n v2.1.0-my-feature

配置文件说明

基础配置

| 字段 | 类型 | 说明 | |------|------|------| | name | string | 功能名称 | | version | string | 版本号 | | system | string | 系统名称 | | author | string | 编写人 | | background | string | 需求背景 | | goals | array | 需求目标列表 |

baseConfig

| 字段 | 类型 | 说明 | |------|------|------| | baseUrl | string | 系统基础URL | | viewport | object | 浏览器视口大小 | | username | string | 登录用户名 | | password | string | 登录密码 |

screenshotConfig.steps

截图步骤配置,每个步骤包含:

| 字段 | 类型 | 说明 | |------|------|------| | id | number | 步骤ID | | name | string | 步骤名称 | | filename | string | 截图文件名 | | actions | array | 执行的操作列表 |

Action类型

| 类型 | 参数 | 说明 | |------|------|------| | navigate | target, waitFor | 导航到页面 | | click | selector, delayAfter | 点击元素 | | input | selector, value | 输入内容 | | delay | ms | 等待毫秒 | | toast | message | 显示提示 |

文档输出

生成的Word文档包含:

  1. 封面页 - 文档标题、归属部门、编写人、日期
  2. 修订记录 - 版本变更历史
  3. 文档简介 - 需求背景、目标、范围
  4. 需求说明 - 功能描述 + 页面原型截图
  5. 验收标准 - 功能验收、数据验收、性能验收

文档格式:

  • 字体:微软雅黑
  • 标题:二号(22pt)
  • 正文:五号(10.5pt)
  • 截图:16厘米宽,保持比例

依赖要求

  • Node.js >= 14.0.0
  • Puppeteer(会自动安装Chromium)

许可证

MIT

作者

laofan666