# 代码生成器 **Repository Path**: wuzhongwei.com/code-generator ## Basic Information - **Project Name**: 代码生成器 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-02-26 - **Last Updated**: 2025-03-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 如何编译 ``` npm run build ``` ## 如何运行 ```js schematics .:generaterFiles --name=role --path=用户 --dry-run=false ``` ```js nest g generaterFiles role 角色 --collection=D:/nestjs/cms-generator ``` --dry-run=false false生成文件 true不生成 package.json中的schematics字段指示该包是一个schematics集合它指定了schematics集合的入口文件 ```js "schematics": "./src/collection.json" ``` - collection.json ```js { "$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json", "schematics": { "generaterFiles": { "description": "A blank schematic.", "factory": "./cms-generator/index#generaterFiles" } } } ``` - $schema 指定了用于验证和解释此JSON文件的模式schema.它指向了collection-schema.json文件,它可以确保文件的结构符合schematics集合的准备格式 - schematics 是配置的核心部分,定义了该集合所有的schematics - generaterFiles是 schematics的名称,在运行这个schematics的时候,可以通过命令行使用这个名称执行此generaterFiles - description 描述 - factory 指定了工厂函数的位置,这个工厂函数就是schematics的真正逻辑 - 表示工厂函数位于./cms-generator/index文件中 - 并且工厂函数名称为generaterFiles # https://www.astexplorer.net/