Skip to main content

Generate commands

CLI is very helpful in generating files for MonsterJS application. It makes creating components, services, modules and other files very easy.

The syntax for generate command is mn generate <type> <name>. The type is the type of file we want to generate and the name is the name of the files to be generated. The name can also be a pathname.

Here is an example command to generate a component.

mn generate component hello-world

The command above will generate the files like the following.

├── hello-world.component.tsx
└── hello-world.component.scss

Generate types

Here's a list of available types for generate command:

componentGenerate a component file.
guardGenerate a route guard that can help the developer to allow or prevent the user from navigating certain paths or viewing components.
serviceGenerate a service file that will hold the business logic of the application.
classGenerate a simple typescript class.
interfaceGenerate a typescript interface to describe a data.
directiveGenerate a directive file.
pipeGenerate a pipe file.
moduleGenerate a module file to group our components, directives, and other files that are related to the module.

For more information about each command, we can check the help feature of the cli. The syntax for this is mn generate <command type> --help.


mn generate component --help

This will show additional information for the generate component command.