@webpieces/nx-webpieces-rules 0.3.347 → 0.3.348
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/executors.json +0 -5
- package/package.json +6 -6
- package/src/executors/generate/executor.js +9 -8
- package/src/executors/generate/executor.js.map +1 -1
- package/src/executors/validate-runtime-architecture/executor.js +16 -7
- package/src/executors/validate-runtime-architecture/executor.js.map +1 -1
- package/src/lib/runtime-config.d.ts +0 -3
- package/src/lib/runtime-config.js +0 -3
- package/src/lib/runtime-config.js.map +1 -1
- package/src/lib/runtime-graph.d.ts +12 -11
- package/src/lib/runtime-graph.js +0 -0
- package/src/lib/runtime-graph.js.map +1 -1
- package/src/plugin.js +1 -6
- package/src/plugin.js.map +1 -1
- package/src/runtime-targets.d.ts +0 -2
- package/src/runtime-targets.js +1 -14
- package/src/runtime-targets.js.map +1 -1
- package/src/executors/validate-runtime-markers/executor.d.ts +0 -25
- package/src/executors/validate-runtime-markers/executor.js +0 -91
- package/src/executors/validate-runtime-markers/executor.js.map +0 -1
- package/src/executors/validate-runtime-markers/schema.json +0 -8
- package/src/lib/runtime-markers.d.ts +0 -58
- package/src/lib/runtime-markers.js +0 -130
- package/src/lib/runtime-markers.js.map +0 -1
package/executors.json
CHANGED
|
@@ -15,11 +15,6 @@
|
|
|
15
15
|
"schema": "./src/executors/visualize-runtime/schema.json",
|
|
16
16
|
"description": "Render the runtime microservice graph (runtime-dependencies.json)"
|
|
17
17
|
},
|
|
18
|
-
"validate-runtime-markers": {
|
|
19
|
-
"implementation": "./src/executors/validate-runtime-markers/executor",
|
|
20
|
-
"schema": "./src/executors/validate-runtime-markers/schema.json",
|
|
21
|
-
"description": "Per-project: validate live.json matches the project's api-project dependencies"
|
|
22
|
-
},
|
|
23
18
|
"validate-runtime-architecture": {
|
|
24
19
|
"implementation": "./src/executors/validate-runtime-architecture/executor",
|
|
25
20
|
"schema": "./src/executors/validate-runtime-architecture/schema.json",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/nx-webpieces-rules",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.348",
|
|
4
4
|
"description": "Nx-specific webpieces validation rules and graph tooling. Bundles all @webpieces rule packages with Nx graph validators and an inference plugin.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@webpieces/ai-hook-rules": "0.3.
|
|
25
|
-
"@webpieces/code-rules": "0.3.
|
|
26
|
-
"@webpieces/eslint-rules": "0.3.
|
|
27
|
-
"@webpieces/pr-gate": "0.3.
|
|
28
|
-
"@webpieces/rules-config": "0.3.
|
|
24
|
+
"@webpieces/ai-hook-rules": "0.3.348",
|
|
25
|
+
"@webpieces/code-rules": "0.3.348",
|
|
26
|
+
"@webpieces/eslint-rules": "0.3.348",
|
|
27
|
+
"@webpieces/pr-gate": "0.3.348",
|
|
28
|
+
"@webpieces/rules-config": "0.3.348",
|
|
29
29
|
"madge": "8.0.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
@@ -19,14 +19,15 @@ const graph_visualizer_1 = require("../../lib/graph-visualizer");
|
|
|
19
19
|
const runtime_graph_1 = require("../../lib/runtime-graph");
|
|
20
20
|
const toError_1 = require("../../toError");
|
|
21
21
|
/**
|
|
22
|
-
* Generate the runtime microservice graph alongside the compile-time graph, from the
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* Generate the runtime microservice graph alongside the compile-time graph, DERIVED from the same
|
|
23
|
+
* dependencies.json (its per-project apiRelations) — one regenerate produces both committed files, and
|
|
24
|
+
* validate derives from the SAME source so they can't diverge. rpc APIs become direct runtime edges;
|
|
25
|
+
* pubsub APIs become edges the viz draws through a queue.
|
|
25
26
|
*/
|
|
26
27
|
// webpieces-disable no-function-outside-class -- executor step helper, like the rest of this executor file
|
|
27
|
-
function generateRuntimeGraph(workspaceRoot,
|
|
28
|
-
console.log('📡
|
|
29
|
-
const runtimeGraph = (0, runtime_graph_1.
|
|
28
|
+
function generateRuntimeGraph(workspaceRoot, graph, hiddenProjects) {
|
|
29
|
+
console.log('📡 Deriving runtime graph from dependencies.json (implements × uses per API)...');
|
|
30
|
+
const runtimeGraph = (0, runtime_graph_1.deriveRuntimeGraph)(graph, hiddenProjects);
|
|
30
31
|
(0, runtime_graph_1.saveRuntimeGraph)(runtimeGraph, workspaceRoot);
|
|
31
32
|
const serviceCount = Object.keys(runtimeGraph.services).length;
|
|
32
33
|
console.log(`✅ Runtime graph saved (${serviceCount} services, ${runtimeGraph.runtimeEdges.length} runtime edges)`);
|
|
@@ -53,7 +54,7 @@ async function runExecutor(options, context) {
|
|
|
53
54
|
// scanning source, so dependencies.json + the viz + the runtime graph all
|
|
54
55
|
// read the same derived truth.
|
|
55
56
|
console.log('🔎 Scanning source for implements/uses API relations...');
|
|
56
|
-
|
|
57
|
+
(0, api_scanner_1.scanAndAttachApiRelations)(workspaceRoot, enhancedGraph, projectInfos);
|
|
57
58
|
// Step 4: Save the graph
|
|
58
59
|
console.log('💾 Saving graph to architecture/dependencies.json...');
|
|
59
60
|
(0, graph_loader_1.saveGraph)(enhancedGraph, workspaceRoot, graphPath);
|
|
@@ -70,7 +71,7 @@ async function runExecutor(options, context) {
|
|
|
70
71
|
if (enhancedGraph[name].drawOnGraph === false)
|
|
71
72
|
hiddenProjects.add(name);
|
|
72
73
|
}
|
|
73
|
-
generateRuntimeGraph(workspaceRoot,
|
|
74
|
+
generateRuntimeGraph(workspaceRoot, enhancedGraph, hiddenProjects);
|
|
74
75
|
// Print summary
|
|
75
76
|
const projectCount = Object.keys(enhancedGraph).length;
|
|
76
77
|
const levels = new Set(Object.values(enhancedGraph).map((e) => e.level));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/nx-webpieces-rules/src/executors/generate/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/nx-webpieces-rules/src/executors/generate/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAuCH,8BAqEC;AAzGD,0DAAwD;AACxD,+DAAiE;AACjE,yDAAgE;AAChE,yDAAmD;AACnD,6DAAoG;AACpG,iEAA4E;AAE5E,iEAA6D;AAC7D,2DAA+E;AAC/E,2CAAwC;AAUxC;;;;;GAKG;AACH,2GAA2G;AAC3G,SAAS,oBAAoB,CAAC,aAAqB,EAAE,KAAoB,EAAE,cAA2B;IAClG,OAAO,CAAC,GAAG,CAAC,iFAAiF,CAAC,CAAC;IAC/F,MAAM,YAAY,GAAG,IAAA,kCAAkB,EAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAC/D,IAAA,gCAAgB,EAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IAC9C,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;IAC/D,OAAO,CAAC,GAAG,CACP,0BAA0B,YAAY,cAAc,YAAY,CAAC,YAAY,CAAC,MAAM,iBAAiB,CACxG,CAAC;AACN,CAAC;AAEc,KAAK,UAAU,WAAW,CACrC,OAAgC,EAChC,OAAwB;IAExB,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACpC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAEnC,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;IAEnD,8DAA8D;IAC9D,IAAI,CAAC;QACD,gFAAgF;QAChF,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;QACzE,MAAM,YAAY,GAAG,MAAM,IAAA,sCAAoB,GAAE,CAAC;QAElD,gEAAgE;QAChE,OAAO,C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BAAgB;QAChB,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC;QACvD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACzE,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,gBAAgB,YAAY,EAAE,CAAC,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,cAAc,MAAM,CAAC,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAEpE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,IAAA,iBAAO,EAAC,GAAG,CAAC,CAAC;QAC3B,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,KAAK,YAAY,wCAAuB,EAAE,CAAC;YAC3C,MAAM,MAAM,GAAG,IAAA,4BAAa,EAAC,aAAa,EAAE,+BAA+B,CAAC,CAAC;YAC7E,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,mBAAmB,GAAG,MAAM,GAAG,qDAAqD,CAAC,CAAC;QACxG,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;AACL,CAAC","sourcesContent":["/**\n * Generate Executor\n *\n * Generates the architecture dependency graph and saves it to architecture/dependencies.json.\n *\n * Usage:\n * nx run architecture:generate\n */\n\nimport type { ExecutorContext } from '@nx/devkit';\nimport { writeTemplate } from '@webpieces/rules-config';\nimport { generateReducedGraph } from '../../lib/graph-generator';\nimport { sortGraphTopologically } from '../../lib/graph-sorter';\nimport { saveGraph } from '../../lib/graph-loader';\nimport { collectProjectInfo, enrichGraph, MetadataValidationError } from '../../lib/graph-metadata';\nimport { scanAndAttachApiRelations } from '../../lib/api-usage/api-scanner';\nimport type { EnhancedGraph } from '../../lib/graph-sorter';\nimport { GraphVisualizer } from '../../lib/graph-visualizer';\nimport { deriveRuntimeGraph, saveRuntimeGraph } from '../../lib/runtime-graph';\nimport { toError } from '../../toError';\n\nexport interface GenerateExecutorOptions {\n graphPath?: string;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\n/**\n * Generate the runtime microservice graph alongside the compile-time graph, DERIVED from the same\n * dependencies.json (its per-project apiRelations) — one regenerate produces both committed files, and\n * validate derives from the SAME source so they can't diverge. rpc APIs become direct runtime edges;\n * pubsub APIs become edges the viz draws through a queue.\n */\n// webpieces-disable no-function-outside-class -- executor step helper, like the rest of this executor file\nfunction generateRuntimeGraph(workspaceRoot: string, graph: EnhancedGraph, hiddenProjects: Set<string>): void {\n console.log('📡 Deriving runtime graph from dependencies.json (implements × uses per API)...');\n const runtimeGraph = deriveRuntimeGraph(graph, hiddenProjects);\n saveRuntimeGraph(runtimeGraph, workspaceRoot);\n const serviceCount = Object.keys(runtimeGraph.services).length;\n console.log(\n `✅ Runtime graph saved (${serviceCount} services, ${runtimeGraph.runtimeEdges.length} runtime edges)`,\n );\n}\n\nexport default async function runExecutor(\n options: GenerateExecutorOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const graphPath = options.graphPath;\n const workspaceRoot = context.root;\n\n console.log('\\n📊 Architecture Graph Generator\\n');\n\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // Step 1: Build the full graph from nx, then transitively reduce it to the view\n console.log(\"📊 Generating dependency graph from nx's project graph...\");\n const reducedGraph = await generateReducedGraph();\n\n // Step 2: Topological sort (to assign levels for visualization)\n console.log('🔄 Computing topological layers...');\n const enhancedGraph = sortGraphTopologically(reducedGraph);\n\n // Step 3: Enrich with AI metadata (framework, shortDescription, file\n // pointers). This VALIDATES (responsibilities.md required per project)\n // and throws before any write, so a failure never clobbers the file.\n console.log('🏷️ Enriching graph with framework + responsibilities metadata...');\n const projectInfos = await collectProjectInfo();\n enrichGraph(enhancedGraph, projectInfos, workspaceRoot);\n\n // Step 3b: Classify each api-lib edge (implements/uses + rpc/pubsub) by\n // scanning source, so dependencies.json + the viz + the runtime graph all\n // read the same derived truth.\n console.log('🔎 Scanning source for implements/uses API relations...');\n scanAndAttachApiRelations(workspaceRoot, enhancedGraph, projectInfos);\n\n // Step 4: Save the graph\n console.log('💾 Saving graph to architecture/dependencies.json...');\n saveGraph(enhancedGraph, workspaceRoot, graphPath);\n console.log('✅ Graph saved successfully');\n\n // Step 4b: Write the committed, clickable HTML view next to the JSON so\n // dependencies.html regenerates in lock-step with dependencies.json.\n const vizPaths = new GraphVisualizer().writeVisualization(enhancedGraph, workspaceRoot);\n console.log(`✅ Wrote ${vizPaths.htmlPath}`);\n\n // Step 5: Generate the runtime microservice graph from the same scan.\n // Projects tagged drawOnGraph:false are threaded through so the runtime\n // graph hides them too (they stay flagged in runtime-dependencies.json).\n const hiddenProjects = new Set<string>();\n for (const name of Object.keys(enhancedGraph)) {\n if (enhancedGraph[name].drawOnGraph === false) hiddenProjects.add(name);\n }\n generateRuntimeGraph(workspaceRoot, enhancedGraph, hiddenProjects);\n\n // Print summary\n const projectCount = Object.keys(enhancedGraph).length;\n const levels = new Set(Object.values(enhancedGraph).map((e) => e.level));\n console.log(`\\n📈 Graph Summary:`);\n console.log(` Projects: ${projectCount}`);\n console.log(` Levels: ${levels.size} (0-${Math.max(...levels)})`);\n\n return { success: true };\n } catch (err: unknown) {\n const error = toError(err);\n console.error('❌ Graph generation failed:', error.message);\n if (error instanceof MetadataValidationError) {\n const mdPath = writeTemplate(workspaceRoot, 'webpieces.responsibilities.md');\n console.error('');\n console.error('⚠️ *** Refer to ' + mdPath + ' for how to author responsibilities.md files *** ⚠️');\n }\n return { success: false };\n }\n}\n"]}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.default = runExecutor;
|
|
18
|
-
const
|
|
18
|
+
const graph_loader_1 = require("../../lib/graph-loader");
|
|
19
19
|
const runtime_graph_1 = require("../../lib/runtime-graph");
|
|
20
20
|
const runtime_cycles_1 = require("../../lib/runtime-cycles");
|
|
21
21
|
const runtime_config_1 = require("../../lib/runtime-config");
|
|
@@ -64,13 +64,22 @@ async function runExecutor(_options, context) {
|
|
|
64
64
|
console.log(`\n⏭️ Skipping ${runtime_config_1.RUNTIME_RULE_NAME} (mode: OFF)\n`);
|
|
65
65
|
return { success: true };
|
|
66
66
|
}
|
|
67
|
-
if (config.servicePaths.length === 0) {
|
|
68
|
-
console.log(`\n⏭️ ${runtime_config_1.RUNTIME_RULE_NAME}: no servicePaths configured — nothing to validate\n`);
|
|
69
|
-
return { success: true };
|
|
70
|
-
}
|
|
71
67
|
console.log('\n📡 Validating runtime microservice architecture\n');
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
// Derive the "current" runtime graph from the committed dependencies.json — the SAME source
|
|
69
|
+
// architecture:generate derives from — so the unchanged-check compares like-for-like and can
|
|
70
|
+
// never fail on a clean, freshly-generated tree. (validate-architecture-unchanged separately
|
|
71
|
+
// guarantees dependencies.json itself is fresh.)
|
|
72
|
+
const depsFile = (0, graph_loader_1.loadBlessedGraph)(workspaceRoot);
|
|
73
|
+
if (depsFile === null) {
|
|
74
|
+
console.error('❌ No architecture/dependencies.json — run: nx run architecture:generate');
|
|
75
|
+
return { success: false };
|
|
76
|
+
}
|
|
77
|
+
const hiddenProjects = new Set();
|
|
78
|
+
for (const name of Object.keys(depsFile.projects)) {
|
|
79
|
+
if (depsFile.projects[name].drawOnGraph === false)
|
|
80
|
+
hiddenProjects.add(name);
|
|
81
|
+
}
|
|
82
|
+
const graph = (0, runtime_graph_1.deriveRuntimeGraph)(depsFile.projects, hiddenProjects);
|
|
74
83
|
const problems = checkCycles(graph, config.allowedCycles);
|
|
75
84
|
const unchanged = checkUnchanged(workspaceRoot, graph);
|
|
76
85
|
if (unchanged)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/nx-webpieces-rules/src/executors/validate-runtime-architecture/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;AA+DH,
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/nx-webpieces-rules/src/executors/validate-runtime-architecture/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;AA+DH,8BAmDC;AA/GD,yDAA0D;AAC1D,2DAMiC;AAEjC,6DAAuE;AAEvE,6DAAmG;AAUnG,sFAAsF;AACtF,SAAS,iBAAiB,CAAC,OAAuB;IAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC5C,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC;QACrE,IAAI,MAAM;YAAE,GAAG,CAAC,GAAG,CAAC,IAAA,yBAAQ,EAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAED,8EAA8E;AAC9E,SAAS,WAAW,CAAC,KAAmB,EAAE,OAAuB;IAC7D,MAAM,MAAM,GAAG,IAAA,kCAAiB,EAAC,IAAA,gCAAgB,EAAC,KAAK,CAAC,CAAC,CAAC;IAC1D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE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B,OAAO,CAAC,GAAG,CAAC,wEAAwE,CAAC,CAAC;QACtF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAC/D,KAAK,MAAM,CAAC,IAAI,QAAQ;QAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpD,OAAO,CAAC,KAAK,CAAC,4HAA4H,CAAC,CAAC;IAE5I,MAAM,UAAU,GAAG,IAAA,kCAAiB,EAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,+BAA+B,UAAU,CAAC,MAAM,MAAM,CAAC,CAAC;QACpE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * Validate Runtime Architecture Executor (workspace)\n *\n * Two workspace-level checks on the runtime microservice graph:\n * 1. No-cycles: every runtime cycle must be in the `allowedCycles` allowlist\n * with an unexpired `until`; any other cycle fails the build.\n * 2. Unchanged: the freshly-assembled graph must match the committed\n * architecture/runtime-dependencies.json (run `architecture:generate`).\n *\n * On/off + a whole-rule grace window come from webpieces.config.json\n * (rule: runtime-architecture).\n *\n * Usage: nx run architecture:validate-runtime-architecture\n */\n\nimport type { ExecutorContext } from '@nx/devkit';\nimport { loadBlessedGraph } from '../../lib/graph-loader';\nimport {\n deriveRuntimeGraph,\n loadRuntimeGraph,\n runtimeAdjacency,\n runtimeGraphFileExists,\n serializeRuntimeGraph,\n} from '../../lib/runtime-graph';\nimport type { RuntimeGraph } from '../../lib/runtime-graph';\nimport { findRuntimeCycles, cycleKey } from '../../lib/runtime-cycles';\nimport type { AllowedCycle } from '../../lib/runtime-config';\nimport { loadRuntimeConfig, runtimeReportOnly, RUNTIME_RULE_NAME } from '../../lib/runtime-config';\n\nexport interface ValidateRuntimeArchitectureOptions {\n // Config comes from webpieces.config.json at runtime.\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\n/** Allowlist keys (sorted-services -> entry) that are still in their grace window. */\nfunction activeAllowedKeys(allowed: AllowedCycle[]): Map<string, AllowedCycle> {\n const nowSeconds = Date.now() / 1000;\n const map = new Map<string, AllowedCycle>();\n for (const entry of allowed) {\n const active = entry.until === undefined || nowSeconds < entry.until;\n if (active) map.set(cycleKey(entry.services), entry);\n }\n return map;\n}\n\n/** Returns disallowed-cycle messages (empty = all cycles allowed or none). */\nfunction checkCycles(graph: RuntimeGraph, allowed: AllowedCycle[]): string[] {\n const cycles = findRuntimeCycles(runtimeAdjacency(graph));\n if (cycles.length === 0) return [];\n\n const activeAllow = activeAllowedKeys(allowed);\n const problems: string[] = [];\n for (const cycle of cycles) {\n const entry = activeAllow.get(cycle.key);\n if (entry) {\n console.log(`⏳ Allowed runtime cycle [${cycle.services.join(' <-> ')}] — ${entry.reason ?? 'no reason given'}`);\n continue;\n }\n problems.push(`runtime cycle: ${cycle.services.join(' -> ')} -> ${cycle.services[0]}`);\n }\n return problems;\n}\n\n/** Returns an unchanged-check message, or null if the committed graph matches. */\nfunction checkUnchanged(workspaceRoot: string, current: RuntimeGraph): string | null {\n if (!runtimeGraphFileExists(workspaceRoot)) {\n return 'No committed architecture/runtime-dependencies.json — run: nx run architecture:generate';\n }\n const saved = loadRuntimeGraph(workspaceRoot);\n if (saved && serializeRuntimeGraph(saved) === serializeRuntimeGraph(current)) return null;\n return 'Runtime graph changed since last commit — run: nx run architecture:generate and commit the result';\n}\n\nexport default async function runExecutor(\n _options: ValidateRuntimeArchitectureOptions,\n context: ExecutorContext,\n): Promise<ExecutorResult> {\n const workspaceRoot = context.root;\n const config = loadRuntimeConfig(workspaceRoot);\n\n if (config.off) {\n console.log(`\\n⏭️ Skipping ${RUNTIME_RULE_NAME} (mode: OFF)\\n`);\n return { success: true };\n }\n\n console.log('\\n📡 Validating runtime microservice architecture\\n');\n // Derive the \"current\" runtime graph from the committed dependencies.json — the SAME source\n // architecture:generate derives from — so the unchanged-check compares like-for-like and can\n // never fail on a clean, freshly-generated tree. (validate-architecture-unchanged separately\n // guarantees dependencies.json itself is fresh.)\n const depsFile = loadBlessedGraph(workspaceRoot);\n if (depsFile === null) {\n console.error('❌ No architecture/dependencies.json — run: nx run architecture:generate');\n return { success: false };\n }\n const hiddenProjects = new Set<string>();\n for (const name of Object.keys(depsFile.projects)) {\n if (depsFile.projects[name].drawOnGraph === false) hiddenProjects.add(name);\n }\n const graph = deriveRuntimeGraph(depsFile.projects, hiddenProjects);\n\n const problems: string[] = checkCycles(graph, config.allowedCycles);\n const unchanged = checkUnchanged(workspaceRoot, graph);\n if (unchanged) problems.push(unchanged);\n\n for (const u of graph.unresolvedUses) {\n console.log(`⚠️ ${u.service} uses \"${u.api}\" but no in-repo service implements it (external?)`);\n }\n\n if (problems.length === 0) {\n console.log('✅ Runtime architecture valid (no disallowed cycles, graph unchanged)\\n');\n return { success: true };\n }\n\n console.error('\\n❌ Runtime architecture validation failed:\\n');\n for (const p of problems) console.error(` - ${p}`);\n console.error('\\nAllow a cycle temporarily via runtime-architecture.allowedCycles (services + reason + until) in webpieces.config.json.\\n');\n\n const reportOnly = runtimeReportOnly(config);\n if (reportOnly.skip) {\n console.log(`⏳ Reported but not failing (${reportOnly.reason}).\\n`);\n return { success: true };\n }\n return { success: false };\n}\n"]}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*
|
|
7
7
|
* "runtime-architecture": {
|
|
8
8
|
* "mode": "ON", // "OFF" disables the whole feature
|
|
9
|
-
* "apiProjectPaths": ["libraries/apis/*"],
|
|
10
9
|
* "ignoreModifiedUntilEpoch": 0, // whole-rule punt (epoch seconds)
|
|
11
10
|
* "allowedCycles": [ { "services": ["a","b"], "reason": "...", "until": 1771931925 } ]
|
|
12
11
|
* }
|
|
@@ -20,8 +19,6 @@ export interface AllowedCycle {
|
|
|
20
19
|
}
|
|
21
20
|
export interface RuntimeRuleConfig {
|
|
22
21
|
off: boolean;
|
|
23
|
-
apiProjectPaths: string[];
|
|
24
|
-
servicePaths: string[];
|
|
25
22
|
ignoreModifiedUntilEpoch?: number;
|
|
26
23
|
ignoreRuleWhileOnBranch?: string;
|
|
27
24
|
allowedCycles: AllowedCycle[];
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*
|
|
8
8
|
* "runtime-architecture": {
|
|
9
9
|
* "mode": "ON", // "OFF" disables the whole feature
|
|
10
|
-
* "apiProjectPaths": ["libraries/apis/*"],
|
|
11
10
|
* "ignoreModifiedUntilEpoch": 0, // whole-rule punt (epoch seconds)
|
|
12
11
|
* "allowedCycles": [ { "services": ["a","b"], "reason": "...", "until": 1771931925 } ]
|
|
13
12
|
* }
|
|
@@ -30,8 +29,6 @@ function loadRuntimeConfig(workspaceRoot) {
|
|
|
30
29
|
const raw = (rule?.options ?? {});
|
|
31
30
|
return {
|
|
32
31
|
off: rule?.isOff ?? false,
|
|
33
|
-
apiProjectPaths: Array.isArray(raw.apiProjectPaths) ? raw.apiProjectPaths : [],
|
|
34
|
-
servicePaths: Array.isArray(raw.servicePaths) ? raw.servicePaths : [],
|
|
35
32
|
ignoreModifiedUntilEpoch: typeof raw.ignoreModifiedUntilEpoch === 'number' ? raw.ignoreModifiedUntilEpoch : undefined,
|
|
36
33
|
ignoreRuleWhileOnBranch: typeof raw.ignoreRuleWhileOnBranch === 'string' ? raw.ignoreRuleWhileOnBranch : undefined,
|
|
37
34
|
allowedCycles: Array.isArray(raw.allowedCycles) ? raw.allowedCycles.filter(isUsableCycle) : [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-config.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/runtime-config.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"runtime-config.js","sourceRoot":"","sources":["../../../../../../packages/tooling/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,CAAC,CAAC;AAC3F,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,KAAyB;IACnD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,KAAK,CAAC;AACrC,CAAC;AAED,wDAAwD;AACxD,SAAgB,SAAS,CAAC,KAAa;IACnC,OAAO,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["/**\n * Runtime Config\n *\n * Loads the `runtime-architecture` rule from webpieces.config.json and exposes\n * typed accessors shared by the generate + validate + visualize executors.\n *\n * \"runtime-architecture\": {\n * \"mode\": \"ON\", // \"OFF\" disables the whole feature\n * \"ignoreModifiedUntilEpoch\": 0, // whole-rule punt (epoch seconds)\n * \"allowedCycles\": [ { \"services\": [\"a\",\"b\"], \"reason\": \"...\", \"until\": 1771931925 } ]\n * }\n */\n\nimport { loadAndValidate, shouldSkipRule, SkipRuleResult } from '@webpieces/rules-config';\n\nexport const RUNTIME_RULE_NAME = 'runtime-architecture';\n\nexport interface AllowedCycle {\n services: string[];\n reason?: string;\n until?: number;\n}\n\nexport interface RuntimeRuleConfig {\n off: boolean;\n ignoreModifiedUntilEpoch?: number;\n ignoreRuleWhileOnBranch?: string;\n allowedCycles: AllowedCycle[];\n}\n\n/**\n * Typed view of the opaque webpieces.config.json option bag for this rule. The\n * config is trusted (it is the workspace's own file), so we cast once here and\n * defensively narrow arrays/numbers rather than threading `unknown` everywhere.\n */\ninterface RuntimeRuleRaw {\n ignoreModifiedUntilEpoch?: number;\n ignoreRuleWhileOnBranch?: string;\n allowedCycles?: AllowedCycle[];\n}\n\nfunction isUsableCycle(cycle: AllowedCycle): boolean {\n return Array.isArray(cycle.services) && cycle.services.length > 0;\n}\n\n/** Load the runtime-architecture rule config (with safe defaults). */\nexport function loadRuntimeConfig(workspaceRoot: string): RuntimeRuleConfig {\n const shared = loadAndValidate(workspaceRoot).resolved;\n const rule = shared.rules.get(RUNTIME_RULE_NAME);\n const raw = (rule?.options ?? {}) as RuntimeRuleRaw;\n return {\n off: rule?.isOff ?? false,\n ignoreModifiedUntilEpoch:\n typeof raw.ignoreModifiedUntilEpoch === 'number' ? raw.ignoreModifiedUntilEpoch : undefined,\n ignoreRuleWhileOnBranch:\n typeof raw.ignoreRuleWhileOnBranch === 'string' ? raw.ignoreRuleWhileOnBranch : undefined,\n allowedCycles: Array.isArray(raw.allowedCycles) ? raw.allowedCycles.filter(isUsableCycle) : [],\n };\n}\n\n/**\n * Whole-rule report-only window honoring BOTH escape hatches: skip while on the\n * named branch (ignoreRuleWhileOnBranch) or until the epoch passes\n * (ignoreModifiedUntilEpoch). When `.skip` is true, problems are reported but\n * the build is not failed.\n */\nexport function runtimeReportOnly(config: RuntimeRuleConfig): SkipRuleResult {\n return shouldSkipRule(config.ignoreModifiedUntilEpoch, config.ignoreRuleWhileOnBranch);\n}\n\n/**\n * Whole-rule grace window: while now < epoch, failures are reported but do not\n * fail the build (warn). Mirrors the other webpieces rules.\n */\nexport function isGraceActive(epoch: number | undefined): boolean {\n if (epoch === undefined) return false;\n return Date.now() / 1000 < epoch;\n}\n\n/** Format the epoch as an ISO date for log messages. */\nexport function epochDate(epoch: number): string {\n return new Date(epoch * 1000).toISOString().split('T')[0];\n}\n"]}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runtime Graph
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* `
|
|
6
|
-
*
|
|
4
|
+
* Derives the runtime microservice graph SOLELY from architecture/dependencies.json
|
|
5
|
+
* (the single source of truth): each project's `apiRelations` carry which api
|
|
6
|
+
* classes it implements/uses and their transport (rpc | pubsub). Both
|
|
7
|
+
* `architecture:generate` and `architecture:validate-runtime-architecture` call
|
|
8
|
+
* the SAME `deriveRuntimeGraph`, so the committed graph and the validated graph
|
|
9
|
+
* can never diverge.
|
|
7
10
|
*
|
|
8
11
|
* The runtime edge Z -> X (Z depends on X at runtime) is INFERRED: Z `uses` api
|
|
9
12
|
* Y and X `implements` api Y. This edge does not exist in the compile-time
|
|
10
13
|
* dependencies.json (both Z and X only compile-depend on the api library Y).
|
|
11
14
|
*/
|
|
12
|
-
import type {
|
|
13
|
-
import type { ApiScanResult } from './api-usage/api-scanner';
|
|
15
|
+
import type { EnhancedGraph } from './graph-sorter';
|
|
14
16
|
import type { ApiTransport } from './api-usage/api-relations';
|
|
15
17
|
export declare const DEFAULT_RUNTIME_GRAPH_PATH = "architecture/runtime-dependencies.json";
|
|
16
18
|
export interface RuntimeService {
|
|
@@ -56,14 +58,13 @@ export interface RuntimeGraph {
|
|
|
56
58
|
}
|
|
57
59
|
/** Adjacency (service -> [targets]) from a loaded runtime graph. */
|
|
58
60
|
export declare function runtimeAdjacency(graph: RuntimeGraph): Record<string, string[]>;
|
|
59
|
-
/** Assemble the full runtime graph from the workspace model + service contracts. */
|
|
60
|
-
export declare function assembleRuntimeGraph(model: WorkspaceModel, workspaceRoot: string): RuntimeGraph;
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
62
|
+
* Derive the runtime graph from dependencies.json's project `apiRelations` — the
|
|
63
|
+
* single source of truth shared by generate + validate. `hiddenProjects`
|
|
64
|
+
* (drawOnGraph:false, defaults to none) are kept in the graph but flagged so the
|
|
65
|
+
* runtime visualizer omits their nodes + edges.
|
|
65
66
|
*/
|
|
66
|
-
export declare function
|
|
67
|
+
export declare function deriveRuntimeGraph(projects: EnhancedGraph, hiddenProjects?: Set<string>): RuntimeGraph;
|
|
67
68
|
export declare function saveRuntimeGraph(graph: RuntimeGraph, workspaceRoot: string, graphPath?: string): void;
|
|
68
69
|
export declare function runtimeGraphFileExists(workspaceRoot: string, graphPath?: string): boolean;
|
|
69
70
|
export declare function loadRuntimeGraph(workspaceRoot: string, graphPath?: string): RuntimeGraph | null;
|
package/src/lib/runtime-graph.js
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-graph.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/runtime-graph.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AA8JH,4CAEC;AAkBD,oDAyBC;AAoID,oEAKC;AAcD,4CASC;AAED,wDAKC;AAED,4CAaC;AAGD,sDAEC;;AApYD,+CAAyB;AACzB,mDAA6B;AAC7B,iDAAwD;AACxD,uDAA6E;AAI7E,6DAAwD;AACxD,wCAAqC;AAExB,QAAA,0BAA0B,GAAG,wCAAwC,CAAC;AA4DnF,gGAAgG;AAChG,SAAS,mBAAmB,CAAC,KAAqB,EAAE,aAAqB;IACrE,MAAM,KAAK,GAAkB,EAAE,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,SAAS;QAC9B,wEAAwE;QACxE,qEAAqE;QACrE,MAAM,QAAQ,GAAG,IAAA,qCAAmB,EAAC,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,KAAK,CAAC,IAAI,CAAC;YACP,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAA,qCAAmB,EAAC,KAAK,EAAE,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE;YACtE,IAAI,EAAE,IAAA,qCAAmB,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAC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,KAAK,CAAC,qCAAqC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACvF,CAAC;AACL,CAAC;AAED,8EAA8E;AAC9E,SAAgB,qBAAqB,CAAC,KAAmB;IACrD,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC","sourcesContent":["/**\n * Runtime Graph\n *\n * Assembles the runtime microservice graph from the per-service\n * `service-contract.json` files, and saves/loads the committed\n * `architecture/runtime-dependencies.json`.\n *\n * The runtime edge Z -> X (Z depends on X at runtime) is INFERRED: Z `uses` api\n * Y and X `implements` api Y. This edge does not exist in the compile-time\n * dependencies.json (both Z and X only compile-depend on the api library Y).\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { sortGraphTopologically } from './graph-sorter';\nimport { readServiceContract, resolvePackageNames } from './runtime-markers';\nimport type { WorkspaceModel } from './runtime-markers';\nimport type { ApiScanResult } from './api-usage/api-scanner';\nimport type { ApiRef, ApiTransport } from './api-usage/api-relations';\nimport { sortApiRefs } from './api-usage/api-relations';\nimport { toError } from '../toError';\n\nexport const DEFAULT_RUNTIME_GRAPH_PATH = 'architecture/runtime-dependencies.json';\n\nexport interface RuntimeService {\n level: number;\n implements: string[];\n uses: string[];\n dependsOn: string[];\n /**\n * When false, this service is hidden from the rendered runtime graph (its\n * node AND every edge touching it are omitted from the HTML/DOT). It stays\n * in runtime-dependencies.json so the data view is complete. Absent means\n * drawn (the default). Mirrors GraphEntry.drawOnGraph from the `drawOnGraph:`\n * nx tag.\n */\n drawOnGraph?: boolean;\n}\n\nexport interface RuntimeApi {\n implementedBy: string[];\n usedBy: string[];\n /** Transport of this API — 'rpc' (direct call) or 'pubsub' (delivered through a queue). */\n type?: ApiTransport;\n}\n\nexport interface RuntimeEdge {\n from: string;\n to: string;\n via: string[];\n /**\n * Transport of this edge. 'rpc' → a direct call arrow. 'pubsub' → the producer enqueues and the\n * consumer is delivered later, so the runtime viz draws it as producer → QUEUE → consumer.\n * Edges are split by transport, so every edge is a single kind.\n */\n type?: ApiTransport;\n}\n\nexport interface RuntimeUnresolved {\n service: string;\n api: string;\n}\n\nexport interface RuntimeGraph {\n services: Record<string, RuntimeService>;\n apis: Record<string, RuntimeApi>;\n runtimeEdges: RuntimeEdge[];\n unresolvedUses: RuntimeUnresolved[];\n}\n\n/** One service's declared relationships, resolved to workspace project names. */\ninterface ServiceDecl {\n name: string;\n implements: string[];\n uses: string[];\n}\n\ninterface EdgeResult {\n edges: RuntimeEdge[];\n unresolved: RuntimeUnresolved[];\n}\n\n/** Collect every service project (servicePaths), with its declarations resolved to projects. */\nfunction collectServiceDecls(model: WorkspaceModel, workspaceRoot: string): ServiceDecl[] {\n const decls: ServiceDecl[] = [];\n for (const info of model.projects.values()) {\n if (!info.isService) continue;\n // A service missing its contract still appears as a node (empty edges);\n // validate-runtime-markers fails it separately for the missing file.\n const contract = readServiceContract(workspaceRoot, info.root);\n const implementsPkgs = contract ? contract.implements : [];\n const usesPkgs = contract ? contract.uses : [];\n decls.push({\n name: info.name,\n implements: resolvePackageNames(model, implementsPkgs).projects.sort(),\n uses: resolvePackageNames(model, usesPkgs).projects.sort(),\n });\n }\n return decls.sort((a: ServiceDecl, b: ServiceDecl) => a.name.localeCompare(b.name));\n}\n\nfunction buildApiIndex(decls: ServiceDecl[]): Map<string, RuntimeApi> {\n const apis = new Map<string, RuntimeApi>();\n const ensure = (api: string): RuntimeApi => {\n let entry = apis.get(api);\n if (!entry) {\n entry = { implementedBy: [], usedBy: [] };\n apis.set(api, entry);\n }\n return entry;\n };\n for (const decl of decls) {\n for (const api of decl.implements) ensure(api).implementedBy.push(decl.name);\n for (const api of decl.uses) ensure(api).usedBy.push(decl.name);\n }\n for (const entry of apis.values()) {\n entry.implementedBy.sort();\n entry.usedBy.sort();\n }\n return apis;\n}\n\n/** Build inferred runtime edges (Z -> X via Y) and the unresolved-uses list. */\nfunction buildEdges(decls: ServiceDecl[], apis: Map<string, RuntimeApi>): EdgeResult {\n const viaByEdge = new Map<string, Set<string>>();\n const unresolved: RuntimeUnresolved[] = [];\n\n for (const decl of decls) {\n for (const api of decl.uses) {\n const implementers = apis.get(api)?.implementedBy ?? [];\n if (implementers.length === 0) {\n unresolved.push({ service: decl.name, api });\n continue;\n }\n for (const target of implementers) {\n if (target === decl.name) continue;\n const key = `${decl.name} ${target}`;\n if (!viaByEdge.has(key)) viaByEdge.set(key, new Set());\n viaByEdge.get(key)!.add(api);\n }\n }\n }\n\n const edges: RuntimeEdge[] = [];\n for (const key of viaByEdge.keys()) {\n const parts = key.split(' ');\n edges.push({ from: parts[0], to: parts[1], via: Array.from(viaByEdge.get(key)!).sort() });\n }\n edges.sort((a: RuntimeEdge, b: RuntimeEdge) => a.from.localeCompare(b.from) || a.to.localeCompare(b.to));\n unresolved.sort(\n (a: RuntimeUnresolved, b: RuntimeUnresolved) =>\n a.service.localeCompare(b.service) || a.api.localeCompare(b.api),\n );\n return { edges, unresolved };\n}\n\n/** Adjacency (service -> [targets]) used for leveling + cycle checks. */\nfunction adjacencyFromEdges(serviceNames: string[], edges: RuntimeEdge[]): Record<string, string[]> {\n const adj: Record<string, string[]> = {};\n for (const name of serviceNames) adj[name] = [];\n for (const edge of edges) {\n if (!adj[edge.from]) adj[edge.from] = [];\n adj[edge.from].push(edge.to);\n }\n return adj;\n}\n\n/** Adjacency (service -> [targets]) from a loaded runtime graph. */\nexport function runtimeAdjacency(graph: RuntimeGraph): Record<string, string[]> {\n return adjacencyFromEdges(Object.keys(graph.services), graph.runtimeEdges);\n}\n\n/** Assign levels via topological sort; falls back to level 0 when a cycle exists. */\nfunction assignLevels(adjacency: Record<string, string[]>): Record<string, number> {\n const levels: Record<string, number> = {};\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const sorted = sortGraphTopologically(adjacency);\n for (const name of Object.keys(sorted)) levels[name] = sorted[name].level;\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n for (const name of Object.keys(adjacency)) levels[name] = 0;\n }\n return levels;\n}\n\n/** Assemble the full runtime graph from the workspace model + service contracts. */\nexport function assembleRuntimeGraph(model: WorkspaceModel, workspaceRoot: string): RuntimeGraph {\n const decls = collectServiceDecls(model, workspaceRoot);\n const apis = buildApiIndex(decls);\n const edgeResult = buildEdges(decls, apis);\n\n const services: Record<string, RuntimeService> = {};\n for (const decl of decls) {\n const dependsOn = Array.from(\n new Set(edgeResult.edges.filter((e: RuntimeEdge) => e.from === decl.name).map((e: RuntimeEdge) => e.to)),\n ).sort();\n services[decl.name] = { level: 0, implements: decl.implements, uses: decl.uses, dependsOn };\n }\n\n const levels = assignLevels(adjacencyFromEdges(Object.keys(services), edgeResult.edges));\n for (const name of Object.keys(services)) services[name].level = levels[name] ?? 0;\n\n const apisObj: Record<string, RuntimeApi> = {};\n for (const api of Array.from(apis.keys()).sort()) apisObj[api] = apis.get(api)!;\n\n return {\n services,\n apis: apisObj,\n runtimeEdges: edgeResult.edges,\n unresolvedUses: edgeResult.unresolved,\n };\n}\n\n/** One project's implements/uses at api-CLASS granularity, from the source scan. */\ninterface ScanDecl {\n name: string;\n implementsApis: ApiRef[];\n usesApis: ApiRef[];\n}\n\n/**\n * Assembles the runtime microservice graph from the SOURCE SCAN (apiRelations) instead of\n * service-contract.json: implementers × users per API, split by transport. An rpc edge is a direct\n * call; a pubsub edge flows through a queue (drawn producer → queue → consumer by the visualizer).\n */\nclass ScanRuntimeAssembler {\n constructor(\n private readonly scan: ApiScanResult,\n /** Project names tagged drawOnGraph:false — kept in the JSON but flagged so the viz omits them. */\n private readonly hiddenProjects: Set<string>\n ) {}\n\n assemble(): RuntimeGraph {\n const decls = this.collectDecls();\n const apis = this.buildApis(decls);\n const edgeResult = this.buildEdges(decls, apis);\n const services = this.buildServices(decls, edgeResult.edges);\n const apisObj: Record<string, RuntimeApi> = {};\n for (const api of Array.from(apis.keys()).sort()) apisObj[api] = apis.get(api)!;\n return { services, apis: apisObj, runtimeEdges: edgeResult.edges, unresolvedUses: edgeResult.unresolved };\n }\n\n /** Flatten each project's api-lib relations into implements/uses ApiRef lists. */\n private collectDecls(): ScanDecl[] {\n const decls: ScanDecl[] = [];\n for (const name of Array.from(this.scan.relationsByProject.keys()).sort()) {\n const relations = this.scan.relationsByProject.get(name)!;\n const implementsApis: ApiRef[] = [];\n const usesApis: ApiRef[] = [];\n for (const owner of Object.keys(relations)) {\n implementsApis.push(...relations[owner].implements);\n usesApis.push(...relations[owner].uses);\n }\n if (implementsApis.length > 0 || usesApis.length > 0) {\n decls.push({ name, implementsApis: sortApiRefs(implementsApis), usesApis: sortApiRefs(usesApis) });\n }\n }\n return decls;\n }\n\n /** apiClassName -> { implementedBy, usedBy, type }. */\n private buildApis(decls: ScanDecl[]): Map<string, RuntimeApi> {\n const apis = new Map<string, RuntimeApi>();\n const ensure = (api: string, type: ApiTransport): RuntimeApi => {\n let entry = apis.get(api);\n if (!entry) {\n entry = { implementedBy: [], usedBy: [], type };\n apis.set(api, entry);\n }\n return entry;\n };\n for (const decl of decls) {\n for (const ref of decl.implementsApis) ensure(ref.api, ref.type).implementedBy.push(decl.name);\n for (const ref of decl.usesApis) ensure(ref.api, ref.type).usedBy.push(decl.name);\n }\n for (const entry of apis.values()) {\n entry.implementedBy.sort();\n entry.usedBy.sort();\n }\n return apis;\n }\n\n /** Inferred edges U -> I via api A, split by transport; plus uses with no implementer. */\n private buildEdges(decls: ScanDecl[], apis: Map<string, RuntimeApi>): EdgeResult {\n const viaByKey = new Map<string, Set<string>>();\n const unresolved: RuntimeUnresolved[] = [];\n for (const decl of decls) {\n for (const ref of decl.usesApis) {\n const implementers = apis.get(ref.api)?.implementedBy ?? [];\n if (implementers.length === 0) {\n unresolved.push({ service: decl.name, api: ref.api });\n continue;\n }\n for (const target of implementers) {\n if (target === decl.name) continue;\n const key = `${decl.name}\u0000${target}\u0000${ref.type}`;\n if (!viaByKey.has(key)) viaByKey.set(key, new Set());\n viaByKey.get(key)!.add(ref.api);\n }\n }\n }\n return { edges: this.edgesFromKeys(viaByKey), unresolved: sortUnresolved(unresolved) };\n }\n\n private edgesFromKeys(viaByKey: Map<string, Set<string>>): RuntimeEdge[] {\n const edges: RuntimeEdge[] = [];\n for (const key of viaByKey.keys()) {\n const parts = key.split('\u0000');\n edges.push({ from: parts[0], to: parts[1], via: Array.from(viaByKey.get(key)!).sort(), type: parts[2] as ApiTransport });\n }\n edges.sort(\n (a: RuntimeEdge, b: RuntimeEdge) =>\n a.from.localeCompare(b.from) || a.to.localeCompare(b.to) || (a.type ?? '').localeCompare(b.type ?? ''),\n );\n return edges;\n }\n\n private buildServices(decls: ScanDecl[], edges: RuntimeEdge[]): Record<string, RuntimeService> {\n const services: Record<string, RuntimeService> = {};\n for (const decl of decls) {\n const dependsOn = Array.from(\n new Set(edges.filter((e: RuntimeEdge) => e.from === decl.name).map((e: RuntimeEdge) => e.to)),\n ).sort();\n services[decl.name] = {\n level: 0,\n implements: decl.implementsApis.map((r: ApiRef) => r.api),\n uses: decl.usesApis.map((r: ApiRef) => r.api),\n dependsOn,\n };\n if (this.hiddenProjects.has(decl.name)) services[decl.name].drawOnGraph = false;\n }\n const levels = assignLevels(adjacencyFromEdges(Object.keys(services), edges));\n for (const name of Object.keys(services)) services[name].level = levels[name] ?? 0;\n return services;\n }\n}\n\n/**\n * Assemble the runtime graph from the source scan (the derived apiRelations).\n * `hiddenProjects` (drawOnGraph:false, defaults to none) are kept in the graph\n * but flagged so the runtime visualizer omits their nodes + edges.\n */\n// webpieces-disable no-function-outside-class -- module entry point, mirrors assembleRuntimeGraph\nexport function assembleRuntimeGraphFromScan(\n scan: ApiScanResult,\n hiddenProjects: Set<string> = new Set<string>()\n): RuntimeGraph {\n return new ScanRuntimeAssembler(scan, hiddenProjects).assemble();\n}\n\n// webpieces-disable no-function-outside-class -- pure sort helper, matches the sibling helpers in this file\nfunction sortUnresolved(unresolved: RuntimeUnresolved[]): RuntimeUnresolved[] {\n return [...unresolved].sort(\n (a: RuntimeUnresolved, b: RuntimeUnresolved) => a.service.localeCompare(b.service) || a.api.localeCompare(b.api),\n );\n}\n\n/** Deterministic JSON (sorted keys + arrays already sorted during assembly). */\nfunction formatRuntimeJson(graph: RuntimeGraph): string {\n return JSON.stringify(graph, null, 4) + '\\n';\n}\n\nexport function saveRuntimeGraph(\n graph: RuntimeGraph,\n workspaceRoot: string,\n graphPath: string = DEFAULT_RUNTIME_GRAPH_PATH,\n): void {\n const fullPath = path.join(workspaceRoot, graphPath);\n const dir = path.dirname(fullPath);\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n fs.writeFileSync(fullPath, formatRuntimeJson(graph), 'utf-8');\n}\n\nexport function runtimeGraphFileExists(\n workspaceRoot: string,\n graphPath: string = DEFAULT_RUNTIME_GRAPH_PATH,\n): boolean {\n return fs.existsSync(path.join(workspaceRoot, graphPath));\n}\n\nexport function loadRuntimeGraph(\n workspaceRoot: string,\n graphPath: string = DEFAULT_RUNTIME_GRAPH_PATH,\n): RuntimeGraph | null {\n const fullPath = path.join(workspaceRoot, graphPath);\n if (!fs.existsSync(fullPath)) return null;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return JSON.parse(fs.readFileSync(fullPath, 'utf-8')) as RuntimeGraph;\n } catch (err: unknown) {\n const error = toError(err);\n throw new Error(`Failed to load runtime graph from ${fullPath}`, { cause: error });\n }\n}\n\n/** Serialize for an in-memory equality check (matches the on-disk format). */\nexport function serializeRuntimeGraph(graph: RuntimeGraph): string {\n return formatRuntimeJson(graph);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runtime-graph.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/runtime-graph.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AA2EH,4CAEC;AAqJD,gDAKC;AAcD,4CASC;AAED,wDAKC;AAED,4CAaC;AAGD,sDAEC;;AAvRD,+CAAyB;AACzB,mDAA6B;AAC7B,iDAAwD;AAGxD,6DAAwD;AACxD,wCAAqC;AA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AAC9D,CAAC;AAED,SAAgB,gBAAgB,CAC5B,aAAqB,EACrB,YAAoB,kCAA0B;IAE9C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACrD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,8DAA8D;IAC9D,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAiB,CAAC;IAC1E,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,IAAA,iBAAO,EAAC,GAAG,CAAC,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,qCAAqC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACvF,CAAC;AACL,CAAC;AAED,8EAA8E;AAC9E,SAAgB,qBAAqB,CAAC,KAAmB;IACrD,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC","sourcesContent":["/**\n * Runtime Graph\n *\n * Derives the runtime microservice graph SOLELY from architecture/dependencies.json\n * (the single source of truth): each project's `apiRelations` carry which api\n * classes it implements/uses and their transport (rpc | pubsub). Both\n * `architecture:generate` and `architecture:validate-runtime-architecture` call\n * the SAME `deriveRuntimeGraph`, so the committed graph and the validated graph\n * can never diverge.\n *\n * The runtime edge Z -> X (Z depends on X at runtime) is INFERRED: Z `uses` api\n * Y and X `implements` api Y. This edge does not exist in the compile-time\n * dependencies.json (both Z and X only compile-depend on the api library Y).\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { sortGraphTopologically } from './graph-sorter';\nimport type { EnhancedGraph } from './graph-sorter';\nimport type { ApiRef, ApiTransport } from './api-usage/api-relations';\nimport { sortApiRefs } from './api-usage/api-relations';\nimport { toError } from '../toError';\n\nexport const DEFAULT_RUNTIME_GRAPH_PATH = 'architecture/runtime-dependencies.json';\n\nexport interface RuntimeService {\n level: number;\n implements: string[];\n uses: string[];\n dependsOn: string[];\n /**\n * When false, this service is hidden from the rendered runtime graph (its\n * node AND every edge touching it are omitted from the HTML/DOT). It stays\n * in runtime-dependencies.json so the data view is complete. Absent means\n * drawn (the default). Mirrors GraphEntry.drawOnGraph from the `drawOnGraph:`\n * nx tag.\n */\n drawOnGraph?: boolean;\n}\n\nexport interface RuntimeApi {\n implementedBy: string[];\n usedBy: string[];\n /** Transport of this API — 'rpc' (direct call) or 'pubsub' (delivered through a queue). */\n type?: ApiTransport;\n}\n\nexport interface RuntimeEdge {\n from: string;\n to: string;\n via: string[];\n /**\n * Transport of this edge. 'rpc' → a direct call arrow. 'pubsub' → the producer enqueues and the\n * consumer is delivered later, so the runtime viz draws it as producer → QUEUE → consumer.\n * Edges are split by transport, so every edge is a single kind.\n */\n type?: ApiTransport;\n}\n\nexport interface RuntimeUnresolved {\n service: string;\n api: string;\n}\n\nexport interface RuntimeGraph {\n services: Record<string, RuntimeService>;\n apis: Record<string, RuntimeApi>;\n runtimeEdges: RuntimeEdge[];\n unresolvedUses: RuntimeUnresolved[];\n}\n\ninterface EdgeResult {\n edges: RuntimeEdge[];\n unresolved: RuntimeUnresolved[];\n}\n\n/** Adjacency (service -> [targets]) used for leveling + cycle checks. */\nfunction adjacencyFromEdges(serviceNames: string[], edges: RuntimeEdge[]): Record<string, string[]> {\n const adj: Record<string, string[]> = {};\n for (const name of serviceNames) adj[name] = [];\n for (const edge of edges) {\n if (!adj[edge.from]) adj[edge.from] = [];\n adj[edge.from].push(edge.to);\n }\n return adj;\n}\n\n/** Adjacency (service -> [targets]) from a loaded runtime graph. */\nexport function runtimeAdjacency(graph: RuntimeGraph): Record<string, string[]> {\n return adjacencyFromEdges(Object.keys(graph.services), graph.runtimeEdges);\n}\n\n/** Assign levels via topological sort; falls back to level 0 when a cycle exists. */\nfunction assignLevels(adjacency: Record<string, string[]>): Record<string, number> {\n const levels: Record<string, number> = {};\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const sorted = sortGraphTopologically(adjacency);\n for (const name of Object.keys(sorted)) levels[name] = sorted[name].level;\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n for (const name of Object.keys(adjacency)) levels[name] = 0;\n }\n return levels;\n}\n\n/** One project's implements/uses at api-CLASS granularity, from dependencies.json apiRelations. */\ninterface ScanDecl {\n name: string;\n implementsApis: ApiRef[];\n usesApis: ApiRef[];\n}\n\n/**\n * Derives the runtime microservice graph from architecture/dependencies.json `apiRelations`:\n * implementers × users per API, split by transport. An rpc edge is a direct call; a pubsub edge flows\n * through a queue (drawn producer → queue → consumer by the visualizer).\n */\nclass RuntimeGraphDeriver {\n constructor(\n private readonly projects: EnhancedGraph,\n /** Project names tagged drawOnGraph:false — kept in the JSON but flagged so the viz omits them. */\n private readonly hiddenProjects: Set<string>\n ) {}\n\n assemble(): RuntimeGraph {\n const decls = this.collectDecls();\n const apis = this.buildApis(decls);\n const edgeResult = this.buildEdges(decls, apis);\n const services = this.buildServices(decls, edgeResult.edges);\n const apisObj: Record<string, RuntimeApi> = {};\n for (const api of Array.from(apis.keys()).sort()) apisObj[api] = apis.get(api)!;\n return { services, apis: apisObj, runtimeEdges: edgeResult.edges, unresolvedUses: edgeResult.unresolved };\n }\n\n /** Flatten each project's api-lib relations into implements/uses ApiRef lists. */\n private collectDecls(): ScanDecl[] {\n const decls: ScanDecl[] = [];\n for (const name of Object.keys(this.projects).sort()) {\n const relations = this.projects[name].apiRelations;\n if (relations === undefined) continue;\n const implementsApis: ApiRef[] = [];\n const usesApis: ApiRef[] = [];\n for (const owner of Object.keys(relations)) {\n implementsApis.push(...relations[owner].implements);\n usesApis.push(...relations[owner].uses);\n }\n if (implementsApis.length > 0 || usesApis.length > 0) {\n decls.push({ name, implementsApis: sortApiRefs(implementsApis), usesApis: sortApiRefs(usesApis) });\n }\n }\n return decls;\n }\n\n /** apiClassName -> { implementedBy, usedBy, type }. */\n private buildApis(decls: ScanDecl[]): Map<string, RuntimeApi> {\n const apis = new Map<string, RuntimeApi>();\n const ensure = (api: string, type: ApiTransport): RuntimeApi => {\n let entry = apis.get(api);\n if (!entry) {\n entry = { implementedBy: [], usedBy: [], type };\n apis.set(api, entry);\n }\n return entry;\n };\n for (const decl of decls) {\n for (const ref of decl.implementsApis) ensure(ref.api, ref.type).implementedBy.push(decl.name);\n for (const ref of decl.usesApis) ensure(ref.api, ref.type).usedBy.push(decl.name);\n }\n for (const entry of apis.values()) {\n entry.implementedBy.sort();\n entry.usedBy.sort();\n }\n return apis;\n }\n\n /** Inferred edges U -> I via api A, split by transport; plus uses with no implementer. */\n private buildEdges(decls: ScanDecl[], apis: Map<string, RuntimeApi>): EdgeResult {\n const viaByKey = new Map<string, Set<string>>();\n const unresolved: RuntimeUnresolved[] = [];\n for (const decl of decls) {\n for (const ref of decl.usesApis) {\n const implementers = apis.get(ref.api)?.implementedBy ?? [];\n if (implementers.length === 0) {\n unresolved.push({ service: decl.name, api: ref.api });\n continue;\n }\n for (const target of implementers) {\n if (target === decl.name) continue;\n const key = `${decl.name}\u0000${target}\u0000${ref.type}`;\n if (!viaByKey.has(key)) viaByKey.set(key, new Set());\n viaByKey.get(key)!.add(ref.api);\n }\n }\n }\n return { edges: this.edgesFromKeys(viaByKey), unresolved: sortUnresolved(unresolved) };\n }\n\n private edgesFromKeys(viaByKey: Map<string, Set<string>>): RuntimeEdge[] {\n const edges: RuntimeEdge[] = [];\n for (const key of viaByKey.keys()) {\n const parts = key.split('\u0000');\n edges.push({ from: parts[0], to: parts[1], via: Array.from(viaByKey.get(key)!).sort(), type: parts[2] as ApiTransport });\n }\n edges.sort(\n (a: RuntimeEdge, b: RuntimeEdge) =>\n a.from.localeCompare(b.from) || a.to.localeCompare(b.to) || (a.type ?? '').localeCompare(b.type ?? ''),\n );\n return edges;\n }\n\n private buildServices(decls: ScanDecl[], edges: RuntimeEdge[]): Record<string, RuntimeService> {\n const services: Record<string, RuntimeService> = {};\n for (const decl of decls) {\n const dependsOn = Array.from(\n new Set(edges.filter((e: RuntimeEdge) => e.from === decl.name).map((e: RuntimeEdge) => e.to)),\n ).sort();\n services[decl.name] = {\n level: 0,\n implements: decl.implementsApis.map((r: ApiRef) => r.api),\n uses: decl.usesApis.map((r: ApiRef) => r.api),\n dependsOn,\n };\n if (this.hiddenProjects.has(decl.name)) services[decl.name].drawOnGraph = false;\n }\n const levels = assignLevels(adjacencyFromEdges(Object.keys(services), edges));\n for (const name of Object.keys(services)) services[name].level = levels[name] ?? 0;\n return services;\n }\n}\n\n/**\n * Derive the runtime graph from dependencies.json's project `apiRelations` — the\n * single source of truth shared by generate + validate. `hiddenProjects`\n * (drawOnGraph:false, defaults to none) are kept in the graph but flagged so the\n * runtime visualizer omits their nodes + edges.\n */\n// webpieces-disable no-function-outside-class -- module entry point for the runtime graph derivation\nexport function deriveRuntimeGraph(\n projects: EnhancedGraph,\n hiddenProjects: Set<string> = new Set<string>()\n): RuntimeGraph {\n return new RuntimeGraphDeriver(projects, hiddenProjects).assemble();\n}\n\n// webpieces-disable no-function-outside-class -- pure sort helper, matches the sibling helpers in this file\nfunction sortUnresolved(unresolved: RuntimeUnresolved[]): RuntimeUnresolved[] {\n return [...unresolved].sort(\n (a: RuntimeUnresolved, b: RuntimeUnresolved) => a.service.localeCompare(b.service) || a.api.localeCompare(b.api),\n );\n}\n\n/** Deterministic JSON (sorted keys + arrays already sorted during assembly). */\nfunction formatRuntimeJson(graph: RuntimeGraph): string {\n return JSON.stringify(graph, null, 4) + '\\n';\n}\n\nexport function saveRuntimeGraph(\n graph: RuntimeGraph,\n workspaceRoot: string,\n graphPath: string = DEFAULT_RUNTIME_GRAPH_PATH,\n): void {\n const fullPath = path.join(workspaceRoot, graphPath);\n const dir = path.dirname(fullPath);\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n fs.writeFileSync(fullPath, formatRuntimeJson(graph), 'utf-8');\n}\n\nexport function runtimeGraphFileExists(\n workspaceRoot: string,\n graphPath: string = DEFAULT_RUNTIME_GRAPH_PATH,\n): boolean {\n return fs.existsSync(path.join(workspaceRoot, graphPath));\n}\n\nexport function loadRuntimeGraph(\n workspaceRoot: string,\n graphPath: string = DEFAULT_RUNTIME_GRAPH_PATH,\n): RuntimeGraph | null {\n const fullPath = path.join(workspaceRoot, graphPath);\n if (!fs.existsSync(fullPath)) return null;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return JSON.parse(fs.readFileSync(fullPath, 'utf-8')) as RuntimeGraph;\n } catch (err: unknown) {\n const error = toError(err);\n throw new Error(`Failed to load runtime graph from ${fullPath}`, { cause: error });\n }\n}\n\n/** Serialize for an in-memory equality check (matches the on-disk format). */\nexport function serializeRuntimeGraph(graph: RuntimeGraph): string {\n return formatRuntimeJson(graph);\n}\n"]}
|
package/src/plugin.js
CHANGED
|
@@ -91,7 +91,7 @@ async function createNodesFunction(projectFiles, options, context) {
|
|
|
91
91
|
const results = [];
|
|
92
92
|
// Add workspace-level architecture targets
|
|
93
93
|
addArchitectureProject(results, projectFiles, opts, context);
|
|
94
|
-
// Add per-project targets (circular-deps, ci,
|
|
94
|
+
// Add per-project targets (circular-deps, ci, di-graph)
|
|
95
95
|
addPerProjectTargets(results, projectFiles, opts, context);
|
|
96
96
|
return results;
|
|
97
97
|
}
|
|
@@ -187,11 +187,6 @@ function buildPerProjectTargets(isProjectJson, projectRoot, opts) {
|
|
|
187
187
|
targets[targetName] = createCircularDepsTarget(projectRoot, targetName);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
// Add per-project runtime-marker validation (validates this project's
|
|
191
|
-
// service-contract.json against its own api-project deps, independently).
|
|
192
|
-
if (isProjectJson && opts.workspace.validations.runtimeArchitecture) {
|
|
193
|
-
targets['validate-runtime-markers'] = (0, runtime_targets_1.createValidateRuntimeMarkersTarget)();
|
|
194
|
-
}
|
|
195
190
|
// Per-project DI design DAG: regenerate design.json/design.md on every build,
|
|
196
191
|
// then gate the build on the committed copies being current.
|
|
197
192
|
if (isProjectJson && opts.workspace.validations.diGraph) {
|
package/src/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../../packages/tooling/nx-webpieces-rules/src/plugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAiNH,sDASC;AAxND,+BAAqC;AACrC,2BAAgC;AAQhC,uDAI2B;AAC3B,6DAAyD;AACzD,yDAG4B;AAqE5B,MAAM,eAAe,GAAwC;IACzD,YAAY,EAAE;QACV,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,gCAAgC;QAC5C,eAAe,EAAE,EAAE;KACtB;IACD,SAAS,EAAE;QACP,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,OAAO;QACrB,SAAS,EAAE,gCAAgC;QAC3C,WAAW,EAAE;YACT,QAAQ,EAAE,IAAI;YACd,4EAA4E;YAC5E,yEAAyE;YACzE,4EAA4E;YAC5E,eAAe,EAAE,KAAK;YACtB,qBAAqB,EAAE,IAAI;YAC3B,mBAAmB,EAAE,IAAI;YACzB,kBAAkB,EAAE,IAAI;YACxB,uBAAuB,EAAE,IAAI;YAC7B,qBAAqB,EAAE,IAAI;YAC3B,sBAAsB,EAAE,IAAI;YAC5B,eAAe,EAAE,IAAI;YACrB,gBAAgB,EAAE,IAAI;YACtB,mBAAmB,EAAE,IAAI;YACzB,oBAAoB,EAAE,IAAI;YAC1B,iBAAiB,EAAE,IAAI;YACvB,OAAO,EAAE,IAAI;YACb,kBAAkB,EAAE,EAAE;YACtB,6BAA6B,EAAE,EAAE;YACjC,qBAAqB,EAAE,GAAG;YAC1B,cAAc,EAAE,QAAQ;SAC3B;QACD,QAAQ,EAAE;YACN,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;YACf,gBAAgB,EAAE,IAAI;SACzB;KACJ;CACJ,CAAC;AAEF,SAAS,gBAAgB,CAC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;KACJ,CAAC;AACN,CAAC;AAED;;GAEG;AACH,SAAS,UAAU,CAAC,WAAmB,EAAE,eAAyB;IAC9D,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,oEAAoE;IACpE,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QACpC,gCAAgC;QAChC,MAAM,YAAY,GAAG,OAAO;aACvB,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,sBAAsB;aAC7C,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,gCAAgC;QAE9D,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,YAAY,GAAG,CAAC,CAAC;QAC9C,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;GAEG;AACH,kBAAe,EAAE,aAAa,EAAb,qBAAa,EAAE,CAAC","sourcesContent":["/**\n * Unified Nx Inference Plugin for @webpieces/nx-webpieces-rules\n *\n * This plugin automatically creates targets for:\n * 1. Workspace-level architecture validation (generate, visualize, validate-*)\n * 2. Per-project circular dependency checking\n *\n * Install with: nx add @webpieces/nx-webpieces-rules\n *\n * Usage:\n * Add to nx.json plugins array:\n * {\n * \"plugins\": [\"@webpieces/nx-webpieces-rules\"]\n * }\n *\n * Then all targets appear automatically without manual project.json configuration.\n */\n\nimport { dirname, join } from 'path';\nimport { existsSync } from 'fs';\nimport type {\n CreateNodesV2,\n CreateNodesContextV2,\n CreateNodesResultV2,\n CreateNodesResult,\n TargetConfiguration,\n} from '@nx/devkit';\nimport {\n createVisualizeRuntimeTarget,\n createValidateRuntimeArchitectureTarget,\n createValidateRuntimeMarkersTarget,\n} from './runtime-targets';\nimport { ValidationTargets } from './validation-targets';\nimport {\n createDiGraphGenerateTarget,\n createValidateDiGraphUnchangedTarget,\n} from './di-graph-targets';\n\n/**\n * Circular dependency checking options\n */\nexport interface CircularDepsOptions {\n enabled?: boolean;\n targetName?: string;\n excludePatterns?: string[];\n}\n\n/**\n * Validation options for architecture checks\n */\nexport interface ValidationOptions {\n noCycles?: boolean;\n noSkipLevelDeps?: boolean;\n architectureUnchanged?: boolean;\n validatePackageJson?: boolean;\n validateNewMethods?: boolean;\n validateModifiedMethods?: boolean;\n validateModifiedFiles?: boolean;\n validateVersionsLocked?: boolean;\n validateTsInSrc?: boolean;\n validateNxWiring?: boolean;\n runtimeArchitecture?: boolean;\n validateApiRelations?: boolean;\n validateApiLibTag?: boolean;\n diGraph?: boolean;\n newMethodsMaxLines?: number;\n modifiedAndNewMethodsMaxLines?: number;\n modifiedFilesMaxLines?: number;\n /**\n * Validation mode for method/file size limits:\n * - STRICT: All limits enforced, disable comments ignored\n * - NORMAL: Limits enforced, disable comments with dates work\n * - OFF: Skip size validations entirely (for fast iteration)\n */\n validationMode?: 'STRICT' | 'NORMAL' | 'OFF';\n}\n\n/**\n * Feature flags for workspace targets\n */\nexport interface FeatureOptions {\n generate?: boolean;\n visualize?: boolean;\n visualizeRuntime?: boolean;\n}\n\n/**\n * Workspace-level configuration options\n */\nexport interface WorkspaceOptions {\n enabled?: boolean;\n targetPrefix?: string;\n graphPath?: string;\n validations?: ValidationOptions;\n features?: FeatureOptions;\n}\n\n/**\n * Configuration for @webpieces/nx-webpieces-rules Nx plugin\n */\nexport interface ArchitecturePluginOptions {\n circularDeps?: CircularDepsOptions;\n workspace?: WorkspaceOptions;\n}\n\nconst DEFAULT_OPTIONS: Required<ArchitecturePluginOptions> = {\n circularDeps: {\n enabled: true,\n targetName: 'validate-no-file-import-cycles',\n excludePatterns: [],\n },\n workspace: {\n enabled: true,\n targetPrefix: 'arch:',\n graphPath: 'architecture/dependencies.json',\n validations: {\n noCycles: true,\n // Retired: the architecture graph is now auto-reduced in `generate`, so the\n // committed graph can never contain a skip-level edge. Defaults off; the\n // executor is a no-op kept for one release. See validate-no-skiplevel-deps.\n noSkipLevelDeps: false,\n architectureUnchanged: true,\n validatePackageJson: true,\n validateNewMethods: true,\n validateModifiedMethods: true,\n validateModifiedFiles: true,\n validateVersionsLocked: true,\n validateTsInSrc: true,\n validateNxWiring: true,\n runtimeArchitecture: true,\n validateApiRelations: true,\n validateApiLibTag: true,\n diGraph: true,\n newMethodsMaxLines: 30,\n modifiedAndNewMethodsMaxLines: 80,\n modifiedFilesMaxLines: 900,\n validationMode: 'NORMAL',\n },\n features: {\n generate: true,\n visualize: true,\n visualizeRuntime: true,\n },\n },\n};\n\nfunction normalizeOptions(\n options: ArchitecturePluginOptions | undefined,\n): Required<ArchitecturePluginOptions> {\n const circularDeps = {\n ...DEFAULT_OPTIONS.circularDeps,\n ...options?.circularDeps,\n };\n\n const workspace = {\n ...DEFAULT_OPTIONS.workspace,\n ...options?.workspace,\n validations: {\n ...DEFAULT_OPTIONS.workspace.validations,\n ...options?.workspace?.validations,\n },\n features: {\n ...DEFAULT_OPTIONS.workspace.features,\n ...options?.workspace?.features,\n },\n };\n\n return {\n circularDeps,\n workspace,\n } as Required<ArchitecturePluginOptions>;\n}\n\nasync function createNodesFunction(\n projectFiles: readonly string[],\n options: ArchitecturePluginOptions | undefined,\n context: CreateNodesContextV2,\n): Promise<CreateNodesResultV2> {\n const opts = normalizeOptions(options);\n const results: CreateNodesResultV2 = [];\n\n // Add workspace-level architecture targets\n addArchitectureProject(results, projectFiles, opts, context);\n\n // Add per-project targets (circular-deps, ci, runtime-markers)\n addPerProjectTargets(results, projectFiles, opts, context);\n\n return results;\n}\n\nfunction addArchitectureProject(\n results: CreateNodesResultV2,\n projectFiles: readonly string[],\n opts: Required<ArchitecturePluginOptions>,\n context: CreateNodesContextV2,\n): void {\n if (!opts.workspace.enabled) return;\n\n const archDirPath = join(context.workspaceRoot, 'architecture');\n if (!existsSync(archDirPath)) return;\n\n const workspaceTargets = createWorkspaceTargetsWithoutPrefix(opts);\n if (Object.keys(workspaceTargets).length === 0) return;\n\n const result: CreateNodesResult = {\n projects: {\n architecture: {\n name: 'architecture',\n root: 'architecture',\n targets: workspaceTargets,\n },\n },\n };\n\n const firstProjectFile = projectFiles[0];\n if (firstProjectFile) {\n results.push([firstProjectFile, result] as const);\n }\n}\n\n\n// A project sits inside a NESTED git repo (e.g. a clone under repositories/) when any of its\n// ancestor dirs — up to but NOT including the workspace root — contains a `.git`. Such projects are\n// separate repos, not part of THIS workspace's graph, so they must not get inferred targets (that is\n// what drags foreign clones into `nx affected`). Same repo-boundary signal the AI guards use.\nexport function isInsideNestedGitRepo(workspaceRoot: string, projectRoot: string): boolean {\n let dir = projectRoot;\n while (dir && dir !== '.' && dir !== '/') {\n if (existsSync(join(workspaceRoot, dir, '.git'))) return true;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return false;\n}\n\nfunction addPerProjectTargets(\n results: CreateNodesResultV2,\n projectFiles: readonly string[],\n opts: Required<ArchitecturePluginOptions>,\n context: CreateNodesContextV2,\n): void {\n // Track processed project roots to avoid duplicates when both files exist\n const processedRoots = new Set<string>();\n\n for (const projectFile of projectFiles) {\n const isProjectJson = projectFile.endsWith('project.json');\n const isPackageJson = projectFile.endsWith('package.json');\n\n if (!isProjectJson && !isPackageJson) continue;\n\n const projectRoot = dirname(projectFile);\n\n // Skip root (workspace manifest, not a project)\n if (projectRoot === '.') continue;\n\n // Skip projects inside a nested git repo (vendored clones under repositories/): they are\n // separate repos and must not be swept into this workspace's `nx affected` graph.\n if (isInsideNestedGitRepo(context.workspaceRoot, projectRoot)) continue;\n\n // Skip if we've already processed this project root\n if (processedRoots.has(projectRoot)) continue;\n\n // For package.json, skip if project.json also exists in same directory\n // (prefer project.json - it will be processed separately)\n if (isPackageJson) {\n const projectJsonPath = join(context.workspaceRoot, projectRoot, 'project.json');\n if (existsSync(projectJsonPath)) continue;\n }\n\n processedRoots.add(projectRoot);\n\n const targets = buildPerProjectTargets(isProjectJson, projectRoot, opts);\n\n if (Object.keys(targets).length === 0) continue;\n\n const result: CreateNodesResult = {\n projects: {\n [projectRoot]: {\n targets,\n },\n },\n };\n\n results.push([projectFile, result] as const);\n }\n}\n\n/**\n * Build the target map for one project. Most targets are project.json-only\n * (package.json-only projects may not have TypeScript source); `ci` goes on all.\n */\nfunction buildPerProjectTargets(\n isProjectJson: boolean,\n projectRoot: string,\n opts: Required<ArchitecturePluginOptions>,\n): Record<string, TargetConfiguration> {\n const targets: Record<string, TargetConfiguration> = {};\n\n // Add circular-deps target ONLY for project.json projects\n if (isProjectJson && opts.circularDeps.enabled) {\n if (!isExcluded(projectRoot, opts.circularDeps.excludePatterns!)) {\n const targetName = opts.circularDeps.targetName!;\n targets[targetName] = createCircularDepsTarget(projectRoot, targetName);\n }\n }\n\n // Add per-project runtime-marker validation (validates this project's\n // service-contract.json against its own api-project deps, independently).\n if (isProjectJson && opts.workspace.validations!.runtimeArchitecture) {\n targets['validate-runtime-markers'] = createValidateRuntimeMarkersTarget();\n }\n\n // Per-project DI design DAG: regenerate design.json/design.md on every build,\n // then gate the build on the committed copies being current.\n if (isProjectJson && opts.workspace.validations!.diGraph) {\n targets['di-graph-generate'] = createDiGraphGenerateTarget();\n targets['validate-di-graph-unchanged'] = createValidateDiGraphUnchangedTarget();\n }\n\n // Add ci target to ALL projects (both project.json and package.json)\n targets['ci'] = createCiTarget();\n\n return targets;\n}\n\n/**\n * Nx V2 Inference Plugin\n * Matches project.json and package.json files to create targets\n */\nexport const createNodesV2: CreateNodesV2<ArchitecturePluginOptions> = [\n // Pattern to match project.json and package.json files\n '**/{project,package}.json',\n\n // Inference function\n createNodesFunction,\n];\n\n/**\n * Build list of enabled validation target names for validate-complete dependency chain\n */\nfunction buildValidationTargetsList(\n validations: Required<ArchitecturePluginOptions>['workspace']['validations'],\n): string[] {\n const targets: string[] = [];\n if (validations!.noCycles) targets.push('validate-no-architecture-cycles');\n if (validations!.architectureUnchanged) targets.push('validate-architecture-unchanged');\n if (validations!.noSkipLevelDeps) targets.push('validate-no-skiplevel-deps');\n if (validations!.validatePackageJson) targets.push('validate-packagejson');\n // Use combined validate-code instead of 3 separate targets\n if (\n validations!.validateNewMethods ||\n validations!.validateModifiedMethods ||\n validations!.validateModifiedFiles\n ) {\n targets.push('validate-code');\n }\n if (validations!.validateVersionsLocked) targets.push('validate-versions-locked');\n if (validations!.validateTsInSrc) targets.push('validate-ts-in-src');\n if (validations!.validateNxWiring) targets.push('validate-nx-wiring');\n if (validations!.runtimeArchitecture) targets.push('validate-runtime-architecture');\n if (validations!.validateApiRelations) targets.push('validate-api-relations');\n if (validations!.validateApiLibTag) targets.push('validate-api-lib-tag');\n return targets;\n}\n\n/**\n * Create workspace-level architecture validation targets WITHOUT prefix\n * Used for virtual 'architecture' project\n */\nfunction createWorkspaceTargetsWithoutPrefix(\n opts: Required<ArchitecturePluginOptions>,\n): Record<string, TargetConfiguration> {\n const targets: Record<string, TargetConfiguration> = {};\n const graphPath = opts.workspace.graphPath!;\n const validations = opts.workspace.validations!;\n // One ValidationTargets instance, injected below to build each target config.\n const targetFactory = new ValidationTargets();\n\n // Add help target (always available)\n targets['help'] = createHelpTarget();\n\n if (opts.workspace.features!.generate) {\n targets['generate'] = createGenerateTarget(graphPath);\n }\n if (opts.workspace.features!.visualize) {\n targets['visualize'] = createVisualizeTargetWithoutPrefix(graphPath);\n }\n if (opts.workspace.features!.visualizeRuntime) {\n targets['visualize-runtime'] = createVisualizeRuntimeTarget();\n }\n if (validations.noCycles) {\n targets['validate-no-architecture-cycles'] = targetFactory.noCycles();\n }\n if (validations.architectureUnchanged) {\n targets['validate-architecture-unchanged'] = createValidateUnchangedTarget(graphPath);\n }\n if (validations.noSkipLevelDeps) {\n targets['validate-no-skiplevel-deps'] = targetFactory.noSkipLevel();\n }\n if (validations.validatePackageJson) {\n targets['validate-packagejson'] = targetFactory.packageJson();\n }\n // Use combined validate-code instead of 3 separate targets\n // Options come from webpieces.config.json at the workspace root\n // (loaded via @webpieces/rules-config; same source of truth as @webpieces/ai-hook-rules)\n if (\n validations.validateNewMethods ||\n validations.validateModifiedMethods ||\n validations.validateModifiedFiles\n ) {\n targets['validate-code'] = targetFactory.code();\n }\n if (validations.validateVersionsLocked) {\n targets['validate-versions-locked'] = targetFactory.versionsLocked();\n }\n if (validations.validateTsInSrc) {\n targets['validate-ts-in-src'] = targetFactory.tsInSrc();\n }\n if (validations.validateNxWiring) {\n targets['validate-nx-wiring'] = targetFactory.nxWiring();\n }\n if (validations.runtimeArchitecture) {\n targets['validate-runtime-architecture'] = createValidateRuntimeArchitectureTarget();\n }\n if (validations.validateApiRelations) {\n targets['validate-api-relations'] = targetFactory.apiRelations();\n }\n if (validations.validateApiLibTag) {\n targets['validate-api-lib-tag'] = targetFactory.apiLibTag();\n }\n\n // Add validate-complete target that runs all enabled validations\n const validationTargets = buildValidationTargetsList(validations);\n if (validationTargets.length > 0) {\n targets['validate-complete'] = createValidateCompleteTarget(validationTargets);\n }\n\n return targets;\n}\n\nfunction createGenerateTarget(graphPath: string): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:generate',\n cache: false,\n outputs: [\n '{workspaceRoot}/architecture/dependencies.json',\n '{workspaceRoot}/architecture/dependencies.html',\n '{workspaceRoot}/architecture/runtime-dependencies.json',\n ],\n options: { graphPath },\n metadata: {\n technologies: ['nx'],\n description:\n 'Generate the architecture dependency graph (+ clickable dependencies.html) and the runtime microservice graph',\n },\n };\n}\n\nfunction createVisualizeTargetWithoutPrefix(graphPath: string): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:visualize',\n dependsOn: ['generate'],\n options: { graphPath },\n metadata: {\n technologies: ['nx'],\n description: 'Generate visual representations of the architecture graph',\n },\n };\n}\n\nfunction createValidateUnchangedTarget(graphPath: string): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-architecture-unchanged',\n cache: false,\n inputs: ['default', '{workspaceRoot}/architecture/dependencies.json'],\n options: { graphPath },\n metadata: {\n technologies: ['nx'],\n description: 'Validate the architecture matches the saved blessed graph',\n },\n };\n}\n\nfunction createValidateNewMethodsTarget(\n maxLines: number,\n mode: 'STRICT' | 'NORMAL' | 'OFF',\n): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-new-methods',\n cache: false, // Don't cache - depends on git state\n inputs: ['default'],\n options: { max: maxLines, mode },\n metadata: {\n technologies: ['nx'],\n description: `Validate new methods do not exceed ${maxLines} lines (only runs in affected mode)`,\n },\n };\n}\n\nfunction createValidateModifiedMethodsTarget(\n maxLines: number,\n mode: 'STRICT' | 'NORMAL' | 'OFF',\n): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-modified-methods',\n cache: false, // Don't cache - depends on git state\n inputs: ['default'],\n options: { max: maxLines, mode },\n metadata: {\n technologies: ['nx'],\n description: `Validate new and modified methods do not exceed ${maxLines} lines (encourages gradual cleanup)`,\n },\n };\n}\n\nfunction createValidateModifiedFilesTarget(\n maxLines: number,\n mode: 'STRICT' | 'NORMAL' | 'OFF',\n): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-modified-files',\n cache: false, // Don't cache - depends on git state\n inputs: ['default'],\n options: { max: maxLines, mode },\n metadata: {\n technologies: ['nx'],\n description: `Validate modified files do not exceed ${maxLines} lines (encourages keeping files small)`,\n },\n };\n}\n\nfunction createValidateCompleteTarget(validationTargets: string[]): TargetConfiguration {\n return {\n executor: 'nx:noop',\n cache: true,\n dependsOn: validationTargets,\n metadata: {\n technologies: ['nx'],\n description: 'Run all architecture validations (cycles, unchanged, skip-level deps)',\n },\n };\n}\n\n/**\n * Create per-project ci target - Gradle-style composite target\n * Runs lint, build, and test in parallel\n * (with test depending on build via targetDefaults)\n *\n * NOTE: Type checking is done by the build target (@nx/js:tsc) during compilation.\n */\nfunction createCiTarget(): TargetConfiguration {\n return {\n executor: 'nx:noop',\n cache: true,\n dependsOn: ['lint', 'build', 'test'],\n metadata: {\n technologies: ['nx'],\n description: 'Run all CI checks: lint, build, and test (Gradle-style composite target)',\n },\n };\n}\n\nfunction createHelpTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:help',\n cache: false, // Never cache - always show help output\n metadata: {\n technologies: ['nx'],\n description: 'Display help for @webpieces/nx-webpieces-rules commands and targets',\n },\n };\n}\n\n/**\n * Create per-project circular dependency checking target.\n *\n * Uses the `validate-no-file-import-cycles` executor (which bundles madge as a\n * dependency) rather than a runtime `npx madge` fetch. The executor reads\n * webpieces.config.json so the gate can be turned on/off (`mode`) and\n * time-boxed (`ignoreModifiedUntilEpoch`) like every other webpieces rule.\n *\n * Note `projectRoot` is intentionally unused now — the executor derives the\n * project root from the Nx context — but the param is kept for call-site\n * symmetry with the rest of the per-project target factories.\n */\nfunction createCircularDepsTarget(_projectRoot: string, _targetName: string): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-no-file-import-cycles',\n cache: true,\n inputs: ['default'],\n outputs: [] as string[],\n metadata: {\n technologies: ['madge'],\n description: 'Check for circular file-import dependencies using madge',\n },\n };\n}\n\n/**\n * Check if a project should be excluded based on patterns\n */\nfunction isExcluded(projectRoot: string, excludePatterns: string[]): boolean {\n if (excludePatterns.length === 0) {\n return false;\n }\n\n // Simple glob matching (could be enhanced with minimatch if needed)\n return excludePatterns.some((pattern) => {\n // Convert glob pattern to regex\n const regexPattern = pattern\n .replace(/\\*\\*/g, '.*') // ** matches any path\n .replace(/\\*/g, '[^/]*'); // * matches any string except /\n\n const regex = new RegExp(`^${regexPattern}$`);\n return regex.test(projectRoot);\n });\n}\n\n/**\n * Export plugin as default for Nx\n */\nexport default { createNodesV2 };\n"]}
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../../packages/tooling/nx-webpieces-rules/src/plugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAgNH,sDASC;AAvND,+BAAqC;AACrC,2BAAgC;AAQhC,uDAG2B;AAC3B,6DAAyD;AACzD,yDAG4B;AAqE5B,MAA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IACnC,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;GAEG;AACH,kBAAe,EAAE,aAAa,EAAb,qBAAa,EAAE,CAAC","sourcesContent":["/**\n * Unified Nx Inference Plugin for @webpieces/nx-webpieces-rules\n *\n * This plugin automatically creates targets for:\n * 1. Workspace-level architecture validation (generate, visualize, validate-*)\n * 2. Per-project circular dependency checking\n *\n * Install with: nx add @webpieces/nx-webpieces-rules\n *\n * Usage:\n * Add to nx.json plugins array:\n * {\n * \"plugins\": [\"@webpieces/nx-webpieces-rules\"]\n * }\n *\n * Then all targets appear automatically without manual project.json configuration.\n */\n\nimport { dirname, join } from 'path';\nimport { existsSync } from 'fs';\nimport type {\n CreateNodesV2,\n CreateNodesContextV2,\n CreateNodesResultV2,\n CreateNodesResult,\n TargetConfiguration,\n} from '@nx/devkit';\nimport {\n createVisualizeRuntimeTarget,\n createValidateRuntimeArchitectureTarget,\n} from './runtime-targets';\nimport { ValidationTargets } from './validation-targets';\nimport {\n createDiGraphGenerateTarget,\n createValidateDiGraphUnchangedTarget,\n} from './di-graph-targets';\n\n/**\n * Circular dependency checking options\n */\nexport interface CircularDepsOptions {\n enabled?: boolean;\n targetName?: string;\n excludePatterns?: string[];\n}\n\n/**\n * Validation options for architecture checks\n */\nexport interface ValidationOptions {\n noCycles?: boolean;\n noSkipLevelDeps?: boolean;\n architectureUnchanged?: boolean;\n validatePackageJson?: boolean;\n validateNewMethods?: boolean;\n validateModifiedMethods?: boolean;\n validateModifiedFiles?: boolean;\n validateVersionsLocked?: boolean;\n validateTsInSrc?: boolean;\n validateNxWiring?: boolean;\n runtimeArchitecture?: boolean;\n validateApiRelations?: boolean;\n validateApiLibTag?: boolean;\n diGraph?: boolean;\n newMethodsMaxLines?: number;\n modifiedAndNewMethodsMaxLines?: number;\n modifiedFilesMaxLines?: number;\n /**\n * Validation mode for method/file size limits:\n * - STRICT: All limits enforced, disable comments ignored\n * - NORMAL: Limits enforced, disable comments with dates work\n * - OFF: Skip size validations entirely (for fast iteration)\n */\n validationMode?: 'STRICT' | 'NORMAL' | 'OFF';\n}\n\n/**\n * Feature flags for workspace targets\n */\nexport interface FeatureOptions {\n generate?: boolean;\n visualize?: boolean;\n visualizeRuntime?: boolean;\n}\n\n/**\n * Workspace-level configuration options\n */\nexport interface WorkspaceOptions {\n enabled?: boolean;\n targetPrefix?: string;\n graphPath?: string;\n validations?: ValidationOptions;\n features?: FeatureOptions;\n}\n\n/**\n * Configuration for @webpieces/nx-webpieces-rules Nx plugin\n */\nexport interface ArchitecturePluginOptions {\n circularDeps?: CircularDepsOptions;\n workspace?: WorkspaceOptions;\n}\n\nconst DEFAULT_OPTIONS: Required<ArchitecturePluginOptions> = {\n circularDeps: {\n enabled: true,\n targetName: 'validate-no-file-import-cycles',\n excludePatterns: [],\n },\n workspace: {\n enabled: true,\n targetPrefix: 'arch:',\n graphPath: 'architecture/dependencies.json',\n validations: {\n noCycles: true,\n // Retired: the architecture graph is now auto-reduced in `generate`, so the\n // committed graph can never contain a skip-level edge. Defaults off; the\n // executor is a no-op kept for one release. See validate-no-skiplevel-deps.\n noSkipLevelDeps: false,\n architectureUnchanged: true,\n validatePackageJson: true,\n validateNewMethods: true,\n validateModifiedMethods: true,\n validateModifiedFiles: true,\n validateVersionsLocked: true,\n validateTsInSrc: true,\n validateNxWiring: true,\n runtimeArchitecture: true,\n validateApiRelations: true,\n validateApiLibTag: true,\n diGraph: true,\n newMethodsMaxLines: 30,\n modifiedAndNewMethodsMaxLines: 80,\n modifiedFilesMaxLines: 900,\n validationMode: 'NORMAL',\n },\n features: {\n generate: true,\n visualize: true,\n visualizeRuntime: true,\n },\n },\n};\n\nfunction normalizeOptions(\n options: ArchitecturePluginOptions | undefined,\n): Required<ArchitecturePluginOptions> {\n const circularDeps = {\n ...DEFAULT_OPTIONS.circularDeps,\n ...options?.circularDeps,\n };\n\n const workspace = {\n ...DEFAULT_OPTIONS.workspace,\n ...options?.workspace,\n validations: {\n ...DEFAULT_OPTIONS.workspace.validations,\n ...options?.workspace?.validations,\n },\n features: {\n ...DEFAULT_OPTIONS.workspace.features,\n ...options?.workspace?.features,\n },\n };\n\n return {\n circularDeps,\n workspace,\n } as Required<ArchitecturePluginOptions>;\n}\n\nasync function createNodesFunction(\n projectFiles: readonly string[],\n options: ArchitecturePluginOptions | undefined,\n context: CreateNodesContextV2,\n): Promise<CreateNodesResultV2> {\n const opts = normalizeOptions(options);\n const results: CreateNodesResultV2 = [];\n\n // Add workspace-level architecture targets\n addArchitectureProject(results, projectFiles, opts, context);\n\n // Add per-project targets (circular-deps, ci, di-graph)\n addPerProjectTargets(results, projectFiles, opts, context);\n\n return results;\n}\n\nfunction addArchitectureProject(\n results: CreateNodesResultV2,\n projectFiles: readonly string[],\n opts: Required<ArchitecturePluginOptions>,\n context: CreateNodesContextV2,\n): void {\n if (!opts.workspace.enabled) return;\n\n const archDirPath = join(context.workspaceRoot, 'architecture');\n if (!existsSync(archDirPath)) return;\n\n const workspaceTargets = createWorkspaceTargetsWithoutPrefix(opts);\n if (Object.keys(workspaceTargets).length === 0) return;\n\n const result: CreateNodesResult = {\n projects: {\n architecture: {\n name: 'architecture',\n root: 'architecture',\n targets: workspaceTargets,\n },\n },\n };\n\n const firstProjectFile = projectFiles[0];\n if (firstProjectFile) {\n results.push([firstProjectFile, result] as const);\n }\n}\n\n\n// A project sits inside a NESTED git repo (e.g. a clone under repositories/) when any of its\n// ancestor dirs — up to but NOT including the workspace root — contains a `.git`. Such projects are\n// separate repos, not part of THIS workspace's graph, so they must not get inferred targets (that is\n// what drags foreign clones into `nx affected`). Same repo-boundary signal the AI guards use.\nexport function isInsideNestedGitRepo(workspaceRoot: string, projectRoot: string): boolean {\n let dir = projectRoot;\n while (dir && dir !== '.' && dir !== '/') {\n if (existsSync(join(workspaceRoot, dir, '.git'))) return true;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return false;\n}\n\nfunction addPerProjectTargets(\n results: CreateNodesResultV2,\n projectFiles: readonly string[],\n opts: Required<ArchitecturePluginOptions>,\n context: CreateNodesContextV2,\n): void {\n // Track processed project roots to avoid duplicates when both files exist\n const processedRoots = new Set<string>();\n\n for (const projectFile of projectFiles) {\n const isProjectJson = projectFile.endsWith('project.json');\n const isPackageJson = projectFile.endsWith('package.json');\n\n if (!isProjectJson && !isPackageJson) continue;\n\n const projectRoot = dirname(projectFile);\n\n // Skip root (workspace manifest, not a project)\n if (projectRoot === '.') continue;\n\n // Skip projects inside a nested git repo (vendored clones under repositories/): they are\n // separate repos and must not be swept into this workspace's `nx affected` graph.\n if (isInsideNestedGitRepo(context.workspaceRoot, projectRoot)) continue;\n\n // Skip if we've already processed this project root\n if (processedRoots.has(projectRoot)) continue;\n\n // For package.json, skip if project.json also exists in same directory\n // (prefer project.json - it will be processed separately)\n if (isPackageJson) {\n const projectJsonPath = join(context.workspaceRoot, projectRoot, 'project.json');\n if (existsSync(projectJsonPath)) continue;\n }\n\n processedRoots.add(projectRoot);\n\n const targets = buildPerProjectTargets(isProjectJson, projectRoot, opts);\n\n if (Object.keys(targets).length === 0) continue;\n\n const result: CreateNodesResult = {\n projects: {\n [projectRoot]: {\n targets,\n },\n },\n };\n\n results.push([projectFile, result] as const);\n }\n}\n\n/**\n * Build the target map for one project. Most targets are project.json-only\n * (package.json-only projects may not have TypeScript source); `ci` goes on all.\n */\nfunction buildPerProjectTargets(\n isProjectJson: boolean,\n projectRoot: string,\n opts: Required<ArchitecturePluginOptions>,\n): Record<string, TargetConfiguration> {\n const targets: Record<string, TargetConfiguration> = {};\n\n // Add circular-deps target ONLY for project.json projects\n if (isProjectJson && opts.circularDeps.enabled) {\n if (!isExcluded(projectRoot, opts.circularDeps.excludePatterns!)) {\n const targetName = opts.circularDeps.targetName!;\n targets[targetName] = createCircularDepsTarget(projectRoot, targetName);\n }\n }\n\n // Per-project DI design DAG: regenerate design.json/design.md on every build,\n // then gate the build on the committed copies being current.\n if (isProjectJson && opts.workspace.validations!.diGraph) {\n targets['di-graph-generate'] = createDiGraphGenerateTarget();\n targets['validate-di-graph-unchanged'] = createValidateDiGraphUnchangedTarget();\n }\n\n // Add ci target to ALL projects (both project.json and package.json)\n targets['ci'] = createCiTarget();\n\n return targets;\n}\n\n/**\n * Nx V2 Inference Plugin\n * Matches project.json and package.json files to create targets\n */\nexport const createNodesV2: CreateNodesV2<ArchitecturePluginOptions> = [\n // Pattern to match project.json and package.json files\n '**/{project,package}.json',\n\n // Inference function\n createNodesFunction,\n];\n\n/**\n * Build list of enabled validation target names for validate-complete dependency chain\n */\nfunction buildValidationTargetsList(\n validations: Required<ArchitecturePluginOptions>['workspace']['validations'],\n): string[] {\n const targets: string[] = [];\n if (validations!.noCycles) targets.push('validate-no-architecture-cycles');\n if (validations!.architectureUnchanged) targets.push('validate-architecture-unchanged');\n if (validations!.noSkipLevelDeps) targets.push('validate-no-skiplevel-deps');\n if (validations!.validatePackageJson) targets.push('validate-packagejson');\n // Use combined validate-code instead of 3 separate targets\n if (\n validations!.validateNewMethods ||\n validations!.validateModifiedMethods ||\n validations!.validateModifiedFiles\n ) {\n targets.push('validate-code');\n }\n if (validations!.validateVersionsLocked) targets.push('validate-versions-locked');\n if (validations!.validateTsInSrc) targets.push('validate-ts-in-src');\n if (validations!.validateNxWiring) targets.push('validate-nx-wiring');\n if (validations!.runtimeArchitecture) targets.push('validate-runtime-architecture');\n if (validations!.validateApiRelations) targets.push('validate-api-relations');\n if (validations!.validateApiLibTag) targets.push('validate-api-lib-tag');\n return targets;\n}\n\n/**\n * Create workspace-level architecture validation targets WITHOUT prefix\n * Used for virtual 'architecture' project\n */\nfunction createWorkspaceTargetsWithoutPrefix(\n opts: Required<ArchitecturePluginOptions>,\n): Record<string, TargetConfiguration> {\n const targets: Record<string, TargetConfiguration> = {};\n const graphPath = opts.workspace.graphPath!;\n const validations = opts.workspace.validations!;\n // One ValidationTargets instance, injected below to build each target config.\n const targetFactory = new ValidationTargets();\n\n // Add help target (always available)\n targets['help'] = createHelpTarget();\n\n if (opts.workspace.features!.generate) {\n targets['generate'] = createGenerateTarget(graphPath);\n }\n if (opts.workspace.features!.visualize) {\n targets['visualize'] = createVisualizeTargetWithoutPrefix(graphPath);\n }\n if (opts.workspace.features!.visualizeRuntime) {\n targets['visualize-runtime'] = createVisualizeRuntimeTarget();\n }\n if (validations.noCycles) {\n targets['validate-no-architecture-cycles'] = targetFactory.noCycles();\n }\n if (validations.architectureUnchanged) {\n targets['validate-architecture-unchanged'] = createValidateUnchangedTarget(graphPath);\n }\n if (validations.noSkipLevelDeps) {\n targets['validate-no-skiplevel-deps'] = targetFactory.noSkipLevel();\n }\n if (validations.validatePackageJson) {\n targets['validate-packagejson'] = targetFactory.packageJson();\n }\n // Use combined validate-code instead of 3 separate targets\n // Options come from webpieces.config.json at the workspace root\n // (loaded via @webpieces/rules-config; same source of truth as @webpieces/ai-hook-rules)\n if (\n validations.validateNewMethods ||\n validations.validateModifiedMethods ||\n validations.validateModifiedFiles\n ) {\n targets['validate-code'] = targetFactory.code();\n }\n if (validations.validateVersionsLocked) {\n targets['validate-versions-locked'] = targetFactory.versionsLocked();\n }\n if (validations.validateTsInSrc) {\n targets['validate-ts-in-src'] = targetFactory.tsInSrc();\n }\n if (validations.validateNxWiring) {\n targets['validate-nx-wiring'] = targetFactory.nxWiring();\n }\n if (validations.runtimeArchitecture) {\n targets['validate-runtime-architecture'] = createValidateRuntimeArchitectureTarget();\n }\n if (validations.validateApiRelations) {\n targets['validate-api-relations'] = targetFactory.apiRelations();\n }\n if (validations.validateApiLibTag) {\n targets['validate-api-lib-tag'] = targetFactory.apiLibTag();\n }\n\n // Add validate-complete target that runs all enabled validations\n const validationTargets = buildValidationTargetsList(validations);\n if (validationTargets.length > 0) {\n targets['validate-complete'] = createValidateCompleteTarget(validationTargets);\n }\n\n return targets;\n}\n\nfunction createGenerateTarget(graphPath: string): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:generate',\n cache: false,\n outputs: [\n '{workspaceRoot}/architecture/dependencies.json',\n '{workspaceRoot}/architecture/dependencies.html',\n '{workspaceRoot}/architecture/runtime-dependencies.json',\n ],\n options: { graphPath },\n metadata: {\n technologies: ['nx'],\n description:\n 'Generate the architecture dependency graph (+ clickable dependencies.html) and the runtime microservice graph',\n },\n };\n}\n\nfunction createVisualizeTargetWithoutPrefix(graphPath: string): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:visualize',\n dependsOn: ['generate'],\n options: { graphPath },\n metadata: {\n technologies: ['nx'],\n description: 'Generate visual representations of the architecture graph',\n },\n };\n}\n\nfunction createValidateUnchangedTarget(graphPath: string): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-architecture-unchanged',\n cache: false,\n inputs: ['default', '{workspaceRoot}/architecture/dependencies.json'],\n options: { graphPath },\n metadata: {\n technologies: ['nx'],\n description: 'Validate the architecture matches the saved blessed graph',\n },\n };\n}\n\nfunction createValidateNewMethodsTarget(\n maxLines: number,\n mode: 'STRICT' | 'NORMAL' | 'OFF',\n): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-new-methods',\n cache: false, // Don't cache - depends on git state\n inputs: ['default'],\n options: { max: maxLines, mode },\n metadata: {\n technologies: ['nx'],\n description: `Validate new methods do not exceed ${maxLines} lines (only runs in affected mode)`,\n },\n };\n}\n\nfunction createValidateModifiedMethodsTarget(\n maxLines: number,\n mode: 'STRICT' | 'NORMAL' | 'OFF',\n): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-modified-methods',\n cache: false, // Don't cache - depends on git state\n inputs: ['default'],\n options: { max: maxLines, mode },\n metadata: {\n technologies: ['nx'],\n description: `Validate new and modified methods do not exceed ${maxLines} lines (encourages gradual cleanup)`,\n },\n };\n}\n\nfunction createValidateModifiedFilesTarget(\n maxLines: number,\n mode: 'STRICT' | 'NORMAL' | 'OFF',\n): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-modified-files',\n cache: false, // Don't cache - depends on git state\n inputs: ['default'],\n options: { max: maxLines, mode },\n metadata: {\n technologies: ['nx'],\n description: `Validate modified files do not exceed ${maxLines} lines (encourages keeping files small)`,\n },\n };\n}\n\nfunction createValidateCompleteTarget(validationTargets: string[]): TargetConfiguration {\n return {\n executor: 'nx:noop',\n cache: true,\n dependsOn: validationTargets,\n metadata: {\n technologies: ['nx'],\n description: 'Run all architecture validations (cycles, unchanged, skip-level deps)',\n },\n };\n}\n\n/**\n * Create per-project ci target - Gradle-style composite target\n * Runs lint, build, and test in parallel\n * (with test depending on build via targetDefaults)\n *\n * NOTE: Type checking is done by the build target (@nx/js:tsc) during compilation.\n */\nfunction createCiTarget(): TargetConfiguration {\n return {\n executor: 'nx:noop',\n cache: true,\n dependsOn: ['lint', 'build', 'test'],\n metadata: {\n technologies: ['nx'],\n description: 'Run all CI checks: lint, build, and test (Gradle-style composite target)',\n },\n };\n}\n\nfunction createHelpTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:help',\n cache: false, // Never cache - always show help output\n metadata: {\n technologies: ['nx'],\n description: 'Display help for @webpieces/nx-webpieces-rules commands and targets',\n },\n };\n}\n\n/**\n * Create per-project circular dependency checking target.\n *\n * Uses the `validate-no-file-import-cycles` executor (which bundles madge as a\n * dependency) rather than a runtime `npx madge` fetch. The executor reads\n * webpieces.config.json so the gate can be turned on/off (`mode`) and\n * time-boxed (`ignoreModifiedUntilEpoch`) like every other webpieces rule.\n *\n * Note `projectRoot` is intentionally unused now — the executor derives the\n * project root from the Nx context — but the param is kept for call-site\n * symmetry with the rest of the per-project target factories.\n */\nfunction createCircularDepsTarget(_projectRoot: string, _targetName: string): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-no-file-import-cycles',\n cache: true,\n inputs: ['default'],\n outputs: [] as string[],\n metadata: {\n technologies: ['madge'],\n description: 'Check for circular file-import dependencies using madge',\n },\n };\n}\n\n/**\n * Check if a project should be excluded based on patterns\n */\nfunction isExcluded(projectRoot: string, excludePatterns: string[]): boolean {\n if (excludePatterns.length === 0) {\n return false;\n }\n\n // Simple glob matching (could be enhanced with minimatch if needed)\n return excludePatterns.some((pattern) => {\n // Convert glob pattern to regex\n const regexPattern = pattern\n .replace(/\\*\\*/g, '.*') // ** matches any path\n .replace(/\\*/g, '[^/]*'); // * matches any string except /\n\n const regex = new RegExp(`^${regexPattern}$`);\n return regex.test(projectRoot);\n });\n}\n\n/**\n * Export plugin as default for Nx\n */\nexport default { createNodesV2 };\n"]}
|
package/src/runtime-targets.d.ts
CHANGED
|
@@ -7,5 +7,3 @@ import type { TargetConfiguration } from '@nx/devkit';
|
|
|
7
7
|
export declare function createVisualizeRuntimeTarget(): TargetConfiguration;
|
|
8
8
|
/** Workspace: validate no disallowed runtime cycles + graph unchanged. */
|
|
9
9
|
export declare function createValidateRuntimeArchitectureTarget(): TargetConfiguration;
|
|
10
|
-
/** Per-project: validate this project's service-contract.json matches its api-project deps. */
|
|
11
|
-
export declare function createValidateRuntimeMarkersTarget(): TargetConfiguration;
|
package/src/runtime-targets.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.createVisualizeRuntimeTarget = createVisualizeRuntimeTarget;
|
|
8
8
|
exports.createValidateRuntimeArchitectureTarget = createValidateRuntimeArchitectureTarget;
|
|
9
|
-
exports.createValidateRuntimeMarkersTarget = createValidateRuntimeMarkersTarget;
|
|
10
9
|
/** `architecture:visualize-runtime` — render the runtime microservice graph. */
|
|
11
10
|
function createVisualizeRuntimeTarget() {
|
|
12
11
|
return {
|
|
@@ -25,7 +24,7 @@ function createValidateRuntimeArchitectureTarget() {
|
|
|
25
24
|
cache: false,
|
|
26
25
|
inputs: [
|
|
27
26
|
'default',
|
|
28
|
-
'{workspaceRoot}
|
|
27
|
+
'{workspaceRoot}/architecture/dependencies.json',
|
|
29
28
|
'{workspaceRoot}/architecture/runtime-dependencies.json',
|
|
30
29
|
'{workspaceRoot}/webpieces.config.json',
|
|
31
30
|
],
|
|
@@ -35,16 +34,4 @@ function createValidateRuntimeArchitectureTarget() {
|
|
|
35
34
|
},
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
|
-
/** Per-project: validate this project's service-contract.json matches its api-project deps. */
|
|
39
|
-
function createValidateRuntimeMarkersTarget() {
|
|
40
|
-
return {
|
|
41
|
-
executor: '@webpieces/nx-webpieces-rules:validate-runtime-markers',
|
|
42
|
-
cache: true,
|
|
43
|
-
inputs: ['default', '{workspaceRoot}/**/service-contract.json', '{workspaceRoot}/webpieces.config.json'],
|
|
44
|
-
metadata: {
|
|
45
|
-
technologies: ['nx'],
|
|
46
|
-
description: "Validate this service's service-contract.json matches its api-project dependencies",
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
37
|
//# sourceMappingURL=runtime-targets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-targets.js","sourceRoot":"","sources":["../../../../../packages/tooling/nx-webpieces-rules/src/runtime-targets.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAKH,oEASC;AAGD,0FAeC;
|
|
1
|
+
{"version":3,"file":"runtime-targets.js","sourceRoot":"","sources":["../../../../../packages/tooling/nx-webpieces-rules/src/runtime-targets.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAKH,oEASC;AAGD,0FAeC;AA5BD,gFAAgF;AAChF,SAAgB,4BAA4B;IACxC,OAAO;QACH,QAAQ,EAAE,iDAAiD;QAC3D,SAAS,EAAE,CAAC,uBAAuB,CAAC;QACpC,QAAQ,EAAE;YACN,YAAY,EAAE,CAAC,IAAI,CAAC;YACpB,WAAW,EAAE,mEAAmE;SACnF;KACJ,CAAC;AACN,CAAC;AAED,0EAA0E;AAC1E,SAAgB,uCAAuC;IACnD,OAAO;QACH,QAAQ,EAAE,6DAA6D;QACvE,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE;YACJ,SAAS;YACT,gDAAgD;YAChD,wDAAwD;YACxD,uCAAuC;SAC1C;QACD,QAAQ,EAAE;YACN,YAAY,EAAE,CAAC,IAAI,CAAC;YACpB,WAAW,EAAE,2EAA2E;SAC3F;KACJ,CAAC;AACN,CAAC","sourcesContent":["/**\n * Runtime-graph target factories for the inference plugin (kept out of plugin.ts\n * to keep that file under the file-size limit).\n */\n\nimport type { TargetConfiguration } from '@nx/devkit';\n\n/** `architecture:visualize-runtime` — render the runtime microservice graph. */\nexport function createVisualizeRuntimeTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:visualize-runtime',\n dependsOn: ['architecture:generate'],\n metadata: {\n technologies: ['nx'],\n description: 'Render the runtime microservice graph (runtime-dependencies.json)',\n },\n };\n}\n\n/** Workspace: validate no disallowed runtime cycles + graph unchanged. */\nexport function createValidateRuntimeArchitectureTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-runtime-architecture',\n cache: false,\n inputs: [\n 'default',\n '{workspaceRoot}/architecture/dependencies.json',\n '{workspaceRoot}/architecture/runtime-dependencies.json',\n '{workspaceRoot}/webpieces.config.json',\n ],\n metadata: {\n technologies: ['nx'],\n description: 'Validate the runtime microservice graph (no disallowed cycles, unchanged)',\n },\n };\n}\n"]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validate Runtime Markers Executor (per-project)
|
|
3
|
-
*
|
|
4
|
-
* Validates ONE service's `service-contract.json` against its actual api-project
|
|
5
|
-
* dependencies (from the Nx graph), independently of all other projects:
|
|
6
|
-
*
|
|
7
|
-
* set(api-project deps) === set(implements ∪ uses declared in the contract)
|
|
8
|
-
*
|
|
9
|
-
* - Every service (root matches servicePaths) MUST have a service-contract.json
|
|
10
|
-
* -> FAIL if missing.
|
|
11
|
-
* - An api-project dependency not declared in the contract -> FAIL (undeclared).
|
|
12
|
-
* - A contract entry that is not an actual api dependency -> FAIL (phantom).
|
|
13
|
-
*
|
|
14
|
-
* Only service projects are checked; non-services pass. On/off + a whole-rule
|
|
15
|
-
* grace window come from webpieces.config.json (rule: runtime-architecture).
|
|
16
|
-
*
|
|
17
|
-
* Usage: nx run <project>:validate-runtime-markers
|
|
18
|
-
*/
|
|
19
|
-
import type { ExecutorContext } from '@nx/devkit';
|
|
20
|
-
export interface ValidateRuntimeMarkersOptions {
|
|
21
|
-
}
|
|
22
|
-
export interface ExecutorResult {
|
|
23
|
-
success: boolean;
|
|
24
|
-
}
|
|
25
|
-
export default function runExecutor(_options: ValidateRuntimeMarkersOptions, context: ExecutorContext): Promise<ExecutorResult>;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Validate Runtime Markers Executor (per-project)
|
|
4
|
-
*
|
|
5
|
-
* Validates ONE service's `service-contract.json` against its actual api-project
|
|
6
|
-
* dependencies (from the Nx graph), independently of all other projects:
|
|
7
|
-
*
|
|
8
|
-
* set(api-project deps) === set(implements ∪ uses declared in the contract)
|
|
9
|
-
*
|
|
10
|
-
* - Every service (root matches servicePaths) MUST have a service-contract.json
|
|
11
|
-
* -> FAIL if missing.
|
|
12
|
-
* - An api-project dependency not declared in the contract -> FAIL (undeclared).
|
|
13
|
-
* - A contract entry that is not an actual api dependency -> FAIL (phantom).
|
|
14
|
-
*
|
|
15
|
-
* Only service projects are checked; non-services pass. On/off + a whole-rule
|
|
16
|
-
* grace window come from webpieces.config.json (rule: runtime-architecture).
|
|
17
|
-
*
|
|
18
|
-
* Usage: nx run <project>:validate-runtime-markers
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.default = runExecutor;
|
|
22
|
-
const runtime_markers_1 = require("../../lib/runtime-markers");
|
|
23
|
-
const runtime_config_1 = require("../../lib/runtime-config");
|
|
24
|
-
function apiDepsOf(model, info) {
|
|
25
|
-
return info.deps.filter((dep) => model.projects.get(dep)?.isApi === true).sort();
|
|
26
|
-
}
|
|
27
|
-
async function runExecutor(_options, context) {
|
|
28
|
-
const workspaceRoot = context.root;
|
|
29
|
-
const config = (0, runtime_config_1.loadRuntimeConfig)(workspaceRoot);
|
|
30
|
-
if (config.off) {
|
|
31
|
-
console.log(`\n⏭️ Skipping ${runtime_config_1.RUNTIME_RULE_NAME} markers (mode: OFF)\n`);
|
|
32
|
-
return { success: true };
|
|
33
|
-
}
|
|
34
|
-
if (config.servicePaths.length === 0) {
|
|
35
|
-
return { success: true };
|
|
36
|
-
}
|
|
37
|
-
const projectName = context.projectName ?? '';
|
|
38
|
-
const model = await (0, runtime_markers_1.buildWorkspaceModel)(workspaceRoot, config.apiProjectPaths, config.servicePaths);
|
|
39
|
-
const info = model.projects.get(projectName);
|
|
40
|
-
if (!info || !info.isService) {
|
|
41
|
-
return { success: true };
|
|
42
|
-
}
|
|
43
|
-
const violations = collectViolations(model, info, workspaceRoot);
|
|
44
|
-
if (violations.length === 0) {
|
|
45
|
-
console.log(`\n✅ ${projectName}: service-contract.json matches api dependencies\n`);
|
|
46
|
-
return { success: true };
|
|
47
|
-
}
|
|
48
|
-
console.error(`\n❌ ${projectName}: service-contract.json does not match api dependencies:\n`);
|
|
49
|
-
for (const v of violations)
|
|
50
|
-
console.error(` - ${v}`);
|
|
51
|
-
console.error(`\nFix ${info.root}/service-contract.json so "implements" ∪ "uses" equals the api projects in deps.\n`);
|
|
52
|
-
const reportOnly = (0, runtime_config_1.runtimeReportOnly)(config);
|
|
53
|
-
if (reportOnly.skip) {
|
|
54
|
-
console.log(`⏳ Reported but not failing (${reportOnly.reason}).\n`);
|
|
55
|
-
return { success: true };
|
|
56
|
-
}
|
|
57
|
-
return { success: false };
|
|
58
|
-
}
|
|
59
|
-
/** Bidirectional-exact comparison of api deps vs the service contract. */
|
|
60
|
-
function collectViolations(model, info, workspaceRoot) {
|
|
61
|
-
const apiDeps = apiDepsOf(model, info);
|
|
62
|
-
const contract = (0, runtime_markers_1.readServiceContract)(workspaceRoot, info.root);
|
|
63
|
-
if (!contract) {
|
|
64
|
-
return [`missing service-contract.json (every service requires one)`];
|
|
65
|
-
}
|
|
66
|
-
const declaredNames = Array.from(new Set([...contract.implements, ...contract.uses]));
|
|
67
|
-
const resolved = (0, runtime_markers_1.resolvePackageNames)(model, declaredNames);
|
|
68
|
-
const declaredProjects = new Set(resolved.projects);
|
|
69
|
-
const apiDepSet = new Set(apiDeps);
|
|
70
|
-
const violations = [];
|
|
71
|
-
for (const pkg of resolved.unknown) {
|
|
72
|
-
violations.push(`declared "${pkg}" which is not a workspace package`);
|
|
73
|
-
}
|
|
74
|
-
for (const proj of resolved.projects) {
|
|
75
|
-
if (!model.projects.get(proj)?.isApi) {
|
|
76
|
-
violations.push(`declared "${proj}" which is not an api project`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
for (const dep of apiDeps) {
|
|
80
|
-
if (!declaredProjects.has(dep)) {
|
|
81
|
-
violations.push(`api dependency "${dep}" is not declared in service-contract.json`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
for (const proj of declaredProjects) {
|
|
85
|
-
if (model.projects.get(proj)?.isApi && !apiDepSet.has(proj)) {
|
|
86
|
-
violations.push(`service-contract.json declares "${proj}" but it is not an actual dependency`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return violations;
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=executor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/nx-webpieces-rules/src/executors/validate-runtime-markers/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAmBH,8BAsCC;AAtDD,+DAA0G;AAE1G,6DAAmG;AAUnG,SAAS,SAAS,CAAC,KAAqB,EAAE,IAAiB;IACvD,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK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AO,EAAE,CAAC;QACjC,UAAU,CAAC,IAAI,CAAC,aAAa,GAAG,oCAAoC,CAAC,CAAC;IAC1E,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;YACnC,UAAU,CAAC,IAAI,CAAC,aAAa,IAAI,+BAA+B,CAAC,CAAC;QACtE,CAAC;IACL,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,UAAU,CAAC,IAAI,CAAC,mBAAmB,GAAG,4CAA4C,CAAC,CAAC;QACxF,CAAC;IACL,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,gBAAgB,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1D,UAAU,CAAC,IAAI,CAAC,mCAAmC,IAAI,sCAAsC,CAAC,CAAC;QACnG,CAAC;IACL,CAAC;IACD,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["/**\n * Validate Runtime Markers Executor (per-project)\n *\n * Validates ONE service's `service-contract.json` against its actual api-project\n * dependencies (from the Nx graph), independently of all other projects:\n *\n * set(api-project deps) === set(implements ∪ uses declared in the contract)\n *\n * - Every service (root matches servicePaths) MUST have a service-contract.json\n * -> FAIL if missing.\n * - An api-project dependency not declared in the contract -> FAIL (undeclared).\n * - A contract entry that is not an actual api dependency -> FAIL (phantom).\n *\n * Only service projects are checked; non-services pass. On/off + a whole-rule\n * grace window come from webpieces.config.json (rule: runtime-architecture).\n *\n * Usage: nx run <project>:validate-runtime-markers\n */\n\nimport type { ExecutorContext } from '@nx/devkit';\nimport { buildWorkspaceModel, readServiceContract, resolvePackageNames } from '../../lib/runtime-markers';\nimport type { WorkspaceModel, ProjectInfo } from '../../lib/runtime-markers';\nimport { loadRuntimeConfig, runtimeReportOnly, RUNTIME_RULE_NAME } from '../../lib/runtime-config';\n\nexport interface ValidateRuntimeMarkersOptions {\n // Config comes from webpieces.config.json at runtime.\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\nfunction apiDepsOf(model: WorkspaceModel, info: ProjectInfo): string[] {\n return info.deps.filter((dep: string) => model.projects.get(dep)?.isApi === true).sort();\n}\n\nexport default async function runExecutor(\n _options: ValidateRuntimeMarkersOptions,\n context: ExecutorContext,\n): Promise<ExecutorResult> {\n const workspaceRoot = context.root;\n const config = loadRuntimeConfig(workspaceRoot);\n\n if (config.off) {\n console.log(`\\n⏭️ Skipping ${RUNTIME_RULE_NAME} markers (mode: OFF)\\n`);\n return { success: true };\n }\n if (config.servicePaths.length === 0) {\n return { success: true };\n }\n\n const projectName = context.projectName ?? '';\n const model = await buildWorkspaceModel(workspaceRoot, config.apiProjectPaths, config.servicePaths);\n const info = model.projects.get(projectName);\n if (!info || !info.isService) {\n return { success: true };\n }\n\n const violations = collectViolations(model, info, workspaceRoot);\n if (violations.length === 0) {\n console.log(`\\n✅ ${projectName}: service-contract.json matches api dependencies\\n`);\n return { success: true };\n }\n\n console.error(`\\n❌ ${projectName}: service-contract.json does not match api dependencies:\\n`);\n for (const v of violations) console.error(` - ${v}`);\n console.error(`\\nFix ${info.root}/service-contract.json so \"implements\" ∪ \"uses\" equals the api projects in deps.\\n`);\n\n const reportOnly = runtimeReportOnly(config);\n if (reportOnly.skip) {\n console.log(`⏳ Reported but not failing (${reportOnly.reason}).\\n`);\n return { success: true };\n }\n return { success: false };\n}\n\n/** Bidirectional-exact comparison of api deps vs the service contract. */\nfunction collectViolations(model: WorkspaceModel, info: ProjectInfo, workspaceRoot: string): string[] {\n const apiDeps = apiDepsOf(model, info);\n const contract = readServiceContract(workspaceRoot, info.root);\n\n if (!contract) {\n return [`missing service-contract.json (every service requires one)`];\n }\n\n const declaredNames = Array.from(new Set([...contract.implements, ...contract.uses]));\n const resolved = resolvePackageNames(model, declaredNames);\n const declaredProjects = new Set(resolved.projects);\n const apiDepSet = new Set(apiDeps);\n\n const violations: string[] = [];\n for (const pkg of resolved.unknown) {\n violations.push(`declared \"${pkg}\" which is not a workspace package`);\n }\n for (const proj of resolved.projects) {\n if (!model.projects.get(proj)?.isApi) {\n violations.push(`declared \"${proj}\" which is not an api project`);\n }\n }\n for (const dep of apiDeps) {\n if (!declaredProjects.has(dep)) {\n violations.push(`api dependency \"${dep}\" is not declared in service-contract.json`);\n }\n }\n for (const proj of declaredProjects) {\n if (model.projects.get(proj)?.isApi && !apiDepSet.has(proj)) {\n violations.push(`service-contract.json declares \"${proj}\" but it is not an actual dependency`);\n }\n }\n return violations;\n}\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"title": "Validate Runtime Markers Executor",
|
|
4
|
-
"description": "Per-project: validate live.json matches the project's api-project dependencies. Config from webpieces.config.json (runtime-architecture).",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {},
|
|
7
|
-
"required": []
|
|
8
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime Markers
|
|
3
|
-
*
|
|
4
|
-
* Reads the per-service `service-contract.json` files and builds a workspace
|
|
5
|
-
* model used to assemble the runtime microservice graph and to validate each
|
|
6
|
-
* service independently.
|
|
7
|
-
*
|
|
8
|
-
* `service-contract.json` (at a service's project root) declares, at api-PROJECT
|
|
9
|
-
* granularity (by package name), which api projects a service IMPLEMENTS (serves)
|
|
10
|
-
* and which it USES (calls as a client):
|
|
11
|
-
*
|
|
12
|
-
* { "implements": ["@scope/checkout-api"], "uses": ["@scope/payments-api"] }
|
|
13
|
-
*
|
|
14
|
-
* Classification (from webpieces.config.json globs):
|
|
15
|
-
* - api project: root matches `apiProjectPaths` (e.g. "libraries/apis/*").
|
|
16
|
-
* - service: root matches `servicePaths` (e.g. "services/*") AND is not an
|
|
17
|
-
* api project (api classification wins, so the lists may overlap
|
|
18
|
-
* harmlessly). Every service must have a service-contract.json.
|
|
19
|
-
*/
|
|
20
|
-
export declare const SERVICE_CONTRACT_FILENAME = "service-contract.json";
|
|
21
|
-
/** Parsed `service-contract.json` contents (api package names). */
|
|
22
|
-
export interface ServiceContract {
|
|
23
|
-
implements: string[];
|
|
24
|
-
uses: string[];
|
|
25
|
-
}
|
|
26
|
-
/** Everything we know about one workspace project for runtime analysis. */
|
|
27
|
-
export interface ProjectInfo {
|
|
28
|
-
name: string;
|
|
29
|
-
root: string;
|
|
30
|
-
packageName: string | null;
|
|
31
|
-
isApi: boolean;
|
|
32
|
-
isService: boolean;
|
|
33
|
-
/** Workspace project names this project depends on (from the Nx graph). */
|
|
34
|
-
deps: string[];
|
|
35
|
-
}
|
|
36
|
-
/** The whole-workspace model used by the generator and validators. */
|
|
37
|
-
export interface WorkspaceModel {
|
|
38
|
-
projects: Map<string, ProjectInfo>;
|
|
39
|
-
byPackageName: Map<string, string>;
|
|
40
|
-
}
|
|
41
|
-
/** Result of mapping package names to workspace projects. */
|
|
42
|
-
export interface ResolvedNames {
|
|
43
|
-
projects: string[];
|
|
44
|
-
unknown: string[];
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Build the workspace model from the Nx project graph. Dependency edges come
|
|
48
|
-
* from Nx (imports + package.json), the same source dependencies.json uses, so
|
|
49
|
-
* this works whether or not a service has its own package.json.
|
|
50
|
-
*/
|
|
51
|
-
export declare function buildWorkspaceModel(workspaceRoot: string, apiProjectPaths: string[], servicePaths: string[]): Promise<WorkspaceModel>;
|
|
52
|
-
/** Read and normalize a project's `service-contract.json`, or null if it has none. */
|
|
53
|
-
export declare function readServiceContract(workspaceRoot: string, projectRoot: string): ServiceContract | null;
|
|
54
|
-
/**
|
|
55
|
-
* Map a list of api package names (from a service contract) to workspace project
|
|
56
|
-
* names. Unknown names (not a workspace package) are returned in `unknown`.
|
|
57
|
-
*/
|
|
58
|
-
export declare function resolvePackageNames(model: WorkspaceModel, packageNames: string[]): ResolvedNames;
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Runtime Markers
|
|
4
|
-
*
|
|
5
|
-
* Reads the per-service `service-contract.json` files and builds a workspace
|
|
6
|
-
* model used to assemble the runtime microservice graph and to validate each
|
|
7
|
-
* service independently.
|
|
8
|
-
*
|
|
9
|
-
* `service-contract.json` (at a service's project root) declares, at api-PROJECT
|
|
10
|
-
* granularity (by package name), which api projects a service IMPLEMENTS (serves)
|
|
11
|
-
* and which it USES (calls as a client):
|
|
12
|
-
*
|
|
13
|
-
* { "implements": ["@scope/checkout-api"], "uses": ["@scope/payments-api"] }
|
|
14
|
-
*
|
|
15
|
-
* Classification (from webpieces.config.json globs):
|
|
16
|
-
* - api project: root matches `apiProjectPaths` (e.g. "libraries/apis/*").
|
|
17
|
-
* - service: root matches `servicePaths` (e.g. "services/*") AND is not an
|
|
18
|
-
* api project (api classification wins, so the lists may overlap
|
|
19
|
-
* harmlessly). Every service must have a service-contract.json.
|
|
20
|
-
*/
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.SERVICE_CONTRACT_FILENAME = void 0;
|
|
23
|
-
exports.buildWorkspaceModel = buildWorkspaceModel;
|
|
24
|
-
exports.readServiceContract = readServiceContract;
|
|
25
|
-
exports.resolvePackageNames = resolvePackageNames;
|
|
26
|
-
const tslib_1 = require("tslib");
|
|
27
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
28
|
-
const path = tslib_1.__importStar(require("path"));
|
|
29
|
-
const devkit_1 = require("@nx/devkit");
|
|
30
|
-
const rules_config_1 = require("@webpieces/rules-config");
|
|
31
|
-
const toError_1 = require("../toError");
|
|
32
|
-
exports.SERVICE_CONTRACT_FILENAME = 'service-contract.json';
|
|
33
|
-
/** True when a project root matches one of the given globs (segment/glob/dir-prefix). */
|
|
34
|
-
function matchesGlobs(root, globs) {
|
|
35
|
-
if (globs.length === 0)
|
|
36
|
-
return false;
|
|
37
|
-
return (0, rules_config_1.isPathExcluded)(root, globs);
|
|
38
|
-
}
|
|
39
|
-
function readPackageName(workspaceRoot, projectRoot) {
|
|
40
|
-
const pkgPath = path.join(workspaceRoot, projectRoot, 'package.json');
|
|
41
|
-
if (!fs.existsSync(pkgPath))
|
|
42
|
-
return null;
|
|
43
|
-
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
44
|
-
try {
|
|
45
|
-
const raw = fs.readFileSync(pkgPath, 'utf-8');
|
|
46
|
-
const parsed = JSON.parse(raw);
|
|
47
|
-
return typeof parsed.name === 'string' ? parsed.name : null;
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
const error = (0, toError_1.toError)(err);
|
|
51
|
-
void error;
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function collectDeps(name, dependencies, workspaceNames) {
|
|
56
|
-
const deps = [];
|
|
57
|
-
for (const edge of dependencies[name] ?? []) {
|
|
58
|
-
if (edge.target !== name && workspaceNames.has(edge.target)) {
|
|
59
|
-
deps.push(edge.target);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return Array.from(new Set(deps)).sort();
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Build the workspace model from the Nx project graph. Dependency edges come
|
|
66
|
-
* from Nx (imports + package.json), the same source dependencies.json uses, so
|
|
67
|
-
* this works whether or not a service has its own package.json.
|
|
68
|
-
*/
|
|
69
|
-
async function buildWorkspaceModel(workspaceRoot, apiProjectPaths, servicePaths) {
|
|
70
|
-
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
71
|
-
const projectsConfig = (0, devkit_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
72
|
-
const projects = new Map();
|
|
73
|
-
const byPackageName = new Map();
|
|
74
|
-
const workspaceNames = new Set(Object.keys(projectGraph.nodes));
|
|
75
|
-
for (const [name, cfg] of Object.entries(projectsConfig.projects)) {
|
|
76
|
-
const root = cfg.root;
|
|
77
|
-
if (root === '' || root === '.')
|
|
78
|
-
continue;
|
|
79
|
-
const packageName = readPackageName(workspaceRoot, root);
|
|
80
|
-
const isApi = matchesGlobs(root, apiProjectPaths);
|
|
81
|
-
projects.set(name, {
|
|
82
|
-
name,
|
|
83
|
-
root,
|
|
84
|
-
packageName,
|
|
85
|
-
isApi,
|
|
86
|
-
// api classification wins, so servicePaths and apiProjectPaths may overlap.
|
|
87
|
-
isService: !isApi && matchesGlobs(root, servicePaths),
|
|
88
|
-
deps: collectDeps(name, projectGraph.dependencies, workspaceNames),
|
|
89
|
-
});
|
|
90
|
-
if (packageName)
|
|
91
|
-
byPackageName.set(packageName, name);
|
|
92
|
-
}
|
|
93
|
-
return { projects, byPackageName };
|
|
94
|
-
}
|
|
95
|
-
/** Read and normalize a project's `service-contract.json`, or null if it has none. */
|
|
96
|
-
function readServiceContract(workspaceRoot, projectRoot) {
|
|
97
|
-
const fullPath = path.join(workspaceRoot, projectRoot, exports.SERVICE_CONTRACT_FILENAME);
|
|
98
|
-
if (!fs.existsSync(fullPath))
|
|
99
|
-
return null;
|
|
100
|
-
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
101
|
-
try {
|
|
102
|
-
const raw = fs.readFileSync(fullPath, 'utf-8');
|
|
103
|
-
const parsed = JSON.parse(raw);
|
|
104
|
-
return {
|
|
105
|
-
implements: Array.isArray(parsed.implements) ? parsed.implements : [],
|
|
106
|
-
uses: Array.isArray(parsed.uses) ? parsed.uses : [],
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
catch (err) {
|
|
110
|
-
const error = (0, toError_1.toError)(err);
|
|
111
|
-
throw new Error(`Failed to parse ${projectRoot}/${exports.SERVICE_CONTRACT_FILENAME}`, { cause: error });
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Map a list of api package names (from a service contract) to workspace project
|
|
116
|
-
* names. Unknown names (not a workspace package) are returned in `unknown`.
|
|
117
|
-
*/
|
|
118
|
-
function resolvePackageNames(model, packageNames) {
|
|
119
|
-
const resolved = [];
|
|
120
|
-
const unknown = [];
|
|
121
|
-
for (const pkg of packageNames) {
|
|
122
|
-
const project = model.byPackageName.get(pkg);
|
|
123
|
-
if (project)
|
|
124
|
-
resolved.push(project);
|
|
125
|
-
else
|
|
126
|
-
unknown.push(pkg);
|
|
127
|
-
}
|
|
128
|
-
return { projects: resolved, unknown };
|
|
129
|
-
}
|
|
130
|
-
//# sourceMappingURL=runtime-markers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-markers.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/runtime-markers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AA4FH,kDA+BC;AAGD,kDAgBC;AAMD,kDAYC;;AA9JD,+CAAyB;AACzB,mDAA6B;AAC7B,uCAAgG;AAChG,0DAAyD;AACzD,wCAAqC;AAExB,QAAA,yBAAyB,GAAG,uBAAuB,CAAC;AA4CjE,yFAAyF;AACzF,SAAS,YAAY,CAAC,IAAY,EAAE,KAAe;IAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACrC,OAAO,IAAA,6BAAc,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,eAAe,CAAC,aAAqB,EAAE,WAAmB;IAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;IACtE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,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,EAAE,OAAO,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAyB,CAAC;QACvD,OAAO;YACH,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;YACrE,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;SACtD,CAAC;IACN,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,IAAA,iBAAO,EAAC,GAAG,CAAC,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,mBAAmB,WAAW,IAAI,iCAAyB,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACrG,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CAC/B,KAAqB,EACrB,YAAsB;IAEtB,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,OAAO;YAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;;YAC/B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["/**\n * Runtime Markers\n *\n * Reads the per-service `service-contract.json` files and builds a workspace\n * model used to assemble the runtime microservice graph and to validate each\n * service independently.\n *\n * `service-contract.json` (at a service's project root) declares, at api-PROJECT\n * granularity (by package name), which api projects a service IMPLEMENTS (serves)\n * and which it USES (calls as a client):\n *\n * { \"implements\": [\"@scope/checkout-api\"], \"uses\": [\"@scope/payments-api\"] }\n *\n * Classification (from webpieces.config.json globs):\n * - api project: root matches `apiProjectPaths` (e.g. \"libraries/apis/*\").\n * - service: root matches `servicePaths` (e.g. \"services/*\") AND is not an\n * api project (api classification wins, so the lists may overlap\n * harmlessly). Every service must have a service-contract.json.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph } from '@nx/devkit';\nimport { isPathExcluded } from '@webpieces/rules-config';\nimport { toError } from '../toError';\n\nexport const SERVICE_CONTRACT_FILENAME = 'service-contract.json';\n\n/** Parsed `service-contract.json` contents (api package names). */\nexport interface ServiceContract {\n implements: string[];\n uses: string[];\n}\n\n/** Everything we know about one workspace project for runtime analysis. */\nexport interface ProjectInfo {\n name: string;\n root: string;\n packageName: string | null;\n isApi: boolean;\n isService: boolean;\n /** Workspace project names this project depends on (from the Nx graph). */\n deps: string[];\n}\n\n/** The whole-workspace model used by the generator and validators. */\nexport interface WorkspaceModel {\n projects: Map<string, ProjectInfo>;\n byPackageName: Map<string, string>;\n}\n\n/** Result of mapping package names to workspace projects. */\nexport interface ResolvedNames {\n projects: string[];\n unknown: string[];\n}\n\n/** Minimal shapes for the JSON files we parse. */\ninterface PackageJsonShape {\n name?: string;\n}\ninterface ServiceContractShape {\n implements?: string[];\n uses?: string[];\n}\n/** One Nx project-graph dependency edge (the slice we use). */\ninterface GraphEdge {\n target: string;\n}\n\n/** True when a project root matches one of the given globs (segment/glob/dir-prefix). */\nfunction matchesGlobs(root: string, globs: string[]): boolean {\n if (globs.length === 0) return false;\n return isPathExcluded(root, globs);\n}\n\nfunction readPackageName(workspaceRoot: string, projectRoot: string): string | null {\n const pkgPath = path.join(workspaceRoot, projectRoot, 'package.json');\n if (!fs.existsSync(pkgPath)) return null;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const raw = fs.readFileSync(pkgPath, 'utf-8');\n const parsed = JSON.parse(raw) as PackageJsonShape;\n return typeof parsed.name === 'string' ? parsed.name : null;\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n}\n\nfunction collectDeps(\n name: string,\n dependencies: Record<string, GraphEdge[]>,\n workspaceNames: Set<string>,\n): string[] {\n const deps: string[] = [];\n for (const edge of dependencies[name] ?? []) {\n if (edge.target !== name && workspaceNames.has(edge.target)) {\n deps.push(edge.target);\n }\n }\n return Array.from(new Set(deps)).sort();\n}\n\n/**\n * Build the workspace model from the Nx project graph. Dependency edges come\n * from Nx (imports + package.json), the same source dependencies.json uses, so\n * this works whether or not a service has its own package.json.\n */\nexport async function buildWorkspaceModel(\n workspaceRoot: string,\n apiProjectPaths: string[],\n servicePaths: string[],\n): Promise<WorkspaceModel> {\n const projectGraph = await createProjectGraphAsync();\n const projectsConfig = readProjectsConfigurationFromProjectGraph(projectGraph);\n\n const projects = new Map<string, ProjectInfo>();\n const byPackageName = new Map<string, string>();\n const workspaceNames = new Set(Object.keys(projectGraph.nodes));\n\n for (const [name, cfg] of Object.entries(projectsConfig.projects)) {\n const root = cfg.root;\n if (root === '' || root === '.') continue;\n\n const packageName = readPackageName(workspaceRoot, root);\n const isApi = matchesGlobs(root, apiProjectPaths);\n projects.set(name, {\n name,\n root,\n packageName,\n isApi,\n // api classification wins, so servicePaths and apiProjectPaths may overlap.\n isService: !isApi && matchesGlobs(root, servicePaths),\n deps: collectDeps(name, projectGraph.dependencies, workspaceNames),\n });\n if (packageName) byPackageName.set(packageName, name);\n }\n\n return { projects, byPackageName };\n}\n\n/** Read and normalize a project's `service-contract.json`, or null if it has none. */\nexport function readServiceContract(workspaceRoot: string, projectRoot: string): ServiceContract | null {\n const fullPath = path.join(workspaceRoot, projectRoot, SERVICE_CONTRACT_FILENAME);\n if (!fs.existsSync(fullPath)) return null;\n\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const raw = fs.readFileSync(fullPath, 'utf-8');\n const parsed = JSON.parse(raw) as ServiceContractShape;\n return {\n implements: Array.isArray(parsed.implements) ? parsed.implements : [],\n uses: Array.isArray(parsed.uses) ? parsed.uses : [],\n };\n } catch (err: unknown) {\n const error = toError(err);\n throw new Error(`Failed to parse ${projectRoot}/${SERVICE_CONTRACT_FILENAME}`, { cause: error });\n }\n}\n\n/**\n * Map a list of api package names (from a service contract) to workspace project\n * names. Unknown names (not a workspace package) are returned in `unknown`.\n */\nexport function resolvePackageNames(\n model: WorkspaceModel,\n packageNames: string[],\n): ResolvedNames {\n const resolved: string[] = [];\n const unknown: string[] = [];\n for (const pkg of packageNames) {\n const project = model.byPackageName.get(pkg);\n if (project) resolved.push(project);\n else unknown.push(pkg);\n }\n return { projects: resolved, unknown };\n}\n"]}
|