New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nestjs-gen

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-gen - npm Package Compare versions

Comparing version 1.2.4 to 1.2.5

lib/TypeHelper.js

90

index.js
#!/usr/bin/env node
const pjson = require(__dirname + '/package.json');
const prog = require('caporal');

@@ -7,47 +8,50 @@ const fs = require('fs');

const generate = require('./lib/generator');
const TypeHelper = require('./lib/TypeHelper');
let version = pjson ? pjson.version : '<unknown version>';
prog
.version('1.0.0')
.version(version)
.argument('<name>', 'Name of the model or module')
.argument('<name>', 'Name of the model or module')
.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 file')
.option('--model', 'Generate the model file')
.option('--model-class <name>', 'Specify a custom class name for the model')
.option('--model-dir <dir>', 'Specify a subdirectory to put the model in (ie. \'models\')')
.option('--model-base-class <class>', 'Specify a base class that your model should extend from')
.option('--model-base-dir <dir>', 'Specify the import location for the base class model')
.option('-d', 'Generate the model file')
.option('--model [test]', 'Generate the model file (and optional model definition)')
.option('--model-class <name>', 'Specify a custom class name for the model')
.option('--model-dir <dir>', 'Specify a subdirectory to put the model in (ie. \'models\')')
.option('--model-base-class <class>', 'Specify a base class that your model should extend from')
.option('--model-base-dir <dir>', 'Specify the import location for the base class model')
.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')
.option('--crud', 'Generates CRUD actions within the Controller and Service')
// add prefix/subdir to generate in
.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')
// 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')
.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')
.option('--template-dir <dir>', 'The location of the template files to use')
.option('--no-subdir', 'Don\'t put generated files in <name> subdirectory (only if not using a module)')
.option('--template-dir <dir>', 'The location of the template files to use')
.option('--no-subdir', 'Don\'t put generated files in <name> subdirectory (only if not using a module)')
.option('--casing <pascal>', 'default = "example.controller.ts", pascal = "ExampleController.ts"')
.option('--casing <pascal>', 'default = "example.controller.ts", pascal = "ExampleController.ts"')

@@ -57,3 +61,4 @@ .action((args, o, logger) => {

// first see if there is a configuration file available, and start with that
let config = _findConfig();
const config = _findConfig();
if (config) {

@@ -90,2 +95,4 @@ console.log("Using tsconfig settings...");

let modelDef = undefined;
// normalize and validate

@@ -96,2 +103,3 @@ if (o.p) { o.prefix = o.p };

if (o.r || o.repo || o.repository) { o.repository = true };
if (o.model && typeof o.model == 'string') { modelDef = o.model };
if (o.md || o.model || o.repository) { o.model = true };

@@ -107,3 +115,3 @@ if (o.c || o.controller) { o.controller = true };

// set auth guarding params if applicable
// set auth guarding params if applicable?
if (o.auth) {

@@ -123,3 +131,13 @@ if (!o.authGuardClass)

// make containing folder
// Parse out model property definitions, if given
if (modelDef) {
o.modelProps = TypeHelper.parseModelProps(modelDef);
} else {
o.modelProps = undefined;
}
////////////////////
// make containing folder for the module, if using, or otherwise the package name
let outPath = path.resolve((o.prefix ? o.prefix : './'));

@@ -134,3 +152,4 @@ if (o.module) {

// container for which files will be generated
// Stage generation of each type of file...
let stagedFiles = [];

@@ -199,2 +218,3 @@

// Actually output the staged files
stagedFiles.forEach(fd => {

@@ -209,3 +229,3 @@ generate(fd.type, o, fd.outFile);

// utils
// Utils ------------------------

@@ -239,7 +259,7 @@ function _capitalize(str) {

// look in tsconfig.app.json
// look in tsconfig.app.json?
let configFile = path.resolve("./tsconfig.app.json");
ngenConfig = _read(configFile);
// look in tsconfig.json
// look in tsconfig.json?
if (!ngenConfig) {

@@ -246,0 +266,0 @@ configFile = path.resolve("./tsconfig.json");

{
"name": "nestjs-gen",
"version": "1.2.4",
"version": "1.2.5",
"description": "NestJS model package generator",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc