jarvis-arch-hexagonal-gen 1.0.8 → 1.0.10
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/dist/cli/commands/generate.js +2 -1
- package/dist/core/generator.js +9 -2
- package/dist/plugins/controller/manifest.json +1 -1
- package/dist/plugins/controller/templates/controller.ejs +5 -5
- package/dist/plugins/dto/manifest.json +2 -2
- package/dist/plugins/dto/templates/create.ejs +0 -2
- package/dist/plugins/dto/templates/update.ejs +0 -2
- package/dist/plugins/repository/manifest.json +2 -2
- package/dist/plugins/repository/templates/repository.ejs +1 -1
- package/dist/plugins/routes/manifest.json +1 -1
- package/dist/plugins/routes/templates/routes.ejs +12 -8
- package/dist/plugins/swagger/manifest.json +1 -1
- package/dist/plugins/tests/manifest.json +6 -6
- package/dist/plugins/tests/templates/usecase.spec.ejs +2 -2
- package/dist/plugins/usecases/templates/create.ejs +1 -1
- package/package.json +1 -1
|
@@ -18,7 +18,8 @@ async function generateCommand(plugin, entity, options) {
|
|
|
18
18
|
const metadata = (0, parser_1.parseEntity)(entity, { columns });
|
|
19
19
|
// Lê configuração
|
|
20
20
|
const pluginsDir = path_1.default.join(__dirname, '..', '..', 'plugins');
|
|
21
|
-
const
|
|
21
|
+
const outputDir = process.cwd();
|
|
22
|
+
const generator = new generator_1.Generator(pluginsDir, outputDir);
|
|
22
23
|
try {
|
|
23
24
|
await generator.generate(plugin, metadata, options);
|
|
24
25
|
console.log('✨ Geração concluída!');
|
package/dist/core/generator.js
CHANGED
|
@@ -11,10 +11,15 @@ const path_1 = __importDefault(require("path"));
|
|
|
11
11
|
const plugin_manager_1 = require("./plugin-manager");
|
|
12
12
|
const hook_runner_1 = require("./hook-runner");
|
|
13
13
|
class Generator {
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @param pluginsDir Caminho absoluto para a pasta onde estão os plugins (ex: dentro do pacote)
|
|
16
|
+
* @param outputDir Caminho absoluto onde os arquivos gerados serão escritos (padrão: process.cwd())
|
|
17
|
+
*/
|
|
18
|
+
constructor(pluginsDir, outputDir = process.cwd()) {
|
|
15
19
|
const defaultPluginsDir = path_1.default.join(__dirname, '..', 'plugins');
|
|
16
20
|
this.pluginManager = new plugin_manager_1.PluginManager(pluginsDir || defaultPluginsDir);
|
|
17
21
|
this.hookRunner = new hook_runner_1.HookRunner();
|
|
22
|
+
this.outputDir = outputDir;
|
|
18
23
|
}
|
|
19
24
|
async generate(pluginName, metadata, options = {}) {
|
|
20
25
|
const plugin = this.pluginManager.load(pluginName);
|
|
@@ -35,8 +40,10 @@ class Generator {
|
|
|
35
40
|
if (file.condition && !this.evaluateCondition(file.condition, options)) {
|
|
36
41
|
continue;
|
|
37
42
|
}
|
|
43
|
+
// Renderiza o caminho de saída (relativo ao projeto)
|
|
38
44
|
const outputPath = ejs_1.default.render(file.output, { ...metadata, ...options });
|
|
39
|
-
|
|
45
|
+
// 👇 CAMINHO CORRIGIDO: usa this.outputDir (process.cwd()) como base
|
|
46
|
+
const fullOutputPath = path_1.default.join(this.outputDir, outputPath);
|
|
40
47
|
const templatePath = path_1.default.join(plugin.templatesDir, file.template);
|
|
41
48
|
if (!fs_extra_1.default.existsSync(templatePath)) {
|
|
42
49
|
console.warn(`⚠️ Template não encontrado: ${templatePath}`);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
|
-
import { Create<%= entity %>UseCase } from '
|
|
3
|
-
import { Update<%= entity %>UseCase } from '
|
|
4
|
-
import { Delete<%= entity %>UseCase } from '
|
|
5
|
-
import { Find<%= entity %>ByIdUseCase } from '
|
|
6
|
-
import { FindAll<%= plural %>UseCase } from '
|
|
2
|
+
import { Create<%= entity %>UseCase } from '../../../core/usecases/<%= entity %>/create-<%= entityLower %>.usecase';
|
|
3
|
+
import { Update<%= entity %>UseCase } from '../../../core/usecases/<%= entity %>/update-<%= entityLower %>.usecase';
|
|
4
|
+
import { Delete<%= entity %>UseCase } from '../../../core/usecases/<%= entity %>/delete-<%= entityLower %>.usecase';
|
|
5
|
+
import { Find<%= entity %>ByIdUseCase } from '../../../core/usecases/<%= entity %>/find-<%= entityLower %>-by-id.usecase';
|
|
6
|
+
import { FindAll<%= plural %>UseCase } from '../../../core/usecases/<%= entity %>/find-all-<%= pluralLower %>.usecase';
|
|
7
7
|
|
|
8
8
|
export class <%= entity %>Controller {
|
|
9
9
|
constructor(
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"files": [
|
|
6
6
|
{
|
|
7
7
|
"template": "create.ejs",
|
|
8
|
-
"output": "src/core/dtos/create-<%=
|
|
8
|
+
"output": "src/core/dtos/create-<%= entityLower %>.dto.ts"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"template": "update.ejs",
|
|
12
|
-
"output": "src/core/dtos/update-<%=
|
|
12
|
+
"output": "src/core/dtos/update-<%= entityLower %>.dto.ts"
|
|
13
13
|
}
|
|
14
14
|
],
|
|
15
15
|
"hooks": {
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"files": [
|
|
6
6
|
{
|
|
7
7
|
"template": "interface.ejs",
|
|
8
|
-
"output": "src/core/ports/outbound/repositories/
|
|
8
|
+
"output": "src/core/ports/outbound/repositories/i<%= entityLower %>.repository.ts"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"template": "repository.ejs",
|
|
12
|
-
"output": "src/adapters/outbound/persistence/typeorm/repositories/<%=
|
|
12
|
+
"output": "src/adapters/outbound/persistence/typeorm/repositories/<%= entityLower %>.repository.ts"
|
|
13
13
|
}
|
|
14
14
|
]
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { <%= entity %> } from '../entities/<%= entityLower %>.entity';
|
|
2
|
-
import { I<%= entity %>Repository } from '
|
|
2
|
+
import { I<%= entity %>Repository } from '../../../../../core/ports/outbound/repositories/I<%= entity %>Repository';
|
|
3
3
|
|
|
4
4
|
export class <%= entity %>Repository implements I<%= entity %>Repository {
|
|
5
5
|
private items: <%= entity %>[] = [];
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
|
|
3
|
-
import { <%= entity %>
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
|
|
3
|
+
import { <%= entity %>Controller } from '../controllers/<%= entityLower %>.controller';
|
|
4
|
+
import { <%= entity %>Repository } from '../../outbound/persistence/typeorm/repositories/repositories/<%= entityLower %>.repository';
|
|
5
|
+
|
|
6
|
+
/* Use Cases */
|
|
7
|
+
import { Create<%= entity %>UseCase } from '../../../core/usecases/<%= entity %>/create-<%= entityLower %>.usecase';
|
|
8
|
+
import { Update<%= entity %>UseCase } from '../../../core/usecases/<%= entity %>/update-<%= entityLower %>.usecase';
|
|
9
|
+
import { Delete<%= entity %>UseCase } from '../../../core/usecases/<%= entity %>/delete-<%= entityLower %>.usecase';
|
|
10
|
+
import { Find<%= entity %>ByIdUseCase } from '../../../core/usecases/<%= entity %>/find-<%= entityLower %>-by-id.usecase';
|
|
11
|
+
import { FindAll<%= plural %>UseCase } from '../../../core/usecases/<%= entity %>/find-all-<%= pluralLower %>.usecase';
|
|
9
12
|
|
|
10
13
|
const router = Router();
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
|
|
16
|
+
/* Instâncias */
|
|
13
17
|
const repository = new <%= entity %>Repository();
|
|
14
18
|
const createUseCase = new Create<%= entity %>UseCase(repository);
|
|
15
19
|
const updateUseCase = new Update<%= entity %>UseCase(repository);
|
|
@@ -5,27 +5,27 @@
|
|
|
5
5
|
"files": [
|
|
6
6
|
{
|
|
7
7
|
"template": "usecase.spec.ejs",
|
|
8
|
-
"output": "
|
|
8
|
+
"output": "tests/unit/<%= entity %>/create-<%= entityLower %>.usecase.spec.ts"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"template": "usecase.spec.ejs",
|
|
12
|
-
"output": "
|
|
12
|
+
"output": "tests/unit/<%= entity %>/update-<%= entityLower %>.usecase.spec.ts"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"template": "usecase.spec.ejs",
|
|
16
|
-
"output": "
|
|
16
|
+
"output": "tests/unit/<%= entity %>/delete-<%= entityLower %>.usecase.spec.ts"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"template": "usecase.spec.ejs",
|
|
20
|
-
"output": "
|
|
20
|
+
"output": "tests/unit/<%= entity %>/find-<%= entityLower %>-by-id.usecase.spec.ts"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
"template": "usecase.spec.ejs",
|
|
24
|
-
"output": "
|
|
24
|
+
"output": "tests/unit/<%= entity %>/find-all-<%= pluralLower %>.usecase.spec.ts"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"template": "integration.ejs",
|
|
28
|
-
"output": "
|
|
28
|
+
"output": "tests/integration/<%= route %>.integration.spec.ts"
|
|
29
29
|
}
|
|
30
30
|
]
|
|
31
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Create<%= entity %>UseCase } from '
|
|
2
|
-
import { I<%= entity %>Repository } from '
|
|
1
|
+
import { Create<%= entity %>UseCase } from 'src/core/usecases/<%= entityLower %>/create-<%= entityLower %>.usecase';
|
|
2
|
+
import { I<%= entity %>Repository } from 'src/core/ports/outbound/repositories/i<%= entityLower %>.repository';
|
|
3
3
|
|
|
4
4
|
describe('Create<%= entity %>UseCase', () => {
|
|
5
5
|
let useCase: Create<%= entity %>UseCase;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { <%= entity %> } from '../entities/<%= entityLower %>.entity';
|
|
2
|
-
import { I<%= entity %>Repository } from '
|
|
2
|
+
import { I<%= entity %>Repository } from '../../ports/outbound/repositories/i<%= entityLower %>.repository';
|
|
3
3
|
|
|
4
4
|
export class Create<%= entity %>UseCase {
|
|
5
5
|
constructor(private readonly repository: I<%= entity %>Repository) {}
|