datocms-plugin-scaffold
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDatoCMS Plugin Scaffold
DatoCMS 插件脚手架
Create the smallest working first version of a new plugin project. Keep the
initial scaffold narrow, then hand later incremental edits to
.
datocms-plugin-builder创建新插件项目的最小可用初始版本。保持初始脚手架的范围精简,后续的增量编辑交由 处理。
datocms-plugin-builderStep 1: Confirm scaffold mode
步骤1:确认脚手架模式
Silently inspect the current directory.
- Check for an existing plugin project (with
package.json, adatocms-plugin-sdkentrypoint, and Vite config).connect() - If a plugin already exists and the request is an edit, switch to
.
datocms-plugin-builder - Infer the likely starting surface from the request before asking questions.
静默检查当前目录。
- 检查是否存在现有插件项目(包含 的
datocms-plugin-sdk、package.json入口文件以及 Vite 配置)。connect() - 若已存在插件且请求为编辑操作,则切换至 。
datocms-plugin-builder - 在提问前,从请求中推断可能的初始界面类型。
Step 2: Ask only for missing essentials
步骤2:仅询问缺失的必要信息
Ask only when the request or repo does not already answer them:
- plugin name or folder name
- private vs marketplace distribution
- initial surface and target model or field scope when that changes the scaffold
- whether the plugin needs or other external API access
currentUserAccessToken
Skip the question round if those points are already clear enough to scaffold
safely.
仅当请求或仓库未明确以下信息时才提问:
- 插件名称或文件夹名称
- 私有分发还是市场分发
- 初始界面以及目标模型或字段范围(若会影响脚手架结构)
- 插件是否需要 或其他外部 API 访问权限
currentUserAccessToken
若上述信息已足够明确可安全搭建脚手架,则跳过提问环节。
Step 3: Load the small reference set
步骤3:加载小型参考集
Always load:
references/project-scaffold.mdreferences/surface-starters.md
Stay with these files for the first implementation. Route later feature
expansion or maintenance work to .
datocms-plugin-builder始终加载以下文件:
references/project-scaffold.mdreferences/surface-starters.md
首次实现仅依赖这些文件。后续的功能扩展或维护工作交由 处理。
datocms-plugin-builderStep 4: Scaffold the project
步骤4:搭建项目
- Create the plugin directory inside the current working directory.
- Use the standard Vite/React layout from .
references/project-scaffold.md - Add only the entrypoints the requested surfaces need.
- Keep package metadata minimal for private plugins.
- For marketplace plugins, set the npm package name, keywords, homepage, and permissions correctly.
- Add only the optional dependencies required by the first implementation.
- Install dependencies before verification.
- 在当前工作目录内创建插件目录。
- 使用 中的标准 Vite/React 布局。
references/project-scaffold.md - 仅添加所需界面对应的入口文件。
- 私有插件的包元数据保持极简。
- 针对市场插件,正确设置 npm 包名称、关键词、主页和权限。
- 仅添加首次实现所需的可选依赖。
- 在验证前安装依赖。
Step 5: Wire the first surface
步骤5:对接第一个界面
Use to choose the declaration, render, and
execute hooks.
references/surface-starters.mdKeep these starter guardrails:
- Keep exactly one top-level call.
connect() - Wrap rendered UI in ; use
<Canvas ctx={ctx}>for pages, inspectors, and full-width sidebars.noAutoResizer - Use for ID-dispatched render hooks.
switch - Use for SDK types.
import type { ... } - Keep parameters and
ctx.openModal()values JSON-serializable.ctx.resolve() - Do not create editor field extensions for modular content, single block, or structured text fields.
- Stop at the smallest working first version. Do not pre-build extra surfaces or settings the user did not ask for.
使用 选择声明、渲染和执行钩子。
references/surface-starters.md遵循以下初始约束:
- 仅保留一个顶层 调用。
connect() - 将渲染的 UI 包裹在 中;页面、检查器和全宽侧边栏需使用
<Canvas ctx={ctx}>。noAutoResizer - 使用 语句处理基于 ID 分发的渲染钩子。
switch - 使用 导入 SDK 类型。
import type { ... } - 确保 参数和
ctx.openModal()的值可序列化为 JSON。ctx.resolve() - 不要为模块化内容、单个区块或结构化文本字段创建编辑器字段扩展。
- 止步于最小可用初始版本,不要预构建用户未要求的额外界面或设置。
Step 6: Verify
步骤6:验证
- Install dependencies with the selected package manager.
- Run the build script with that same package manager.
- Tell the user which dev command to run with that package manager.
- Tell the user how to install the local plugin in DatoCMS and name the single manual surface check that matters most.
- 使用选定的包管理器安装依赖。
- 使用同一包管理器运行构建脚本。
- 告知用户使用该包管理器运行的开发命令。
- 告知用户如何在 DatoCMS 中安装本地插件,并说明最重要的单个手动界面检查项。
Cross-skill routing
跨技能路由
- Existing plugin maintenance ->
datocms-plugin-builder - Native DatoCMS plugin UI design, layout restyling, or design-system alignment ->
datocms-plugin-design-system - Standalone CMA scripts or schema work outside the plugin iframe ->
datocms-cma
- 现有插件维护 ->
datocms-plugin-builder - 原生 DatoCMS 插件 UI 设计、布局重定义或设计系统对齐 ->
datocms-plugin-design-system - 插件 iframe 外的独立 CMA 脚本或架构工作 ->
datocms-cma