run-nx-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRun Nx Generator
运行Nx生成器
This skill helps you execute Nx generators efficiently, with special focus on workspace-plugin generators from your internal tooling.
本技能可帮助你高效执行Nx生成器,重点关注来自内部工具的工作区插件生成器。
Generator Priority List
生成器优先级列表
Use the tool to get more information about how to use the generator
mcp__nx-mcp__nx_generator_schemaChoose which generators to run in this priority order:
使用工具获取有关如何使用生成器的更多信息
mcp__nx-mcp__nx_generator_schema请按照以下优先级选择要运行的生成器:
🔥 Workspace-Plugin Generators (High Priority)
🔥 工作区插件生成器(高优先级)
These are your custom internal tools in
tools/workspace-plugin/这些是位于中的自定义内部工具
tools/workspace-plugin/📦 Core Nx Generators (Standard)
📦 核心Nx生成器(标准优先级)
Only use these if workspace-plugin generators don't fit:
- - DevKit utilities
nx generate @nx/devkit:... - - Node.js libraries
nx generate @nx/node:... - - React components and apps
nx generate @nx/react:... - Framework-specific generators
仅当工作区插件生成器不适用时才使用这些:
- - DevKit工具集
nx generate @nx/devkit:... - - Node.js库
nx generate @nx/node:... - - React组件与应用
nx generate @nx/react:... - 框架专属生成器
How to Run Generators
如何运行生成器
-
List available generators:
-
Get generator schema (to see available options): Use thetool to get more information about how to use the generator
mcp__nx-mcp__nx_generator_schema -
Run the generator:bash
nx generate [generator-path] [options] -
Verify the changes:
- Review generated files
- Run tests:
nx affected -t test - Format code:
npx prettier --write [files]
-
列出可用生成器:
-
获取生成器 schema(查看可用选项): 使用工具获取有关如何使用生成器的更多信息
mcp__nx-mcp__nx_generator_schema -
运行生成器:bash
nx generate [generator-path] [options] -
验证更改:
- 查看生成的文件
- 运行测试:
nx affected -t test - 格式化代码:
npx prettier --write [files]
Best Practices
最佳实践
- ✅ Always check workspace-plugin first - it has your custom solutions
- ✅ Use flag to preview changes before applying
--dry-run - ✅ Format generated code immediately with Prettier
- ✅ Test affected projects after generation
- ✅ Commit generator changes separately from manual edits
- ✅ 始终先检查工作区插件——它包含你的自定义解决方案
- ✅ 使用标志在应用更改前预览效果
--dry-run - ✅ 立即使用Prettier格式化生成的代码
- ✅ 在生成后测试受影响的项目
- ✅ 将生成器的更改与手动编辑分开提交
Examples
示例
Bumping Maven Version
升级Maven版本
When updating the Maven plugin version, use the workspace-plugin generator:
bash
nx generate @nx/workspace-plugin:bump-maven-version \
--newVersion 0.0.10 \
--nxVersion 22.1.0-beta.7This automates all the version bumping instead of manual file edits.
更新Maven插件版本时,请使用工作区插件生成器:
bash
nx generate @nx/workspace-plugin:bump-maven-version \
--newVersion 0.0.10 \
--nxVersion 22.1.0-beta.7这会自动完成所有版本升级操作,无需手动编辑文件。
Creating a New Plugin
创建新插件
For creating a new create-nodes plugin:
bash
nx generate @nx/workspace-plugin:create-nodes-plugin \
--name my-custom-plugin创建新的create-nodes插件时:
bash
nx generate @nx/workspace-plugin:create-nodes-plugin \
--name my-custom-pluginWhen to Use This Skill
何时使用本技能
Use this skill when you need to:
- Generate new code or projects
- Scaffold new features or libraries
- Automate repetitive setup tasks
- Update internal tools and configurations
- Create migrations or version updates
在以下场景中可使用本技能:
- 生成新代码或项目
- 搭建新功能或库
- 自动化重复的设置任务
- 更新内部工具和配置
- 创建迁移或版本更新