@webpieces/nx-webpieces-rules 0.4.970 → 0.4.972
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/executors.json +1 -6
- package/package.json +7 -7
- package/src/executors/help/executor.js +1 -3
- package/src/executors/help/executor.js.map +1 -1
- package/src/executors/visualize-runtime/executor.d.ts +22 -3
- package/src/executors/visualize-runtime/executor.js +55 -8
- package/src/executors/visualize-runtime/executor.js.map +1 -1
- package/src/executors/visualize-runtime/schema.json +7 -2
- package/src/lib/graph-color-modes.d.ts +10 -0
- package/src/lib/graph-color-modes.js +16 -1
- package/src/lib/graph-color-modes.js.map +1 -1
- package/src/lib/graph-mode-state.client.d.ts +6 -1
- package/src/lib/graph-mode-state.client.js +9 -1
- package/src/lib/graph-mode-state.client.js.map +1 -1
- package/src/lib/graph-page-shell.d.ts +10 -2
- package/src/lib/graph-page-shell.js +20 -8
- package/src/lib/graph-page-shell.js.map +1 -1
- package/src/lib/graph-render-model.d.ts +10 -0
- package/src/lib/graph-render-model.js +7 -0
- package/src/lib/graph-render-model.js.map +1 -1
- package/src/lib/graph-visualizer.client.js +2 -2
- package/src/lib/graph-visualizer.client.js.map +1 -1
- package/src/lib/runtime-edge-merge.d.ts +18 -0
- package/src/lib/runtime-edge-merge.js +38 -0
- package/src/lib/runtime-edge-merge.js.map +1 -0
- package/src/lib/runtime-goal-comparison.js +1 -1
- package/src/lib/runtime-goal-comparison.js.map +1 -1
- package/src/lib/runtime-goal-file.d.ts +6 -11
- package/src/lib/runtime-goal-file.js +10 -23
- package/src/lib/runtime-goal-file.js.map +1 -1
- package/src/lib/runtime-goal-validator.d.ts +4 -4
- package/src/lib/runtime-goal-validator.js +4 -4
- package/src/lib/runtime-goal-validator.js.map +1 -1
- package/src/lib/runtime-goal-view.d.ts +18 -11
- package/src/lib/runtime-goal-view.js +27 -27
- package/src/lib/runtime-goal-view.js.map +1 -1
- package/src/lib/runtime-html-page.d.ts +2 -0
- package/src/lib/runtime-html-page.js +8 -2
- package/src/lib/runtime-html-page.js.map +1 -1
- package/src/lib/runtime-union-graph.d.ts +0 -2
- package/src/lib/runtime-union-graph.js +3 -19
- package/src/lib/runtime-union-graph.js.map +1 -1
- package/src/lib/runtime-visualizer.d.ts +2 -3
- package/src/lib/runtime-visualizer.js +3 -4
- package/src/lib/runtime-visualizer.js.map +1 -1
- package/src/lib/runtime-viz-options.d.ts +3 -5
- package/src/lib/runtime-viz-options.js +3 -7
- package/src/lib/runtime-viz-options.js.map +1 -1
- package/src/plugin.js +0 -1
- package/src/plugin.js.map +1 -1
- package/src/runtime-targets.d.ts +0 -6
- package/src/runtime-targets.js +1 -18
- package/src/runtime-targets.js.map +1 -1
- package/src/executors/visualize-runtime-goal/executor.d.ts +0 -27
- package/src/executors/visualize-runtime-goal/executor.js +0 -99
- package/src/executors/visualize-runtime-goal/executor.js.map +0 -1
- package/src/executors/visualize-runtime-goal/schema.json +0 -13
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Visualize Runtime Goal Executor (#1239)
|
|
3
|
-
*
|
|
4
|
-
* Renders the hand-authored runtime PROPOSAL, architecture/runtime-dependencies-goal.json, with the
|
|
5
|
-
* same shared runtime renderer as visualize-runtime, into its own files:
|
|
6
|
-
* tmp/webpieces/runtime-architecture-goal.{dot,html}. It never generates anything from source first,
|
|
7
|
-
* never writes either JSON input, and never overwrites the current page.
|
|
8
|
-
*
|
|
9
|
-
* The page carries Goal vs Current when the saved current graph is usable; otherwise that mode says
|
|
10
|
-
* why. A missing goal fails with its expected path and how to start one — the current graph is never
|
|
11
|
-
* rendered in its place.
|
|
12
|
-
*
|
|
13
|
-
* `--prepare` is the one explicit, WRITING step: it recomputes the goal's derived levels, self-queue
|
|
14
|
-
* flags, contract queues and maxLevel with the generator's own level machinery, saves the goal, and
|
|
15
|
-
* then views it.
|
|
16
|
-
*
|
|
17
|
-
* Usage: nx run architecture:visualize-runtime-goal [--prepare]
|
|
18
|
-
*/
|
|
19
|
-
import type { ExecutorContext } from '@nx/devkit';
|
|
20
|
-
export interface VisualizeRuntimeGoalOptions {
|
|
21
|
-
/** Recompute and SAVE the goal's derived levels before viewing. Viewing alone never writes. */
|
|
22
|
-
prepare?: boolean;
|
|
23
|
-
}
|
|
24
|
-
export interface ExecutorResult {
|
|
25
|
-
success: boolean;
|
|
26
|
-
}
|
|
27
|
-
export default function runExecutor(options: VisualizeRuntimeGoalOptions, context: ExecutorContext): Promise<ExecutorResult>;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Visualize Runtime Goal Executor (#1239)
|
|
4
|
-
*
|
|
5
|
-
* Renders the hand-authored runtime PROPOSAL, architecture/runtime-dependencies-goal.json, with the
|
|
6
|
-
* same shared runtime renderer as visualize-runtime, into its own files:
|
|
7
|
-
* tmp/webpieces/runtime-architecture-goal.{dot,html}. It never generates anything from source first,
|
|
8
|
-
* never writes either JSON input, and never overwrites the current page.
|
|
9
|
-
*
|
|
10
|
-
* The page carries Goal vs Current when the saved current graph is usable; otherwise that mode says
|
|
11
|
-
* why. A missing goal fails with its expected path and how to start one — the current graph is never
|
|
12
|
-
* rendered in its place.
|
|
13
|
-
*
|
|
14
|
-
* `--prepare` is the one explicit, WRITING step: it recomputes the goal's derived levels, self-queue
|
|
15
|
-
* flags, contract queues and maxLevel with the generator's own level machinery, saves the goal, and
|
|
16
|
-
* then views it.
|
|
17
|
-
*
|
|
18
|
-
* Usage: nx run architecture:visualize-runtime-goal [--prepare]
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.default = runExecutor;
|
|
22
|
-
const tslib_1 = require("tslib");
|
|
23
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
24
|
-
const path = tslib_1.__importStar(require("path"));
|
|
25
|
-
const rules_config_1 = require("@webpieces/rules-config");
|
|
26
|
-
const graph_loader_1 = require("../../lib/graph-loader");
|
|
27
|
-
const graph_impact_1 = require("../../lib/graph-impact");
|
|
28
|
-
const graph_edge_diff_1 = require("../../lib/graph-edge-diff");
|
|
29
|
-
const saved_snapshot_1 = require("../../lib/saved-snapshot");
|
|
30
|
-
const runtime_visualizer_1 = require("../../lib/runtime-visualizer");
|
|
31
|
-
const runtime_config_1 = require("../../lib/runtime-config");
|
|
32
|
-
const graph_visualizer_1 = require("../../lib/graph-visualizer");
|
|
33
|
-
const runtime_goal_view_1 = require("../../lib/runtime-goal-view");
|
|
34
|
-
const runtime_goal_file_1 = require("../../lib/runtime-goal-file");
|
|
35
|
-
const toError_1 = require("../../toError");
|
|
36
|
-
// webpieces-disable no-function-outside-class -- Nx executor entry point: Nx requires a default-exported function
|
|
37
|
-
async function runExecutor(options, context) {
|
|
38
|
-
const workspaceRoot = context.root;
|
|
39
|
-
const goalFile = new runtime_goal_file_1.RuntimeGoalFile();
|
|
40
|
-
const snapshot = new saved_snapshot_1.SavedSnapshot();
|
|
41
|
-
console.log('\n🎯 Runtime Goal Visualization\n');
|
|
42
|
-
console.log(new runtime_goal_file_1.RuntimeGoalProvenance().message());
|
|
43
|
-
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- Nx command rendering boundary; success:false propagates failure to Nx
|
|
44
|
-
try {
|
|
45
|
-
const goal = options.prepare === true ? prepared(goalFile, workspaceRoot) : goalFile.load(workspaceRoot);
|
|
46
|
-
reportDrift(goalFile, goal);
|
|
47
|
-
const config = (0, runtime_config_1.loadRuntimeConfig)(workspaceRoot);
|
|
48
|
-
const projects = fs.existsSync(path.join(workspaceRoot, graph_loader_1.DEFAULT_GRAPH_PATH)) ? snapshot.loadProjects(workspaceRoot, graph_loader_1.DEFAULT_GRAPH_PATH).projects : null;
|
|
49
|
-
const vizOptions = new runtime_visualizer_1.RuntimeVizOptions(config.showExternalNodes, projects, workspaceRoot, runtime_visualizer_1.RuntimePageKind.GOAL);
|
|
50
|
-
const inputs = new runtime_goal_view_1.RuntimeComparisonInputs(snapshot, goalFile);
|
|
51
|
-
const comparison = inputs.view(inputs.current(workspaceRoot), goal, vizOptions);
|
|
52
|
-
console.log(comparison.available ? `Goal vs Current: ${comparison.summary}` : `Goal vs Current unavailable: ${comparison.reason}`);
|
|
53
|
-
const vizPaths = (0, runtime_visualizer_1.writeRuntimeVisualization)(goal, workspaceRoot, 'Goal / Proposed Runtime Architecture', vizOptions, comparison);
|
|
54
|
-
console.log(`✅ Generated: ${vizPaths.dotPath}`);
|
|
55
|
-
console.log(`✅ Generated: ${vizPaths.htmlPath}`);
|
|
56
|
-
if (projects !== null)
|
|
57
|
-
console.log(await new graph_impact_1.ImpactRefresh().run(path.dirname(vizPaths.htmlPath), workspaceRoot, projects, graph_impact_1.VISUALIZE_IMPACT_KINDS, new graph_edge_diff_1.LiveGraphSource()));
|
|
58
|
-
else {
|
|
59
|
-
new graph_impact_1.ImpactSidecar().remove(path.dirname(vizPaths.htmlPath));
|
|
60
|
-
console.log('Impact and framework metadata unavailable: no saved project graph. Proposed services carry their goal facts only.');
|
|
61
|
-
}
|
|
62
|
-
console.log('\n🌐 Opening visualization in browser...');
|
|
63
|
-
if (new graph_visualizer_1.GraphVisualizer().openVisualization(vizPaths.htmlPath))
|
|
64
|
-
console.log('✅ Browser opened');
|
|
65
|
-
else
|
|
66
|
-
console.log(`⚠️ Could not auto-open. Open manually: ${vizPaths.htmlPath}`);
|
|
67
|
-
return { success: true };
|
|
68
|
-
}
|
|
69
|
-
catch (err) {
|
|
70
|
-
const error = (0, toError_1.toError)(err);
|
|
71
|
-
const rendered = error instanceof rules_config_1.RuleFailError ? (0, rules_config_1.renderRuleFailForHuman)(error) : error.message;
|
|
72
|
-
console.error(`❌ Runtime goal visualization failed for ${goalFile.goalPath}:`, rendered);
|
|
73
|
-
return { success: false };
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// webpieces-disable no-function-outside-class -- executor step helper, sibling of runExecutor
|
|
77
|
-
function prepared(goalFile, workspaceRoot) {
|
|
78
|
-
const preparation = goalFile.prepare(workspaceRoot);
|
|
79
|
-
if (!preparation.written)
|
|
80
|
-
console.log(`✅ ${goalFile.goalPath} derived facts already consistent; nothing written.`);
|
|
81
|
-
else if (preparation.changes.length === 0)
|
|
82
|
-
console.log(`✍️ Prepared ${goalFile.goalPath}: rewrote explanatory levelBecause text only.`);
|
|
83
|
-
else
|
|
84
|
-
console.log(`✍️ Prepared ${goalFile.goalPath}:\n ${preparation.changes.join('\n ')}`);
|
|
85
|
-
return preparation.graph;
|
|
86
|
-
}
|
|
87
|
-
// webpieces-disable no-function-outside-class -- executor step helper, sibling of runExecutor
|
|
88
|
-
function reportDrift(goalFile, goal) {
|
|
89
|
-
const drift = goalFile.drift(goal);
|
|
90
|
-
if (drift.cycle !== null) {
|
|
91
|
-
console.warn(`⚠️ ${drift.cycle}\n Rendered with its saved levels. ${goalFile.cycleOption().text}`);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (drift.differences.length === 0)
|
|
95
|
-
return;
|
|
96
|
-
console.warn(`⚠️ ${goalFile.goalPath} saves derived facts that disagree with its relationships (rendered as saved):\n ` +
|
|
97
|
-
`${drift.differences.join('\n ')}\n Recompute them explicitly: ${runtime_goal_file_1.RUNTIME_GOAL_PREPARE_COMMAND}`);
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=executor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/nx-webpieces-rules/src/executors/visualize-runtime-goal/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AA4BH,8BAqCC;;AA/DD,+CAAyB;AACzB,mDAA6B;AAE7B,0DAAgF;AAChF,yDAA4D;AAC5D,yDAA8F;AAC9F,+DAA4D;AAC5D,6DAAyD;AACzD,qEAA6G;AAC7G,6DAA6D;AAC7D,iEAA6D;AAC7D,mEAAsE;AACtE,mEAAmH;A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,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC3C,OAAO,CAAC,IAAI,CACR,OAAO,QAAQ,CAAC,QAAQ,oFAAoF;QACxG,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,kCAAkC,gDAA4B,EAAE,CACxG,CAAC;AACN,CAAC","sourcesContent":["/**\n * Visualize Runtime Goal Executor (#1239)\n *\n * Renders the hand-authored runtime PROPOSAL, architecture/runtime-dependencies-goal.json, with the\n * same shared runtime renderer as visualize-runtime, into its own files:\n * tmp/webpieces/runtime-architecture-goal.{dot,html}. It never generates anything from source first,\n * never writes either JSON input, and never overwrites the current page.\n *\n * The page carries Goal vs Current when the saved current graph is usable; otherwise that mode says\n * why. A missing goal fails with its expected path and how to start one — the current graph is never\n * rendered in its place.\n *\n * `--prepare` is the one explicit, WRITING step: it recomputes the goal's derived levels, self-queue\n * flags, contract queues and maxLevel with the generator's own level machinery, saves the goal, and\n * then views it.\n *\n * Usage: nx run architecture:visualize-runtime-goal [--prepare]\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { ExecutorContext } from '@nx/devkit';\nimport { RuleFailError, renderRuleFailForHuman } from '@webpieces/rules-config';\nimport { DEFAULT_GRAPH_PATH } from '../../lib/graph-loader';\nimport { ImpactRefresh, ImpactSidecar, VISUALIZE_IMPACT_KINDS } from '../../lib/graph-impact';\nimport { LiveGraphSource } from '../../lib/graph-edge-diff';\nimport { SavedSnapshot } from '../../lib/saved-snapshot';\nimport { writeRuntimeVisualization, RuntimeVizOptions, RuntimePageKind } from '../../lib/runtime-visualizer';\nimport { loadRuntimeConfig } from '../../lib/runtime-config';\nimport { GraphVisualizer } from '../../lib/graph-visualizer';\nimport { RuntimeComparisonInputs } from '../../lib/runtime-goal-view';\nimport { RuntimeGoalFile, RuntimeGoalProvenance, RUNTIME_GOAL_PREPARE_COMMAND } from '../../lib/runtime-goal-file';\nimport type { RuntimeGraph } from '../../lib/runtime-graph-model';\nimport { toError } from '../../toError';\n\nexport interface VisualizeRuntimeGoalOptions {\n /** Recompute and SAVE the goal's derived levels before viewing. Viewing alone never writes. */\n prepare?: boolean;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\n// webpieces-disable no-function-outside-class -- Nx executor entry point: Nx requires a default-exported function\nexport default async function runExecutor(\n options: VisualizeRuntimeGoalOptions,\n context: ExecutorContext,\n): Promise<ExecutorResult> {\n const workspaceRoot = context.root;\n const goalFile = new RuntimeGoalFile();\n const snapshot = new SavedSnapshot();\n\n console.log('\\n🎯 Runtime Goal Visualization\\n');\n console.log(new RuntimeGoalProvenance().message());\n\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- Nx command rendering boundary; success:false propagates failure to Nx\n try {\n const goal = options.prepare === true ? prepared(goalFile, workspaceRoot) : goalFile.load(workspaceRoot);\n reportDrift(goalFile, goal);\n const config = loadRuntimeConfig(workspaceRoot);\n const projects = fs.existsSync(path.join(workspaceRoot, DEFAULT_GRAPH_PATH)) ? snapshot.loadProjects(workspaceRoot, DEFAULT_GRAPH_PATH).projects : null;\n const vizOptions = new RuntimeVizOptions(config.showExternalNodes, projects, workspaceRoot, RuntimePageKind.GOAL);\n const inputs = new RuntimeComparisonInputs(snapshot, goalFile);\n const comparison = inputs.view(inputs.current(workspaceRoot), goal, vizOptions);\n console.log(comparison.available ? `Goal vs Current: ${comparison.summary}` : `Goal vs Current unavailable: ${comparison.reason}`);\n const vizPaths = writeRuntimeVisualization(goal, workspaceRoot, 'Goal / Proposed Runtime Architecture', vizOptions, comparison);\n console.log(`✅ Generated: ${vizPaths.dotPath}`);\n console.log(`✅ Generated: ${vizPaths.htmlPath}`);\n if (projects !== null) console.log(await new ImpactRefresh().run(path.dirname(vizPaths.htmlPath), workspaceRoot, projects, VISUALIZE_IMPACT_KINDS, new LiveGraphSource()));\n else { new ImpactSidecar().remove(path.dirname(vizPaths.htmlPath)); console.log('Impact and framework metadata unavailable: no saved project graph. Proposed services carry their goal facts only.'); }\n\n console.log('\\n🌐 Opening visualization in browser...');\n if (new GraphVisualizer().openVisualization(vizPaths.htmlPath)) console.log('✅ Browser opened');\n else console.log(`⚠️ Could not auto-open. Open manually: ${vizPaths.htmlPath}`);\n return { success: true };\n } catch (err: unknown) {\n const error = toError(err);\n const rendered = error instanceof RuleFailError ? renderRuleFailForHuman(error) : error.message;\n console.error(`❌ Runtime goal visualization failed for ${goalFile.goalPath}:`, rendered);\n return { success: false };\n }\n}\n\n// webpieces-disable no-function-outside-class -- executor step helper, sibling of runExecutor\nfunction prepared(goalFile: RuntimeGoalFile, workspaceRoot: string): RuntimeGraph {\n const preparation = goalFile.prepare(workspaceRoot);\n if (!preparation.written) console.log(`✅ ${goalFile.goalPath} derived facts already consistent; nothing written.`);\n else if (preparation.changes.length === 0) console.log(`✍️ Prepared ${goalFile.goalPath}: rewrote explanatory levelBecause text only.`);\n else console.log(`✍️ Prepared ${goalFile.goalPath}:\\n ${preparation.changes.join('\\n ')}`);\n return preparation.graph;\n}\n\n// webpieces-disable no-function-outside-class -- executor step helper, sibling of runExecutor\nfunction reportDrift(goalFile: RuntimeGoalFile, goal: RuntimeGraph): void {\n const drift = goalFile.drift(goal);\n if (drift.cycle !== null) {\n console.warn(`⚠️ ${drift.cycle}\\n Rendered with its saved levels. ${goalFile.cycleOption().text}`);\n return;\n }\n if (drift.differences.length === 0) return;\n console.warn(\n `⚠️ ${goalFile.goalPath} saves derived facts that disagree with its relationships (rendered as saved):\\n ` +\n `${drift.differences.join('\\n ')}\\n Recompute them explicitly: ${RUNTIME_GOAL_PREPARE_COMMAND}`,\n );\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"title": "Visualize Runtime Goal Executor",
|
|
4
|
-
"description": "View the hand-authored runtime goal (architecture/runtime-dependencies-goal.json) as DOT + HTML, with Goal vs Current. Viewing never writes; --prepare explicitly recomputes the goal's derived levels first.",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"prepare": {
|
|
8
|
-
"type": "boolean",
|
|
9
|
-
"description": "Recompute and save the goal's derived levels, self-queue flags, contract queues and maxLevel before viewing."
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"required": []
|
|
13
|
-
}
|