@webpieces/nx-webpieces-rules 0.3.128 → 0.3.129

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 CHANGED
@@ -119,6 +119,11 @@
119
119
  "implementation": "./src/executors/validate-eslint-sync/executor",
120
120
  "schema": "./src/executors/validate-eslint-sync/schema.json",
121
121
  "description": "Validate that workspace and template eslint.webpieces.config.mjs files have identical rules"
122
+ },
123
+ "validate-nx-wiring": {
124
+ "implementation": "./src/executors/validate-nx-wiring/executor",
125
+ "schema": "./src/executors/validate-nx-wiring/schema.json",
126
+ "description": "Validate the webpieces validators are wired into the build via nx.json targetDefaults dependsOn"
122
127
  }
123
128
  }
124
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/nx-webpieces-rules",
3
- "version": "0.3.128",
3
+ "version": "0.3.129",
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",
@@ -18,10 +18,10 @@
18
18
  "README.md"
19
19
  ],
20
20
  "dependencies": {
21
- "@webpieces/ai-hook-rules": "0.3.128",
22
- "@webpieces/code-rules": "0.3.128",
23
- "@webpieces/eslint-rules": "0.3.128",
24
- "@webpieces/rules-config": "0.3.128"
21
+ "@webpieces/ai-hook-rules": "0.3.129",
22
+ "@webpieces/code-rules": "0.3.129",
23
+ "@webpieces/eslint-rules": "0.3.129",
24
+ "@webpieces/rules-config": "0.3.129"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@nx/devkit": ">=18.0.0"
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Validate Nx Wiring Executor
3
+ *
4
+ * Enforces that the webpieces validators are actually wired into the build in
5
+ * nx.json. The plugin auto-infers the validator targets (architecture:validate-complete,
6
+ * per-project validate-no-file-import-cycles), but the load-bearing connection that
7
+ * makes a build DEPEND on them lives in each repo's hand-edited nx.json:
8
+ *
9
+ * "@nx/js:tsc": {
10
+ * "dependsOn": ["architecture:validate-complete", "validate-no-file-import-cycles", "^build"]
11
+ * }
12
+ *
13
+ * If that dependsOn is stripped, the validators exist but never run and a build stays
14
+ * green while validating nothing. This executor fails when the wiring is missing.
15
+ *
16
+ * Conservative by design: it only REQUIRES wiring on compile executors that are
17
+ * actually used somewhere in the project graph (@nx/js:tsc, @angular/build:application).
18
+ * A repo that uses neither has nothing to gate and passes.
19
+ *
20
+ * Disable per validator in webpieces.config.json (rules[name].mode="OFF"), but the
21
+ * wiring itself is governed by the "nx-wiring" rule (default on) so the build gate stays.
22
+ *
23
+ * Usage: nx run architecture:validate-nx-wiring
24
+ */
25
+ import type { ExecutorContext } from '@nx/devkit';
26
+ export interface ValidateNxWiringOptions {
27
+ requiredDeps?: string[];
28
+ compileExecutors?: string[];
29
+ }
30
+ export interface ExecutorResult {
31
+ success: boolean;
32
+ }
33
+ export default function runExecutor(options: ValidateNxWiringOptions, context: ExecutorContext): Promise<ExecutorResult>;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ /**
3
+ * Validate Nx Wiring Executor
4
+ *
5
+ * Enforces that the webpieces validators are actually wired into the build in
6
+ * nx.json. The plugin auto-infers the validator targets (architecture:validate-complete,
7
+ * per-project validate-no-file-import-cycles), but the load-bearing connection that
8
+ * makes a build DEPEND on them lives in each repo's hand-edited nx.json:
9
+ *
10
+ * "@nx/js:tsc": {
11
+ * "dependsOn": ["architecture:validate-complete", "validate-no-file-import-cycles", "^build"]
12
+ * }
13
+ *
14
+ * If that dependsOn is stripped, the validators exist but never run and a build stays
15
+ * green while validating nothing. This executor fails when the wiring is missing.
16
+ *
17
+ * Conservative by design: it only REQUIRES wiring on compile executors that are
18
+ * actually used somewhere in the project graph (@nx/js:tsc, @angular/build:application).
19
+ * A repo that uses neither has nothing to gate and passes.
20
+ *
21
+ * Disable per validator in webpieces.config.json (rules[name].mode="OFF"), but the
22
+ * wiring itself is governed by the "nx-wiring" rule (default on) so the build gate stays.
23
+ *
24
+ * Usage: nx run architecture:validate-nx-wiring
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.default = runExecutor;
28
+ const tslib_1 = require("tslib");
29
+ const devkit_1 = require("@nx/devkit");
30
+ const rules_config_1 = require("@webpieces/rules-config");
31
+ const fs = tslib_1.__importStar(require("fs"));
32
+ const path = tslib_1.__importStar(require("path"));
33
+ const DEFAULT_REQUIRED_DEPS = [
34
+ 'architecture:validate-complete',
35
+ 'validate-no-file-import-cycles',
36
+ ];
37
+ const DEFAULT_COMPILE_EXECUTORS = [
38
+ '@nx/js:tsc',
39
+ '@angular/build:application',
40
+ ];
41
+ class WiringProblem {
42
+ constructor(executorName, missing, found) {
43
+ this.executorName = executorName;
44
+ this.missing = missing;
45
+ this.found = found;
46
+ }
47
+ }
48
+ function readTargetDefaults(workspaceRoot) {
49
+ const nxJsonPath = path.join(workspaceRoot, 'nx.json');
50
+ if (!fs.existsSync(nxJsonPath))
51
+ return {};
52
+ // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
53
+ try {
54
+ const raw = fs.readFileSync(nxJsonPath, 'utf8');
55
+ const parsed = JSON.parse(raw);
56
+ return parsed.targetDefaults ?? {};
57
+ // webpieces-disable catch-error-pattern -- malformed nx.json fails open so the check does not crash the build
58
+ }
59
+ catch (err) {
60
+ //const error = toError(err); -- malformed nx.json fails open
61
+ void err;
62
+ return {};
63
+ }
64
+ }
65
+ async function findCompileExecutorsInUse(compileExecutors) {
66
+ const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
67
+ const projectsConfig = (0, devkit_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
68
+ const known = new Set(compileExecutors);
69
+ const inUse = new Set();
70
+ for (const cfg of Object.values(projectsConfig.projects)) {
71
+ const targets = cfg.targets ?? {};
72
+ for (const target of Object.values(targets)) {
73
+ const executorName = target.executor;
74
+ if (executorName && known.has(executorName)) {
75
+ inUse.add(executorName);
76
+ }
77
+ }
78
+ }
79
+ return inUse;
80
+ }
81
+ function findProblems(relevantExecutors, targetDefaults, requiredDeps) {
82
+ const problems = [];
83
+ for (const executorName of relevantExecutors) {
84
+ const entry = targetDefaults[executorName];
85
+ const dependsOn = entry?.dependsOn ?? [];
86
+ const missing = requiredDeps.filter((dep) => !dependsOn.includes(dep));
87
+ if (missing.length > 0) {
88
+ problems.push(new WiringProblem(executorName, missing, dependsOn));
89
+ }
90
+ }
91
+ return problems;
92
+ }
93
+ function reportFailure(problems, requiredDeps) {
94
+ console.error('\n❌ webpieces validators are not wired into your build.\n');
95
+ console.error('The validators exist but no build depends on them, so they never run.');
96
+ console.error('Add the missing dependsOn entries to nx.json targetDefaults:\n');
97
+ const depsList = requiredDeps.map((dep) => `"${dep}"`).join(', ');
98
+ for (const problem of problems) {
99
+ const missingList = problem.missing.map((dep) => `"${dep}"`).join(', ');
100
+ console.error(` "${problem.executorName}": {`);
101
+ console.error(` "dependsOn": [${depsList}, "^build"]`);
102
+ console.error(' }');
103
+ console.error(` missing: ${missingList}\n`);
104
+ }
105
+ console.error('To disable an INDIVIDUAL validator, set rules[name].mode="OFF" in');
106
+ console.error('webpieces.config.json — but the wiring above must stay installed so the');
107
+ console.error('build gate keeps working. To turn this wiring check itself off, set');
108
+ console.error('rules["nx-wiring"].mode="OFF" in webpieces.config.json.\n');
109
+ }
110
+ async function runExecutor(options, context) {
111
+ const shared = (0, rules_config_1.loadConfig)(context.root);
112
+ const rule = shared.rules.get('nx-wiring');
113
+ if (rule && rule.isOff) {
114
+ console.log('\n⏭️ Skipping validate-nx-wiring (mode: OFF)\n');
115
+ return { success: true };
116
+ }
117
+ const requiredDeps = options.requiredDeps ?? DEFAULT_REQUIRED_DEPS;
118
+ const compileExecutors = options.compileExecutors ?? DEFAULT_COMPILE_EXECUTORS;
119
+ console.log('\n🔌 Validating webpieces validators are wired into the build\n');
120
+ const inUse = await findCompileExecutorsInUse(compileExecutors);
121
+ const relevantExecutors = compileExecutors.filter((executorName) => inUse.has(executorName));
122
+ if (relevantExecutors.length === 0) {
123
+ console.log('✅ No known compile executors in use — nothing to gate\n');
124
+ return { success: true };
125
+ }
126
+ const targetDefaults = readTargetDefaults(context.root);
127
+ const problems = findProblems(relevantExecutors, targetDefaults, requiredDeps);
128
+ if (problems.length === 0) {
129
+ console.log('✅ Validators are wired into the build\n');
130
+ return { success: true };
131
+ }
132
+ reportFailure(problems, requiredDeps);
133
+ return { success: false };
134
+ }
135
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/nx-webpieces-rules/src/executors/validate-nx-wiring/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAmHH,8BAoCC;;AApJD,uCAAgG;AAChG,0DAAqD;AACrD,+CAAyB;AACzB,mDAA6B;AAW7B,MAAM,qBAAqB,GAAa;IACpC,gCAAgC;IAChC,gCAAgC;CACnC,CAAC;AAEF,MAAM,yBAAyB,GAAa;IACxC,YAAY;IACZ,4BAA4B;CAC/B,CAAC;AAEF,MAAM,aAAa;IAKf,YAAY,YAAoB,EAAE,OAAiB,EAAE,KAAe;QAChE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAUD,SAAS,kBAAkB,CAAC,aAAqB;IAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACvD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,EAAE,CAAC;IAC1C,8DAA8D;IAC9D,IAAI,CAAC;QACD,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,IAAI,CA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K,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,aAAa,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACtC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * Validate Nx Wiring Executor\n *\n * Enforces that the webpieces validators are actually wired into the build in\n * nx.json. The plugin auto-infers the validator targets (architecture:validate-complete,\n * per-project validate-no-file-import-cycles), but the load-bearing connection that\n * makes a build DEPEND on them lives in each repo's hand-edited nx.json:\n *\n * \"@nx/js:tsc\": {\n * \"dependsOn\": [\"architecture:validate-complete\", \"validate-no-file-import-cycles\", \"^build\"]\n * }\n *\n * If that dependsOn is stripped, the validators exist but never run and a build stays\n * green while validating nothing. This executor fails when the wiring is missing.\n *\n * Conservative by design: it only REQUIRES wiring on compile executors that are\n * actually used somewhere in the project graph (@nx/js:tsc, @angular/build:application).\n * A repo that uses neither has nothing to gate and passes.\n *\n * Disable per validator in webpieces.config.json (rules[name].mode=\"OFF\"), but the\n * wiring itself is governed by the \"nx-wiring\" rule (default on) so the build gate stays.\n *\n * Usage: nx run architecture:validate-nx-wiring\n */\n\nimport type { ExecutorContext } from '@nx/devkit';\nimport { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph } from '@nx/devkit';\nimport { loadConfig } from '@webpieces/rules-config';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nexport interface ValidateNxWiringOptions {\n requiredDeps?: string[];\n compileExecutors?: string[];\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\nconst DEFAULT_REQUIRED_DEPS: string[] = [\n 'architecture:validate-complete',\n 'validate-no-file-import-cycles',\n];\n\nconst DEFAULT_COMPILE_EXECUTORS: string[] = [\n '@nx/js:tsc',\n '@angular/build:application',\n];\n\nclass WiringProblem {\n executorName: string;\n missing: string[];\n found: string[];\n\n constructor(executorName: string, missing: string[], found: string[]) {\n this.executorName = executorName;\n this.missing = missing;\n this.found = found;\n }\n}\n\ninterface TargetDefaultEntry {\n dependsOn?: string[];\n}\n\ninterface RawNxJson {\n targetDefaults?: Record<string, TargetDefaultEntry>;\n}\n\nfunction readTargetDefaults(workspaceRoot: string): Record<string, TargetDefaultEntry> {\n const nxJsonPath = path.join(workspaceRoot, 'nx.json');\n if (!fs.existsSync(nxJsonPath)) return {};\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const raw = fs.readFileSync(nxJsonPath, 'utf8');\n const parsed = JSON.parse(raw) as RawNxJson;\n return parsed.targetDefaults ?? {};\n // webpieces-disable catch-error-pattern -- malformed nx.json fails open so the check does not crash the build\n } catch (err: unknown) {\n //const error = toError(err); -- malformed nx.json fails open\n void err;\n return {};\n }\n}\n\nasync function findCompileExecutorsInUse(compileExecutors: string[]): Promise<Set<string>> {\n const projectGraph = await createProjectGraphAsync();\n const projectsConfig = readProjectsConfigurationFromProjectGraph(projectGraph);\n const known = new Set(compileExecutors);\n const inUse = new Set<string>();\n for (const cfg of Object.values(projectsConfig.projects)) {\n const targets = cfg.targets ?? {};\n for (const target of Object.values(targets)) {\n const executorName = target.executor;\n if (executorName && known.has(executorName)) {\n inUse.add(executorName);\n }\n }\n }\n return inUse;\n}\n\nfunction findProblems(\n relevantExecutors: string[],\n targetDefaults: Record<string, TargetDefaultEntry>,\n requiredDeps: string[],\n): WiringProblem[] {\n const problems: WiringProblem[] = [];\n for (const executorName of relevantExecutors) {\n const entry = targetDefaults[executorName];\n const dependsOn = entry?.dependsOn ?? [];\n const missing = requiredDeps.filter((dep: string) => !dependsOn.includes(dep));\n if (missing.length > 0) {\n problems.push(new WiringProblem(executorName, missing, dependsOn));\n }\n }\n return problems;\n}\n\nfunction reportFailure(problems: WiringProblem[], requiredDeps: string[]): void {\n console.error('\\n❌ webpieces validators are not wired into your build.\\n');\n console.error('The validators exist but no build depends on them, so they never run.');\n console.error('Add the missing dependsOn entries to nx.json targetDefaults:\\n');\n const depsList = requiredDeps.map((dep: string) => `\"${dep}\"`).join(', ');\n for (const problem of problems) {\n const missingList = problem.missing.map((dep: string) => `\"${dep}\"`).join(', ');\n console.error(` \"${problem.executorName}\": {`);\n console.error(` \"dependsOn\": [${depsList}, \"^build\"]`);\n console.error(' }');\n console.error(` missing: ${missingList}\\n`);\n }\n console.error('To disable an INDIVIDUAL validator, set rules[name].mode=\"OFF\" in');\n console.error('webpieces.config.json — but the wiring above must stay installed so the');\n console.error('build gate keeps working. To turn this wiring check itself off, set');\n console.error('rules[\"nx-wiring\"].mode=\"OFF\" in webpieces.config.json.\\n');\n}\n\nexport default async function runExecutor(\n options: ValidateNxWiringOptions,\n context: ExecutorContext,\n): Promise<ExecutorResult> {\n const shared = loadConfig(context.root);\n const rule = shared.rules.get('nx-wiring');\n if (rule && rule.isOff) {\n console.log('\\n⏭️ Skipping validate-nx-wiring (mode: OFF)\\n');\n return { success: true };\n }\n\n const requiredDeps = options.requiredDeps ?? DEFAULT_REQUIRED_DEPS;\n const compileExecutors = options.compileExecutors ?? DEFAULT_COMPILE_EXECUTORS;\n\n console.log('\\n🔌 Validating webpieces validators are wired into the build\\n');\n\n const inUse = await findCompileExecutorsInUse(compileExecutors);\n const relevantExecutors = compileExecutors.filter((executorName: string) =>\n inUse.has(executorName),\n );\n\n if (relevantExecutors.length === 0) {\n console.log('✅ No known compile executors in use — nothing to gate\\n');\n return { success: true };\n }\n\n const targetDefaults = readTargetDefaults(context.root);\n const problems = findProblems(relevantExecutors, targetDefaults, requiredDeps);\n\n if (problems.length === 0) {\n console.log('✅ Validators are wired into the build\\n');\n return { success: true };\n }\n\n reportFailure(problems, requiredDeps);\n return { success: false };\n}\n"]}
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "title": "Validate Nx Wiring Executor",
4
+ "description": "Validates that the webpieces validators are wired into the build via nx.json targetDefaults dependsOn, so a build cannot pass while running zero validators.",
5
+ "type": "object",
6
+ "properties": {
7
+ "requiredDeps": {
8
+ "type": "array",
9
+ "items": { "type": "string" },
10
+ "description": "Target names that each compile executor's dependsOn must include. Defaults: architecture:validate-complete, validate-no-file-import-cycles."
11
+ },
12
+ "compileExecutors": {
13
+ "type": "array",
14
+ "items": { "type": "string" },
15
+ "description": "Compile executors to require wiring on, but only when actually used in the project graph. Defaults: @nx/js:tsc, @angular/build:application."
16
+ }
17
+ },
18
+ "required": []
19
+ }
package/src/plugin.d.ts CHANGED
@@ -37,6 +37,7 @@ export interface ValidationOptions {
37
37
  validateModifiedFiles?: boolean;
38
38
  validateVersionsLocked?: boolean;
39
39
  validateTsInSrc?: boolean;
40
+ validateNxWiring?: boolean;
40
41
  newMethodsMaxLines?: number;
41
42
  modifiedAndNewMethodsMaxLines?: number;
42
43
  modifiedFilesMaxLines?: number;
package/src/plugin.js CHANGED
@@ -40,6 +40,7 @@ const DEFAULT_OPTIONS = {
40
40
  validateModifiedFiles: true,
41
41
  validateVersionsLocked: true,
42
42
  validateTsInSrc: true,
43
+ validateNxWiring: true,
43
44
  newMethodsMaxLines: 30,
44
45
  modifiedAndNewMethodsMaxLines: 80,
45
46
  modifiedFilesMaxLines: 900,
@@ -184,6 +185,8 @@ function buildValidationTargetsList(validations) {
184
185
  targets.push('validate-versions-locked');
185
186
  if (validations.validateTsInSrc)
186
187
  targets.push('validate-ts-in-src');
188
+ if (validations.validateNxWiring)
189
+ targets.push('validate-nx-wiring');
187
190
  return targets;
188
191
  }
189
192
  /**
@@ -228,6 +231,9 @@ function createWorkspaceTargetsWithoutPrefix(opts) {
228
231
  if (validations.validateTsInSrc) {
229
232
  targets['validate-ts-in-src'] = createValidateTsInSrcTarget();
230
233
  }
234
+ if (validations.validateNxWiring) {
235
+ targets['validate-nx-wiring'] = createValidateNxWiringTarget();
236
+ }
231
237
  // Add validate-complete target that runs all enabled validations
232
238
  const validationTargets = buildValidationTargetsList(validations);
233
239
  if (validationTargets.length > 0) {
@@ -428,6 +434,17 @@ function createValidateTsInSrcTarget() {
428
434
  },
429
435
  };
430
436
  }
437
+ function createValidateNxWiringTarget() {
438
+ return {
439
+ executor: '@webpieces/nx-webpieces-rules:validate-nx-wiring',
440
+ cache: false, // Cheap; depends on nx.json + project graph, not worth caching
441
+ inputs: ['{workspaceRoot}/nx.json', '{workspaceRoot}/webpieces.config.json'],
442
+ metadata: {
443
+ technologies: ['nx'],
444
+ description: 'Validate the webpieces validators are wired into the build via nx.json dependsOn',
445
+ },
446
+ };
447
+ }
431
448
  function createValidateCompleteTarget(validationTargets) {
432
449
  return {
433
450
  executor: 'nx:noop',
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;;;AAEH,+BAAqC;AACrC,2BAAgC;AAsEhC,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,eAAe,EAAE,IAAI;YACrB,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,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;SA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O,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';\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 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}\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 noSkipLevelDeps: true,\n architectureUnchanged: true,\n validatePackageJson: true,\n validateNewMethods: true,\n validateModifiedMethods: true,\n validateModifiedFiles: true,\n validateVersionsLocked: true,\n validateTsInSrc: true,\n newMethodsMaxLines: 30,\n modifiedAndNewMethodsMaxLines: 80,\n modifiedFilesMaxLines: 900,\n validationMode: 'NORMAL',\n },\n features: {\n generate: true,\n visualize: 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)\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\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 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: Record<string, TargetConfiguration> = {};\n\n // Add circular-deps target ONLY for project.json projects\n // (package.json-only projects may not have TypeScript source)\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 ci target to ALL projects (both project.json and package.json)\n targets['ci'] = createCiTarget();\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 * 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 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\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 (validations.noCycles) {\n targets['validate-no-architecture-cycles'] = createValidateNoCyclesTarget();\n }\n if (validations.architectureUnchanged) {\n targets['validate-architecture-unchanged'] = createValidateUnchangedTarget(graphPath);\n }\n if (validations.noSkipLevelDeps) {\n targets['validate-no-skiplevel-deps'] = createValidateNoSkipLevelTarget();\n }\n if (validations.validatePackageJson) {\n targets['validate-packagejson'] = createValidatePackageJsonTarget();\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'] = createValidateCodeTarget();\n }\n if (validations.validateVersionsLocked) {\n targets['validate-versions-locked'] = createValidateVersionsLockedTarget();\n }\n if (validations.validateTsInSrc) {\n targets['validate-ts-in-src'] = createValidateTsInSrcTarget();\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\n/**\n * Create workspace-level architecture validation targets (DEPRECATED - keeping for backward compat)\n * Used when root project.json exists (old style with '.' project)\n */\nfunction createWorkspaceTargets(\n opts: Required<ArchitecturePluginOptions>,\n): Record<string, TargetConfiguration> {\n const targets: Record<string, TargetConfiguration> = {};\n const prefix = opts.workspace.targetPrefix!;\n const graphPath = opts.workspace.graphPath!;\n\n // Add help target (always available)\n targets[`${prefix}help`] = createHelpTarget();\n\n if (opts.workspace.features!.generate) {\n targets[`${prefix}generate`] = createGenerateTarget(graphPath);\n }\n\n if (opts.workspace.features!.visualize) {\n targets[`${prefix}visualize`] = createVisualizeTarget(prefix, graphPath);\n }\n\n if (opts.workspace.validations!.noCycles) {\n targets[`${prefix}validate-no-architecture-cycles`] = createValidateNoCyclesTarget();\n }\n\n if (opts.workspace.validations!.architectureUnchanged) {\n targets[`${prefix}validate-architecture-unchanged`] =\n createValidateUnchangedTarget(graphPath);\n }\n\n if (opts.workspace.validations!.noSkipLevelDeps) {\n targets[`${prefix}validate-no-skiplevel-deps`] = createValidateNoSkipLevelTarget();\n }\n\n if (opts.workspace.validations!.validatePackageJson) {\n targets[`${prefix}validate-packagejson`] = createValidatePackageJsonTarget();\n }\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 opts.workspace.validations!.validateNewMethods ||\n opts.workspace.validations!.validateModifiedMethods ||\n opts.workspace.validations!.validateModifiedFiles\n ) {\n targets[`${prefix}validate-code`] = createValidateCodeTarget();\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: ['{workspaceRoot}/architecture/dependencies.json'],\n options: { graphPath },\n metadata: {\n technologies: ['nx'],\n description: 'Generate the architecture dependency graph from project.json files',\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 createVisualizeTarget(prefix: string, graphPath: string): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:visualize',\n dependsOn: [`${prefix}generate`],\n options: { graphPath },\n metadata: {\n technologies: ['nx'],\n description: 'Generate visual representations of the architecture graph',\n },\n };\n}\n\nfunction createValidateNoCyclesTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-no-architecture-cycles',\n cache: true,\n inputs: ['{workspaceRoot}/**/project.json', '{workspaceRoot}/architecture/dependencies.json'],\n metadata: {\n technologies: ['nx'],\n description: 'Validate the architecture has no circular project dependencies',\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 createValidateNoSkipLevelTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-no-skiplevel-deps',\n cache: true,\n inputs: ['{workspaceRoot}/**/project.json', '{workspaceRoot}/architecture/dependencies.json'],\n metadata: {\n technologies: ['nx'],\n description: 'Validate no project has redundant transitive dependencies',\n },\n };\n}\n\nfunction createValidatePackageJsonTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-packagejson',\n cache: true,\n inputs: ['{workspaceRoot}/**/project.json', '{workspaceRoot}/**/package.json'],\n metadata: {\n technologies: ['nx'],\n description: 'Validate package.json dependencies match project.json build dependencies',\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\n/**\n * Create combined validate-code target\n * Options come from webpieces.config.json at the workspace root\n * (loaded by the executor via @webpieces/rules-config — same source of truth as @webpieces/ai-hook-rules)\n */\nfunction createValidateCodeTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-code',\n cache: false, // Don't cache - depends on git state\n inputs: ['default', '{workspaceRoot}/webpieces.config.json'],\n // No options here - they come from webpieces.config.json at runtime\n metadata: {\n technologies: ['nx'],\n description: 'Combined validation for new methods, modified methods, and file sizes',\n },\n };\n}\n\nfunction createValidateVersionsLockedTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-versions-locked',\n cache: true,\n inputs: ['{workspaceRoot}/**/package.json'],\n metadata: {\n technologies: ['nx'],\n description:\n 'Validate package.json versions are locked (no semver ranges) and consistent across projects',\n },\n };\n}\n\nfunction createValidateTsInSrcTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-ts-in-src',\n cache: false,\n inputs: ['default', '{workspaceRoot}/webpieces.config.json'],\n metadata: {\n technologies: ['nx'],\n description: 'Validate all .ts files in projects are inside the src/ directory',\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 * Runs on project root (.) to check ALL TypeScript files in the project\n */\nfunction createCircularDepsTarget(projectRoot: string, targetName: string): TargetConfiguration {\n return {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default'],\n outputs: [] as string[],\n options: {\n command: 'npx madge --circular --extensions ts,tsx .',\n cwd: projectRoot,\n },\n metadata: {\n technologies: ['madge'],\n description: 'Check for circular 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;;;;;;;;;;;;;;;;G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AAC,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';\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 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}\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 noSkipLevelDeps: true,\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 newMethodsMaxLines: 30,\n modifiedAndNewMethodsMaxLines: 80,\n modifiedFilesMaxLines: 900,\n validationMode: 'NORMAL',\n },\n features: {\n generate: true,\n visualize: 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)\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\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 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: Record<string, TargetConfiguration> = {};\n\n // Add circular-deps target ONLY for project.json projects\n // (package.json-only projects may not have TypeScript source)\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 ci target to ALL projects (both project.json and package.json)\n targets['ci'] = createCiTarget();\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 * 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 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\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 (validations.noCycles) {\n targets['validate-no-architecture-cycles'] = createValidateNoCyclesTarget();\n }\n if (validations.architectureUnchanged) {\n targets['validate-architecture-unchanged'] = createValidateUnchangedTarget(graphPath);\n }\n if (validations.noSkipLevelDeps) {\n targets['validate-no-skiplevel-deps'] = createValidateNoSkipLevelTarget();\n }\n if (validations.validatePackageJson) {\n targets['validate-packagejson'] = createValidatePackageJsonTarget();\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'] = createValidateCodeTarget();\n }\n if (validations.validateVersionsLocked) {\n targets['validate-versions-locked'] = createValidateVersionsLockedTarget();\n }\n if (validations.validateTsInSrc) {\n targets['validate-ts-in-src'] = createValidateTsInSrcTarget();\n }\n if (validations.validateNxWiring) {\n targets['validate-nx-wiring'] = createValidateNxWiringTarget();\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\n/**\n * Create workspace-level architecture validation targets (DEPRECATED - keeping for backward compat)\n * Used when root project.json exists (old style with '.' project)\n */\nfunction createWorkspaceTargets(\n opts: Required<ArchitecturePluginOptions>,\n): Record<string, TargetConfiguration> {\n const targets: Record<string, TargetConfiguration> = {};\n const prefix = opts.workspace.targetPrefix!;\n const graphPath = opts.workspace.graphPath!;\n\n // Add help target (always available)\n targets[`${prefix}help`] = createHelpTarget();\n\n if (opts.workspace.features!.generate) {\n targets[`${prefix}generate`] = createGenerateTarget(graphPath);\n }\n\n if (opts.workspace.features!.visualize) {\n targets[`${prefix}visualize`] = createVisualizeTarget(prefix, graphPath);\n }\n\n if (opts.workspace.validations!.noCycles) {\n targets[`${prefix}validate-no-architecture-cycles`] = createValidateNoCyclesTarget();\n }\n\n if (opts.workspace.validations!.architectureUnchanged) {\n targets[`${prefix}validate-architecture-unchanged`] =\n createValidateUnchangedTarget(graphPath);\n }\n\n if (opts.workspace.validations!.noSkipLevelDeps) {\n targets[`${prefix}validate-no-skiplevel-deps`] = createValidateNoSkipLevelTarget();\n }\n\n if (opts.workspace.validations!.validatePackageJson) {\n targets[`${prefix}validate-packagejson`] = createValidatePackageJsonTarget();\n }\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 opts.workspace.validations!.validateNewMethods ||\n opts.workspace.validations!.validateModifiedMethods ||\n opts.workspace.validations!.validateModifiedFiles\n ) {\n targets[`${prefix}validate-code`] = createValidateCodeTarget();\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: ['{workspaceRoot}/architecture/dependencies.json'],\n options: { graphPath },\n metadata: {\n technologies: ['nx'],\n description: 'Generate the architecture dependency graph from project.json files',\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 createVisualizeTarget(prefix: string, graphPath: string): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:visualize',\n dependsOn: [`${prefix}generate`],\n options: { graphPath },\n metadata: {\n technologies: ['nx'],\n description: 'Generate visual representations of the architecture graph',\n },\n };\n}\n\nfunction createValidateNoCyclesTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-no-architecture-cycles',\n cache: true,\n inputs: ['{workspaceRoot}/**/project.json', '{workspaceRoot}/architecture/dependencies.json'],\n metadata: {\n technologies: ['nx'],\n description: 'Validate the architecture has no circular project dependencies',\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 createValidateNoSkipLevelTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-no-skiplevel-deps',\n cache: true,\n inputs: ['{workspaceRoot}/**/project.json', '{workspaceRoot}/architecture/dependencies.json'],\n metadata: {\n technologies: ['nx'],\n description: 'Validate no project has redundant transitive dependencies',\n },\n };\n}\n\nfunction createValidatePackageJsonTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-packagejson',\n cache: true,\n inputs: ['{workspaceRoot}/**/project.json', '{workspaceRoot}/**/package.json'],\n metadata: {\n technologies: ['nx'],\n description: 'Validate package.json dependencies match project.json build dependencies',\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\n/**\n * Create combined validate-code target\n * Options come from webpieces.config.json at the workspace root\n * (loaded by the executor via @webpieces/rules-config — same source of truth as @webpieces/ai-hook-rules)\n */\nfunction createValidateCodeTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-code',\n cache: false, // Don't cache - depends on git state\n inputs: ['default', '{workspaceRoot}/webpieces.config.json'],\n // No options here - they come from webpieces.config.json at runtime\n metadata: {\n technologies: ['nx'],\n description: 'Combined validation for new methods, modified methods, and file sizes',\n },\n };\n}\n\nfunction createValidateVersionsLockedTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-versions-locked',\n cache: true,\n inputs: ['{workspaceRoot}/**/package.json'],\n metadata: {\n technologies: ['nx'],\n description:\n 'Validate package.json versions are locked (no semver ranges) and consistent across projects',\n },\n };\n}\n\nfunction createValidateTsInSrcTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-ts-in-src',\n cache: false,\n inputs: ['default', '{workspaceRoot}/webpieces.config.json'],\n metadata: {\n technologies: ['nx'],\n description: 'Validate all .ts files in projects are inside the src/ directory',\n },\n };\n}\n\nfunction createValidateNxWiringTarget(): TargetConfiguration {\n return {\n executor: '@webpieces/nx-webpieces-rules:validate-nx-wiring',\n cache: false, // Cheap; depends on nx.json + project graph, not worth caching\n inputs: ['{workspaceRoot}/nx.json', '{workspaceRoot}/webpieces.config.json'],\n metadata: {\n technologies: ['nx'],\n description: 'Validate the webpieces validators are wired into the build via nx.json dependsOn',\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 * Runs on project root (.) to check ALL TypeScript files in the project\n */\nfunction createCircularDepsTarget(projectRoot: string, targetName: string): TargetConfiguration {\n return {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default'],\n outputs: [] as string[],\n options: {\n command: 'npx madge --circular --extensions ts,tsx .',\n cwd: projectRoot,\n },\n metadata: {\n technologies: ['madge'],\n description: 'Check for circular 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"]}