aact 2.1.3 → 2.1.5
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
|
@@ -19,6 +19,8 @@ CLI и библиотека для валидации, анализа и ген
|
|
|
19
19
|
|
|
20
20
|
<img src="https://github.com/Byndyusoft/aact/assets/1096954/a3c3b3b0-a09b-4da7-aca4-5538159b371c" width="15"/> Телеграм-канал: [Архитектура распределённых систем](https://t.me/rsa_enc)
|
|
21
21
|
|
|
22
|
+
aact можно использовать двумя способами: как **CLI** (`npx aact check`, авто-фикс, генерация артефактов) или как **библиотеку** (импортировать `checkAcl`, `analyzeArchitecture` и пр. в свои тесты на vitest/jest). CLI — ниже, library-режим — в [соответствующем разделе](#использование-как-библиотеки).
|
|
23
|
+
|
|
22
24
|
## Quick Start (CLI)
|
|
23
25
|
|
|
24
26
|
В пустой папке:
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { defineCommand, runMain } from 'citty';
|
|
3
3
|
import consola from 'consola';
|
|
4
|
-
import { A as AactConfigSchema, H as loadStructurizrElements, G as loadPlantumlElements, J as mapContainersFromPlantumlElements, q as analyzeArchitecture, E as EXTERNAL_SYSTEM_TYPE, b as CONTAINER_DB_TYPE, r as checkAcl, s as checkAcyclic, t as checkApiGateway, w as checkCrud, x as checkDbPerService, u as checkCohesion, y as checkStableDependencies, v as checkCommonReuse, L as structurizrDslSyntax, D as generateKubernetes, F as generatePlantumlFromModel } from '../shared/aact.
|
|
4
|
+
import { A as AactConfigSchema, H as loadStructurizrElements, G as loadPlantumlElements, J as mapContainersFromPlantumlElements, q as analyzeArchitecture, E as EXTERNAL_SYSTEM_TYPE, b as CONTAINER_DB_TYPE, r as checkAcl, s as checkAcyclic, t as checkApiGateway, w as checkCrud, x as checkDbPerService, u as checkCohesion, y as checkStableDependencies, v as checkCommonReuse, L as structurizrDslSyntax, D as generateKubernetes, F as generatePlantumlFromModel } from '../shared/aact.CJGFUdeF.mjs';
|
|
5
5
|
import { loadConfig } from 'c12';
|
|
6
6
|
import * as v from 'valibot';
|
|
7
7
|
import path from 'node:path';
|
|
@@ -10,7 +10,7 @@ import pc from 'picocolors';
|
|
|
10
10
|
import 'yaml';
|
|
11
11
|
import 'plantuml-parser';
|
|
12
12
|
|
|
13
|
-
const version = "2.1.
|
|
13
|
+
const version = "2.1.5";
|
|
14
14
|
|
|
15
15
|
const loadAndValidateConfig = async (configPath) => {
|
|
16
16
|
const { config } = await loadConfig({
|
|
@@ -715,7 +715,12 @@ const handleFixMode = async (model, results, config, dryRun) => {
|
|
|
715
715
|
consola.info("No auto-fixes available for these violations");
|
|
716
716
|
exitWithViolations();
|
|
717
717
|
}
|
|
718
|
+
console.log(
|
|
719
|
+
pc.bold(dryRun ? "Suggested fixes (dry run):" : "Applying fixes:")
|
|
720
|
+
);
|
|
721
|
+
console.log();
|
|
718
722
|
formatFixes(fixes);
|
|
723
|
+
console.log();
|
|
719
724
|
if (!dryRun) {
|
|
720
725
|
await writeFixes(config, fixes);
|
|
721
726
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AactConfigSchema, B as BOUNDARY_TYPE, C as COMPONENT_TYPE, a as CONTAINER_BOUNDARY_TYPE, b as CONTAINER_DB_TYPE, c as CONTAINER_TYPE, E as EXTERNAL_SYSTEM_TYPE, P as PERSON_TYPE, d as PLANTUML_BOUNDARY, e as PLANTUML_COMPONENT, f as PLANTUML_CONTAINER, g as PLANTUML_CONTAINER_BOUNDARY, h as PLANTUML_CONTAINER_DB, i as PLANTUML_PERSON, j as PLANTUML_SYSTEM, k as PLANTUML_SYSTEM_BOUNDARY, l as PLANTUML_SYSTEM_EXT, S as STRUCTURIZR_INTERACTION_ASYNC, m as STRUCTURIZR_LOCATION_EXTERNAL, n as STRUCTURIZR_TAG_ASYNC, o as SYSTEM_BOUNDARY_TYPE, p as SYSTEM_TYPE, q as analyzeArchitecture, r as checkAcl, s as checkAcyclic, t as checkApiGateway, u as checkCohesion, v as checkCommonReuse, w as checkCrud, x as checkDbPerService, y as checkStableDependencies, z as defineConfig, D as generateKubernetes, F as generatePlantumlFromModel, G as loadPlantumlElements, H as loadStructurizrElements, I as loadStructurizrWorkspace, J as mapContainersFromPlantumlElements, K as mapContainersFromStructurizr, L as structurizrDslSyntax } from './shared/aact.
|
|
1
|
+
export { A as AactConfigSchema, B as BOUNDARY_TYPE, C as COMPONENT_TYPE, a as CONTAINER_BOUNDARY_TYPE, b as CONTAINER_DB_TYPE, c as CONTAINER_TYPE, E as EXTERNAL_SYSTEM_TYPE, P as PERSON_TYPE, d as PLANTUML_BOUNDARY, e as PLANTUML_COMPONENT, f as PLANTUML_CONTAINER, g as PLANTUML_CONTAINER_BOUNDARY, h as PLANTUML_CONTAINER_DB, i as PLANTUML_PERSON, j as PLANTUML_SYSTEM, k as PLANTUML_SYSTEM_BOUNDARY, l as PLANTUML_SYSTEM_EXT, S as STRUCTURIZR_INTERACTION_ASYNC, m as STRUCTURIZR_LOCATION_EXTERNAL, n as STRUCTURIZR_TAG_ASYNC, o as SYSTEM_BOUNDARY_TYPE, p as SYSTEM_TYPE, q as analyzeArchitecture, r as checkAcl, s as checkAcyclic, t as checkApiGateway, u as checkCohesion, v as checkCommonReuse, w as checkCrud, x as checkDbPerService, y as checkStableDependencies, z as defineConfig, D as generateKubernetes, F as generatePlantumlFromModel, G as loadPlantumlElements, H as loadStructurizrElements, I as loadStructurizrWorkspace, J as mapContainersFromPlantumlElements, K as mapContainersFromStructurizr, L as structurizrDslSyntax } from './shared/aact.CJGFUdeF.mjs';
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import YAML from 'yaml';
|
|
@@ -221,7 +221,7 @@ const generateKubernetes = (model, options) => {
|
|
|
221
221
|
const dbConnectionTemplate = options?.dbConnectionTemplate ?? "postgresql://{name}:pass-{name}@postgresql:5432/{name}";
|
|
222
222
|
const resolvedOptions = { defaultPort, dbConnectionTemplate };
|
|
223
223
|
const containers = model.allContainers.filter(
|
|
224
|
-
(c) => c.type
|
|
224
|
+
(c) => (c.type ?? CONTAINER_TYPE) === CONTAINER_TYPE
|
|
225
225
|
);
|
|
226
226
|
return containers.map((container) => {
|
|
227
227
|
const kebabName = toKebab(container.name);
|
|
@@ -262,7 +262,9 @@ const containerTypeMap = {
|
|
|
262
262
|
[CONTAINER_TYPE]: PLANTUML_CONTAINER,
|
|
263
263
|
[CONTAINER_DB_TYPE]: PLANTUML_CONTAINER_DB,
|
|
264
264
|
[EXTERNAL_SYSTEM_TYPE]: PLANTUML_SYSTEM_EXT,
|
|
265
|
-
[PERSON_TYPE]: PLANTUML_PERSON
|
|
265
|
+
[PERSON_TYPE]: PLANTUML_PERSON,
|
|
266
|
+
[SYSTEM_TYPE]: PLANTUML_SYSTEM,
|
|
267
|
+
[COMPONENT_TYPE]: PLANTUML_COMPONENT
|
|
266
268
|
};
|
|
267
269
|
const renderContainer = (container) => {
|
|
268
270
|
const type = containerTypeMap[container.type ?? CONTAINER_TYPE] ?? PLANTUML_CONTAINER;
|
|
@@ -677,18 +679,18 @@ const checkApiGateway = (containers, options) => {
|
|
|
677
679
|
return violations;
|
|
678
680
|
};
|
|
679
681
|
|
|
680
|
-
const getBoundaryCohesion = (boundary) => {
|
|
682
|
+
const getBoundaryCohesion = (boundary, externalType, internalType) => {
|
|
681
683
|
const names = new Set(boundary.containers.map((c) => c.name));
|
|
682
684
|
let result = 0;
|
|
683
685
|
for (const container of boundary.containers) {
|
|
684
686
|
result += container.relations.filter((r) => names.has(r.to.name)).length;
|
|
685
687
|
}
|
|
686
688
|
for (const innerBoundary of boundary.boundaries) {
|
|
687
|
-
result += getBoundaryCoupling(innerBoundary);
|
|
689
|
+
result += getBoundaryCoupling(innerBoundary, externalType, internalType);
|
|
688
690
|
}
|
|
689
691
|
return result;
|
|
690
692
|
};
|
|
691
|
-
const getBoundaryCoupling = (boundary, externalType
|
|
693
|
+
const getBoundaryCoupling = (boundary, externalType, internalType) => {
|
|
692
694
|
const names = new Set(boundary.containers.map((c) => c.name));
|
|
693
695
|
let result = 0;
|
|
694
696
|
for (const container of boundary.containers) {
|
|
@@ -710,7 +712,7 @@ const checkCohesion = (model, options) => {
|
|
|
710
712
|
const internalType = options?.internalType ?? CONTAINER_TYPE;
|
|
711
713
|
const violations = [];
|
|
712
714
|
for (const boundary of model.boundaries) {
|
|
713
|
-
const cohesion = getBoundaryCohesion(boundary);
|
|
715
|
+
const cohesion = getBoundaryCohesion(boundary, externalType, internalType);
|
|
714
716
|
const coupling = getBoundaryCoupling(boundary, externalType, internalType);
|
|
715
717
|
if (cohesion <= coupling) {
|
|
716
718
|
violations.push({
|
|
@@ -720,7 +722,7 @@ const checkCohesion = (model, options) => {
|
|
|
720
722
|
}
|
|
721
723
|
if (boundary.boundaries.length > 0) {
|
|
722
724
|
const innerCohesionSum = boundary.boundaries.reduce(
|
|
723
|
-
(sum, current) => sum + getBoundaryCohesion(current),
|
|
725
|
+
(sum, current) => sum + getBoundaryCohesion(current, externalType, internalType),
|
|
724
726
|
0
|
|
725
727
|
);
|
|
726
728
|
if (cohesion >= innerCohesionSum) {
|