@webpieces/dev-config 0.2.65 → 0.2.66
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/architecture/executors/validate-code/executor.d.ts +12 -0
- package/architecture/executors/validate-code/executor.js +33 -0
- package/architecture/executors/validate-code/executor.js.map +1 -0
- package/architecture/executors/validate-code/executor.ts +62 -0
- package/architecture/executors/validate-code/schema.json +30 -0
- package/executors.json +5 -0
- package/package.json +1 -1
- package/plugin.js +28 -22
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
export type ValidationMode = 'STRICT' | 'NORMAL' | 'OFF';
|
|
3
|
+
export interface ValidateCodeOptions {
|
|
4
|
+
mode?: ValidationMode;
|
|
5
|
+
newMethodsMaxLines?: number;
|
|
6
|
+
modifiedMethodsMaxLines?: number;
|
|
7
|
+
modifiedFilesMaxLines?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ExecutorResult {
|
|
10
|
+
success: boolean;
|
|
11
|
+
}
|
|
12
|
+
export default function runExecutor(options: ValidateCodeOptions, context: ExecutorContext): Promise<ExecutorResult>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = runExecutor;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const executor_1 = tslib_1.__importDefault(require("../validate-new-methods/executor"));
|
|
6
|
+
const executor_2 = tslib_1.__importDefault(require("../validate-modified-methods/executor"));
|
|
7
|
+
const executor_3 = tslib_1.__importDefault(require("../validate-modified-files/executor"));
|
|
8
|
+
async function runExecutor(options, context) {
|
|
9
|
+
const mode = options.mode ?? 'NORMAL';
|
|
10
|
+
if (mode === 'OFF') {
|
|
11
|
+
console.log('\n⏭️ Skipping all code validations (validationMode: OFF)\n');
|
|
12
|
+
return { success: true };
|
|
13
|
+
}
|
|
14
|
+
console.log('\n📏 Running Code Validations\n');
|
|
15
|
+
console.log(` Validation mode: ${mode}${mode === 'STRICT' ? ' (disable comments ignored for modified code)' : ''}`);
|
|
16
|
+
console.log(` New methods max: ${options.newMethodsMaxLines ?? 30} lines`);
|
|
17
|
+
console.log(` Modified methods max: ${options.modifiedMethodsMaxLines ?? 80} lines`);
|
|
18
|
+
console.log(` Modified files max: ${options.modifiedFilesMaxLines ?? 900} lines`);
|
|
19
|
+
console.log('');
|
|
20
|
+
// Run all three validators sequentially to avoid interleaved output
|
|
21
|
+
const newMethodsResult = await (0, executor_1.default)({ max: options.newMethodsMaxLines ?? 30, mode }, context);
|
|
22
|
+
const modifiedMethodsResult = await (0, executor_2.default)({ max: options.modifiedMethodsMaxLines ?? 80, mode }, context);
|
|
23
|
+
const modifiedFilesResult = await (0, executor_3.default)({ max: options.modifiedFilesMaxLines ?? 900, mode }, context);
|
|
24
|
+
const allSuccess = newMethodsResult.success && modifiedMethodsResult.success && modifiedFilesResult.success;
|
|
25
|
+
if (allSuccess) {
|
|
26
|
+
console.log('\n✅ All code validations passed\n');
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.log('\n❌ Some code validations failed\n');
|
|
30
|
+
}
|
|
31
|
+
return { success: allSuccess };
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/architecture/executors/validate-code/executor.ts"],"names":[],"mappings":";;AAkBA,8BA2CC;;AA5DD,wFAAqE;AACrE,6FAA+E;AAC/E,2FAA2E;AAe5D,KAAK,UAAU,WAAW,CACrC,OAA4B,EAC5B,OAAwB;IAExB,MAAM,IAAI,GAAmB,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC;IAEtD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;QAC3E,O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O,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { ExecutorContext } from '@nx/devkit';\nimport runNewMethodsExecutor from '../validate-new-methods/executor';\nimport runModifiedMethodsExecutor from '../validate-modified-methods/executor';\nimport runModifiedFilesExecutor from '../validate-modified-files/executor';\n\nexport type ValidationMode = 'STRICT' | 'NORMAL' | 'OFF';\n\nexport interface ValidateCodeOptions {\n mode?: ValidationMode;\n newMethodsMaxLines?: number;\n modifiedMethodsMaxLines?: number;\n modifiedFilesMaxLines?: number;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\nexport default async function runExecutor(\n options: ValidateCodeOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const mode: ValidationMode = options.mode ?? 'NORMAL';\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping all code validations (validationMode: OFF)\\n');\n return { success: true };\n }\n\n console.log('\\n📏 Running Code Validations\\n');\n console.log(` Validation mode: ${mode}${mode === 'STRICT' ? ' (disable comments ignored for modified code)' : ''}`);\n console.log(` New methods max: ${options.newMethodsMaxLines ?? 30} lines`);\n console.log(` Modified methods max: ${options.modifiedMethodsMaxLines ?? 80} lines`);\n console.log(` Modified files max: ${options.modifiedFilesMaxLines ?? 900} lines`);\n console.log('');\n\n // Run all three validators sequentially to avoid interleaved output\n const newMethodsResult = await runNewMethodsExecutor(\n { max: options.newMethodsMaxLines ?? 30, mode },\n context\n );\n\n const modifiedMethodsResult = await runModifiedMethodsExecutor(\n { max: options.modifiedMethodsMaxLines ?? 80, mode },\n context\n );\n\n const modifiedFilesResult = await runModifiedFilesExecutor(\n { max: options.modifiedFilesMaxLines ?? 900, mode },\n context\n );\n\n const allSuccess = newMethodsResult.success && modifiedMethodsResult.success && modifiedFilesResult.success;\n\n if (allSuccess) {\n console.log('\\n✅ All code validations passed\\n');\n } else {\n console.log('\\n❌ Some code validations failed\\n');\n }\n\n return { success: allSuccess };\n}\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import runNewMethodsExecutor from '../validate-new-methods/executor';
|
|
3
|
+
import runModifiedMethodsExecutor from '../validate-modified-methods/executor';
|
|
4
|
+
import runModifiedFilesExecutor from '../validate-modified-files/executor';
|
|
5
|
+
|
|
6
|
+
export type ValidationMode = 'STRICT' | 'NORMAL' | 'OFF';
|
|
7
|
+
|
|
8
|
+
export interface ValidateCodeOptions {
|
|
9
|
+
mode?: ValidationMode;
|
|
10
|
+
newMethodsMaxLines?: number;
|
|
11
|
+
modifiedMethodsMaxLines?: number;
|
|
12
|
+
modifiedFilesMaxLines?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ExecutorResult {
|
|
16
|
+
success: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default async function runExecutor(
|
|
20
|
+
options: ValidateCodeOptions,
|
|
21
|
+
context: ExecutorContext
|
|
22
|
+
): Promise<ExecutorResult> {
|
|
23
|
+
const mode: ValidationMode = options.mode ?? 'NORMAL';
|
|
24
|
+
|
|
25
|
+
if (mode === 'OFF') {
|
|
26
|
+
console.log('\n⏭️ Skipping all code validations (validationMode: OFF)\n');
|
|
27
|
+
return { success: true };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.log('\n📏 Running Code Validations\n');
|
|
31
|
+
console.log(` Validation mode: ${mode}${mode === 'STRICT' ? ' (disable comments ignored for modified code)' : ''}`);
|
|
32
|
+
console.log(` New methods max: ${options.newMethodsMaxLines ?? 30} lines`);
|
|
33
|
+
console.log(` Modified methods max: ${options.modifiedMethodsMaxLines ?? 80} lines`);
|
|
34
|
+
console.log(` Modified files max: ${options.modifiedFilesMaxLines ?? 900} lines`);
|
|
35
|
+
console.log('');
|
|
36
|
+
|
|
37
|
+
// Run all three validators sequentially to avoid interleaved output
|
|
38
|
+
const newMethodsResult = await runNewMethodsExecutor(
|
|
39
|
+
{ max: options.newMethodsMaxLines ?? 30, mode },
|
|
40
|
+
context
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const modifiedMethodsResult = await runModifiedMethodsExecutor(
|
|
44
|
+
{ max: options.modifiedMethodsMaxLines ?? 80, mode },
|
|
45
|
+
context
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const modifiedFilesResult = await runModifiedFilesExecutor(
|
|
49
|
+
{ max: options.modifiedFilesMaxLines ?? 900, mode },
|
|
50
|
+
context
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const allSuccess = newMethodsResult.success && modifiedMethodsResult.success && modifiedFilesResult.success;
|
|
54
|
+
|
|
55
|
+
if (allSuccess) {
|
|
56
|
+
console.log('\n✅ All code validations passed\n');
|
|
57
|
+
} else {
|
|
58
|
+
console.log('\n❌ Some code validations failed\n');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return { success: allSuccess };
|
|
62
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"title": "Validate Code Executor",
|
|
4
|
+
"description": "Combined validation for new methods, modified methods, and file sizes. Configure via targetDefaults in nx.json for runtime options (no cache issues).",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"mode": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"enum": ["STRICT", "NORMAL", "OFF"],
|
|
10
|
+
"description": "OFF: skip all validations. NORMAL: enforce limits, disable comments work. STRICT: enforce limits, no disable comments for modified code.",
|
|
11
|
+
"default": "NORMAL"
|
|
12
|
+
},
|
|
13
|
+
"newMethodsMaxLines": {
|
|
14
|
+
"type": "number",
|
|
15
|
+
"description": "Maximum lines for NEW methods (disable comments always allowed regardless of mode)",
|
|
16
|
+
"default": 30
|
|
17
|
+
},
|
|
18
|
+
"modifiedMethodsMaxLines": {
|
|
19
|
+
"type": "number",
|
|
20
|
+
"description": "Maximum lines for MODIFIED methods",
|
|
21
|
+
"default": 80
|
|
22
|
+
},
|
|
23
|
+
"modifiedFilesMaxLines": {
|
|
24
|
+
"type": "number",
|
|
25
|
+
"description": "Maximum lines for MODIFIED files",
|
|
26
|
+
"default": 900
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"required": []
|
|
30
|
+
}
|
package/executors.json
CHANGED
|
@@ -59,6 +59,11 @@
|
|
|
59
59
|
"implementation": "./architecture/executors/validate-modified-files/executor",
|
|
60
60
|
"schema": "./architecture/executors/validate-modified-files/schema.json",
|
|
61
61
|
"description": "Validate modified files don't exceed max line count"
|
|
62
|
+
},
|
|
63
|
+
"validate-code": {
|
|
64
|
+
"implementation": "./architecture/executors/validate-code/executor",
|
|
65
|
+
"schema": "./architecture/executors/validate-code/schema.json",
|
|
66
|
+
"description": "Combined validation for new methods, modified methods, and file sizes"
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
69
|
}
|
package/package.json
CHANGED
package/plugin.js
CHANGED
|
@@ -156,12 +156,10 @@ function buildValidationTargetsList(validations) {
|
|
|
156
156
|
targets.push('validate-no-skiplevel-deps');
|
|
157
157
|
if (validations.validatePackageJson)
|
|
158
158
|
targets.push('validate-packagejson');
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (validations.validateModifiedFiles)
|
|
164
|
-
targets.push('validate-modified-files');
|
|
159
|
+
// Use combined validate-code instead of 3 separate targets
|
|
160
|
+
if (validations.validateNewMethods || validations.validateModifiedMethods || validations.validateModifiedFiles) {
|
|
161
|
+
targets.push('validate-code');
|
|
162
|
+
}
|
|
165
163
|
if (validations.validateVersionsLocked)
|
|
166
164
|
targets.push('validate-versions-locked');
|
|
167
165
|
return targets;
|
|
@@ -194,14 +192,10 @@ function createWorkspaceTargetsWithoutPrefix(opts) {
|
|
|
194
192
|
if (validations.validatePackageJson) {
|
|
195
193
|
targets['validate-packagejson'] = createValidatePackageJsonTarget();
|
|
196
194
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
targets['validate-modified-methods'] = createValidateModifiedMethodsTarget(validations.modifiedAndNewMethodsMaxLines, validations.validationMode);
|
|
202
|
-
}
|
|
203
|
-
if (validations.validateModifiedFiles) {
|
|
204
|
-
targets['validate-modified-files'] = createValidateModifiedFilesTarget(validations.modifiedFilesMaxLines, validations.validationMode);
|
|
195
|
+
// Use combined validate-code instead of 3 separate targets
|
|
196
|
+
// Options come from targetDefaults in nx.json (applied at runtime, no cache issues)
|
|
197
|
+
if (validations.validateNewMethods || validations.validateModifiedMethods || validations.validateModifiedFiles) {
|
|
198
|
+
targets['validate-code'] = createValidateCodeTarget();
|
|
205
199
|
}
|
|
206
200
|
if (validations.validateVersionsLocked) {
|
|
207
201
|
targets['validate-versions-locked'] = createValidateVersionsLockedTarget();
|
|
@@ -241,14 +235,10 @@ function createWorkspaceTargets(opts) {
|
|
|
241
235
|
if (opts.workspace.validations.validatePackageJson) {
|
|
242
236
|
targets[`${prefix}validate-packagejson`] = createValidatePackageJsonTarget();
|
|
243
237
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
targets[`${prefix}validate-modified-methods`] = createValidateModifiedMethodsTarget(opts.workspace.validations.modifiedAndNewMethodsMaxLines, opts.workspace.validations.validationMode);
|
|
249
|
-
}
|
|
250
|
-
if (opts.workspace.validations.validateModifiedFiles) {
|
|
251
|
-
targets[`${prefix}validate-modified-files`] = createValidateModifiedFilesTarget(opts.workspace.validations.modifiedFilesMaxLines, opts.workspace.validations.validationMode);
|
|
238
|
+
// Use combined validate-code instead of 3 separate targets
|
|
239
|
+
// Options come from targetDefaults in nx.json (applied at runtime, no cache issues)
|
|
240
|
+
if (opts.workspace.validations.validateNewMethods || opts.workspace.validations.validateModifiedMethods || opts.workspace.validations.validateModifiedFiles) {
|
|
241
|
+
targets[`${prefix}validate-code`] = createValidateCodeTarget();
|
|
252
242
|
}
|
|
253
243
|
return targets;
|
|
254
244
|
}
|
|
@@ -368,6 +358,22 @@ function createValidateModifiedFilesTarget(maxLines, mode) {
|
|
|
368
358
|
},
|
|
369
359
|
};
|
|
370
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Create combined validate-code target
|
|
363
|
+
* Options come from targetDefaults in nx.json (applied at runtime, no cache issues)
|
|
364
|
+
*/
|
|
365
|
+
function createValidateCodeTarget() {
|
|
366
|
+
return {
|
|
367
|
+
executor: '@webpieces/dev-config:validate-code',
|
|
368
|
+
cache: false, // Don't cache - depends on git state
|
|
369
|
+
inputs: ['default'],
|
|
370
|
+
// No options here - they come from targetDefaults at runtime
|
|
371
|
+
metadata: {
|
|
372
|
+
technologies: ['nx'],
|
|
373
|
+
description: 'Combined validation for new methods, modified methods, and file sizes',
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
}
|
|
371
377
|
function createValidateVersionsLockedTarget() {
|
|
372
378
|
return {
|
|
373
379
|
executor: '@webpieces/dev-config:validate-versions-locked',
|