website/docs/commands/generate.mdx
The moon generate <id> (or moon g) command will generate code (files and folders) from a
pre-defined template of the same name, using an interactive series of prompts. Templates are located
based on the generator.templates setting.
# Generate code from a template
$ moon generate npm-package
# Generate code from a template to a target directory
$ moon generate npm-package --to ./packages/example
# Generate code while declaring custom variable values
$ moon generate npm-package --to ./packages/example -- --name "@company/example"
# Create a new template
$ moon generate react-app --template
View the official code generation guide for a more in-depth example of how to utilize this command.
<id> - ID of the template to generate.[-- <vars>] - Additional arguments to override default variable values.--defaults - Use the default value of all variables instead of prompting the user.--dry-run - Run entire generator process without writing files.--force - Force overwrite any existing files at the destination.--template - Create a new template with the provided name.--to - Destination to write files to, relative from the current working directory. If not
defined, will be prompted during generation.generator in .moon/workspace.*