@saulpaulus17/node-module-generator 3.0.0 โ†’ 3.1.2

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/README.md CHANGED
@@ -49,7 +49,7 @@ graph TD
49
49
  - ๐Ÿ’Ž **Clean Architecture by Design**: Strict separation into Domain, Application, Infrastructure, and Interface layers.
50
50
  - ๐Ÿ’‰ **Native Dependency Injection**: Fully pre-configured for **Awilix**, providing seamless DI management.
51
51
  - ๐Ÿงช **Test-Ready Scaffolding**: Automatically generates **Jest** test suites for Controllers and Use Cases.
52
- - ๐Ÿš€ **Full ESM Support**: Native support for **ECMAScript Modules (ESM)** with consistent **kebab-case** file naming.
52
+ - ๐Ÿš€ **Full ESM Support**: Native support for **ECMAScript Modules (ESM)** with consistent **camelCase** file naming.
53
53
  - ๐Ÿค– **Granular Control**: Generate full modules or individual components (UseCases, Repos, DTOs) without disrupting existing code.
54
54
 
55
55
  ---
@@ -127,24 +127,24 @@ Scaffolding a module (e.g., `nmg module Product`) produces the following industr
127
127
  ```text
128
128
  src/modules/Product/
129
129
  โ”œโ”€โ”€ application/
130
- โ”‚ โ”œโ”€โ”€ dtos/ # DTO schemas (e.g., product-dto.js)
130
+ โ”‚ โ”œโ”€โ”€ dtos/ # DTO schemas (e.g., productDto.js)
131
131
  โ”‚ โ””โ”€โ”€ usecases/ # Business orchestration
132
- โ”‚ โ”œโ”€โ”€ product-use-case.js # Logic implementation
133
- โ”‚ โ””โ”€โ”€ product-use-case.test.js # Unit tests
132
+ โ”‚ โ”œโ”€โ”€ productUseCase.js # Logic implementation
133
+ โ”‚ โ””โ”€โ”€ productUseCase.test.js # Unit tests
134
134
  โ”œโ”€โ”€ domain/
135
135
  โ”‚ โ”œโ”€โ”€ entities/ # Business entity definitions
136
- โ”‚ โ”‚ โ””โ”€โ”€ product-entity.js
136
+ โ”‚ โ”‚ โ””โ”€โ”€ productEntity.js
137
137
  โ”‚ โ””โ”€โ”€ repositories/ # Repository Interface (Contracts)
138
- โ”‚ โ””โ”€โ”€ product-repository.js
138
+ โ”‚ โ””โ”€โ”€ productRepository.js
139
139
  โ”œโ”€โ”€ infrastructure/
140
140
  โ”‚ โ”œโ”€โ”€ repositories/ # Implementation (default: Prisma)
141
- โ”‚ โ”‚ โ””โ”€โ”€ prisma-product-repository.js
141
+ โ”‚ โ”‚ โ””โ”€โ”€ prismaProductRepository.js
142
142
  โ”œโ”€โ”€ interfaces/
143
143
  โ”‚ โ”œโ”€โ”€ controllers/ # Express handlers
144
- โ”‚ โ”‚ โ”œโ”€โ”€ product-controller.js
145
- โ”‚ โ”‚ โ””โ”€โ”€ product-controller.test.js
144
+ โ”‚ โ”‚ โ”œโ”€โ”€ productController.js
145
+ โ”‚ โ”‚ โ””โ”€โ”€ productController.test.js
146
146
  โ”‚ โ””โ”€โ”€ routes/ # Express routes & method binding
147
- โ”‚ โ””โ”€โ”€ product-routes.js
147
+ โ”‚ โ””โ”€โ”€ productRoutes.js
148
148
  โ””โ”€โ”€ product.module.js # Central Awilix Module Registration
149
149
  ```
150
150
 
@@ -157,7 +157,7 @@ To finalize your new module integration, follow these standard steps:
157
157
  1. **DI Registration**: Open `src/container.js` and register any specific repository aliases or scoped usecases.
158
158
  2. **Route Mounting**: Mount the generated router in `src/app.js`:
159
159
  ```javascript
160
- import productRoutes from './modules/Product/interfaces/routes/product-routes.js';
160
+ import productRoutes from './modules/Product/interfaces/routes/productRoutes.js';
161
161
  app.use('/api/v1/product', productRoutes);
162
162
  ```
163
163
  3. **Detailed Implementation**: Build out the specific logic in the generated templates (which are already integrated via Awilix).
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { pascalCase, camelCase, kebabCase } from "../utils/case.util.js";
2
+ import { pascalCase, camelCase } from "../utils/case.util.js";
3
3
  import FileUtil from "../utils/file.util.js";
4
4
  import Logger from "../utils/logger.util.js";
5
5
 
@@ -14,14 +14,14 @@ export default async function (schemaName, moduleName) {
14
14
  const templateData = {
15
15
  name: moduleName,
16
16
  className: pascalCase(schemaName),
17
- camelName: camelCase(moduleName),
18
- kebabName: kebabCase(schemaName),
17
+ camelName: camelCase(schemaName),
18
+ moduleCamelName: camelCase(moduleName),
19
19
  };
20
20
 
21
21
  await FileUtil.renderAndWrite(
22
22
  "module/dto.ejs",
23
23
  templateData,
24
- path.join(basePath, dtoDir, `${kebabCase(schemaName)}-dto.js`)
24
+ path.join(basePath, dtoDir, `${camelCase(schemaName)}Dto.js`)
25
25
  );
26
26
 
27
27
  Logger.success(`DTO ${schemaName} generated inside module ${moduleName} at application/dtos.`);
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { pascalCase, camelCase, kebabCase } from "../utils/case.util.js";
2
+ import { pascalCase, camelCase } from "../utils/case.util.js";
3
3
  import FileUtil from "../utils/file.util.js";
4
4
  import Logger from "../utils/logger.util.js";
5
5
 
@@ -25,20 +25,19 @@ export default async function (name) {
25
25
  name,
26
26
  className: pascalCase(name),
27
27
  camelName: camelCase(name),
28
- kebabName: kebabCase(name),
29
28
  };
30
29
 
31
30
  const filesToGenerate = [
32
- { tpl: "module/controller.ejs", out: `interfaces/controllers/${kebabCase(name)}-controller.js` },
33
- { tpl: "module/controller.test.ejs", out: `interfaces/controllers/${kebabCase(name)}-controller.test.js` },
34
- { tpl: "module/route.ejs", out: `interfaces/routes/${kebabCase(name)}-routes.js` },
35
- { tpl: "module/usecase.ejs", out: `application/usecases/${kebabCase(name)}-use-case.js` },
36
- { tpl: "module/usecase.test.ejs", out: `application/usecases/${kebabCase(name)}-use-case.test.js` },
37
- { tpl: "module/entity.ejs", out: `domain/entities/${kebabCase(name)}-entity.js` },
38
- { tpl: "module/repository.interface.ejs", out: `domain/repositories/${kebabCase(name)}-repository.js` },
39
- { tpl: "module/repository.impl.ejs", out: `infrastructure/repositories/prisma-${kebabCase(name)}-repository.js` },
40
- { tpl: "module/dto.ejs", out: `application/dtos/${kebabCase(name)}-dto.js` },
41
- { tpl: "module/di.ejs", out: `${kebabCase(name)}.module.js` }
31
+ { tpl: "module/controller.ejs", out: `interfaces/controllers/${camelCase(name)}Controller.js` },
32
+ { tpl: "module/controller.test.ejs", out: `interfaces/controllers/${camelCase(name)}Controller.test.js` },
33
+ { tpl: "module/route.ejs", out: `interfaces/routes/${camelCase(name)}Routes.js` },
34
+ { tpl: "module/usecase.ejs", out: `application/usecases/${camelCase(name)}UseCase.js` },
35
+ { tpl: "module/usecase.test.ejs", out: `application/usecases/${camelCase(name)}UseCase.test.js` },
36
+ { tpl: "module/entity.ejs", out: `domain/entities/${camelCase(name)}Entity.js` },
37
+ { tpl: "module/repository.interface.ejs", out: `domain/repositories/${camelCase(name)}Repository.js` },
38
+ { tpl: "module/repository.impl.ejs", out: `infrastructure/repositories/prisma${pascalCase(name)}Repository.js` },
39
+ { tpl: "module/dto.ejs", out: `application/dtos/${camelCase(name)}Dto.js` },
40
+ { tpl: "module/di.ejs", out: `${name}.module.js` }
42
41
  ];
43
42
 
44
43
  for (const file of filesToGenerate) {
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { pascalCase, camelCase, kebabCase } from "../utils/case.util.js";
2
+ import { pascalCase, camelCase } from "../utils/case.util.js";
3
3
  import FileUtil from "../utils/file.util.js";
4
4
  import Logger from "../utils/logger.util.js";
5
5
 
@@ -20,13 +20,12 @@ export default async function (moduleName) {
20
20
  name: moduleName,
21
21
  className: pascalCase(moduleName),
22
22
  camelName: camelCase(moduleName),
23
- kebabName: kebabCase(moduleName),
24
23
  };
25
24
 
26
25
  const filesToGenerate = [
27
- { tpl: "module/entity.ejs", out: `domain/entities/${kebabCase(moduleName)}-entity.js` },
28
- { tpl: "module/repository.interface.ejs", out: `domain/repositories/${kebabCase(moduleName)}-repository.js` },
29
- { tpl: "module/repository.impl.ejs", out: `infrastructure/repositories/prisma-${kebabCase(moduleName)}-repository.js` }
26
+ { tpl: "module/entity.ejs", out: `domain/entities/${camelCase(moduleName)}Entity.js` },
27
+ { tpl: "module/repository.interface.ejs", out: `domain/repositories/${camelCase(moduleName)}Repository.js` },
28
+ { tpl: "module/repository.impl.ejs", out: `infrastructure/repositories/prisma${pascalCase(moduleName)}Repository.js` }
30
29
  ];
31
30
 
32
31
  for (const file of filesToGenerate) {
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { pascalCase, camelCase, kebabCase } from "../utils/case.util.js";
2
+ import { pascalCase, camelCase } from "../utils/case.util.js";
3
3
  import FileUtil from "../utils/file.util.js";
4
4
  import Logger from "../utils/logger.util.js";
5
5
 
@@ -24,20 +24,19 @@ export default async function (name) {
24
24
  name,
25
25
  className: pascalCase(name),
26
26
  camelName: camelCase(name),
27
- kebabName: kebabCase(name),
28
27
  };
29
28
 
30
29
  const filesToGenerate = [
31
- { tpl: "module/controller.ejs", out: `interfaces/controllers/${kebabCase(name)}-controller.js` },
32
- { tpl: "module/controller.test.ejs", out: `interfaces/controllers/${kebabCase(name)}-controller.test.js` },
33
- { tpl: "module/route.ejs", out: `interfaces/routes/${kebabCase(name)}-routes.js` },
34
- { tpl: "module/usecase.ejs", out: `application/usecases/${kebabCase(name)}-use-case.js` },
35
- { tpl: "module/usecase.test.ejs", out: `application/usecases/${kebabCase(name)}-use-case.test.js` },
36
- { tpl: "module/entity.ejs", out: `domain/entities/${kebabCase(name)}-entity.js` },
37
- { tpl: "module/repository.interface.ejs", out: `domain/repositories/${kebabCase(name)}-repository.js` },
38
- { tpl: "module/repository.impl.ejs", out: `infrastructure/repositories/prisma-${kebabCase(name)}-repository.js` },
39
- { tpl: "module/dto.ejs", out: `application/dtos/${kebabCase(name)}-dto.js` },
40
- { tpl: "module/di.ejs", out: `${kebabCase(name)}.module.js` }
30
+ { tpl: "module/controller.ejs", out: `interfaces/controllers/${camelCase(name)}Controller.js` },
31
+ { tpl: "module/controller.test.ejs", out: `interfaces/controllers/${camelCase(name)}Controller.test.js` },
32
+ { tpl: "module/route.ejs", out: `interfaces/routes/${camelCase(name)}Routes.js` },
33
+ { tpl: "module/usecase.ejs", out: `application/usecases/${camelCase(name)}UseCase.js` },
34
+ { tpl: "module/usecase.test.ejs", out: `application/usecases/${camelCase(name)}UseCase.test.js` },
35
+ { tpl: "module/entity.ejs", out: `domain/entities/${camelCase(name)}Entity.js` },
36
+ { tpl: "module/repository.interface.ejs", out: `domain/repositories/${camelCase(name)}Repository.js` },
37
+ { tpl: "module/repository.impl.ejs", out: `infrastructure/repositories/prisma${pascalCase(name)}Repository.js` },
38
+ { tpl: "module/dto.ejs", out: `application/dtos/${camelCase(name)}Dto.js` },
39
+ { tpl: "module/di.ejs", out: `${name}.module.js` }
41
40
  ];
42
41
 
43
42
  for (const file of filesToGenerate) {
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { pascalCase, camelCase, kebabCase } from "../utils/case.util.js";
2
+ import { pascalCase, camelCase } from "../utils/case.util.js";
3
3
  import FileUtil from "../utils/file.util.js";
4
4
  import Logger from "../utils/logger.util.js";
5
5
 
@@ -14,21 +14,20 @@ export default async function (useCaseName, moduleName) {
14
14
  const templateData = {
15
15
  name: moduleName,
16
16
  className: pascalCase(useCaseName),
17
- camelName: camelCase(moduleName),
18
- kebabName: kebabCase(useCaseName),
19
- moduleKebabName: kebabCase(moduleName),
17
+ camelName: camelCase(moduleName), // This is used for the repository name
18
+ useCaseCamelName: camelCase(useCaseName),
20
19
  };
21
20
 
22
21
  await FileUtil.renderAndWrite(
23
22
  "module/usecase.ejs",
24
23
  templateData,
25
- path.join(basePath, ucDir, `${kebabCase(useCaseName)}-use-case.js`)
24
+ path.join(basePath, ucDir, `${camelCase(useCaseName)}UseCase.js`)
26
25
  );
27
26
 
28
27
  await FileUtil.renderAndWrite(
29
28
  "module/usecase.test.ejs",
30
29
  templateData,
31
- path.join(basePath, ucDir, `${kebabCase(useCaseName)}-use-case.test.js`)
30
+ path.join(basePath, ucDir, `${camelCase(useCaseName)}UseCase.test.js`)
32
31
  );
33
32
 
34
33
  Logger.success(`Usecase ${useCaseName} generated inside module ${moduleName}.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saulpaulus17/node-module-generator",
3
- "version": "3.0.0",
3
+ "version": "3.1.2",
4
4
  "description": "CLI tool to grenerate modular scaffolding for nodejs projects following clean arsitecture principles. ",
5
5
  "keywords": [
6
6
  "nodejs",
@@ -21,7 +21,7 @@
21
21
  "homepage": "https://github.com/saul-paulus/node-module-generator#readme",
22
22
  "main": "index.js",
23
23
  "bin": {
24
- "nmg": "./bin/cli.js"
24
+ "nmg": "bin/cli.js"
25
25
  },
26
26
  "scripts": {
27
27
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
@@ -1,5 +1,5 @@
1
1
  import { jest, describe, it, expect, beforeEach } from '@jest/globals';
2
- import <%= className %>Controller from './<%= kebabName %>-controller.js';
2
+ import <%= className %>Controller from './<%= camelName %>Controller.js';
3
3
 
4
4
  describe('<%= className %>Controller', () => {
5
5
  let controller;
@@ -1,15 +1,8 @@
1
- import { asClass, asFunction } from 'awilix';
2
-
3
- import <%= className %>Controller from './interfaces/controllers/<%= kebabName %>-controller.js';
4
- import create<%= className %>Routes from './interfaces/routes/<%= kebabName %>-routes.js';
5
- import <%= className %>UseCase from './application/usecases/<%= kebabName %>-use-case.js';
6
- import Prisma<%= className %>Repository from './infrastructure/repositories/prisma-<%= kebabName %>-repository.js';
1
+ import { asFunction } from 'awilix';
7
2
 
8
3
  export default function register<%= className %>Module(container) {
9
4
  container.register({
10
- <%= camelName %>Controller: asClass(<%= className %>Controller).singleton(),
11
- <%= camelName %>Routes: asFunction(create<%= className %>Routes).singleton(),
12
- <%= camelName %>UseCase: asClass(<%= className %>UseCase).singleton(),
13
- <%= camelName %>Repository: asClass(Prisma<%= className %>Repository).singleton(),
5
+ <%= camelName %>Repository: asFunction(({ prisma<%= className %>Repository }) => prisma<%= className %>Repository).scoped(),
14
6
  });
15
7
  }
8
+
@@ -1,5 +1,5 @@
1
1
  import { jest, describe, it, expect, beforeEach } from '@jest/globals';
2
- import <%= className %>UseCase from './<%= kebabName %>-use-case.js';
2
+ import <%= className %>UseCase from './<%= camelName %>UseCase.js';
3
3
 
4
4
  describe('<%= className %>UseCase', () => {
5
5
  let useCase;