@webpieces/dev-config 0.2.83 → 0.2.84
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 +20 -3
- package/architecture/executors/validate-code/executor.js +33 -11
- package/architecture/executors/validate-code/executor.js.map +1 -1
- package/architecture/executors/validate-code/executor.ts +64 -14
- package/architecture/executors/validate-code/schema.json +70 -15
- package/architecture/executors/validate-dtos/executor.d.ts +1 -0
- package/architecture/executors/validate-dtos/executor.js +6 -5
- package/architecture/executors/validate-dtos/executor.js.map +1 -1
- package/architecture/executors/validate-dtos/executor.ts +8 -4
- package/architecture/executors/validate-dtos/schema.json +5 -0
- package/architecture/executors/validate-no-any-unknown/executor.d.ts +2 -0
- package/architecture/executors/validate-no-any-unknown/executor.js +27 -7
- package/architecture/executors/validate-no-any-unknown/executor.js.map +1 -1
- package/architecture/executors/validate-no-any-unknown/executor.ts +31 -7
- package/architecture/executors/validate-no-any-unknown/schema.json +9 -0
- package/architecture/executors/validate-no-inline-types/executor.d.ts +2 -0
- package/architecture/executors/validate-no-inline-types/executor.js +30 -10
- package/architecture/executors/validate-no-inline-types/executor.js.map +1 -1
- package/architecture/executors/validate-no-inline-types/executor.ts +35 -10
- package/architecture/executors/validate-no-inline-types/schema.json +9 -0
- package/architecture/executors/validate-prisma-converters/executor.d.ts +1 -0
- package/architecture/executors/validate-prisma-converters/executor.js +13 -11
- package/architecture/executors/validate-prisma-converters/executor.js.map +1 -1
- package/architecture/executors/validate-prisma-converters/executor.ts +19 -11
- package/architecture/executors/validate-prisma-converters/schema.json +5 -0
- package/architecture/executors/validate-return-types/executor.d.ts +2 -0
- package/architecture/executors/validate-return-types/executor.js +30 -10
- package/architecture/executors/validate-return-types/executor.js.map +1 -1
- package/architecture/executors/validate-return-types/executor.ts +35 -10
- package/architecture/executors/validate-return-types/schema.json +9 -0
- package/package.json +1 -1
|
@@ -18,14 +18,31 @@ export interface FileMaxLimitConfig {
|
|
|
18
18
|
disableAllowed?: boolean;
|
|
19
19
|
ignoreModifiedUntilEpoch?: number;
|
|
20
20
|
}
|
|
21
|
+
export interface RequireReturnTypeConfig {
|
|
22
|
+
mode?: ReturnTypeMode;
|
|
23
|
+
disableAllowed?: boolean;
|
|
24
|
+
ignoreModifiedUntilEpoch?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface NoInlineTypeLiteralsConfig {
|
|
27
|
+
mode?: NoInlineTypesMode;
|
|
28
|
+
disableAllowed?: boolean;
|
|
29
|
+
ignoreModifiedUntilEpoch?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface NoAnyUnknownConfig {
|
|
32
|
+
mode?: NoAnyUnknownMode;
|
|
33
|
+
disableAllowed?: boolean;
|
|
34
|
+
ignoreModifiedUntilEpoch?: number;
|
|
35
|
+
}
|
|
21
36
|
export interface ValidateDtosConfig {
|
|
22
37
|
mode?: ValidateDtosMode;
|
|
38
|
+
disableAllowed?: boolean;
|
|
23
39
|
prismaSchemaPath?: string;
|
|
24
40
|
dtoSourcePaths?: string[];
|
|
25
41
|
ignoreModifiedUntilEpoch?: number;
|
|
26
42
|
}
|
|
27
43
|
export interface PrismaConverterConfig {
|
|
28
44
|
mode?: PrismaConverterMode;
|
|
45
|
+
disableAllowed?: boolean;
|
|
29
46
|
schemaPath?: string;
|
|
30
47
|
convertersPaths?: string[];
|
|
31
48
|
ignoreModifiedUntilEpoch?: number;
|
|
@@ -33,9 +50,9 @@ export interface PrismaConverterConfig {
|
|
|
33
50
|
export interface ValidateCodeOptions {
|
|
34
51
|
methodMaxLimit?: MethodMaxLimitConfig;
|
|
35
52
|
fileMaxLimit?: FileMaxLimitConfig;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
requireReturnType?: RequireReturnTypeConfig;
|
|
54
|
+
noInlineTypeLiterals?: NoInlineTypeLiteralsConfig;
|
|
55
|
+
noAnyUnknown?: NoAnyUnknownConfig;
|
|
39
56
|
validateDtos?: ValidateDtosConfig;
|
|
40
57
|
prismaConverter?: PrismaConverterConfig;
|
|
41
58
|
}
|
|
@@ -62,14 +62,22 @@ function parseConfig(options) {
|
|
|
62
62
|
fileMode: fileResolved.mode,
|
|
63
63
|
fileDisableAllowed: fileConfig.disableAllowed ?? true,
|
|
64
64
|
fileOverride: fileResolved.override,
|
|
65
|
-
returnTypeMode: options.
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
returnTypeMode: options.requireReturnType?.mode ?? 'OFF',
|
|
66
|
+
returnTypeDisableAllowed: options.requireReturnType?.disableAllowed ?? true,
|
|
67
|
+
returnTypeIgnoreEpoch: options.requireReturnType?.ignoreModifiedUntilEpoch,
|
|
68
|
+
noInlineTypesMode: options.noInlineTypeLiterals?.mode ?? 'OFF',
|
|
69
|
+
noInlineTypesDisableAllowed: options.noInlineTypeLiterals?.disableAllowed ?? true,
|
|
70
|
+
noInlineTypesIgnoreEpoch: options.noInlineTypeLiterals?.ignoreModifiedUntilEpoch,
|
|
71
|
+
noAnyUnknownMode: options.noAnyUnknown?.mode ?? 'OFF',
|
|
72
|
+
noAnyUnknownDisableAllowed: options.noAnyUnknown?.disableAllowed ?? true,
|
|
73
|
+
noAnyUnknownIgnoreEpoch: options.noAnyUnknown?.ignoreModifiedUntilEpoch,
|
|
68
74
|
validateDtosMode: options.validateDtos?.mode ?? 'OFF',
|
|
75
|
+
validateDtosDisableAllowed: options.validateDtos?.disableAllowed ?? true,
|
|
69
76
|
validateDtosPrismaPath: options.validateDtos?.prismaSchemaPath,
|
|
70
77
|
validateDtosSrcPaths: options.validateDtos?.dtoSourcePaths ?? [],
|
|
71
78
|
validateDtosIgnoreEpoch: options.validateDtos?.ignoreModifiedUntilEpoch,
|
|
72
79
|
prismaConverterMode: options.prismaConverter?.mode ?? 'OFF',
|
|
80
|
+
prismaConverterDisableAllowed: options.prismaConverter?.disableAllowed ?? true,
|
|
73
81
|
prismaConverterSchemaPath: options.prismaConverter?.schemaPath,
|
|
74
82
|
prismaConverterConvertersPaths: options.prismaConverter?.convertersPaths ?? [],
|
|
75
83
|
prismaConverterIgnoreEpoch: options.prismaConverter?.ignoreModifiedUntilEpoch,
|
|
@@ -85,11 +93,11 @@ function logConfig(config) {
|
|
|
85
93
|
console.log('\n\ud83d\udccf Running Code Validations\n');
|
|
86
94
|
console.log(` Method limits: mode=${config.methodMode}${formatOverride(config.methodOverride)}, limit=${config.methodLimit}, disableAllowed=${config.methodDisableAllowed}`);
|
|
87
95
|
console.log(` File limits: mode=${config.fileMode}${formatOverride(config.fileOverride)}, limit=${config.fileLimit}, disableAllowed=${config.fileDisableAllowed}`);
|
|
88
|
-
console.log(` Require return types:
|
|
89
|
-
console.log(` No inline type literals:
|
|
90
|
-
console.log(` No any/unknown:
|
|
91
|
-
console.log(` Validate DTOs:
|
|
92
|
-
console.log(` Prisma converters:
|
|
96
|
+
console.log(` Require return types: mode=${config.returnTypeMode}, disableAllowed=${config.returnTypeDisableAllowed}`);
|
|
97
|
+
console.log(` No inline type literals: mode=${config.noInlineTypesMode}, disableAllowed=${config.noInlineTypesDisableAllowed}`);
|
|
98
|
+
console.log(` No any/unknown: mode=${config.noAnyUnknownMode}, disableAllowed=${config.noAnyUnknownDisableAllowed}`);
|
|
99
|
+
console.log(` Validate DTOs: mode=${config.validateDtosMode}, disableAllowed=${config.validateDtosDisableAllowed}`);
|
|
100
|
+
console.log(` Prisma converters: mode=${config.prismaConverterMode}, disableAllowed=${config.prismaConverterDisableAllowed}`);
|
|
93
101
|
console.log('');
|
|
94
102
|
}
|
|
95
103
|
function isAllOff(config) {
|
|
@@ -126,17 +134,31 @@ async function runExecutor(options, context) {
|
|
|
126
134
|
const fileResult = await (0, executor_3.default)({
|
|
127
135
|
limit: config.fileLimit, mode: config.fileMode, disableAllowed: config.fileDisableAllowed,
|
|
128
136
|
}, context);
|
|
129
|
-
const returnTypesResult = await (0, executor_4.default)({
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
const returnTypesResult = await (0, executor_4.default)({
|
|
138
|
+
mode: config.returnTypeMode,
|
|
139
|
+
disableAllowed: config.returnTypeDisableAllowed,
|
|
140
|
+
ignoreModifiedUntilEpoch: config.returnTypeIgnoreEpoch,
|
|
141
|
+
}, context);
|
|
142
|
+
const noInlineTypesResult = await (0, executor_5.default)({
|
|
143
|
+
mode: config.noInlineTypesMode,
|
|
144
|
+
disableAllowed: config.noInlineTypesDisableAllowed,
|
|
145
|
+
ignoreModifiedUntilEpoch: config.noInlineTypesIgnoreEpoch,
|
|
146
|
+
}, context);
|
|
147
|
+
const noAnyUnknownResult = await (0, executor_6.default)({
|
|
148
|
+
mode: config.noAnyUnknownMode,
|
|
149
|
+
disableAllowed: config.noAnyUnknownDisableAllowed,
|
|
150
|
+
ignoreModifiedUntilEpoch: config.noAnyUnknownIgnoreEpoch,
|
|
151
|
+
}, context);
|
|
132
152
|
const validateDtosResult = await (0, executor_7.default)({
|
|
133
153
|
mode: config.validateDtosMode,
|
|
154
|
+
disableAllowed: config.validateDtosDisableAllowed,
|
|
134
155
|
prismaSchemaPath: config.validateDtosPrismaPath,
|
|
135
156
|
dtoSourcePaths: config.validateDtosSrcPaths,
|
|
136
157
|
ignoreModifiedUntilEpoch: config.validateDtosIgnoreEpoch,
|
|
137
158
|
}, context);
|
|
138
159
|
const prismaConverterResult = await (0, executor_8.default)({
|
|
139
160
|
mode: config.prismaConverterMode,
|
|
161
|
+
disableAllowed: config.prismaConverterDisableAllowed,
|
|
140
162
|
schemaPath: config.prismaConverterSchemaPath,
|
|
141
163
|
convertersPaths: config.prismaConverterConvertersPaths,
|
|
142
164
|
ignoreModifiedUntilEpoch: config.prismaConverterIgnoreEpoch,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/architecture/executors/validate-code/executor.ts"],"names":[],"mappings":";;AAuNA,8BAwCC;;AA9PD,wFAAqE;AACrE,6FAA+E;AAC/E,2FAA2E;AAC3E,yFAA2F;AAC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,EAAE,IAAI,EAAE,MAAM,CAAC,gBAAgB,EAAE,EAAE,OAAO,CAAC,CAAC;IACrG,MAAM,kBAAkB,GAAG,MAAM,IAAA,kBAAuB,EAAC;QACrD,IAAI,EAAE,MAAM,CAAC,gBAAgB;QAC7B,gBAAgB,EAAE,MAAM,CAAC,sBAAsB;QAC/C,cAAc,EAAE,MAAM,CAAC,oBAAoB;QAC3C,wBAAwB,EAAE,MAAM,CAAC,uBAAuB;KAC3D,EAAE,OAAO,CAAC,CAAC;IACZ,MAAM,qBAAqB,GAAG,MAAM,IAAA,kBAA2B,EAAC;QAC5D,IAAI,EAAE,MAAM,CAAC,mBAAmB;QAChC,UAAU,EAAE,MAAM,CAAC,yBAAyB;QAC5C,eAAe,EAAE,MAAM,CAAC,8BAA8B;QACtD,wBAAwB,EAAE,MAAM,CAAC,0BAA0B;KAC9D,EAAE,OAAO,CAAC,CAAC;IAEZ,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QACpD,UAAU,CAAC,OAAO,IAAI,iBAAiB,CAAC,OAAO;QAC/C,mBAAmB,CAAC,OAAO,IAAI,kBAAkB,CAAC,OAAO;QACzD,kBAAkB,CAAC,OAAO,IAAI,qBAAqB,CAAC,OAAO,CAAC;IAEhE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC,yCAAyC,CAAC,CAAC;IAC/G,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';\nimport runReturnTypesExecutor, { ReturnTypeMode } from '../validate-return-types/executor';\nimport runNoInlineTypesExecutor, { NoInlineTypesMode } from '../validate-no-inline-types/executor';\nimport runNoAnyUnknownExecutor, { NoAnyUnknownMode } from '../validate-no-any-unknown/executor';\nimport runValidateDtosExecutor, { ValidateDtosMode } from '../validate-dtos/executor';\nimport runPrismaConvertersExecutor, { PrismaConverterMode } from '../validate-prisma-converters/executor';\n\nexport type MethodMaxLimitMode = 'OFF' | 'NEW_METHODS' | 'NEW_AND_MODIFIED_METHODS' | 'MODIFIED_FILES';\nexport type FileMaxLimitMode = 'OFF' | 'MODIFIED_FILES';\n\nexport interface MethodMaxLimitConfig {\n limit?: number;\n mode?: MethodMaxLimitMode;\n disableAllowed?: boolean;\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface FileMaxLimitConfig {\n limit?: number;\n mode?: FileMaxLimitMode;\n disableAllowed?: boolean;\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface ValidateDtosConfig {\n mode?: ValidateDtosMode;\n prismaSchemaPath?: string;\n dtoSourcePaths?: string[];\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface PrismaConverterConfig {\n mode?: PrismaConverterMode;\n schemaPath?: string;\n convertersPaths?: string[];\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface ValidateCodeOptions {\n methodMaxLimit?: MethodMaxLimitConfig;\n fileMaxLimit?: FileMaxLimitConfig;\n requireReturnTypeMode?: ReturnTypeMode;\n noInlineTypeLiteralsMode?: NoInlineTypesMode;\n noAnyUnknownMode?: NoAnyUnknownMode;\n validateDtos?: ValidateDtosConfig;\n prismaConverter?: PrismaConverterConfig;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\ninterface OverrideInfo {\n active: boolean;\n normalMode: string;\n expiresDate: string;\n}\n\ninterface ParsedConfig {\n methodLimit: number;\n methodMode: MethodMaxLimitMode;\n methodDisableAllowed: boolean;\n methodOverride: OverrideInfo | undefined;\n fileLimit: number;\n fileMode: FileMaxLimitMode;\n fileDisableAllowed: boolean;\n fileOverride: OverrideInfo | undefined;\n returnTypeMode: ReturnTypeMode;\n noInlineTypesMode: NoInlineTypesMode;\n noAnyUnknownMode: NoAnyUnknownMode;\n validateDtosMode: ValidateDtosMode;\n validateDtosPrismaPath: string | undefined;\n validateDtosSrcPaths: string[];\n validateDtosIgnoreEpoch: number | undefined;\n prismaConverterMode: PrismaConverterMode;\n prismaConverterSchemaPath: string | undefined;\n prismaConverterConvertersPaths: string[];\n prismaConverterIgnoreEpoch: number | undefined;\n}\n\ninterface ResolvedMethodMode {\n mode: MethodMaxLimitMode;\n override: OverrideInfo | undefined;\n}\n\ninterface ResolvedFileMode {\n mode: FileMaxLimitMode;\n override: OverrideInfo | undefined;\n}\n\nfunction formatEpochDate(epoch: number): string {\n return new Date(epoch * 1000).toISOString().split('T')[0];\n}\n\nfunction resolveMethodMode(\n normalMode: MethodMaxLimitMode, epoch: number | undefined\n): ResolvedMethodMode {\n if (epoch === undefined) {\n return { mode: normalMode, override: undefined };\n }\n const nowSeconds = Date.now() / 1000;\n if (nowSeconds < epoch) {\n // Active: downgrade to skip modified checking\n const downgraded: MethodMaxLimitMode =\n normalMode === 'OFF' ? 'OFF' : 'NEW_METHODS';\n return {\n mode: downgraded,\n override: { active: true, normalMode, expiresDate: formatEpochDate(epoch) },\n };\n }\n // Expired\n console.log(`\\n\\u26a0\\ufe0f methodMaxLimit.ignoreModifiedUntilEpoch (${epoch}) has expired (${formatEpochDate(epoch)}). Remove it from nx.json. Using normal mode: ${normalMode}\\n`);\n return { mode: normalMode, override: undefined };\n}\n\nfunction resolveFileMode(\n normalMode: FileMaxLimitMode, epoch: number | undefined\n): ResolvedFileMode {\n if (epoch === undefined) {\n return { mode: normalMode, override: undefined };\n }\n const nowSeconds = Date.now() / 1000;\n if (nowSeconds < epoch) {\n // Active: file checking is inherently about modified files, so skip entirely\n return {\n mode: 'OFF',\n override: { active: true, normalMode, expiresDate: formatEpochDate(epoch) },\n };\n }\n // Expired\n console.log(`\\n\\u26a0\\ufe0f fileMaxLimit.ignoreModifiedUntilEpoch (${epoch}) has expired (${formatEpochDate(epoch)}). Remove it from nx.json. Using normal mode: ${normalMode}\\n`);\n return { mode: normalMode, override: undefined };\n}\n\nfunction parseConfig(options: ValidateCodeOptions): ParsedConfig {\n const methodConfig: MethodMaxLimitConfig = options.methodMaxLimit ?? {};\n const fileConfig: FileMaxLimitConfig = options.fileMaxLimit ?? {};\n\n const normalMethodMode = methodConfig.mode ?? 'NEW_AND_MODIFIED_METHODS';\n const normalFileMode = fileConfig.mode ?? 'MODIFIED_FILES';\n\n const methodResolved = resolveMethodMode(normalMethodMode, methodConfig.ignoreModifiedUntilEpoch);\n const fileResolved = resolveFileMode(normalFileMode, fileConfig.ignoreModifiedUntilEpoch);\n\n return {\n methodLimit: methodConfig.limit ?? 80,\n methodMode: methodResolved.mode,\n methodDisableAllowed: methodConfig.disableAllowed ?? true,\n methodOverride: methodResolved.override,\n fileLimit: fileConfig.limit ?? 900,\n fileMode: fileResolved.mode,\n fileDisableAllowed: fileConfig.disableAllowed ?? true,\n fileOverride: fileResolved.override,\n returnTypeMode: options.requireReturnTypeMode ?? 'OFF',\n noInlineTypesMode: options.noInlineTypeLiteralsMode ?? 'OFF',\n noAnyUnknownMode: options.noAnyUnknownMode ?? 'OFF',\n validateDtosMode: options.validateDtos?.mode ?? 'OFF',\n validateDtosPrismaPath: options.validateDtos?.prismaSchemaPath,\n validateDtosSrcPaths: options.validateDtos?.dtoSourcePaths ?? [],\n validateDtosIgnoreEpoch: options.validateDtos?.ignoreModifiedUntilEpoch,\n prismaConverterMode: options.prismaConverter?.mode ?? 'OFF',\n prismaConverterSchemaPath: options.prismaConverter?.schemaPath,\n prismaConverterConvertersPaths: options.prismaConverter?.convertersPaths ?? [],\n prismaConverterIgnoreEpoch: options.prismaConverter?.ignoreModifiedUntilEpoch,\n };\n}\n\nfunction formatOverride(override: OverrideInfo | undefined): string {\n if (!override) {\n return '';\n }\n return ` (override active, normal: ${override.normalMode}, expires: ${override.expiresDate})`;\n}\n\nfunction logConfig(config: ParsedConfig): void {\n console.log('\\n\\ud83d\\udccf Running Code Validations\\n');\n console.log(` Method limits: mode=${config.methodMode}${formatOverride(config.methodOverride)}, limit=${config.methodLimit}, disableAllowed=${config.methodDisableAllowed}`);\n console.log(` File limits: mode=${config.fileMode}${formatOverride(config.fileOverride)}, limit=${config.fileLimit}, disableAllowed=${config.fileDisableAllowed}`);\n console.log(` Require return types: ${config.returnTypeMode}`);\n console.log(` No inline type literals: ${config.noInlineTypesMode}`);\n console.log(` No any/unknown: ${config.noAnyUnknownMode}`);\n console.log(` Validate DTOs: ${config.validateDtosMode}`);\n console.log(` Prisma converters: ${config.prismaConverterMode}`);\n console.log('');\n}\n\nfunction isAllOff(config: ParsedConfig): boolean {\n return config.methodMode === 'OFF' && config.fileMode === 'OFF' &&\n config.returnTypeMode === 'OFF' && config.noInlineTypesMode === 'OFF' &&\n config.noAnyUnknownMode === 'OFF' && config.validateDtosMode === 'OFF' &&\n config.prismaConverterMode === 'OFF';\n}\n\nasync function runMethodValidators(config: ParsedConfig, context: ExecutorContext): Promise<ExecutorResult[]> {\n const results: ExecutorResult[] = [];\n const runNew = config.methodMode === 'NEW_METHODS' || config.methodMode === 'NEW_AND_MODIFIED_METHODS';\n const runModified = config.methodMode === 'NEW_AND_MODIFIED_METHODS' || config.methodMode === 'MODIFIED_FILES';\n\n if (runNew) {\n results.push(await runNewMethodsExecutor({\n limit: config.methodLimit,\n mode: config.methodMode, disableAllowed: config.methodDisableAllowed,\n }, context));\n }\n if (runModified) {\n results.push(await runModifiedMethodsExecutor({\n limit: config.methodLimit, mode: config.methodMode, disableAllowed: config.methodDisableAllowed,\n }, context));\n }\n return results;\n}\n\nexport default async function runExecutor(\n options: ValidateCodeOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const config = parseConfig(options);\n\n if (isAllOff(config)) {\n console.log('\\n\\u23ed\\ufe0f Skipping all code validations (all modes: OFF)\\n');\n return { success: true };\n }\n\n logConfig(config);\n\n const methodResults = await runMethodValidators(config, context);\n const fileResult = await runModifiedFilesExecutor({\n limit: config.fileLimit, mode: config.fileMode, disableAllowed: config.fileDisableAllowed,\n }, context);\n const returnTypesResult = await runReturnTypesExecutor({ mode: config.returnTypeMode }, context);\n const noInlineTypesResult = await runNoInlineTypesExecutor({ mode: config.noInlineTypesMode }, context);\n const noAnyUnknownResult = await runNoAnyUnknownExecutor({ mode: config.noAnyUnknownMode }, context);\n const validateDtosResult = await runValidateDtosExecutor({\n mode: config.validateDtosMode,\n prismaSchemaPath: config.validateDtosPrismaPath,\n dtoSourcePaths: config.validateDtosSrcPaths,\n ignoreModifiedUntilEpoch: config.validateDtosIgnoreEpoch,\n }, context);\n const prismaConverterResult = await runPrismaConvertersExecutor({\n mode: config.prismaConverterMode,\n schemaPath: config.prismaConverterSchemaPath,\n convertersPaths: config.prismaConverterConvertersPaths,\n ignoreModifiedUntilEpoch: config.prismaConverterIgnoreEpoch,\n }, context);\n\n const allSuccess = methodResults.every((r) => r.success) &&\n fileResult.success && returnTypesResult.success &&\n noInlineTypesResult.success && noAnyUnknownResult.success &&\n validateDtosResult.success && prismaConverterResult.success;\n\n console.log(allSuccess ? '\\n\\u2705 All code validations passed\\n' : '\\n\\u274c Some code validations failed\\n');\n return { success: allSuccess };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/architecture/executors/validate-code/executor.ts"],"names":[],"mappings":";;AA2PA,8BAsDC;;AAhTD,wFAAqE;AACrE,6FAA+E;AAC/E,2FAA2E;AAC3E,yFAA2F;AAC3F,4FAAmG;AACnG,2FAAgG;AAChG,iFAAsF;AACtF,8FAA0G;AAiH1G,SAAS,eAAe,CAAC,KAAa;IAClC,OAAO,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,iBAAiB,CACtB,UAA8B,EAAE,KAAyB;IAEzD,IAAI,K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AAE,OAAO,CAAC,CAAC;IAEZ,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QACpD,UAAU,CAAC,OAAO,IAAI,iBAAiB,CAAC,OAAO;QAC/C,mBAAmB,CAAC,OAAO,IAAI,kBAAkB,CAAC,OAAO;QACzD,kBAAkB,CAAC,OAAO,IAAI,qBAAqB,CAAC,OAAO,CAAC;IAEhE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC,yCAAyC,CAAC,CAAC;IAC/G,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';\nimport runReturnTypesExecutor, { ReturnTypeMode } from '../validate-return-types/executor';\nimport runNoInlineTypesExecutor, { NoInlineTypesMode } from '../validate-no-inline-types/executor';\nimport runNoAnyUnknownExecutor, { NoAnyUnknownMode } from '../validate-no-any-unknown/executor';\nimport runValidateDtosExecutor, { ValidateDtosMode } from '../validate-dtos/executor';\nimport runPrismaConvertersExecutor, { PrismaConverterMode } from '../validate-prisma-converters/executor';\n\nexport type MethodMaxLimitMode = 'OFF' | 'NEW_METHODS' | 'NEW_AND_MODIFIED_METHODS' | 'MODIFIED_FILES';\nexport type FileMaxLimitMode = 'OFF' | 'MODIFIED_FILES';\n\nexport interface MethodMaxLimitConfig {\n limit?: number;\n mode?: MethodMaxLimitMode;\n disableAllowed?: boolean;\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface FileMaxLimitConfig {\n limit?: number;\n mode?: FileMaxLimitMode;\n disableAllowed?: boolean;\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface RequireReturnTypeConfig {\n mode?: ReturnTypeMode;\n disableAllowed?: boolean;\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface NoInlineTypeLiteralsConfig {\n mode?: NoInlineTypesMode;\n disableAllowed?: boolean;\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface NoAnyUnknownConfig {\n mode?: NoAnyUnknownMode;\n disableAllowed?: boolean;\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface ValidateDtosConfig {\n mode?: ValidateDtosMode;\n disableAllowed?: boolean;\n prismaSchemaPath?: string;\n dtoSourcePaths?: string[];\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface PrismaConverterConfig {\n mode?: PrismaConverterMode;\n disableAllowed?: boolean;\n schemaPath?: string;\n convertersPaths?: string[];\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface ValidateCodeOptions {\n methodMaxLimit?: MethodMaxLimitConfig;\n fileMaxLimit?: FileMaxLimitConfig;\n requireReturnType?: RequireReturnTypeConfig;\n noInlineTypeLiterals?: NoInlineTypeLiteralsConfig;\n noAnyUnknown?: NoAnyUnknownConfig;\n validateDtos?: ValidateDtosConfig;\n prismaConverter?: PrismaConverterConfig;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\ninterface OverrideInfo {\n active: boolean;\n normalMode: string;\n expiresDate: string;\n}\n\ninterface ParsedConfig {\n methodLimit: number;\n methodMode: MethodMaxLimitMode;\n methodDisableAllowed: boolean;\n methodOverride: OverrideInfo | undefined;\n fileLimit: number;\n fileMode: FileMaxLimitMode;\n fileDisableAllowed: boolean;\n fileOverride: OverrideInfo | undefined;\n returnTypeMode: ReturnTypeMode;\n returnTypeDisableAllowed: boolean;\n returnTypeIgnoreEpoch: number | undefined;\n noInlineTypesMode: NoInlineTypesMode;\n noInlineTypesDisableAllowed: boolean;\n noInlineTypesIgnoreEpoch: number | undefined;\n noAnyUnknownMode: NoAnyUnknownMode;\n noAnyUnknownDisableAllowed: boolean;\n noAnyUnknownIgnoreEpoch: number | undefined;\n validateDtosMode: ValidateDtosMode;\n validateDtosDisableAllowed: boolean;\n validateDtosPrismaPath: string | undefined;\n validateDtosSrcPaths: string[];\n validateDtosIgnoreEpoch: number | undefined;\n prismaConverterMode: PrismaConverterMode;\n prismaConverterDisableAllowed: boolean;\n prismaConverterSchemaPath: string | undefined;\n prismaConverterConvertersPaths: string[];\n prismaConverterIgnoreEpoch: number | undefined;\n}\n\ninterface ResolvedMethodMode {\n mode: MethodMaxLimitMode;\n override: OverrideInfo | undefined;\n}\n\ninterface ResolvedFileMode {\n mode: FileMaxLimitMode;\n override: OverrideInfo | undefined;\n}\n\nfunction formatEpochDate(epoch: number): string {\n return new Date(epoch * 1000).toISOString().split('T')[0];\n}\n\nfunction resolveMethodMode(\n normalMode: MethodMaxLimitMode, epoch: number | undefined\n): ResolvedMethodMode {\n if (epoch === undefined) {\n return { mode: normalMode, override: undefined };\n }\n const nowSeconds = Date.now() / 1000;\n if (nowSeconds < epoch) {\n // Active: downgrade to skip modified checking\n const downgraded: MethodMaxLimitMode =\n normalMode === 'OFF' ? 'OFF' : 'NEW_METHODS';\n return {\n mode: downgraded,\n override: { active: true, normalMode, expiresDate: formatEpochDate(epoch) },\n };\n }\n // Expired\n console.log(`\\n\\u26a0\\ufe0f methodMaxLimit.ignoreModifiedUntilEpoch (${epoch}) has expired (${formatEpochDate(epoch)}). Remove it from nx.json. Using normal mode: ${normalMode}\\n`);\n return { mode: normalMode, override: undefined };\n}\n\nfunction resolveFileMode(\n normalMode: FileMaxLimitMode, epoch: number | undefined\n): ResolvedFileMode {\n if (epoch === undefined) {\n return { mode: normalMode, override: undefined };\n }\n const nowSeconds = Date.now() / 1000;\n if (nowSeconds < epoch) {\n // Active: file checking is inherently about modified files, so skip entirely\n return {\n mode: 'OFF',\n override: { active: true, normalMode, expiresDate: formatEpochDate(epoch) },\n };\n }\n // Expired\n console.log(`\\n\\u26a0\\ufe0f fileMaxLimit.ignoreModifiedUntilEpoch (${epoch}) has expired (${formatEpochDate(epoch)}). Remove it from nx.json. Using normal mode: ${normalMode}\\n`);\n return { mode: normalMode, override: undefined };\n}\n\nfunction parseConfig(options: ValidateCodeOptions): ParsedConfig {\n const methodConfig: MethodMaxLimitConfig = options.methodMaxLimit ?? {};\n const fileConfig: FileMaxLimitConfig = options.fileMaxLimit ?? {};\n\n const normalMethodMode = methodConfig.mode ?? 'NEW_AND_MODIFIED_METHODS';\n const normalFileMode = fileConfig.mode ?? 'MODIFIED_FILES';\n\n const methodResolved = resolveMethodMode(normalMethodMode, methodConfig.ignoreModifiedUntilEpoch);\n const fileResolved = resolveFileMode(normalFileMode, fileConfig.ignoreModifiedUntilEpoch);\n\n return {\n methodLimit: methodConfig.limit ?? 80,\n methodMode: methodResolved.mode,\n methodDisableAllowed: methodConfig.disableAllowed ?? true,\n methodOverride: methodResolved.override,\n fileLimit: fileConfig.limit ?? 900,\n fileMode: fileResolved.mode,\n fileDisableAllowed: fileConfig.disableAllowed ?? true,\n fileOverride: fileResolved.override,\n returnTypeMode: options.requireReturnType?.mode ?? 'OFF',\n returnTypeDisableAllowed: options.requireReturnType?.disableAllowed ?? true,\n returnTypeIgnoreEpoch: options.requireReturnType?.ignoreModifiedUntilEpoch,\n noInlineTypesMode: options.noInlineTypeLiterals?.mode ?? 'OFF',\n noInlineTypesDisableAllowed: options.noInlineTypeLiterals?.disableAllowed ?? true,\n noInlineTypesIgnoreEpoch: options.noInlineTypeLiterals?.ignoreModifiedUntilEpoch,\n noAnyUnknownMode: options.noAnyUnknown?.mode ?? 'OFF',\n noAnyUnknownDisableAllowed: options.noAnyUnknown?.disableAllowed ?? true,\n noAnyUnknownIgnoreEpoch: options.noAnyUnknown?.ignoreModifiedUntilEpoch,\n validateDtosMode: options.validateDtos?.mode ?? 'OFF',\n validateDtosDisableAllowed: options.validateDtos?.disableAllowed ?? true,\n validateDtosPrismaPath: options.validateDtos?.prismaSchemaPath,\n validateDtosSrcPaths: options.validateDtos?.dtoSourcePaths ?? [],\n validateDtosIgnoreEpoch: options.validateDtos?.ignoreModifiedUntilEpoch,\n prismaConverterMode: options.prismaConverter?.mode ?? 'OFF',\n prismaConverterDisableAllowed: options.prismaConverter?.disableAllowed ?? true,\n prismaConverterSchemaPath: options.prismaConverter?.schemaPath,\n prismaConverterConvertersPaths: options.prismaConverter?.convertersPaths ?? [],\n prismaConverterIgnoreEpoch: options.prismaConverter?.ignoreModifiedUntilEpoch,\n };\n}\n\nfunction formatOverride(override: OverrideInfo | undefined): string {\n if (!override) {\n return '';\n }\n return ` (override active, normal: ${override.normalMode}, expires: ${override.expiresDate})`;\n}\n\nfunction logConfig(config: ParsedConfig): void {\n console.log('\\n\\ud83d\\udccf Running Code Validations\\n');\n console.log(` Method limits: mode=${config.methodMode}${formatOverride(config.methodOverride)}, limit=${config.methodLimit}, disableAllowed=${config.methodDisableAllowed}`);\n console.log(` File limits: mode=${config.fileMode}${formatOverride(config.fileOverride)}, limit=${config.fileLimit}, disableAllowed=${config.fileDisableAllowed}`);\n console.log(` Require return types: mode=${config.returnTypeMode}, disableAllowed=${config.returnTypeDisableAllowed}`);\n console.log(` No inline type literals: mode=${config.noInlineTypesMode}, disableAllowed=${config.noInlineTypesDisableAllowed}`);\n console.log(` No any/unknown: mode=${config.noAnyUnknownMode}, disableAllowed=${config.noAnyUnknownDisableAllowed}`);\n console.log(` Validate DTOs: mode=${config.validateDtosMode}, disableAllowed=${config.validateDtosDisableAllowed}`);\n console.log(` Prisma converters: mode=${config.prismaConverterMode}, disableAllowed=${config.prismaConverterDisableAllowed}`);\n console.log('');\n}\n\nfunction isAllOff(config: ParsedConfig): boolean {\n return config.methodMode === 'OFF' && config.fileMode === 'OFF' &&\n config.returnTypeMode === 'OFF' && config.noInlineTypesMode === 'OFF' &&\n config.noAnyUnknownMode === 'OFF' && config.validateDtosMode === 'OFF' &&\n config.prismaConverterMode === 'OFF';\n}\n\nasync function runMethodValidators(config: ParsedConfig, context: ExecutorContext): Promise<ExecutorResult[]> {\n const results: ExecutorResult[] = [];\n const runNew = config.methodMode === 'NEW_METHODS' || config.methodMode === 'NEW_AND_MODIFIED_METHODS';\n const runModified = config.methodMode === 'NEW_AND_MODIFIED_METHODS' || config.methodMode === 'MODIFIED_FILES';\n\n if (runNew) {\n results.push(await runNewMethodsExecutor({\n limit: config.methodLimit,\n mode: config.methodMode, disableAllowed: config.methodDisableAllowed,\n }, context));\n }\n if (runModified) {\n results.push(await runModifiedMethodsExecutor({\n limit: config.methodLimit, mode: config.methodMode, disableAllowed: config.methodDisableAllowed,\n }, context));\n }\n return results;\n}\n\nexport default async function runExecutor(\n options: ValidateCodeOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const config = parseConfig(options);\n\n if (isAllOff(config)) {\n console.log('\\n\\u23ed\\ufe0f Skipping all code validations (all modes: OFF)\\n');\n return { success: true };\n }\n\n logConfig(config);\n\n const methodResults = await runMethodValidators(config, context);\n const fileResult = await runModifiedFilesExecutor({\n limit: config.fileLimit, mode: config.fileMode, disableAllowed: config.fileDisableAllowed,\n }, context);\n const returnTypesResult = await runReturnTypesExecutor({\n mode: config.returnTypeMode,\n disableAllowed: config.returnTypeDisableAllowed,\n ignoreModifiedUntilEpoch: config.returnTypeIgnoreEpoch,\n }, context);\n const noInlineTypesResult = await runNoInlineTypesExecutor({\n mode: config.noInlineTypesMode,\n disableAllowed: config.noInlineTypesDisableAllowed,\n ignoreModifiedUntilEpoch: config.noInlineTypesIgnoreEpoch,\n }, context);\n const noAnyUnknownResult = await runNoAnyUnknownExecutor({\n mode: config.noAnyUnknownMode,\n disableAllowed: config.noAnyUnknownDisableAllowed,\n ignoreModifiedUntilEpoch: config.noAnyUnknownIgnoreEpoch,\n }, context);\n const validateDtosResult = await runValidateDtosExecutor({\n mode: config.validateDtosMode,\n disableAllowed: config.validateDtosDisableAllowed,\n prismaSchemaPath: config.validateDtosPrismaPath,\n dtoSourcePaths: config.validateDtosSrcPaths,\n ignoreModifiedUntilEpoch: config.validateDtosIgnoreEpoch,\n }, context);\n const prismaConverterResult = await runPrismaConvertersExecutor({\n mode: config.prismaConverterMode,\n disableAllowed: config.prismaConverterDisableAllowed,\n schemaPath: config.prismaConverterSchemaPath,\n convertersPaths: config.prismaConverterConvertersPaths,\n ignoreModifiedUntilEpoch: config.prismaConverterIgnoreEpoch,\n }, context);\n\n const allSuccess = methodResults.every((r) => r.success) &&\n fileResult.success && returnTypesResult.success &&\n noInlineTypesResult.success && noAnyUnknownResult.success &&\n validateDtosResult.success && prismaConverterResult.success;\n\n console.log(allSuccess ? '\\n\\u2705 All code validations passed\\n' : '\\n\\u274c Some code validations failed\\n');\n return { success: allSuccess };\n}\n"]}
|
|
@@ -25,8 +25,27 @@ export interface FileMaxLimitConfig {
|
|
|
25
25
|
ignoreModifiedUntilEpoch?: number;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export interface RequireReturnTypeConfig {
|
|
29
|
+
mode?: ReturnTypeMode;
|
|
30
|
+
disableAllowed?: boolean;
|
|
31
|
+
ignoreModifiedUntilEpoch?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface NoInlineTypeLiteralsConfig {
|
|
35
|
+
mode?: NoInlineTypesMode;
|
|
36
|
+
disableAllowed?: boolean;
|
|
37
|
+
ignoreModifiedUntilEpoch?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface NoAnyUnknownConfig {
|
|
41
|
+
mode?: NoAnyUnknownMode;
|
|
42
|
+
disableAllowed?: boolean;
|
|
43
|
+
ignoreModifiedUntilEpoch?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
28
46
|
export interface ValidateDtosConfig {
|
|
29
47
|
mode?: ValidateDtosMode;
|
|
48
|
+
disableAllowed?: boolean;
|
|
30
49
|
prismaSchemaPath?: string;
|
|
31
50
|
dtoSourcePaths?: string[];
|
|
32
51
|
ignoreModifiedUntilEpoch?: number;
|
|
@@ -34,6 +53,7 @@ export interface ValidateDtosConfig {
|
|
|
34
53
|
|
|
35
54
|
export interface PrismaConverterConfig {
|
|
36
55
|
mode?: PrismaConverterMode;
|
|
56
|
+
disableAllowed?: boolean;
|
|
37
57
|
schemaPath?: string;
|
|
38
58
|
convertersPaths?: string[];
|
|
39
59
|
ignoreModifiedUntilEpoch?: number;
|
|
@@ -42,9 +62,9 @@ export interface PrismaConverterConfig {
|
|
|
42
62
|
export interface ValidateCodeOptions {
|
|
43
63
|
methodMaxLimit?: MethodMaxLimitConfig;
|
|
44
64
|
fileMaxLimit?: FileMaxLimitConfig;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
requireReturnType?: RequireReturnTypeConfig;
|
|
66
|
+
noInlineTypeLiterals?: NoInlineTypeLiteralsConfig;
|
|
67
|
+
noAnyUnknown?: NoAnyUnknownConfig;
|
|
48
68
|
validateDtos?: ValidateDtosConfig;
|
|
49
69
|
prismaConverter?: PrismaConverterConfig;
|
|
50
70
|
}
|
|
@@ -69,13 +89,21 @@ interface ParsedConfig {
|
|
|
69
89
|
fileDisableAllowed: boolean;
|
|
70
90
|
fileOverride: OverrideInfo | undefined;
|
|
71
91
|
returnTypeMode: ReturnTypeMode;
|
|
92
|
+
returnTypeDisableAllowed: boolean;
|
|
93
|
+
returnTypeIgnoreEpoch: number | undefined;
|
|
72
94
|
noInlineTypesMode: NoInlineTypesMode;
|
|
95
|
+
noInlineTypesDisableAllowed: boolean;
|
|
96
|
+
noInlineTypesIgnoreEpoch: number | undefined;
|
|
73
97
|
noAnyUnknownMode: NoAnyUnknownMode;
|
|
98
|
+
noAnyUnknownDisableAllowed: boolean;
|
|
99
|
+
noAnyUnknownIgnoreEpoch: number | undefined;
|
|
74
100
|
validateDtosMode: ValidateDtosMode;
|
|
101
|
+
validateDtosDisableAllowed: boolean;
|
|
75
102
|
validateDtosPrismaPath: string | undefined;
|
|
76
103
|
validateDtosSrcPaths: string[];
|
|
77
104
|
validateDtosIgnoreEpoch: number | undefined;
|
|
78
105
|
prismaConverterMode: PrismaConverterMode;
|
|
106
|
+
prismaConverterDisableAllowed: boolean;
|
|
79
107
|
prismaConverterSchemaPath: string | undefined;
|
|
80
108
|
prismaConverterConvertersPaths: string[];
|
|
81
109
|
prismaConverterIgnoreEpoch: number | undefined;
|
|
@@ -154,14 +182,22 @@ function parseConfig(options: ValidateCodeOptions): ParsedConfig {
|
|
|
154
182
|
fileMode: fileResolved.mode,
|
|
155
183
|
fileDisableAllowed: fileConfig.disableAllowed ?? true,
|
|
156
184
|
fileOverride: fileResolved.override,
|
|
157
|
-
returnTypeMode: options.
|
|
158
|
-
|
|
159
|
-
|
|
185
|
+
returnTypeMode: options.requireReturnType?.mode ?? 'OFF',
|
|
186
|
+
returnTypeDisableAllowed: options.requireReturnType?.disableAllowed ?? true,
|
|
187
|
+
returnTypeIgnoreEpoch: options.requireReturnType?.ignoreModifiedUntilEpoch,
|
|
188
|
+
noInlineTypesMode: options.noInlineTypeLiterals?.mode ?? 'OFF',
|
|
189
|
+
noInlineTypesDisableAllowed: options.noInlineTypeLiterals?.disableAllowed ?? true,
|
|
190
|
+
noInlineTypesIgnoreEpoch: options.noInlineTypeLiterals?.ignoreModifiedUntilEpoch,
|
|
191
|
+
noAnyUnknownMode: options.noAnyUnknown?.mode ?? 'OFF',
|
|
192
|
+
noAnyUnknownDisableAllowed: options.noAnyUnknown?.disableAllowed ?? true,
|
|
193
|
+
noAnyUnknownIgnoreEpoch: options.noAnyUnknown?.ignoreModifiedUntilEpoch,
|
|
160
194
|
validateDtosMode: options.validateDtos?.mode ?? 'OFF',
|
|
195
|
+
validateDtosDisableAllowed: options.validateDtos?.disableAllowed ?? true,
|
|
161
196
|
validateDtosPrismaPath: options.validateDtos?.prismaSchemaPath,
|
|
162
197
|
validateDtosSrcPaths: options.validateDtos?.dtoSourcePaths ?? [],
|
|
163
198
|
validateDtosIgnoreEpoch: options.validateDtos?.ignoreModifiedUntilEpoch,
|
|
164
199
|
prismaConverterMode: options.prismaConverter?.mode ?? 'OFF',
|
|
200
|
+
prismaConverterDisableAllowed: options.prismaConverter?.disableAllowed ?? true,
|
|
165
201
|
prismaConverterSchemaPath: options.prismaConverter?.schemaPath,
|
|
166
202
|
prismaConverterConvertersPaths: options.prismaConverter?.convertersPaths ?? [],
|
|
167
203
|
prismaConverterIgnoreEpoch: options.prismaConverter?.ignoreModifiedUntilEpoch,
|
|
@@ -179,11 +215,11 @@ function logConfig(config: ParsedConfig): void {
|
|
|
179
215
|
console.log('\n\ud83d\udccf Running Code Validations\n');
|
|
180
216
|
console.log(` Method limits: mode=${config.methodMode}${formatOverride(config.methodOverride)}, limit=${config.methodLimit}, disableAllowed=${config.methodDisableAllowed}`);
|
|
181
217
|
console.log(` File limits: mode=${config.fileMode}${formatOverride(config.fileOverride)}, limit=${config.fileLimit}, disableAllowed=${config.fileDisableAllowed}`);
|
|
182
|
-
console.log(` Require return types:
|
|
183
|
-
console.log(` No inline type literals:
|
|
184
|
-
console.log(` No any/unknown:
|
|
185
|
-
console.log(` Validate DTOs:
|
|
186
|
-
console.log(` Prisma converters:
|
|
218
|
+
console.log(` Require return types: mode=${config.returnTypeMode}, disableAllowed=${config.returnTypeDisableAllowed}`);
|
|
219
|
+
console.log(` No inline type literals: mode=${config.noInlineTypesMode}, disableAllowed=${config.noInlineTypesDisableAllowed}`);
|
|
220
|
+
console.log(` No any/unknown: mode=${config.noAnyUnknownMode}, disableAllowed=${config.noAnyUnknownDisableAllowed}`);
|
|
221
|
+
console.log(` Validate DTOs: mode=${config.validateDtosMode}, disableAllowed=${config.validateDtosDisableAllowed}`);
|
|
222
|
+
console.log(` Prisma converters: mode=${config.prismaConverterMode}, disableAllowed=${config.prismaConverterDisableAllowed}`);
|
|
187
223
|
console.log('');
|
|
188
224
|
}
|
|
189
225
|
|
|
@@ -230,17 +266,31 @@ export default async function runExecutor(
|
|
|
230
266
|
const fileResult = await runModifiedFilesExecutor({
|
|
231
267
|
limit: config.fileLimit, mode: config.fileMode, disableAllowed: config.fileDisableAllowed,
|
|
232
268
|
}, context);
|
|
233
|
-
const returnTypesResult = await runReturnTypesExecutor({
|
|
234
|
-
|
|
235
|
-
|
|
269
|
+
const returnTypesResult = await runReturnTypesExecutor({
|
|
270
|
+
mode: config.returnTypeMode,
|
|
271
|
+
disableAllowed: config.returnTypeDisableAllowed,
|
|
272
|
+
ignoreModifiedUntilEpoch: config.returnTypeIgnoreEpoch,
|
|
273
|
+
}, context);
|
|
274
|
+
const noInlineTypesResult = await runNoInlineTypesExecutor({
|
|
275
|
+
mode: config.noInlineTypesMode,
|
|
276
|
+
disableAllowed: config.noInlineTypesDisableAllowed,
|
|
277
|
+
ignoreModifiedUntilEpoch: config.noInlineTypesIgnoreEpoch,
|
|
278
|
+
}, context);
|
|
279
|
+
const noAnyUnknownResult = await runNoAnyUnknownExecutor({
|
|
280
|
+
mode: config.noAnyUnknownMode,
|
|
281
|
+
disableAllowed: config.noAnyUnknownDisableAllowed,
|
|
282
|
+
ignoreModifiedUntilEpoch: config.noAnyUnknownIgnoreEpoch,
|
|
283
|
+
}, context);
|
|
236
284
|
const validateDtosResult = await runValidateDtosExecutor({
|
|
237
285
|
mode: config.validateDtosMode,
|
|
286
|
+
disableAllowed: config.validateDtosDisableAllowed,
|
|
238
287
|
prismaSchemaPath: config.validateDtosPrismaPath,
|
|
239
288
|
dtoSourcePaths: config.validateDtosSrcPaths,
|
|
240
289
|
ignoreModifiedUntilEpoch: config.validateDtosIgnoreEpoch,
|
|
241
290
|
}, context);
|
|
242
291
|
const prismaConverterResult = await runPrismaConvertersExecutor({
|
|
243
292
|
mode: config.prismaConverterMode,
|
|
293
|
+
disableAllowed: config.prismaConverterDisableAllowed,
|
|
244
294
|
schemaPath: config.prismaConverterSchemaPath,
|
|
245
295
|
convertersPaths: config.prismaConverterConvertersPaths,
|
|
246
296
|
ignoreModifiedUntilEpoch: config.prismaConverterIgnoreEpoch,
|
|
@@ -56,23 +56,68 @@
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
"
|
|
60
|
-
"type": "
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
59
|
+
"requireReturnType": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"description": "Configuration for return type validation",
|
|
62
|
+
"properties": {
|
|
63
|
+
"mode": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"enum": ["OFF", "NEW_METHODS", "NEW_AND_MODIFIED_METHODS", "MODIFIED_FILES"],
|
|
66
|
+
"description": "OFF: skip return type validation. NEW_METHODS: only new methods in diff. NEW_AND_MODIFIED_METHODS: new methods + methods with changes. MODIFIED_FILES: all methods in modified files.",
|
|
67
|
+
"default": "OFF"
|
|
68
|
+
},
|
|
69
|
+
"disableAllowed": {
|
|
70
|
+
"type": "boolean",
|
|
71
|
+
"description": "Whether disable comments work. When false, no escape hatch.",
|
|
72
|
+
"default": true
|
|
73
|
+
},
|
|
74
|
+
"ignoreModifiedUntilEpoch": {
|
|
75
|
+
"type": "number",
|
|
76
|
+
"description": "Epoch seconds. Until this time, skip validation entirely. When expired, normal mode resumes. Omit when not needed."
|
|
77
|
+
}
|
|
78
|
+
}
|
|
64
79
|
},
|
|
65
|
-
"
|
|
66
|
-
"type": "
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
|
|
80
|
+
"noInlineTypeLiterals": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"description": "Configuration for no-inline-types validation",
|
|
83
|
+
"properties": {
|
|
84
|
+
"mode": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"enum": ["OFF", "NEW_METHODS", "NEW_AND_MODIFIED_METHODS", "MODIFIED_FILES"],
|
|
87
|
+
"description": "OFF: skip validation. NEW_METHODS: only new methods. NEW_AND_MODIFIED_METHODS: new + modified methods. MODIFIED_FILES: all in modified files. Disallows inline type literals like { x: number } - use named types instead.",
|
|
88
|
+
"default": "OFF"
|
|
89
|
+
},
|
|
90
|
+
"disableAllowed": {
|
|
91
|
+
"type": "boolean",
|
|
92
|
+
"description": "Whether disable comments work. When false, no escape hatch.",
|
|
93
|
+
"default": true
|
|
94
|
+
},
|
|
95
|
+
"ignoreModifiedUntilEpoch": {
|
|
96
|
+
"type": "number",
|
|
97
|
+
"description": "Epoch seconds. Until this time, skip validation entirely. When expired, normal mode resumes. Omit when not needed."
|
|
98
|
+
}
|
|
99
|
+
}
|
|
70
100
|
},
|
|
71
|
-
"
|
|
72
|
-
"type": "
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
101
|
+
"noAnyUnknown": {
|
|
102
|
+
"type": "object",
|
|
103
|
+
"description": "Configuration for no-any-unknown validation",
|
|
104
|
+
"properties": {
|
|
105
|
+
"mode": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"enum": ["OFF", "MODIFIED_CODE", "MODIFIED_FILES"],
|
|
108
|
+
"description": "OFF: skip validation. MODIFIED_CODE: only changed lines in diff. MODIFIED_FILES: all in modified files. Disallows `any` and `unknown` TypeScript keywords.",
|
|
109
|
+
"default": "OFF"
|
|
110
|
+
},
|
|
111
|
+
"disableAllowed": {
|
|
112
|
+
"type": "boolean",
|
|
113
|
+
"description": "Whether disable comments work. When false, no escape hatch.",
|
|
114
|
+
"default": true
|
|
115
|
+
},
|
|
116
|
+
"ignoreModifiedUntilEpoch": {
|
|
117
|
+
"type": "number",
|
|
118
|
+
"description": "Epoch seconds. Until this time, skip validation entirely. When expired, normal mode resumes. Omit when not needed."
|
|
119
|
+
}
|
|
120
|
+
}
|
|
76
121
|
},
|
|
77
122
|
"validateDtos": {
|
|
78
123
|
"type": "object",
|
|
@@ -84,6 +129,11 @@
|
|
|
84
129
|
"description": "OFF: skip validation. MODIFIED_CLASS: only validate Dto classes with changed lines. MODIFIED_FILES: validate all Dtos in modified files.",
|
|
85
130
|
"default": "OFF"
|
|
86
131
|
},
|
|
132
|
+
"disableAllowed": {
|
|
133
|
+
"type": "boolean",
|
|
134
|
+
"description": "Whether @deprecated field exemption works. When false, all fields must match.",
|
|
135
|
+
"default": true
|
|
136
|
+
},
|
|
87
137
|
"prismaSchemaPath": {
|
|
88
138
|
"type": "string",
|
|
89
139
|
"description": "Relative path from workspace root to schema.prisma"
|
|
@@ -109,6 +159,11 @@
|
|
|
109
159
|
"description": "OFF: skip validation. MODIFIED_FILES: validate converter and non-converter files modified in the diff.",
|
|
110
160
|
"default": "OFF"
|
|
111
161
|
},
|
|
162
|
+
"disableAllowed": {
|
|
163
|
+
"type": "boolean",
|
|
164
|
+
"description": "Whether disable comments work. When false, no escape hatch.",
|
|
165
|
+
"default": true
|
|
166
|
+
},
|
|
112
167
|
"schemaPath": {
|
|
113
168
|
"type": "string",
|
|
114
169
|
"description": "Relative path from workspace root to schema.prisma"
|
|
@@ -31,6 +31,7 @@ import type { ExecutorContext } from '@nx/devkit';
|
|
|
31
31
|
export type ValidateDtosMode = 'OFF' | 'MODIFIED_CLASS' | 'MODIFIED_FILES';
|
|
32
32
|
export interface ValidateDtosOptions {
|
|
33
33
|
mode?: ValidateDtosMode;
|
|
34
|
+
disableAllowed?: boolean;
|
|
34
35
|
prismaSchemaPath?: string;
|
|
35
36
|
dtoSourcePaths?: string[];
|
|
36
37
|
ignoreModifiedUntilEpoch?: number;
|
|
@@ -283,7 +283,7 @@ function extractPrefix(name, suffix) {
|
|
|
283
283
|
/**
|
|
284
284
|
* Find violations: Dto fields that don't exist in the corresponding Dbo.
|
|
285
285
|
*/
|
|
286
|
-
function findViolations(dtos, dboModels) {
|
|
286
|
+
function findViolations(dtos, dboModels, disableAllowed) {
|
|
287
287
|
const violations = [];
|
|
288
288
|
// Build a lowercase prefix -> Dbo info map
|
|
289
289
|
const dboByPrefix = new Map();
|
|
@@ -299,7 +299,7 @@ function findViolations(dtos, dboModels) {
|
|
|
299
299
|
continue;
|
|
300
300
|
}
|
|
301
301
|
for (const field of dto.fields) {
|
|
302
|
-
if (field.deprecated)
|
|
302
|
+
if (disableAllowed && field.deprecated)
|
|
303
303
|
continue;
|
|
304
304
|
if (!dbo.fields.has(field.name)) {
|
|
305
305
|
violations.push({
|
|
@@ -466,7 +466,7 @@ function resolveBase(workspaceRoot) {
|
|
|
466
466
|
* Run the core validation after early-exit checks have passed.
|
|
467
467
|
*/
|
|
468
468
|
// webpieces-disable max-lines-new-methods -- Core validation orchestration with multiple early-exit checks
|
|
469
|
-
function validateDtoFiles(workspaceRoot, prismaSchemaPath, changedFiles, dtoSourcePaths, mode, base, head) {
|
|
469
|
+
function validateDtoFiles(workspaceRoot, prismaSchemaPath, changedFiles, dtoSourcePaths, mode, disableAllowed, base, head) {
|
|
470
470
|
if (changedFiles.some((f) => f.endsWith(prismaSchemaPath))) {
|
|
471
471
|
console.log('⏭️ Skipping validate-dtos (schema.prisma is modified - schema in flux)');
|
|
472
472
|
console.log('');
|
|
@@ -500,7 +500,7 @@ function validateDtoFiles(workspaceRoot, prismaSchemaPath, changedFiles, dtoSour
|
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
console.log(` Validating ${allDtos.length} Dto definition(s)`);
|
|
503
|
-
const violations = findViolations(allDtos, dboModels);
|
|
503
|
+
const violations = findViolations(allDtos, dboModels, disableAllowed);
|
|
504
504
|
if (violations.length === 0) {
|
|
505
505
|
console.log('✅ All Dto fields match their Dbo models');
|
|
506
506
|
return { success: true };
|
|
@@ -557,7 +557,8 @@ async function runExecutor(options, context) {
|
|
|
557
557
|
console.log(` Base: ${base}`);
|
|
558
558
|
console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);
|
|
559
559
|
console.log('');
|
|
560
|
+
const disableAllowed = options.disableAllowed ?? true;
|
|
560
561
|
const changedFiles = getChangedFiles(workspaceRoot, base, head);
|
|
561
|
-
return validateDtoFiles(workspaceRoot, prismaSchemaPath, changedFiles, dtoSourcePaths, mode, base, head);
|
|
562
|
+
return validateDtoFiles(workspaceRoot, prismaSchemaPath, changedFiles, dtoSourcePaths, mode, disableAllowed, base, head);
|
|
562
563
|
}
|
|
563
564
|
//# sourceMappingURL=executor.js.map
|