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

@amaster.ai/components-templates

v1.13.0

Published

Amaster component templates collection

Downloads

1,688

Readme

@amaster.ai/components-templates

Amaster 组件模板集合,提供 CLI 工具快速初始化和更新组件。

项目目录

amaster-components-template/
├── bin/amaster.js                    # CLI 入口
├── components/                       # 组件模板目录
│   └── ai-assistant/                 # ai-assistant 组件
│       ├── package.json              # 组件配置(依赖、目标目录等)
│       └── template/                 # 模板文件
│           ├── ai-assistant.tsx
│           ├── index.ts
│           ├── types.ts
│           ├── components/           # 子组件
│           ├── hooks/                # Hooks
│           └── mock/                 # Mock 数据
├── packages/cli/                     # CLI 工具
│   ├── src/index.ts                  # CLI 源码
│   ├── dist/                         # 编译输出
│   └── package.json
├── scripts/
│   ├── publish.js                    # 一键发布脚本
│   └── create-component.js           # 创建新组件模板向导
├── index.js                          # 主入口
├── package.json                      # 包配置
└── README.md

安装

npm install -g @amaster.ai/components-templates

或使用 npx(推荐):

npx @amaster.ai/components-templates <command>

使用

列出所有可用组件

npx @amaster.ai/components-templates list
# 或
npx @amaster.ai/components-templates ls

初始化组件

# 交互式选择组件
npx @amaster.ai/components-templates init

# 安装整个组件
npx @amaster.ai/components-templates init ai-assistant

# 指定目标目录
npx @amaster.ai/components-templates init ai-assistant -d ./src/components/ai-assistant

# 自动依赖安装
npx @amaster.ai/components-templates init ai-assistant --skip-install=false

# 只安装组件中的特定文件夹
npx @amaster.ai/components-templates init ai-assistant/hooks -d ./src/components/ai-assistant/hooks

# 只安装组件中的单个文件
npx @amaster.ai/components-templates init ai-assistant/hooks/useSpeak.ts -d ./src/components/ai-assistant/hooks/useSpeak.ts

查看组件信息

npx @amaster.ai/components-templates info ai-assistant

特性

1. 依赖自动合并

初始化组件时,CLI 会自动:

  • 读取组件模板的 package.json
  • 合并依赖到目标项目的 package.json
  • 自动检测包管理器(pnpm/yarn/npm)并安装依赖

2. 灵活的路径支持

支持多种初始化方式:

  • 整个组件: init ai-assistant
  • 子文件夹: init ai-assistant/hooks
  • 单个文件: init ai-assistant/hooks/useSpeak.ts

3. 智能包管理器检测

自动检测目标项目使用的包管理器:

  • pnpm-lock.yaml → pnpm
  • yarn.lock → yarn
  • package-lock.json → npm

开发

本地调试

# 列出所有组件
node bin/amaster.js list

# 安装组件到目标项目
node bin/amaster.js init ai-assistant -d ../materials/helloword-react/src/components/ai-assistant --clear

# 直接安装依赖
node bin/amaster.js init ai-assistant -d ../test/src/components/ai-assistant --skip-install=false

# 只复制 hooks 文件夹
node bin/amaster.js init ai-assistant/hooks -d ../test/src/components/ai-assistant/hooks

# 只复制单个文件
node bin/amaster.js init ai-assistant/hooks/useSpeak.ts -d ../test/src/components/ai-assistant/hooks/useSpeak.ts

脚本添加新组件模板

# 按提示输入组件名、描述、目标目录
npm run create:component

手动添加新组件模板

  1. components/ 目录下创建新组件目录
  2. 添加 package.json 配置文件
  3. 添加 amaster.config.json 配置文件(配置目标目录)
  4. template/ 目录下放置模板文件
components/
  └── your-component/
      ├── package.json          # 组件依赖配置
      ├── amaster.config.json   # 组件模板配置
      └── template/             # 模板文件
          ├── index.ts
          └── ...

组件 package.json 配置

{
  "name": "your-component",
  "version": "1.0.0",
  "description": "组件描述",
  "dependencies": {
    "some-lib": "^1.0.0"
  },
  "peerDependencies": {
    "react": ">=18.0.0"
  },
  "devDependencies": {
    "@types/react": "^18.0.0"
  }
}

组件 amaster.config.json 配置

{
  "targetDir": "src/components/your-component"
}

发布

# 一键发布(自动构建、更新版本、同步组件版本)
npm run publish:all     # patch
npm run publish:minor   # minor
npm run publish:major   # major

License

MIT