@buildpad/cli

中文文档
3.7.0发布于 2026/11/06MITTypeScriptES Module近 30 天下载 1901

CLI tool for adding Buildpad components to your project - like shadcn/ui

原始使用文档
文档目录39 节
  1. Usage
  2. init
  3. Options
  4. add
  5. Options
  6. Examples
  7. list
  8. Options
  9. bootstrap
  10. Options
  11. What Bootstrap Does
  12. validate
  13. Options
  14. What It Checks
  15. Example Output
  16. diff
  17. Options
  18. status
  19. Options
  20. Example Output
  21. buildpad.json
  22. tsx
  23. srcDir
  24. aliases
  25. installedLib and installedComponents
  26. What Gets Copied
  27. Example: Adding list-m2m
  28. Import Transformation
  29. Component Categories
  30. VForm and CollectionForm
  31. Peer Dependencies
  32. Project Structure After Installation
  33. CLI Commands Reference
  34. Troubleshooting
  35. "Registry file not found"
  36. "buildpad.json not found"
  37. Import errors after adding components
  38. Development
  39. License

@buildpad/cli

A CLI for adding Buildpad components to your project.

npm version

Usage

Use the init command to set up a new project and the add command to add components.

npx @buildpad/cli init
npx @buildpad/cli add input select-dropdown

init

Use the init command to initialize configuration and dependencies for a new project.

The init command creates a buildpad.json file, sets up directory structure, and checks for required dependencies.

npx @buildpad/cli init

Options

Usage: buildpad init [options]

initialize your project and install dependencies

Options:
  -y, --yes       skip confirmation prompt (default: false)
  -c, --cwd <cwd> the working directory (defaults to current directory)
  -h, --help      display help for command

add

Use the add command to add components to your project.

npx @buildpad/cli add [component]

Options

Usage: buildpad add [options] [components...]

add components to your project

Arguments:
  components         name of components to add

Options:
  -a, --all          add all available components (default: false)
  --with-api         also add API routes and Supabase auth templates
  --category <name>  add all components from a category
  -o, --overwrite    overwrite existing files (default: false)
  -n, --dry-run      preview changes without modifying files
  --cwd <cwd>        the working directory (defaults to current directory)
  -h, --help         display help for command

Examples

# Add specific components
npx @buildpad/cli add input
npx @buildpad/cli add input select-dropdown datetime

# Add collection-form (includes VForm + all 32 interface components)
npx @buildpad/cli add collection-form

# Add all components from a category
npx @buildpad/cli add --category selection

# Add all components
npx @buildpad/cli add --all

list

Use the list command to view all available components.

npx @buildpad/cli list

Options

Usage: buildpad list [options]

list available components

Options:
  --category <name>  filter by category
  --json             output as JSON
  -h, --help         display help for command

bootstrap

Use the bootstrap command for full project setup in a single non-interactive command. Recommended for AI agents and CI/CD pipelines.

npx @buildpad/cli bootstrap

Options

Usage: buildpad bootstrap [options]

Full project setup: init + add --all + install deps + validate (single command for AI agents)

Options:
  --cwd <cwd>          the working directory (defaults to current directory)
  --skip-deps          skip npm dependency installation
  --skip-validate      skip post-install validation
  --locales <codes>    locales for app/[lang], comma-separated (e.g. en,id); default: en
  --default-locale <code>  default locale (must be in --locales); default: the first one
  -h, --help           display help for command

What Bootstrap Does

  1. Creates buildpad.json and project skeleton (package.json, tsconfig, the app/[lang] root layout and home page, design tokens, locale routing in lib/i18n/)
  2. Copies all 40+ UI components to components/ui/
  3. Copies types, services, hooks to lib/buildpad/
  4. Copies API proxy routes (fields, items, relations, files)
  5. Copies auth proxy routes (login, logout, user, callback) + login page
  6. Copies Supabase auth utilities and middleware
  7. Runs pnpm install to resolve all dependencies
  8. Validates the installation

Auth Routes Installed:

RouteMethodPurpose
/api/auth/loginPOSTLogin via Supabase Auth (server-side, no CORS)
/api/auth/logoutPOSTSign out and clear session cookies
/api/auth/userGETGet current user profile
/api/auth/callbackGETHandle OAuth/email-confirm redirects
/app/[lang]/login/page.tsx—Login page using proxy pattern (locale-prefixed)

validate

Use the validate command to check your Buildpad installation for common issues.

npx @buildpad/cli validate

Options

Usage: buildpad validate [options]

validate Buildpad installation (check imports, missing files, SSR issues)

Options:
  --json           output as JSON for CI/CD
  --cwd <cwd>      the working directory (defaults to current directory)
  -h, --help       display help for command

What It Checks

  • Untransformed imports - @buildpad/* imports that weren't converted to local paths
  • Missing lib files - Required utility modules not present (types, services, hooks, utils)
  • Missing CSS files - CSS required by rich text editors (RichTextHTML.css, InputBlockEditor.css)
  • SSR issues - Components like InputBlockEditor exported without SSR-safe wrappers
  • Missing API routes - DaaS integration routes for fields, items, permissions

Example Output

✗ Found 2 error(s):

  ✗ src/components/ui/input.tsx:5
    Untransformed import: import { Field } from '@buildpad/types';

  ✗ lib/buildpad/interface-registry.ts
    Missing required file for utils module

⚠ Found 1 warning(s):

  ⚠ components/ui/index.ts
    InputBlockEditor exported directly may cause SSR errors. Use input-block-editor-wrapper instead.

💡 Suggestions:

  1. Fix 2 untransformed import(s) by running: pnpm cli add --all --overwrite --cwd .
  2. Update components/ui/index.ts to export InputBlockEditor from './input-block-editor-wrapper'

diff

Use the diff command to preview changes before adding a component.

npx @buildpad/cli diff [component]

Options

Usage: buildpad diff [options] <component>

preview changes before adding a component

Options:
  --cwd <cwd>      the working directory (defaults to current directory)
  -h, --help       display help for command

status

Use the status command to view all installed Buildpad components and their origins.

npx @buildpad/cli status

Options

Usage: buildpad status [options]

show installed Buildpad components and their origins

Options:
  --json           output as JSON
  --cwd <cwd>      the working directory (defaults to current directory)
  -h, --help       display help for command

Example Output

📦 Buildpad Status

Config file: buildpad.json
Lib modules: types, hooks, services
Components:  input, select-dropdown, list-m2m

Installed Files:

  @buildpad/ui-interfaces/input
    └─ src/components/ui/input.tsx
       v1.0.0 (2026-01-12)

  @buildpad/lib/hooks
    └─ src/lib/buildpad/hooks/useRelationM2M.ts
       v1.0.0 (2026-01-12)

Total: 15 files from Buildpad

buildpad.json

The buildpad.json file holds configuration for your project. We use it to understand how your project is set up and how to generate components customized for your project.

You can create a buildpad.json file by running the init command.

{
  "$schema": "https://buildpad.dev/schema.json",
  "model": "copy-own",
  "tsx": true,
  "srcDir": true,
  "aliases": {
    "components": "@/components/ui",
    "lib": "@/lib/buildpad"
  },
  "installedLib": [],
  "installedComponents": []
}

tsx

Choose between TypeScript or JavaScript components.

Setting this option to false allows components to be added as JavaScript with the .jsx file extension.

{
  "tsx": true | false
}

srcDir

Whether your project uses the src/ directory structure.

{
  "srcDir": true | false
}

aliases

The CLI uses these values to place generated components in the correct location.

{
  "aliases": {
    "components": "@/components/ui",
    "lib": "@/lib/buildpad"
  }
}

Path aliases have to be set up in your tsconfig.json or jsconfig.json file:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

installedLib and installedComponents

These arrays track what has been installed. The CLI uses them to avoid reinstalling dependencies.

What Gets Copied

When you add a component, the CLI:

  1. Copies the component source to your components directory
  2. Copies required lib modules (types, services, hooks) if needed
  3. Transforms imports from @buildpad/* to local paths
  4. Reports missing dependencies that need to be installed

Example: Adding list-m2m

npx @buildpad/cli add list-m2m

This copies:

  • components/ui/list-m2m.tsx - The component
  • lib/buildpad/types/ - Type definitions
  • lib/buildpad/services/ - CRUD services
  • lib/buildpad/hooks/ - React hooks

Import Transformation

Original (in source):

import { useRelationM2M } from '@buildpad/hooks';
import type { M2MItem } from '@buildpad/types';

Transformed (in your project):

import { useRelationM2M } from '@/lib/buildpad/hooks';
import type { M2MItem } from '@/lib/buildpad/types';

Component Categories

CategoryComponents
inputInput, Textarea, InputCode, InputBlockEditor, Tags
selectionSelectDropdown, SelectRadio, SelectMultipleCheckbox, SelectIcon, AutocompleteAPI, CollectionItemDropdown
datetimeDateTime
booleanBoolean, Toggle
mediaFileInterface, FileImage, Files, Upload, Color
relationalListM2M, ListM2O, ListO2M, ListM2A
layoutDivider, Notice, GroupDetail, Slider
rich-textRichTextHtml, RichTextMarkdown
collectionVForm, CollectionForm, CollectionList

VForm and CollectionForm

When you add collection-form, it automatically includes:

  • VForm - Dynamic form component that renders any field type
  • 32 interface components - All field types (input, select, datetime, M2M, M2O, etc.)
  • Lib modules - types, services, hooks, and field-interface-mapper utilities

This is because collection-form has registryDependencies: ["vform"] and VForm has dependencies on all interface components.

Peer Dependencies

Components require these external packages:

Core (always needed):

pnpm add @mantine/core @mantine/hooks react react-dom

Component-specific:

# DateTime component
pnpm add @mantine/dates dayjs

# Icon components
pnpm add @tabler/icons-react

# File upload
pnpm add @mantine/dropzone

# CollectionForm notifications
pnpm add @mantine/notifications

# Rich text editor
pnpm add @tiptap/react @tiptap/starter-kit @tiptap/extension-link

Utils (optional, for cn() helper):

pnpm add clsx tailwind-merge

Project Structure After Installation

your-project/
├── app/
│   ├── api/
│   │   ├── auth/                        # Auth proxy routes
│   │   │   ├── login/route.ts           # POST - Supabase login
│   │   │   ├── logout/route.ts          # POST - Sign out
│   │   │   ├── user/route.ts            # GET - Current user info
│   │   │   └── callback/route.ts        # GET - OAuth callback
│   │   ├── fields/[collection]/route.ts # Fields proxy
│   │   ├── items/[collection]/route.ts  # Items proxy
│   │   └── ...
│   └── login/page.tsx                   # Login page template
├── src/
│   ├── components/
│   │   └── ui/
│   │       ├── input.tsx
│   │       ├── select-dropdown.tsx
│   │       └── datetime.tsx
│   └── lib/
│       ├── buildpad/
│       │   ├── utils.ts
│       │   ├── types/
│       │   │   ├── index.ts
│       │   │   ├── core.ts
│       │   │   ├── file.ts
│       │   │   └── relations.ts
│       │   ├── services/
│       │   │   ├── index.ts
│       │   │   ├── api-request.ts
│       │   │   ├── items.ts
│       │   │   ├── fields.ts
│       │   │   └── collections.ts
│       │   └── hooks/
│       │       ├── index.ts
│       │       ├── useRelationM2M.ts
│       │       ├── useRelationM2O.ts
│       │       └── ...
│       ├── api/auth-headers.ts          # Auth header utilities
│       └── supabase/                    # Supabase client utilities
│           ├── server.ts
│           └── client.ts
├── middleware.ts                         # Auth middleware
├── buildpad.json
└── package.json

CLI Commands Reference

# Initialize project
buildpad init [--yes] [--cwd <path>] [--locales en,id] [--default-locale en]

# Bootstrap full project (init + add all + deps + validate)
buildpad bootstrap [--cwd <path>] [--skip-deps] [--skip-validate] [--locales en,id] [--default-locale en]

# Move an app scaffolded before 2.3 onto locale-prefixed app/[lang] routing
buildpad migrate i18n [--cwd <path>] [--locales en,id] [--dry-run]

# Add components
buildpad add [components...] [--all] [--category <name>] [--overwrite] [--cwd <path>]

# List components
buildpad list [--category <name>] [--json]

# Preview changes
buildpad diff <component> [--cwd <path>]

# Validate installation
buildpad validate [--json] [--cwd <path>]

# Check installed components
buildpad status [--json] [--cwd <path>]

# Component info and dependency tree
buildpad info <component> [--json]
buildpad tree <component> [--json] [--depth <n>]

# Auto-fix common issues
buildpad fix [--dry-run] [--yes] [--cwd <path>]

# Check for component updates
buildpad outdated [--json] [--cwd <path>]

Troubleshooting

"Registry file not found"

Make sure you're running the CLI from within the Buildpad workspace or have the registry properly configured.

"buildpad.json not found"

Run npx @buildpad/cli init first to initialize your project.

Import errors after adding components

Ensure your tsconfig.json has the correct path aliases:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

Development

Build the CLI:

cd packages/cli
pnpm build

Run in development:

pnpm dev

Test locally:

node dist/index.js init
node dist/index.js add input

License

MIT

版本与发布记录

@buildpad/cli 共发布 52 个版本,首次发布于 2026/02/27;过去 12 个月发布了 52 个版本。

版本发布日期距今
3.7.0latest2026/11/063 天前
3.6.02026/11/036 天前
3.5.22026/11/036 天前
3.5.12026/11/027 天前
3.5.02026/10/2911 天前
3.4.12026/10/2317 天前

关于 @buildpad/cli 的常见问题

@buildpad/cli 是什么?

CLI tool for adding Buildpad components to your project - like shadcn/ui

如何安装 @buildpad/cli?

在项目目录运行 npm install @buildpad/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 buildpad,可以用 npx buildpad 直接运行。

@buildpad/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@buildpad/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@buildpad/cli 可以商用吗?

@buildpad/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@buildpad/cli 的下载量有多少?

根据 npm 官方下载统计,@buildpad/cli 在 2026/10/09 – 2026/11/07 这 30 天内被下载 1,901 次,日均约 63 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@buildpad/cli 还在维护吗?

最新版本 3.7.0 发布于 2026/11/06(3 天前);至今共发布 52 个版本,其中过去 12 个月发布了 52 个;首次发布于 2026/02/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。