run-nx-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Run 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
mcp__nx-mcp__nx_generator_schema
tool to get more information about how to use the generator
Choose 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:
  • nx generate @nx/devkit:...
    - DevKit utilities
  • nx generate @nx/node:...
    - Node.js libraries
  • nx generate @nx/react:...
    - React components and apps
  • Framework-specific generators
仅当工作区插件生成器不适用时才使用这些:
  • nx generate @nx/devkit:...
    - DevKit工具集
  • nx generate @nx/node:...
    - Node.js库
  • nx generate @nx/react:...
    - React组件与应用
  • 框架专属生成器

How to Run Generators

如何运行生成器

  1. List available generators:
  2. Get generator schema (to see available options): Use the
    mcp__nx-mcp__nx_generator_schema
    tool to get more information about how to use the generator
  3. Run the generator:
    bash
    nx generate [generator-path] [options]
  4. Verify the changes:
    • Review generated files
    • Run tests:
      nx affected -t test
    • Format code:
      npx prettier --write [files]
  1. 列出可用生成器
  2. 获取生成器 schema(查看可用选项): 使用
    mcp__nx-mcp__nx_generator_schema
    工具获取有关如何使用生成器的更多信息
  3. 运行生成器
    bash
    nx generate [generator-path] [options]
  4. 验证更改
    • 查看生成的文件
    • 运行测试:
      nx affected -t test
    • 格式化代码:
      npx prettier --write [files]

Best Practices

最佳实践

  • ✅ Always check workspace-plugin first - it has your custom solutions
  • ✅ Use
    --dry-run
    flag to preview changes before applying
  • ✅ 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.7
This 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-plugin

When 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
在以下场景中可使用本技能:
  • 生成新代码或项目
  • 搭建新功能或库
  • 自动化重复的设置任务
  • 更新内部工具和配置
  • 创建迁移或版本更新