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

create-sv-print-plugin

v0.1.0

Published

CLI tool to create sv-print plugin projects

Readme

create-sv-print-plugin

sv-print 插件项目脚手架 CLI 工具。

快速开始

npx create-sv-print-plugin init

按提示依次输入:

  1. 插件名称 — 仅支持字母、数字、下划线和连字符(如 my-chart
  2. 选择 Hook 函数 — 多选需要的 hook,生成对应的文件

使用自定义模板

npx create-sv-print-plugin init --template <git 仓库地址>

支持任意 Git 仓库作为模板源,仓库中 src/hooks/ 目录下的 .template 文件会自动识别为可选 Hook。

# 示例
npx create-sv-print-plugin init --template https://github.com/user/my-plugin-template.git

可用 Hook

| Hook | 说明 | |------|------| | init | 新增/重新属性,新增 provider | | ready | document on ready | | documentShortcutKeys | document 注册快捷键 | | shortcutKeys | 面板注册快捷键 | | createPrintElement | 创建打印元素 | | beforePrint | 打印前执行 | | beforePrint2 | 静默打印前执行 | | getOptionItem | 参数选项 | | onDesigned | 设计器挂载后执行 | | onPreview | 预览点击执行 | | newPrintTemplate | 新建打印模板时执行 | | newPanel | 新建面板时执行 |

生成的项目结构

my-plugin/
├── package.json
├── tsconfig.json
├── vite.config.ts
└── src/
    ├── index.ts          # 插件入口
    ├── types.ts          # 类型定义
    └── hooks/
        ├── index.ts      # hook 导出
        ├── init.ts       # 选择的 hook 文件
        └── ...

生成后操作

cd my-plugin
pnpm install
pnpm build

发布插件

# 正式发布
pnpm pub

# Beta 发布
pnpm pub-beta

自定义模板规范

创建自定义模板仓库时,遵循以下结构:

模板仓库/
├── package.json.template
├── tsconfig.json.template
├── vite.config.ts.template
└── src/
    ├── index.ts.template
    ├── types.ts.template
    └── hooks/
        ├── index.ts.template
        ├── init.ts.template
        └── ...

模板使用 Mustache 语法,可用变量:

| 变量 | 说明 | |------|------| | pluginName | 用户输入的插件名称 | | globalName | camelCase 格式的名称 | | umdName | UMD 全局变量名 | | browserifyPrefix | browserify 文件名前缀 | | pluginNameParts | 插件名称按 - 分词后的数组,如 ["ele", "aaa"] | | pluginNamePrefix | 分词后的第一个部分,如 ele | | pluginNameTail | 分词后剩余部分用 - 拼接,如 aaaimage-export | | selectedHooks | 已选 hook 列表 [{hookName, hookCamelName, hookDescription}] | | hasHooks | 是否有选中的 hook | | hookImports | 预计算的 import 语句 | | hookCalls | 预计算的 hook 调用 | | hookExports | 预计算的 export 列表 |

本地开发

# 安装依赖
pnpm install

# 构建
pnpm build

# 方式一:pnpm link 到全局,之后直接用命令名调试
pnpm link --global
create-sv-print-plugin init

# 方式二:npx 直接指向本地包
npx /path/to/cli init

# 开发模式(监听文件变化自动构建)
pnpm dev

取消全局链接:

pnpm unlink --global

License

MIT