ntx_code_generator
v1.0.0
Published
This project is a CLI tool for generating boilerplate code for internal project and resource. It uses NodeJS with TypeScript as the runtime, and handlebars (hbs) as template engine to generate files.
Downloads
8
Readme
Code Generator
Description
This project is a CLI tool for generating boilerplate code for internal project and resource. It uses NodeJS with TypeScript as the runtime, and handlebars (hbs) as template engine to generate files.
Features
- 🏗️ Create new projects from templates
- 🧩 Generate ready-to-use resources (components, modules, etc.)
- ⚡ Quick setup and intuitive commands
- 🔧 Customizable configurations
Installation
Install globally using npm:
npm install -g your-package-nameBuild the project:
npm run buildUsage
To generate a new project, run:
Requirements:
- Installed code_generator
- Empty Gitlab Repository
code_generator create-project <project-name> -b <gitlab-repo-url>This command will create a new project based on the boilerplate with the specified name and initialize a new Git repository with the provided URL.
For generating resource, you need to provide a schema file in JSON format. The schema file should contain the following fields:
Schema Type
| Property Name | Data Type | Description | Mandatory | |:-------------:|:----------:|:-----------------------------------------------:|-----------| | tableName | string | resource name | true | | protected | boolean | declaration if the resource is protected or not | true | | columns | Columns[ ] | list of resource fields | true |
Columns Type
| Property Name | Data Type | Description | Mandatory | |:-------------:|:---------:|:----------------------------------------------------------------:|-----------| | name | string | name of the field | true | | type | string | type of the field in sql | true | | nullable | boolean | to indicate if this field is nullable | true | | primary | boolean | to indicate if this field if the primary key, can only 1 primary | false | | enumValues | string[ ] | list of enum value, mandatory for enum type | false | | dtoValidation | string[ ] | list of dto validation | false | | unique | boolean | to indicate if this field is unique | false | | length | number | to specify the length of the column | false | | relation | Relation | to specify the relation | false |
Relation Type
| Property Name | Data Type | Description | Mandatory | |:-------------:|:---------:|:------------------------------------------:|-----------| | type | string | the type of relation (OneToOne, ManyToOne) | true | | entityName | string | name of entity | true | | columnName | string | name of the foreign key | true | | resourceName | string | other resources folder name | true |
To generate a new resource, run:
code_generator generate resource -f <json of schema file>Sample of schema file: Here
