@webpieces/nx-webpieces-rules 0.0.1 → 0.2.114
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/package.json +4 -4
- package/src/executor-result.d.ts +4 -0
- package/src/executor-result.js +10 -0
- package/src/executor-result.js.map +1 -0
- package/src/executors/generate/executor.d.ts +16 -0
- package/src/executors/generate/{executor.ts → executor.js} +15 -30
- package/src/executors/generate/executor.js.map +1 -0
- package/src/executors/help/executor.d.ts +8 -0
- package/src/executors/help/{executor.ts → executor.js} +5 -12
- package/src/executors/help/executor.js.map +1 -0
- package/src/executors/validate-architecture-unchanged/executor.d.ts +17 -0
- package/src/executors/validate-architecture-unchanged/{executor.ts → executor.js} +24 -46
- package/src/executors/validate-architecture-unchanged/executor.js.map +1 -0
- package/src/executors/validate-catch-error-pattern/executor.d.ts +3 -0
- package/src/executors/validate-catch-error-pattern/executor.js +10 -0
- package/src/executors/validate-catch-error-pattern/executor.js.map +1 -0
- package/src/executors/validate-code/executor.d.ts +3 -0
- package/src/executors/validate-code/executor.js +10 -0
- package/src/executors/validate-code/executor.js.map +1 -0
- package/src/executors/validate-dtos/executor.d.ts +3 -0
- package/src/executors/validate-dtos/executor.js +10 -0
- package/src/executors/validate-dtos/executor.js.map +1 -0
- package/src/executors/validate-eslint-sync/executor.d.ts +7 -0
- package/src/executors/validate-eslint-sync/{executor.ts → executor.js} +19 -37
- package/src/executors/validate-eslint-sync/executor.js.map +1 -0
- package/src/executors/validate-modified-files/executor.d.ts +3 -0
- package/src/executors/validate-modified-files/executor.js +10 -0
- package/src/executors/validate-modified-files/executor.js.map +1 -0
- package/src/executors/validate-modified-methods/executor.d.ts +3 -0
- package/src/executors/validate-modified-methods/executor.js +10 -0
- package/src/executors/validate-modified-methods/executor.js.map +1 -0
- package/src/executors/validate-new-methods/executor.d.ts +3 -0
- package/src/executors/validate-new-methods/executor.js +10 -0
- package/src/executors/validate-new-methods/executor.js.map +1 -0
- package/src/executors/validate-no-any-unknown/executor.d.ts +3 -0
- package/src/executors/validate-no-any-unknown/executor.js +10 -0
- package/src/executors/validate-no-any-unknown/executor.js.map +1 -0
- package/src/executors/validate-no-architecture-cycles/executor.d.ts +16 -0
- package/src/executors/validate-no-architecture-cycles/{executor.ts → executor.js} +16 -28
- package/src/executors/validate-no-architecture-cycles/executor.js.map +1 -0
- package/src/executors/validate-no-destructure/executor.d.ts +3 -0
- package/src/executors/validate-no-destructure/executor.js +10 -0
- package/src/executors/validate-no-destructure/executor.js.map +1 -0
- package/src/executors/validate-no-direct-api-resolver/executor.d.ts +3 -0
- package/src/executors/validate-no-direct-api-resolver/executor.js +10 -0
- package/src/executors/validate-no-direct-api-resolver/executor.js.map +1 -0
- package/src/executors/validate-no-implicit-any/executor.d.ts +3 -0
- package/src/executors/validate-no-implicit-any/executor.js +10 -0
- package/src/executors/validate-no-implicit-any/executor.js.map +1 -0
- package/src/executors/validate-no-inline-types/executor.d.ts +3 -0
- package/src/executors/validate-no-inline-types/executor.js +10 -0
- package/src/executors/validate-no-inline-types/executor.js.map +1 -0
- package/src/executors/validate-no-skiplevel-deps/executor.d.ts +19 -0
- package/src/executors/validate-no-skiplevel-deps/{executor.ts → executor.js} +23 -63
- package/src/executors/validate-no-skiplevel-deps/executor.js.map +1 -0
- package/src/executors/validate-no-unmanaged-exceptions/executor.d.ts +3 -0
- package/src/executors/validate-no-unmanaged-exceptions/executor.js +10 -0
- package/src/executors/validate-no-unmanaged-exceptions/executor.js.map +1 -0
- package/src/executors/validate-packagejson/executor.d.ts +16 -0
- package/src/executors/validate-packagejson/{executor.ts → executor.js} +15 -32
- package/src/executors/validate-packagejson/executor.js.map +1 -0
- package/src/executors/validate-prisma-converters/executor.d.ts +3 -0
- package/src/executors/validate-prisma-converters/executor.js +10 -0
- package/src/executors/validate-prisma-converters/executor.js.map +1 -0
- package/src/executors/validate-return-types/executor.d.ts +3 -0
- package/src/executors/validate-return-types/executor.js +10 -0
- package/src/executors/validate-return-types/executor.js.map +1 -0
- package/src/executors/validate-ts-in-src/executor.d.ts +32 -0
- package/src/executors/validate-ts-in-src/{executor.ts → executor.js} +80 -135
- package/src/executors/validate-ts-in-src/executor.js.map +1 -0
- package/src/executors/validate-versions-locked/executor.d.ts +22 -0
- package/src/executors/validate-versions-locked/{executor.ts → executor.js} +49 -116
- package/src/executors/validate-versions-locked/executor.js.map +1 -0
- package/src/executors/visualize/executor.d.ts +17 -0
- package/src/executors/visualize/{executor.ts → executor.js} +16 -30
- package/src/executors/visualize/executor.js.map +1 -0
- package/src/{index.ts → index.d.ts} +5 -1
- package/src/index.js +14 -0
- package/src/index.js.map +1 -0
- package/src/lib/graph-comparator.d.ts +39 -0
- package/src/lib/{graph-comparator.ts → graph-comparator.js} +18 -67
- package/src/lib/graph-comparator.js.map +1 -0
- package/src/lib/graph-generator.d.ts +19 -0
- package/src/lib/{graph-generator.ts → graph-generator.js} +17 -30
- package/src/lib/graph-generator.js.map +1 -0
- package/src/lib/graph-loader.d.ts +31 -0
- package/src/lib/{graph-loader.ts → graph-loader.js} +24 -42
- package/src/lib/graph-loader.js.map +1 -0
- package/src/lib/graph-sorter.d.ts +37 -0
- package/src/lib/{graph-sorter.ts → graph-sorter.js} +26 -53
- package/src/lib/graph-sorter.js.map +1 -0
- package/src/lib/graph-visualizer.d.ts +31 -0
- package/src/lib/{graph-visualizer.ts → graph-visualizer.js} +32 -56
- package/src/lib/graph-visualizer.js.map +1 -0
- package/src/lib/package-validator.d.ts +40 -0
- package/src/lib/package-validator.js +175 -0
- package/src/lib/package-validator.js.map +1 -0
- package/src/plugin.d.ts +86 -0
- package/src/{plugin.ts → plugin.js} +100 -255
- package/src/plugin.js.map +1 -0
- package/src/toError.d.ts +5 -0
- package/src/{toError.ts → toError.js} +7 -6
- package/src/toError.js.map +1 -0
- package/LICENSE +0 -373
- package/src/executor-result.ts +0 -7
- package/src/executors/validate-catch-error-pattern/executor.ts +0 -11
- package/src/executors/validate-code/executor.ts +0 -11
- package/src/executors/validate-dtos/executor.ts +0 -11
- package/src/executors/validate-modified-files/executor.ts +0 -11
- package/src/executors/validate-modified-methods/executor.ts +0 -11
- package/src/executors/validate-new-methods/executor.ts +0 -11
- package/src/executors/validate-no-any-unknown/executor.ts +0 -11
- package/src/executors/validate-no-destructure/executor.ts +0 -11
- package/src/executors/validate-no-direct-api-resolver/executor.ts +0 -11
- package/src/executors/validate-no-implicit-any/executor.ts +0 -11
- package/src/executors/validate-no-inline-types/executor.ts +0 -11
- package/src/executors/validate-no-unmanaged-exceptions/executor.ts +0 -11
- package/src/executors/validate-prisma-converters/executor.ts +0 -11
- package/src/executors/validate-return-types/executor.ts +0 -11
- package/src/lib/package-validator.ts +0 -184
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { ExecutorResult } from '../../executor-result';
|
|
3
|
-
import { validateNoInlineTypes } from '@webpieces/code-rules';
|
|
4
|
-
|
|
5
|
-
export default async function runExecutor(
|
|
6
|
-
// webpieces-disable no-any-unknown -- options are passed through to code-rules validators
|
|
7
|
-
options: Record<string, unknown>,
|
|
8
|
-
context: ExecutorContext,
|
|
9
|
-
): Promise<ExecutorResult> {
|
|
10
|
-
return validateNoInlineTypes(options, context.root);
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { ExecutorResult } from '../../executor-result';
|
|
3
|
-
import { validateNoUnmanagedExceptions } from '@webpieces/code-rules';
|
|
4
|
-
|
|
5
|
-
export default async function runExecutor(
|
|
6
|
-
// webpieces-disable no-any-unknown -- options are passed through to code-rules validators
|
|
7
|
-
options: Record<string, unknown>,
|
|
8
|
-
context: ExecutorContext,
|
|
9
|
-
): Promise<ExecutorResult> {
|
|
10
|
-
return validateNoUnmanagedExceptions(options, context.root);
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { ExecutorResult } from '../../executor-result';
|
|
3
|
-
import { validatePrismaConverters } from '@webpieces/code-rules';
|
|
4
|
-
|
|
5
|
-
export default async function runExecutor(
|
|
6
|
-
// webpieces-disable no-any-unknown -- options are passed through to code-rules validators
|
|
7
|
-
options: Record<string, unknown>,
|
|
8
|
-
context: ExecutorContext,
|
|
9
|
-
): Promise<ExecutorResult> {
|
|
10
|
-
return validatePrismaConverters(options, context.root);
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { ExecutorResult } from '../../executor-result';
|
|
3
|
-
import { validateReturnTypes } from '@webpieces/code-rules';
|
|
4
|
-
|
|
5
|
-
export default async function runExecutor(
|
|
6
|
-
// webpieces-disable no-any-unknown -- options are passed through to code-rules validators
|
|
7
|
-
options: Record<string, unknown>,
|
|
8
|
-
context: ExecutorContext,
|
|
9
|
-
): Promise<ExecutorResult> {
|
|
10
|
-
return validateReturnTypes(options, context.root);
|
|
11
|
-
}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package Validator
|
|
3
|
-
*
|
|
4
|
-
* Validates that package.json dependencies match the project.json build.dependsOn
|
|
5
|
-
* This ensures the two sources of truth don't drift apart.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import * as fs from 'fs';
|
|
9
|
-
import * as path from 'path';
|
|
10
|
-
import {
|
|
11
|
-
createProjectGraphAsync,
|
|
12
|
-
readProjectsConfigurationFromProjectGraph,
|
|
13
|
-
} from '@nx/devkit';
|
|
14
|
-
import { toError } from '../toError';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Validation result for a single project
|
|
18
|
-
*/
|
|
19
|
-
export interface ProjectValidationResult {
|
|
20
|
-
project: string;
|
|
21
|
-
valid: boolean;
|
|
22
|
-
missingInPackageJson: string[];
|
|
23
|
-
extraInPackageJson: string[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Overall validation result
|
|
28
|
-
*/
|
|
29
|
-
export interface ValidationResult {
|
|
30
|
-
valid: boolean;
|
|
31
|
-
errors: string[];
|
|
32
|
-
projectResults: ProjectValidationResult[];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Read package.json dependencies for a project
|
|
37
|
-
* Returns null if package.json doesn't exist (apps often don't have one)
|
|
38
|
-
*/
|
|
39
|
-
function readPackageJsonDeps(workspaceRoot: string, projectRoot: string): string[] | null {
|
|
40
|
-
const packageJsonPath = path.join(workspaceRoot, projectRoot, 'package.json');
|
|
41
|
-
|
|
42
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
43
|
-
return null; // No package.json - skip validation for this project
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
47
|
-
try {
|
|
48
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
49
|
-
const deps: string[] = [];
|
|
50
|
-
|
|
51
|
-
// Collect ALL dependencies from package.json
|
|
52
|
-
for (const depType of ['dependencies', 'peerDependencies']) {
|
|
53
|
-
const depObj = packageJson[depType] || {};
|
|
54
|
-
for (const depName of Object.keys(depObj)) {
|
|
55
|
-
if (!deps.includes(depName)) {
|
|
56
|
-
deps.push(depName);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return deps.sort();
|
|
62
|
-
} catch (err: unknown) {
|
|
63
|
-
//const error = toError(err);
|
|
64
|
-
void err;
|
|
65
|
-
console.warn(`Could not read package.json at ${packageJsonPath}`);
|
|
66
|
-
return [];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Build map of project names to their package names
|
|
72
|
-
* e.g., "core-util" → "@webpieces/core-util"
|
|
73
|
-
*/
|
|
74
|
-
function buildProjectToPackageMap(
|
|
75
|
-
workspaceRoot: string,
|
|
76
|
-
// webpieces-disable no-any-unknown -- Nx devkit projectsConfig type is dynamic and not strongly typed
|
|
77
|
-
projectsConfig: any
|
|
78
|
-
): Map<string, string> {
|
|
79
|
-
const map = new Map<string, string>();
|
|
80
|
-
|
|
81
|
-
// webpieces-disable no-any-unknown -- Nx devkit projects config entries are untyped
|
|
82
|
-
for (const [projectName, config] of Object.entries<any>(projectsConfig.projects)) {
|
|
83
|
-
const packageJsonPath = path.join(workspaceRoot, config.root, 'package.json');
|
|
84
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
85
|
-
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
86
|
-
try {
|
|
87
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
88
|
-
if (packageJson.name) {
|
|
89
|
-
map.set(projectName, packageJson.name);
|
|
90
|
-
}
|
|
91
|
-
} catch (err: unknown) {
|
|
92
|
-
//const error = toError(err);
|
|
93
|
-
void err;
|
|
94
|
-
// Ignore parse errors
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return map;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Validate that package.json dependencies match the dependency graph
|
|
104
|
-
*
|
|
105
|
-
* For each project in the graph:
|
|
106
|
-
* - Check that all graph dependencies exist in package.json
|
|
107
|
-
* - Maps project names to package names for accurate comparison
|
|
108
|
-
*
|
|
109
|
-
* @param graph - Enhanced graph with project dependencies (uses project names)
|
|
110
|
-
* @param workspaceRoot - Absolute path to workspace root
|
|
111
|
-
* @returns Validation result with errors if any
|
|
112
|
-
*/
|
|
113
|
-
interface GraphEntry {
|
|
114
|
-
level: number;
|
|
115
|
-
dependsOn: string[];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export async function validatePackageJsonDependencies(
|
|
119
|
-
graph: Record<string, GraphEntry>,
|
|
120
|
-
workspaceRoot: string
|
|
121
|
-
): Promise<ValidationResult> {
|
|
122
|
-
const projectGraph = await createProjectGraphAsync();
|
|
123
|
-
const projectsConfig = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
124
|
-
|
|
125
|
-
// Build map: project name → package name
|
|
126
|
-
const projectToPackage = buildProjectToPackageMap(workspaceRoot, projectsConfig);
|
|
127
|
-
|
|
128
|
-
const errors: string[] = [];
|
|
129
|
-
const projectResults: ProjectValidationResult[] = [];
|
|
130
|
-
|
|
131
|
-
for (const [projectName, entry] of Object.entries(graph)) {
|
|
132
|
-
// Find the project config using project name directly
|
|
133
|
-
const projectConfig = projectsConfig.projects[projectName];
|
|
134
|
-
if (!projectConfig) {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const projectRoot = projectConfig.root;
|
|
139
|
-
const packageJsonDeps = readPackageJsonDeps(workspaceRoot, projectRoot);
|
|
140
|
-
|
|
141
|
-
if (packageJsonDeps === null) {
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Convert graph dependencies (project names) to package names for comparison
|
|
146
|
-
const missingInPackageJson: string[] = [];
|
|
147
|
-
for (const depProjectName of entry.dependsOn) {
|
|
148
|
-
const depPackageName = projectToPackage.get(depProjectName) || depProjectName;
|
|
149
|
-
if (!packageJsonDeps.includes(depPackageName)) {
|
|
150
|
-
missingInPackageJson.push(depProjectName);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Check for extra dependencies in package.json (not critical, just informational)
|
|
155
|
-
const extraInPackageJson: string[] = [];
|
|
156
|
-
for (const dep of packageJsonDeps) {
|
|
157
|
-
if (!entry.dependsOn.includes(dep)) {
|
|
158
|
-
extraInPackageJson.push(dep);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const valid = missingInPackageJson.length === 0;
|
|
163
|
-
|
|
164
|
-
if (!valid) {
|
|
165
|
-
errors.push(
|
|
166
|
-
`Project ${projectName} (${projectRoot}/package.json) is missing dependencies: ${missingInPackageJson.join(', ')}\n` +
|
|
167
|
-
` Fix: Add these to package.json dependencies`
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
projectResults.push({
|
|
172
|
-
project: projectName,
|
|
173
|
-
valid,
|
|
174
|
-
missingInPackageJson,
|
|
175
|
-
extraInPackageJson,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
valid: errors.length === 0,
|
|
181
|
-
errors,
|
|
182
|
-
projectResults,
|
|
183
|
-
};
|
|
184
|
-
}
|