nestjs-gen
Advanced tools
Comparing version 1.1.7 to 1.1.8
67
index.js
@@ -13,43 +13,43 @@ #!/usr/bin/env node | ||
prog | ||
.version('1.0.0') | ||
.version('1.0.0') | ||
.argument('<name>', 'Name of the model or module') | ||
.argument('<name>', 'Name of the model or module') | ||
.option('-p <prefix>', 'Specify root/prefix dir to generate in') | ||
.option('--prefix <prefix>', 'Specify root/prefix dir to generate in') | ||
.option('-p <prefix>', 'Specify root/prefix dir to generate in') | ||
.option('--prefix <prefix>', 'Specify root/prefix dir to generate in') | ||
.option('-a', 'Generate all (Module + Controller + Service + Repository + Model') | ||
.option('--all', 'Generate all (Module + Controller + Service + Repository + Model') | ||
.option('-a', 'Generate all (Module + Controller + Service + Repository + Model') | ||
.option('--all', 'Generate all (Module + Controller + Service + Repository + Model') | ||
.option('-m', 'Generate a Module') | ||
.option('--module', 'Generate a Module') | ||
.option('-m', 'Generate a Module') | ||
.option('--module', 'Generate a Module') | ||
.option('-r', 'Generate a Repository for the model') | ||
.option('--repo', 'Generate a Repository for the model') | ||
.option('--repository', 'Generate a Repository for the model') | ||
.option('-r', 'Generate a Repository for the model') | ||
.option('--repo', 'Generate a Repository for the model') | ||
.option('--repository', 'Generate a Repository for the model') | ||
.option('-d', 'Generate the model files') | ||
.option('--model', 'Generate the model file') | ||
.option('--model-name <name>', 'Specify a custom class name for the model') | ||
.option('--model-dir <dir>', 'Specify a subdirectory to put the model in (ie. \'models\')') | ||
.option('-d', 'Generate the model files') | ||
.option('--model', 'Generate the model file') | ||
.option('--model-name <name>', 'Specify a custom class name for the model') | ||
.option('--model-dir <dir>', 'Specify a subdirectory to put the model in (ie. \'models\')') | ||
.option('-c', 'Generate a Controller for the model') | ||
.option('--controller', 'Generate a Controller for the model') | ||
.option('-c', 'Generate a Controller for the model') | ||
.option('--controller', 'Generate a Controller for the model') | ||
.option('-s', 'Generate a Service for the model') | ||
.option('--service', 'Generate a Service for the model') | ||
.option('-s', 'Generate a Service for the model') | ||
.option('--service', 'Generate a Service for the model') | ||
// make interface? | ||
.option('--crud', 'Generates CRUD actions within the Controller and Service') | ||
// add authentication guards? | ||
.option('--auth', 'CRUD actions will add authentication guards, requiring a logged in user') | ||
.option('--auth-guard-class <name>', 'Name of a custom @(Guard<name>) class to use') | ||
.option('--auth-guard-dir <dir>', 'The location of the custom @Guard class file') | ||
// make interface? | ||
.option('--crud', 'Generates CRUD actions within the Controller and Service') | ||
.option('--template-dir <dir>', 'The location of the template files to use') | ||
.option('--no-subdir', 'Don\'t put generated files in <name> subdirectory (if not using a module)') | ||
// add authentication guards? | ||
.option('--auth', 'CRUD actions will add authentication guards, requiring a logged in user') | ||
.option('--auth-guard-class <name>', 'Name of a custom @(Guard<name>) class to use') | ||
.option('--auth-guard-dir <dir>', 'The location of the custom @Guard class file') | ||
.action((args, o, logger) => { | ||
.option('--template-dir <dir>', 'The location of the template files to use') | ||
.option('--no-subdir', 'Don\'t put generated files in <name> subdirectory (if not using a module)') | ||
.action((args, o, logger) => { | ||
// normalize and validate | ||
@@ -142,9 +142,4 @@ if (o.p) { o.prefix = o.p }; | ||
}); | ||
}); | ||
prog.parse(process.argv); | ||
// ask some prompts first | ||
// gen <somename> --module --repo --model --controller --service --crud | ||
prog.parse(process.argv); |
{ | ||
"name": "nestjs-gen", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "NestJS model package generator", | ||
@@ -8,3 +8,4 @@ "main": "index.js", | ||
"bin": { | ||
"ngen": "./index.js" | ||
"ngen": "./index.js", | ||
"ngen-copy-templates": "./scripts/copyTemplates.js" | ||
}, | ||
@@ -11,0 +12,0 @@ "keywords": [ |
@@ -14,2 +14,4 @@ ## What This Is: | ||
Template/schematic files can be edited (see below). | ||
## Install: | ||
@@ -78,9 +80,9 @@ | ||
## To Note: | ||
* Generated models will strip any trailing 's' in the given name argument, if one exists, unless you set the model class name explicitly with --model-name. | ||
* If you specify --repository or --crud, a model will automatically be generated. | ||
* You can specify --auth and `@Guard(<auth-guard-class>)` decorators will be added to the CRUD interfaces. | ||
Your custom auth guard class name and location can be defined with --auth-guard-class and --auth-guard-location. | ||
## Things to Note: | ||
* Generated model class names will strip any trailing 's' in the given name argument, if one exists, unless you set the model class name explicitly with `--model-name <name>`. | ||
* If you specify `--repository` or `--crud`, a model will automatically be generated. | ||
* You can specify `--auth` and `@Guard(<auth-guard-class>)` decorators will be added to the CRUD interfaces. | ||
Your custom auth guard class name and location can be defined with `--auth-guard-class <class-name>` and `--auth-guard-location <dir>`. | ||
* The generated files will all have their imports and injected dependencies referenced correctly relative to each other, but you will still need to add these references to your main AppModule, or wherever you need to use them. In other words: this package doesn't edit existing files. | ||
## All Options: | ||
@@ -122,8 +124,11 @@ | ||
## Other Things to Note: | ||
*The generated files will all reference eachother correctly, but you will still need to add these references to your main AppModule, or wherever you need to use them. | ||
In other words: this package doesn't edit existing files. | ||
## Customizing Templates | ||
To customize the template files, first copy them to your project with this command: | ||
## Editing Templates | ||
To edit the template files, copy all of them from this repository's /templates directory (or ./node_modules/nestjs-gen/templates locally), put them in a custom folder in the root of your project, edit as needed, and specify their location with --template-dir <folder>. | ||
ngen-copy-templates | ||
You can specify `--dir <dir>` to put the templates in a specific directory, otherwise they'll be put in a 'templates' directory. | ||
(Specify `-f` to force-override existing files.) | ||
Then, edit the templates as needed, and specify their custom location in the ngen command with: `ngen --template-dir <dir>`. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24017
10
155
131
3