@nest-extended/cli 0.0.2-beta-13 → 0.0.2-beta-14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands/generate-service.js +19 -10
- package/src/commands/generate-service.js.map +1 -1
- package/src/lib/update-app-module.d.ts +1 -1
- package/src/lib/update-app-module.js +3 -3
- package/src/lib/update-app-module.js.map +1 -1
- package/src/templates/controller.template.d.ts +1 -1
- package/src/templates/controller.template.js +2 -2
- package/src/templates/controller.template.js.map +1 -1
- package/src/templates/module.template.d.ts +1 -1
- package/src/templates/module.template.js +2 -2
- package/src/templates/module.template.js.map +1 -1
- package/src/templates/schema.template.d.ts +1 -1
- package/src/templates/schema.template.js +6 -2
- package/src/templates/schema.template.js.map +1 -1
- package/src/templates/service.template.d.ts +1 -1
- package/src/templates/service.template.js +2 -2
- package/src/templates/service.template.js.map +1 -1
package/package.json
CHANGED
|
@@ -16,23 +16,32 @@ const schema_template_1 = require("../templates/schema.template");
|
|
|
16
16
|
const service_spec_template_1 = require("../templates/service.spec.template");
|
|
17
17
|
const controller_spec_template_1 = require("../templates/controller.spec.template");
|
|
18
18
|
const generateServiceAction = (rawName) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const parts = rawName.split('/');
|
|
20
|
+
const rawBasename = parts.pop() || '';
|
|
21
|
+
const dirPath = parts.join('/');
|
|
19
22
|
// if arg have '-' change to camelCase (Logic from original index.js)
|
|
20
|
-
const argArray =
|
|
23
|
+
const argArray = rawBasename.split('-');
|
|
21
24
|
argArray.forEach((arg, index) => {
|
|
22
25
|
argArray[index] = arg[0].toUpperCase() + arg.slice(1).toLowerCase();
|
|
23
26
|
});
|
|
24
27
|
const Name = argArray.join(''); // PascalCase
|
|
25
28
|
const name = Name[0].toLowerCase() + Name.slice(1); // camelCase
|
|
26
|
-
|
|
29
|
+
const fullPath = dirPath ? `${dirPath}/${name}` : name;
|
|
30
|
+
const targetDir = `src/services/${fullPath}`;
|
|
31
|
+
console.log(`Generating service for: ${Name} (${fullPath})`);
|
|
27
32
|
const isAuthGenerated = fs.existsSync(path.join(process.cwd(), 'src/services/auth'));
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(0, create_file_1.createFileWithContent)(`src/
|
|
33
|
-
(0, create_file_1.createFileWithContent)(
|
|
34
|
-
(0, create_file_1.createFileWithContent)(
|
|
35
|
-
|
|
33
|
+
// To compute depth for relative imports to src/schemas
|
|
34
|
+
// targetDir is `src/services/qna/category`
|
|
35
|
+
// from targetDir to src is `../../` for `src/services/category`, so `../../` + dirPath depth
|
|
36
|
+
const depth = dirPath ? dirPath.split('/').map(() => '../').join('') + '../../' : '../../';
|
|
37
|
+
(0, create_file_1.createFileWithContent)(`src/schemas/${fullPath}.schema.ts`, (0, schema_template_1.getSchema)(Name, 'Users', isAuthGenerated, dirPath));
|
|
38
|
+
(0, create_file_1.createFileWithContent)(`${targetDir}/${name}.module.ts`, (0, module_template_1.getModule)(Name, name, fullPath, depth));
|
|
39
|
+
(0, create_file_1.createFileWithContent)(`${targetDir}/${name}.service.ts`, (0, service_template_1.getService)(Name, name, fullPath));
|
|
40
|
+
(0, create_file_1.createFileWithContent)(`${targetDir}/${name}.controller.ts`, (0, controller_template_1.getController)(Name, name, rawName, depth, fullPath));
|
|
41
|
+
(0, create_file_1.createFileWithContent)(`${targetDir}/dto/${name}.dto.ts`, (0, dto_template_1.getDto)(Name));
|
|
42
|
+
(0, create_file_1.createFileWithContent)(`${targetDir}/${name}.service.spec.ts`, (0, service_spec_template_1.getServiceSpec)(Name, name));
|
|
43
|
+
(0, create_file_1.createFileWithContent)(`${targetDir}/${name}.controller.spec.ts`, (0, controller_spec_template_1.getControllerSpec)(Name, name));
|
|
44
|
+
yield (0, update_app_module_1.updateAppModule)(Name, name, fullPath);
|
|
36
45
|
console.log(chalk.blue('Running lint...'));
|
|
37
46
|
const projectDir = process.cwd();
|
|
38
47
|
const pkgManager = fs.existsSync(path.join(projectDir, 'yarn.lock')) ? 'yarn' : 'npm';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-service.js","sourceRoot":"","sources":["../../../../../packages/cli/src/commands/generate-service.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,6BAA6B;AAC7B,+BAA+B;AAC/B,iDAAsC;AACtC,oDAA2D;AAC3D,gEAA2D;AAC3D,kEAAyD;AACzD,oEAA2D;AAC3D,0EAAiE;AACjE,4DAAmD;AACnD,kEAAyD;AACzD,8EAAoE;AACpE,oFAA0E;AAEnE,MAAM,qBAAqB,GAAG,CAAO,OAAe,EAAE,EAAE;IAC3D,qEAAqE;IACrE,MAAM,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"generate-service.js","sourceRoot":"","sources":["../../../../../packages/cli/src/commands/generate-service.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,6BAA6B;AAC7B,+BAA+B;AAC/B,iDAAsC;AACtC,oDAA2D;AAC3D,gEAA2D;AAC3D,kEAAyD;AACzD,oEAA2D;AAC3D,0EAAiE;AACjE,4DAAmD;AACnD,kEAAyD;AACzD,8EAAoE;AACpE,oFAA0E;AAEnE,MAAM,qBAAqB,GAAG,CAAO,OAAe,EAAE,EAAE;IAC3D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;IACtC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEhC,qEAAqE;IACrE,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC5B,QAAQ,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,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AAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC,CAAA,CAAC;AAvDW,QAAA,qBAAqB,yBAuDhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function updateAppModule(Name: string, name: string): Promise<void>;
|
|
1
|
+
export declare function updateAppModule(Name: string, name: string, fullPath?: string): Promise<void>;
|
|
@@ -5,8 +5,8 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const fs = require("fs-extra");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const chalk = require("chalk");
|
|
8
|
-
function updateAppModule(
|
|
9
|
-
return tslib_1.__awaiter(this,
|
|
8
|
+
function updateAppModule(Name_1, name_1) {
|
|
9
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (Name, name, fullPath = name) {
|
|
10
10
|
const appModulePath = path.join(process.cwd(), 'src/app.module.ts');
|
|
11
11
|
try {
|
|
12
12
|
if (!fs.existsSync(appModulePath)) {
|
|
@@ -28,7 +28,7 @@ function updateAppModule(Name, name) {
|
|
|
28
28
|
lastImportMatch = match;
|
|
29
29
|
}
|
|
30
30
|
// Create the new import statement
|
|
31
|
-
const newImport = `import { ${Name}Module } from './services/${
|
|
31
|
+
const newImport = `import { ${Name}Module } from './services/${fullPath}/${name}.module';`;
|
|
32
32
|
if (lastImportMatch) {
|
|
33
33
|
// Insert after the last service module import
|
|
34
34
|
const insertPosition = lastImportMatch.index + lastImportMatch[0].length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-app-module.js","sourceRoot":"","sources":["../../../../../packages/cli/src/lib/update-app-module.ts"],"names":[],"mappings":";;AAKA,0CA6GC;;AAjHD,+BAA+B;AAC/B,6BAA6B;AAC7B,+BAA+B;AAE/B,SAAsB,eAAe,
|
|
1
|
+
{"version":3,"file":"update-app-module.js","sourceRoot":"","sources":["../../../../../packages/cli/src/lib/update-app-module.ts"],"names":[],"mappings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B,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;oBACjG,MAAM,cAAc,GAAG,mBAAmB,GAAG,wBAAwB,CAAC;oBAEtE,yBAAyB;oBACzB,8BAA8B;oBAC9B,iDAAiD;oBACjD,iDAAiD;oBAEjD,MAAM,YAAY,GAAG,GAAG,MAAM,KAAK,UAAU,GAAG,IAAI,YAAY,UAAU,EAAE,CAAC;oBAE7E,sEAAsE;oBACtE,mBAAmB;oBACnB,4DAA4D;oBAC5D,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,GAAG,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;gBACnG,CAAC;YACL,CAAC;YAED,MAAM,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,sBAAsB,IAAI,yBAAyB,CAAC,CAAC,CAAC;QAClF,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,+BAA+B,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3E,CAAC;IACL,CAAC;CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getController: (Name: string, name: string, url: string) => string;
|
|
1
|
+
export declare const getController: (Name: string, name: string, url: string, depth?: string, fullPath?: string) => string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getController = void 0;
|
|
4
|
-
const getController = (Name, name, url) => `import {
|
|
4
|
+
const getController = (Name, name, url, depth = '../../', fullPath = name) => `import {
|
|
5
5
|
Controller,
|
|
6
6
|
Delete,
|
|
7
7
|
Get,
|
|
@@ -12,7 +12,7 @@ const getController = (Name, name, url) => `import {
|
|
|
12
12
|
} from '@nestjs/common';
|
|
13
13
|
import { ${Name}Service } from './${name}.service';
|
|
14
14
|
import { User, ModifyBody, setCreatedBy } from '@nest-extended/decorators';
|
|
15
|
-
import { ${Name} } from '
|
|
15
|
+
import { ${Name} } from '${depth}schemas/${fullPath}.schema';
|
|
16
16
|
|
|
17
17
|
@Controller('${url}')
|
|
18
18
|
export class ${Name}Controller {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/controller.template.ts"],"names":[],"mappings":";;;AACO,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,GAAW,EAAU,EAAE,CAAC;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"controller.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/controller.template.ts"],"names":[],"mappings":";;;AACO,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,GAAW,EAAE,QAAgB,QAAQ,EAAE,WAAmB,IAAI,EAAU,EAAE,CAAC;;;;;;;;;WAS1H,IAAI,qBAAqB,IAAI;;WAE7B,IAAI,YAAY,KAAK,WAAW,QAAQ;;eAEpC,GAAG;eACH,IAAI;iCACc,IAAI,YAAY,IAAI;;;;wBAI7B,IAAI;;;;;wBAKJ,IAAI;;;;;wCAKY,IAAI,QAAQ,IAAI;;wBAEhC,IAAI,yBAAyB,IAAI;;;;;;kDAMP,IAAI,gBAAgB,IAAI;;;wBAGlD,IAAI,2BAA2B,IAAI;;;;;wBAKnC,IAAI;;;CAG3B,CAAC;AAhDW,QAAA,aAAa,iBAgDxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getModule: (Name: string, name: string) => string;
|
|
1
|
+
export declare const getModule: (Name: string, name: string, fullPath?: string, depth?: string) => string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getModule = void 0;
|
|
4
|
-
const getModule = (Name, name) => `import { Module } from '@nestjs/common';
|
|
4
|
+
const getModule = (Name, name, fullPath = name, depth = '../../') => `import { Module } from '@nestjs/common';
|
|
5
5
|
import { MongooseModule } from '@nestjs/mongoose';
|
|
6
6
|
import { ${Name}Controller } from './${name}.controller';
|
|
7
7
|
import { ${Name}Service } from './${name}.service';
|
|
8
|
-
import { ${Name}, ${Name}Schema } from '
|
|
8
|
+
import { ${Name}, ${Name}Schema } from '${depth}schemas/${fullPath}.schema';
|
|
9
9
|
|
|
10
10
|
@Module({
|
|
11
11
|
imports: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/module.template.ts"],"names":[],"mappings":";;;AACO,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,IAAY,EAAU,EAAE,CAAC;;
|
|
1
|
+
{"version":3,"file":"module.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/module.template.ts"],"names":[],"mappings":";;;AACO,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,WAAmB,IAAI,EAAE,QAAgB,QAAQ,EAAU,EAAE,CAAC;;WAEzG,IAAI,wBAAwB,IAAI;WAChC,IAAI,qBAAqB,IAAI;WAC7B,IAAI,KAAK,IAAI,kBAAkB,KAAK,WAAW,QAAQ;;;;yCAIzB,IAAI,kBAAkB,IAAI;;kBAEjD,IAAI;;MAEhB,IAAI;;cAEI,IAAI;;eAEH,IAAI;CAClB,CAAC;AAjBW,QAAA,SAAS,aAiBpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getSchema: (Name: string, UserEntity?: string, isAuthGenerated?: boolean) => string;
|
|
1
|
+
export declare const getSchema: (Name: string, UserEntity?: string, isAuthGenerated?: boolean, dirPath?: string) => string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSchema = void 0;
|
|
4
|
-
const getSchema = (Name, UserEntity = 'Users', isAuthGenerated = true) => {
|
|
4
|
+
const getSchema = (Name, UserEntity = 'Users', isAuthGenerated = true, dirPath = '') => {
|
|
5
5
|
const authFields = isAuthGenerated ? `
|
|
6
6
|
@Prop({
|
|
7
7
|
type: Types.ObjectId,
|
|
@@ -24,9 +24,13 @@ const getSchema = (Name, UserEntity = 'Users', isAuthGenerated = true) => {
|
|
|
24
24
|
})
|
|
25
25
|
deletedBy?: Types.ObjectId;
|
|
26
26
|
` : '';
|
|
27
|
+
// Calculate schema depth correctly from schemas folder rather than services folder
|
|
28
|
+
// For `src/schemas/qna/category.schema.ts`, dirPath is `qna`, depth is `../`
|
|
29
|
+
const schemaDepth = dirPath ? dirPath.split('/').map(() => '../').join('') : './';
|
|
30
|
+
const relativeUserPath = schemaDepth + 'users.schema';
|
|
27
31
|
return `import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
28
32
|
import { HydratedDocument, Types } from 'mongoose';
|
|
29
|
-
import { ${UserEntity} } from '
|
|
33
|
+
import { ${UserEntity} } from '${relativeUserPath}';
|
|
30
34
|
import { EnsureObjectId } from '@nest-extended/mongoose';
|
|
31
35
|
|
|
32
36
|
export type ${Name}Document = HydratedDocument<${Name}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/schema.template.ts"],"names":[],"mappings":";;;AACO,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,aAAqB,OAAO,EAAE,kBAA2B,IAAI,EAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"schema.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/schema.template.ts"],"names":[],"mappings":";;;AACO,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,aAAqB,OAAO,EAAE,kBAA2B,IAAI,EAAE,UAAkB,EAAE,EAAU,EAAE;IACrI,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC;;;WAG5B,UAAU;;;;;;;WAOV,UAAU;;;;;;;WAOV,UAAU;;;;CAIpB,CAAC,CAAC,CAAC,EAAE,CAAC;IAEL,mFAAmF;IACnF,6EAA6E;IAC7E,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAClF,MAAM,gBAAgB,GAAG,WAAW,GAAG,cAAc,CAAC;IAEtD,OAAO;;WAEE,UAAU,YAAY,gBAAgB;;;cAGnC,IAAI,+BAA+B,IAAI;;;;;eAKtC,IAAI;;;IAGf,UAAU;;;;;;;;;;;;;;;eAeC,IAAI,yCAAyC,IAAI;CAC/D,CAAC;AACF,CAAC,CAAC;AA3DW,QAAA,SAAS,aA2DpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getService: (Name: string, name: string) => string;
|
|
1
|
+
export declare const getService: (Name: string, name: string, fullPath?: string) => string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getService = void 0;
|
|
4
|
-
const getService = (Name, name) => `import { Model } from 'mongoose';
|
|
4
|
+
const getService = (Name, name, fullPath = name) => `import { Model } from 'mongoose';
|
|
5
5
|
import { Injectable } from '@nestjs/common';
|
|
6
6
|
import { InjectModel } from '@nestjs/mongoose';
|
|
7
7
|
import { NestService } from '@nest-extended/mongoose';
|
|
8
|
-
import { ${Name}, ${Name}Document } from 'src/schemas/${
|
|
8
|
+
import { ${Name}, ${Name}Document } from 'src/schemas/${fullPath}.schema';
|
|
9
9
|
|
|
10
10
|
@Injectable()
|
|
11
11
|
export class ${Name}Service extends NestService<${Name}, ${Name}Document> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/service.template.ts"],"names":[],"mappings":";;;AACO,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,IAAY,EAAU,EAAE,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"service.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/service.template.ts"],"names":[],"mappings":";;;AACO,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,WAAmB,IAAI,EAAU,EAAE,CAAC;;;;WAIhF,IAAI,KAAK,IAAI,gCAAgC,QAAQ;;;eAGjD,IAAI,+BAA+B,IAAI,KAAK,IAAI;;mBAE5C,IAAI,2BAA2B,IAAI,gBAAgB,IAAI;;YAE9D,IAAI;;EAEd,CAAC;AAbU,QAAA,UAAU,cAapB"}
|