@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/architecture/executors/validate-prisma-converters/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;;AA6iBH,8BAqCC;;AA/kBD,iDAAyC;AACzC,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AAiCjC;;GAEG;AACH,SAAS,UAAU,CAAC,aAAqB;IACrC,IAAI,CAAC;QACD,MAAM,SAAS,GAAG,IAAA,wBAAQ,EAAC,iCAAiC,EAAE;YAC1D,GAAG,EAAE,aAAa;YAClB,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAClC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEV,IAAI,SAAS,EAAE,CAAC;YACZ,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,IAAI,CAAC;YACD,MAAM,SAAS,GAAG,IAAA,wBAAQ,EAAC,0BAA0B,EAAE;gBACnD,GAAG,EAAE,aAAa;gBAClB,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;aAClC,CAAC,CAAC,IAAI,EAAE,CAAC;YAEV,IAAI,SAAS,EAAE,CAAC;gBACZ,OAAO,SAAS,CAAC;YACrB,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACL,SAAS;QACb,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,oHAAoH;AACpH,SAAS,yBAAyB,CAAC,aAAqB,EAAE,IAAY,EAAE,IAAa;IACjF,IAAI,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACnD,MAAM,MAAM,GAAG,IAAA,wBAAQ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AC,+CAA+C,MAAM,GAAG,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,cAAc,UAAU,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,uBAAuB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEjE,MAAM,IAAI,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;IAExC,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,CAAC,GAAG,CAAC,2EAA2E,CAAC,CAAC;QACzF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,oBAAoB,CAAC,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACxF,CAAC","sourcesContent":["/**\n * Validate Prisma Converters Executor\n *\n * Validates that Prisma converter methods follow a scalable pattern:\n * methods returning XxxDto (where XxxDbo exists in schema.prisma) must\n * accept that exact XxxDbo as the first parameter. This keeps single-table\n * converters clean and forces join converters to compose them.\n *\n * ============================================================================\n * RULES\n * ============================================================================\n *\n * 1. First param must be exact Dbo:\n * If method returns XxxDto and XxxDbo exists in schema.prisma,\n * the first parameter must be of type XxxDbo.\n *\n * 2. Extra params must be booleans:\n * Additional parameters beyond the Dbo are allowed but must be boolean\n * (used for filtering payloads / security info).\n *\n * 3. No async converters:\n * Methods returning Promise<XxxDto> are flagged — converters should be\n * pure data mapping, no async work.\n *\n * 4. No standalone functions:\n * Standalone functions in converter files are flagged — must be class\n * methods so the converter class can be injected (dependency tree tracing).\n *\n * 5. Dto creation outside converters directory:\n * Files outside the configured convertersPath that create `new XxxDto(...)`\n * where XxxDbo exists in schema.prisma are flagged — Dto instances tied to\n * a Dbo must only be created via a converter class.\n *\n * ============================================================================\n * SKIP CONDITIONS\n * ============================================================================\n * - Methods with @deprecated decorator or JSDoc tag\n * - Lines with: // webpieces-disable prisma-converter -- [reason]\n *\n * ============================================================================\n * MODES\n * ============================================================================\n * - OFF: Skip validation entirely\n * - MODIFIED_FILES: Validate converter files that were modified in the diff\n */\n\nimport type { ExecutorContext } from '@nx/devkit';\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\n\nexport type PrismaConverterMode = 'OFF' | 'MODIFIED_FILES';\n\nexport interface ValidatePrismaConvertersOptions {\n mode?: PrismaConverterMode;\n schemaPath?: string;\n convertersPaths?: string[];\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\ninterface PrismaConverterViolation {\n file: string;\n line: number;\n message: string;\n}\n\ninterface UnwrapResult {\n inner: string;\n isAsync: boolean;\n}\n\ninterface FileContext {\n filePath: string;\n fileLines: string[];\n sourceFile: ts.SourceFile;\n prismaModels: Set<string>;\n}\n\n/**\n * Auto-detect the base branch by finding the merge-base with origin/main.\n */\nfunction detectBase(workspaceRoot: string): string | null {\n try {\n const mergeBase = execSync('git merge-base HEAD origin/main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n try {\n const mergeBase = execSync('git merge-base HEAD main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n // Ignore\n }\n }\n return null;\n}\n\n/**\n * Get changed TypeScript files between base and head (or working tree if head not specified).\n */\n// webpieces-disable max-lines-new-methods -- Git command handling with untracked files requires multiple code paths\nfunction getChangedTypeScriptFiles(workspaceRoot: string, base: string, head?: string): string[] {\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const output = execSync(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const changedFiles = output\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n\n if (!head) {\n try {\n const untrackedOutput = execSync(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const untrackedFiles = untrackedOutput\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n const allFiles = new Set([...changedFiles, ...untrackedFiles]);\n return Array.from(allFiles);\n } catch {\n return changedFiles;\n }\n }\n\n return changedFiles;\n } catch {\n return [];\n }\n}\n\n/**\n * Parse schema.prisma to extract all model names into a Set.\n */\nfunction parsePrismaModels(schemaPath: string): Set<string> {\n const models = new Set<string>();\n\n if (!fs.existsSync(schemaPath)) {\n return models;\n }\n\n const content = fs.readFileSync(schemaPath, 'utf-8');\n const regex = /^model\\s+(\\w+)\\s*\\{/gm;\n let match: RegExpExecArray | null;\n\n while ((match = regex.exec(content)) !== null) {\n models.add(match[1]);\n }\n\n return models;\n}\n\n/**\n * Derive the expected Dbo name from a return type ending in Dto.\n * \"XxxDto\" -> \"XxxDbo\". Returns null if name doesn't end with Dto.\n */\nfunction deriveExpectedDboName(returnType: string): string | null {\n if (!returnType.endsWith('Dto')) return null;\n return returnType.slice(0, -3) + 'Dbo';\n}\n\n/**\n * Check if a line has a webpieces-disable comment for prisma-converter.\n */\nfunction hasDisableComment(lines: string[], lineNumber: number): boolean {\n const startCheck = Math.max(0, lineNumber - 5);\n for (let i = lineNumber - 2; i >= startCheck; i--) {\n const line = lines[i]?.trim() ?? '';\n if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {\n break;\n }\n if (line.includes('webpieces-disable') && line.includes('prisma-converter')) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if a method/function node has a @deprecated decorator.\n */\nfunction hasDeprecatedDecorator(node: ts.MethodDeclaration | ts.FunctionDeclaration): boolean {\n const modifiers = ts.canHaveDecorators(node) ? ts.getDecorators(node) : undefined;\n if (!modifiers) return false;\n\n for (const decorator of modifiers) {\n const expr = decorator.expression;\n // @deprecated or @deprecated()\n if (ts.isIdentifier(expr) && expr.text === 'deprecated') return true;\n if (ts.isCallExpression(expr) && ts.isIdentifier(expr.expression) && expr.expression.text === 'deprecated') {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if a node has @deprecated in its JSDoc comments.\n */\nfunction hasDeprecatedJsDoc(node: ts.Node): boolean {\n const jsDocs = ts.getJSDocTags(node);\n for (const tag of jsDocs) {\n if (tag.tagName.text === 'deprecated') return true;\n }\n return false;\n}\n\n/**\n * Check if a method is deprecated via decorator or JSDoc.\n */\nfunction isDeprecated(node: ts.MethodDeclaration | ts.FunctionDeclaration): boolean {\n return hasDeprecatedDecorator(node) || hasDeprecatedJsDoc(node);\n}\n\n/**\n * Extract the text of a type node, stripping whitespace.\n */\nfunction getTypeText(typeNode: ts.TypeNode, sourceFile: ts.SourceFile): string {\n return typeNode.getText(sourceFile).trim();\n}\n\n/**\n * Unwrap Promise<T> to get T. Returns the inner type text if wrapped, otherwise returns as-is.\n */\nfunction unwrapPromise(typeText: string): UnwrapResult {\n const promiseMatch = typeText.match(/^Promise\\s*<\\s*(.+)\\s*>$/);\n if (promiseMatch) {\n return { inner: promiseMatch[1].trim(), isAsync: true };\n }\n return { inner: typeText, isAsync: false };\n}\n\n/**\n * Check a standalone function declaration in a converter file and return a violation if applicable.\n */\nfunction checkStandaloneFunction(\n node: ts.FunctionDeclaration,\n ctx: FileContext\n): PrismaConverterViolation | null {\n if (!node.name) return null;\n\n const startPos = node.getStart(ctx.sourceFile);\n const pos = ctx.sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n\n if (hasDisableComment(ctx.fileLines, line) || isDeprecated(node)) return null;\n\n return {\n file: ctx.filePath,\n line,\n message: `Standalone function \"${node.name.text}\" found in converter file. ` +\n 'Move to a converter class so it can be injected via DI.',\n };\n}\n\n/**\n * Validate the parameters of a converter method that returns a Dto with a matching Dbo.\n */\nfunction checkMethodParams(\n node: ts.MethodDeclaration,\n innerType: string,\n expectedDbo: string,\n ctx: FileContext,\n line: number\n): PrismaConverterViolation[] {\n const violations: PrismaConverterViolation[] = [];\n const params = node.parameters;\n\n if (params.length === 0) {\n violations.push({\n file: ctx.filePath,\n line,\n message: `Method returns \"${innerType}\" but has no parameters. ` +\n `First parameter must be of type \"${expectedDbo}\".`,\n });\n return violations;\n }\n\n const firstParam = params[0];\n if (firstParam.type) {\n const firstParamType = getTypeText(firstParam.type, ctx.sourceFile);\n if (firstParamType !== expectedDbo) {\n violations.push({\n file: ctx.filePath,\n line,\n message: `Method returns \"${innerType}\" but first parameter is \"${firstParamType}\". ` +\n `First parameter must be of type \"${expectedDbo}\".`,\n });\n }\n }\n\n for (let i = 1; i < params.length; i++) {\n const param = params[i];\n if (param.type) {\n const paramType = getTypeText(param.type, ctx.sourceFile);\n if (paramType !== 'boolean') {\n const paramName = param.name.getText(ctx.sourceFile);\n violations.push({\n file: ctx.filePath,\n line,\n message: `Extra parameter \"${paramName}\" has type \"${paramType}\" but must be \"boolean\". ` +\n 'Additional converter parameters are only for boolean flags (payload filtering / security).',\n });\n }\n }\n }\n\n return violations;\n}\n\n/**\n * Check a class method declaration for converter pattern violations.\n */\nfunction checkConverterMethod(\n node: ts.MethodDeclaration,\n ctx: FileContext\n): PrismaConverterViolation[] {\n if (!node.name || !node.type) return [];\n\n const startPos = node.getStart(ctx.sourceFile);\n const pos = ctx.sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n\n if (hasDisableComment(ctx.fileLines, line) || isDeprecated(node)) return [];\n\n const returnTypeText = getTypeText(node.type, ctx.sourceFile);\n const { inner: innerType, isAsync } = unwrapPromise(returnTypeText);\n const expectedDbo = deriveExpectedDboName(innerType);\n\n if (!expectedDbo || !ctx.prismaModels.has(expectedDbo)) return [];\n\n if (isAsync) {\n return [{\n file: ctx.filePath,\n line,\n message: `Async converter method returning \"Promise<${innerType}>\" found. ` +\n 'Converters should be pure data mapping with no async work. Remove async/Promise.',\n }];\n }\n\n return checkMethodParams(node, innerType, expectedDbo, ctx, line);\n}\n\n/**\n * Find converter method violations in a single file.\n * Checks class methods for proper Dbo parameter patterns and flags standalone functions.\n */\nfunction findConverterViolationsInFile(\n filePath: string,\n workspaceRoot: string,\n prismaModels: Set<string>\n): PrismaConverterViolation[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const ctx: FileContext = {\n filePath,\n fileLines: content.split('\\n'),\n sourceFile: ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true),\n prismaModels,\n };\n\n const violations: PrismaConverterViolation[] = [];\n\n function visitNode(node: ts.Node): void {\n if (ts.isFunctionDeclaration(node)) {\n const violation = checkStandaloneFunction(node, ctx);\n if (violation) violations.push(violation);\n }\n\n if (ts.isMethodDeclaration(node)) {\n violations.push(...checkConverterMethod(node, ctx));\n }\n\n ts.forEachChild(node, visitNode);\n }\n\n visitNode(ctx.sourceFile);\n return violations;\n}\n\n/**\n * Find violations in non-converter files: creating `new XxxDto(...)` where XxxDbo exists in prisma.\n * These Dto instances must only be created inside converter classes.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal for new-expression detection with prisma model matching\nfunction findDtoCreationOutsideConverters(\n filePath: string,\n workspaceRoot: string,\n prismaModels: Set<string>,\n convertersPaths: string[]\n): PrismaConverterViolation[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const fileLines = content.split('\\n');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n\n const violations: PrismaConverterViolation[] = [];\n\n function visitNode(node: ts.Node): void {\n // Detect `new XxxDto(...)` expressions\n if (ts.isNewExpression(node) && ts.isIdentifier(node.expression)) {\n const className = node.expression.text;\n const expectedDbo = deriveExpectedDboName(className);\n\n if (expectedDbo && prismaModels.has(expectedDbo)) {\n const startPos = node.getStart(sourceFile);\n const pos = sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n\n if (!hasDisableComment(fileLines, line)) {\n const dirs = convertersPaths.map((p) => `\"${p}\"`).join(', ');\n violations.push({\n file: filePath,\n line,\n message: `\"${className}\" can only be created from its Dbo using a converter in one of these directories: ${dirs}. ` +\n 'Move this Dto construction into a converter class method.',\n });\n }\n }\n }\n\n ts.forEachChild(node, visitNode);\n }\n\n visitNode(sourceFile);\n return violations;\n}\n\n/**\n * Report violations to console.\n */\nfunction reportViolations(violations: PrismaConverterViolation[], mode: PrismaConverterMode): void {\n console.error('');\n console.error('❌ Prisma converter violations found!');\n console.error('');\n console.error('📚 Converter methods returning XxxDto (where XxxDbo exists in schema.prisma)');\n console.error(' must accept XxxDbo as the first parameter. This keeps single-table');\n console.error(' converters clean and forces join converters to compose them.');\n console.error('');\n console.error(' GOOD: convertUserDbo(userDbo: UserDbo): UserDto { }');\n console.error(' GOOD: convertVersionDbo(version: VersionDbo, partial?: boolean): VersionDto { }');\n console.error(' GOOD: convertToJoinDto(item: SomeJoinType): CourseJoinDto { } // no matching JoinDbo');\n console.error('');\n console.error(' BAD: async convertUser(dbo: UserDbo): Promise<UserDto> { } // no async');\n console.error(' BAD: convertCourse(course: CourseWithMeta): CourseDto { } // wrong first param');\n console.error(' BAD: convertUser(dbo: UserDbo, name: string): UserDto { } // extra non-boolean');\n console.error(' BAD: export function convertSession(s: SessionDbo): SessionDto // standalone function');\n console.error('');\n\n for (const v of violations) {\n console.error(` ❌ ${v.file}:${v.line}`);\n console.error(` ${v.message}`);\n }\n console.error('');\n\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable prisma-converter -- [your reason]');\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\n/**\n * Resolve git base ref from env vars or auto-detection.\n */\nfunction resolveBase(workspaceRoot: string): string | undefined {\n const envBase = process.env['NX_BASE'];\n if (envBase) return envBase;\n return detectBase(workspaceRoot) ?? undefined;\n}\n\n/**\n * Collect all violations from converter and non-converter files.\n */\nfunction collectAllViolations(\n changedFiles: string[],\n convertersPaths: string[],\n workspaceRoot: string,\n prismaModels: Set<string>\n): PrismaConverterViolation[] {\n const converterFiles = changedFiles.filter((f) =>\n convertersPaths.some((cp) => f.startsWith(cp))\n );\n const nonConverterFiles = changedFiles.filter((f) =>\n !convertersPaths.some((cp) => f.startsWith(cp))\n );\n\n const allViolations: PrismaConverterViolation[] = [];\n\n if (converterFiles.length > 0) {\n console.log(`📂 Checking ${converterFiles.length} converter file(s)...`);\n for (const file of converterFiles) {\n allViolations.push(...findConverterViolationsInFile(file, workspaceRoot, prismaModels));\n }\n }\n\n if (nonConverterFiles.length > 0) {\n console.log(`📂 Checking ${nonConverterFiles.length} non-converter file(s) for Dto creation...`);\n for (const file of nonConverterFiles) {\n allViolations.push(...findDtoCreationOutsideConverters(file, workspaceRoot, prismaModels, convertersPaths));\n }\n }\n\n return allViolations;\n}\n\n/**\n * Run validation after early-exit checks have passed.\n */\nfunction validateChangedFiles(\n workspaceRoot: string,\n schemaPath: string,\n convertersPaths: string[],\n base: string,\n mode: PrismaConverterMode\n): ExecutorResult {\n const head = process.env['NX_HEAD'];\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log('');\n\n const fullSchemaPath = path.join(workspaceRoot, schemaPath);\n const prismaModels = parsePrismaModels(fullSchemaPath);\n\n if (prismaModels.size === 0) {\n console.log('⏭️ No models found in schema.prisma');\n console.log('');\n return { success: true };\n }\n\n console.log(` Found ${prismaModels.size} model(s) in schema.prisma`);\n\n const changedFiles = getChangedTypeScriptFiles(workspaceRoot, base, head);\n\n if (changedFiles.length === 0) {\n console.log('✅ No TypeScript files changed');\n return { success: true };\n }\n\n const allViolations = collectAllViolations(changedFiles, convertersPaths, workspaceRoot, prismaModels);\n\n if (allViolations.length === 0) {\n console.log('✅ All converter patterns are valid');\n return { success: true };\n }\n\n reportViolations(allViolations, mode);\n return { success: false };\n}\n\n/**\n * Resolve mode considering ignoreModifiedUntilEpoch override.\n * When active, downgrades to OFF. When expired, logs a warning.\n */\nfunction resolvePrismaConverterMode(\n normalMode: PrismaConverterMode,\n epoch: number | undefined\n): PrismaConverterMode {\n if (epoch === undefined || normalMode === 'OFF') {\n return normalMode;\n }\n const nowSeconds = Date.now() / 1000;\n if (nowSeconds < epoch) {\n const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];\n console.log(`\\n⏭️ Skipping prisma-converter validation (ignoreModifiedUntilEpoch active, expires: ${expiresDate})`);\n console.log('');\n return 'OFF';\n }\n const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];\n console.log(`\\n⚠️ prismaConverter.ignoreModifiedUntilEpoch (${epoch}) has expired (${expiresDate}). Remove it from nx.json. Using normal mode: ${normalMode}\\n`);\n return normalMode;\n}\n\nexport default async function runExecutor(\n options: ValidatePrismaConvertersOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const workspaceRoot = context.root;\n const mode = resolvePrismaConverterMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch);\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping prisma-converter validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n const schemaPath = options.schemaPath;\n const convertersPaths = options.convertersPaths ?? [];\n\n if (!schemaPath || convertersPaths.length === 0) {\n const reason = !schemaPath ? 'no schemaPath configured' : 'no convertersPaths configured';\n console.log(`\\n⏭️ Skipping prisma-converter validation (${reason})`);\n console.log('');\n return { success: true };\n }\n\n console.log('\\n📏 Validating Prisma Converters\\n');\n console.log(` Mode: ${mode}`);\n console.log(` Schema: ${schemaPath}`);\n console.log(` Converter paths: ${convertersPaths.join(', ')}`);\n\n const base = resolveBase(workspaceRoot);\n\n if (!base) {\n console.log('\\n⏭️ Skipping prisma-converter validation (could not detect base branch)');\n console.log('');\n return { success: true };\n }\n\n return validateChangedFiles(workspaceRoot, schemaPath, convertersPaths, base, mode);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/architecture/executors/validate-prisma-converters/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;;AAojBH,8BAsCC;;AAvlBD,iDAAyC;AACzC,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AAmCjC;;GAEG;AACH,SAAS,UAAU,CAAC,aAAqB;IACrC,IAAI,CAAC;QACD,MAAM,SAAS,GAAG,IAAA,wBAAQ,EAAC,iCAAiC,EAAE;YAC1D,GAAG,EAAE,aAAa;YAClB,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAClC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEV,IAAI,SAAS,EAAE,CAAC;YACZ,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,IAAI,CAAC;YACD,MAAM,SAAS,GAAG,IAAA,wBAAQ,EAAC,0BAA0B,EAAE;gBACnD,GAAG,EAAE,aAAa;gBAClB,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;aAClC,CAAC,CAAC,IAAI,EAAE,CAAC;YAEV,IAAI,SAAS,EAAE,CAAC;gBACZ,OAAO,SAAS,CAAC;YACrB,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACL,SAAS;QACb,CAAC;IACL,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,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;AACxG,CAAC","sourcesContent":["/**\n * Validate Prisma Converters Executor\n *\n * Validates that Prisma converter methods follow a scalable pattern:\n * methods returning XxxDto (where XxxDbo exists in schema.prisma) must\n * accept that exact XxxDbo as the first parameter. This keeps single-table\n * converters clean and forces join converters to compose them.\n *\n * ============================================================================\n * RULES\n * ============================================================================\n *\n * 1. First param must be exact Dbo:\n * If method returns XxxDto and XxxDbo exists in schema.prisma,\n * the first parameter must be of type XxxDbo.\n *\n * 2. Extra params must be booleans:\n * Additional parameters beyond the Dbo are allowed but must be boolean\n * (used for filtering payloads / security info).\n *\n * 3. No async converters:\n * Methods returning Promise<XxxDto> are flagged — converters should be\n * pure data mapping, no async work.\n *\n * 4. No standalone functions:\n * Standalone functions in converter files are flagged — must be class\n * methods so the converter class can be injected (dependency tree tracing).\n *\n * 5. Dto creation outside converters directory:\n * Files outside the configured convertersPath that create `new XxxDto(...)`\n * where XxxDbo exists in schema.prisma are flagged — Dto instances tied to\n * a Dbo must only be created via a converter class.\n *\n * ============================================================================\n * SKIP CONDITIONS\n * ============================================================================\n * - Methods with @deprecated decorator or JSDoc tag\n * - Lines with: // webpieces-disable prisma-converter -- [reason]\n *\n * ============================================================================\n * MODES\n * ============================================================================\n * - OFF: Skip validation entirely\n * - MODIFIED_FILES: Validate converter files that were modified in the diff\n */\n\nimport type { ExecutorContext } from '@nx/devkit';\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\n\nexport type PrismaConverterMode = 'OFF' | 'MODIFIED_FILES';\n\nexport interface ValidatePrismaConvertersOptions {\n mode?: PrismaConverterMode;\n disableAllowed?: boolean;\n schemaPath?: string;\n convertersPaths?: string[];\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\ninterface PrismaConverterViolation {\n file: string;\n line: number;\n message: string;\n}\n\ninterface UnwrapResult {\n inner: string;\n isAsync: boolean;\n}\n\ninterface FileContext {\n filePath: string;\n fileLines: string[];\n sourceFile: ts.SourceFile;\n prismaModels: Set<string>;\n disableAllowed: boolean;\n}\n\n/**\n * Auto-detect the base branch by finding the merge-base with origin/main.\n */\nfunction detectBase(workspaceRoot: string): string | null {\n try {\n const mergeBase = execSync('git merge-base HEAD origin/main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n try {\n const mergeBase = execSync('git merge-base HEAD main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n // Ignore\n }\n }\n return null;\n}\n\n/**\n * Get changed TypeScript files between base and head (or working tree if head not specified).\n */\n// webpieces-disable max-lines-new-methods -- Git command handling with untracked files requires multiple code paths\nfunction getChangedTypeScriptFiles(workspaceRoot: string, base: string, head?: string): string[] {\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const output = execSync(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const changedFiles = output\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n\n if (!head) {\n try {\n const untrackedOutput = execSync(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const untrackedFiles = untrackedOutput\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n const allFiles = new Set([...changedFiles, ...untrackedFiles]);\n return Array.from(allFiles);\n } catch {\n return changedFiles;\n }\n }\n\n return changedFiles;\n } catch {\n return [];\n }\n}\n\n/**\n * Parse schema.prisma to extract all model names into a Set.\n */\nfunction parsePrismaModels(schemaPath: string): Set<string> {\n const models = new Set<string>();\n\n if (!fs.existsSync(schemaPath)) {\n return models;\n }\n\n const content = fs.readFileSync(schemaPath, 'utf-8');\n const regex = /^model\\s+(\\w+)\\s*\\{/gm;\n let match: RegExpExecArray | null;\n\n while ((match = regex.exec(content)) !== null) {\n models.add(match[1]);\n }\n\n return models;\n}\n\n/**\n * Derive the expected Dbo name from a return type ending in Dto.\n * \"XxxDto\" -> \"XxxDbo\". Returns null if name doesn't end with Dto.\n */\nfunction deriveExpectedDboName(returnType: string): string | null {\n if (!returnType.endsWith('Dto')) return null;\n return returnType.slice(0, -3) + 'Dbo';\n}\n\n/**\n * Check if a line has a webpieces-disable comment for prisma-converter.\n */\nfunction hasDisableComment(lines: string[], lineNumber: number): boolean {\n const startCheck = Math.max(0, lineNumber - 5);\n for (let i = lineNumber - 2; i >= startCheck; i--) {\n const line = lines[i]?.trim() ?? '';\n if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {\n break;\n }\n if (line.includes('webpieces-disable') && line.includes('prisma-converter')) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if a method/function node has a @deprecated decorator.\n */\nfunction hasDeprecatedDecorator(node: ts.MethodDeclaration | ts.FunctionDeclaration): boolean {\n const modifiers = ts.canHaveDecorators(node) ? ts.getDecorators(node) : undefined;\n if (!modifiers) return false;\n\n for (const decorator of modifiers) {\n const expr = decorator.expression;\n // @deprecated or @deprecated()\n if (ts.isIdentifier(expr) && expr.text === 'deprecated') return true;\n if (ts.isCallExpression(expr) && ts.isIdentifier(expr.expression) && expr.expression.text === 'deprecated') {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if a node has @deprecated in its JSDoc comments.\n */\nfunction hasDeprecatedJsDoc(node: ts.Node): boolean {\n const jsDocs = ts.getJSDocTags(node);\n for (const tag of jsDocs) {\n if (tag.tagName.text === 'deprecated') return true;\n }\n return false;\n}\n\n/**\n * Check if a method is deprecated via decorator or JSDoc.\n */\nfunction isDeprecated(node: ts.MethodDeclaration | ts.FunctionDeclaration): boolean {\n return hasDeprecatedDecorator(node) || hasDeprecatedJsDoc(node);\n}\n\n/**\n * Extract the text of a type node, stripping whitespace.\n */\nfunction getTypeText(typeNode: ts.TypeNode, sourceFile: ts.SourceFile): string {\n return typeNode.getText(sourceFile).trim();\n}\n\n/**\n * Unwrap Promise<T> to get T. Returns the inner type text if wrapped, otherwise returns as-is.\n */\nfunction unwrapPromise(typeText: string): UnwrapResult {\n const promiseMatch = typeText.match(/^Promise\\s*<\\s*(.+)\\s*>$/);\n if (promiseMatch) {\n return { inner: promiseMatch[1].trim(), isAsync: true };\n }\n return { inner: typeText, isAsync: false };\n}\n\n/**\n * Check a standalone function declaration in a converter file and return a violation if applicable.\n */\nfunction checkStandaloneFunction(\n node: ts.FunctionDeclaration,\n ctx: FileContext\n): PrismaConverterViolation | null {\n if (!node.name) return null;\n\n const startPos = node.getStart(ctx.sourceFile);\n const pos = ctx.sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n\n if ((ctx.disableAllowed && hasDisableComment(ctx.fileLines, line)) || isDeprecated(node)) return null;\n\n return {\n file: ctx.filePath,\n line,\n message: `Standalone function \"${node.name.text}\" found in converter file. ` +\n 'Move to a converter class so it can be injected via DI.',\n };\n}\n\n/**\n * Validate the parameters of a converter method that returns a Dto with a matching Dbo.\n */\nfunction checkMethodParams(\n node: ts.MethodDeclaration,\n innerType: string,\n expectedDbo: string,\n ctx: FileContext,\n line: number\n): PrismaConverterViolation[] {\n const violations: PrismaConverterViolation[] = [];\n const params = node.parameters;\n\n if (params.length === 0) {\n violations.push({\n file: ctx.filePath,\n line,\n message: `Method returns \"${innerType}\" but has no parameters. ` +\n `First parameter must be of type \"${expectedDbo}\".`,\n });\n return violations;\n }\n\n const firstParam = params[0];\n if (firstParam.type) {\n const firstParamType = getTypeText(firstParam.type, ctx.sourceFile);\n if (firstParamType !== expectedDbo) {\n violations.push({\n file: ctx.filePath,\n line,\n message: `Method returns \"${innerType}\" but first parameter is \"${firstParamType}\". ` +\n `First parameter must be of type \"${expectedDbo}\".`,\n });\n }\n }\n\n for (let i = 1; i < params.length; i++) {\n const param = params[i];\n if (param.type) {\n const paramType = getTypeText(param.type, ctx.sourceFile);\n if (paramType !== 'boolean') {\n const paramName = param.name.getText(ctx.sourceFile);\n violations.push({\n file: ctx.filePath,\n line,\n message: `Extra parameter \"${paramName}\" has type \"${paramType}\" but must be \"boolean\". ` +\n 'Additional converter parameters are only for boolean flags (payload filtering / security).',\n });\n }\n }\n }\n\n return violations;\n}\n\n/**\n * Check a class method declaration for converter pattern violations.\n */\nfunction checkConverterMethod(\n node: ts.MethodDeclaration,\n ctx: FileContext\n): PrismaConverterViolation[] {\n if (!node.name || !node.type) return [];\n\n const startPos = node.getStart(ctx.sourceFile);\n const pos = ctx.sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n\n if ((ctx.disableAllowed && hasDisableComment(ctx.fileLines, line)) || isDeprecated(node)) return [];\n\n const returnTypeText = getTypeText(node.type, ctx.sourceFile);\n const { inner: innerType, isAsync } = unwrapPromise(returnTypeText);\n const expectedDbo = deriveExpectedDboName(innerType);\n\n if (!expectedDbo || !ctx.prismaModels.has(expectedDbo)) return [];\n\n if (isAsync) {\n return [{\n file: ctx.filePath,\n line,\n message: `Async converter method returning \"Promise<${innerType}>\" found. ` +\n 'Converters should be pure data mapping with no async work. Remove async/Promise.',\n }];\n }\n\n return checkMethodParams(node, innerType, expectedDbo, ctx, line);\n}\n\n/**\n * Find converter method violations in a single file.\n * Checks class methods for proper Dbo parameter patterns and flags standalone functions.\n */\nfunction findConverterViolationsInFile(\n filePath: string,\n workspaceRoot: string,\n prismaModels: Set<string>,\n disableAllowed: boolean\n): PrismaConverterViolation[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const ctx: FileContext = {\n filePath,\n fileLines: content.split('\\n'),\n sourceFile: ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true),\n prismaModels,\n disableAllowed,\n };\n\n const violations: PrismaConverterViolation[] = [];\n\n function visitNode(node: ts.Node): void {\n if (ts.isFunctionDeclaration(node)) {\n const violation = checkStandaloneFunction(node, ctx);\n if (violation) violations.push(violation);\n }\n\n if (ts.isMethodDeclaration(node)) {\n violations.push(...checkConverterMethod(node, ctx));\n }\n\n ts.forEachChild(node, visitNode);\n }\n\n visitNode(ctx.sourceFile);\n return violations;\n}\n\n/**\n * Find violations in non-converter files: creating `new XxxDto(...)` where XxxDbo exists in prisma.\n * These Dto instances must only be created inside converter classes.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal for new-expression detection with prisma model matching\nfunction findDtoCreationOutsideConverters(\n filePath: string,\n workspaceRoot: string,\n prismaModels: Set<string>,\n convertersPaths: string[],\n disableAllowed: boolean\n): PrismaConverterViolation[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const fileLines = content.split('\\n');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n\n const violations: PrismaConverterViolation[] = [];\n\n function visitNode(node: ts.Node): void {\n // Detect `new XxxDto(...)` expressions\n if (ts.isNewExpression(node) && ts.isIdentifier(node.expression)) {\n const className = node.expression.text;\n const expectedDbo = deriveExpectedDboName(className);\n\n if (expectedDbo && prismaModels.has(expectedDbo)) {\n const startPos = node.getStart(sourceFile);\n const pos = sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n\n if (!disableAllowed || !hasDisableComment(fileLines, line)) {\n const dirs = convertersPaths.map((p) => `\"${p}\"`).join(', ');\n violations.push({\n file: filePath,\n line,\n message: `\"${className}\" can only be created from its Dbo using a converter in one of these directories: ${dirs}. ` +\n 'Move this Dto construction into a converter class method.',\n });\n }\n }\n }\n\n ts.forEachChild(node, visitNode);\n }\n\n visitNode(sourceFile);\n return violations;\n}\n\n/**\n * Report violations to console.\n */\nfunction reportViolations(violations: PrismaConverterViolation[], mode: PrismaConverterMode): void {\n console.error('');\n console.error('❌ Prisma converter violations found!');\n console.error('');\n console.error('📚 Converter methods returning XxxDto (where XxxDbo exists in schema.prisma)');\n console.error(' must accept XxxDbo as the first parameter. This keeps single-table');\n console.error(' converters clean and forces join converters to compose them.');\n console.error('');\n console.error(' GOOD: convertUserDbo(userDbo: UserDbo): UserDto { }');\n console.error(' GOOD: convertVersionDbo(version: VersionDbo, partial?: boolean): VersionDto { }');\n console.error(' GOOD: convertToJoinDto(item: SomeJoinType): CourseJoinDto { } // no matching JoinDbo');\n console.error('');\n console.error(' BAD: async convertUser(dbo: UserDbo): Promise<UserDto> { } // no async');\n console.error(' BAD: convertCourse(course: CourseWithMeta): CourseDto { } // wrong first param');\n console.error(' BAD: convertUser(dbo: UserDbo, name: string): UserDto { } // extra non-boolean');\n console.error(' BAD: export function convertSession(s: SessionDbo): SessionDto // standalone function');\n console.error('');\n\n for (const v of violations) {\n console.error(` ❌ ${v.file}:${v.line}`);\n console.error(` ${v.message}`);\n }\n console.error('');\n\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable prisma-converter -- [your reason]');\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\n/**\n * Resolve git base ref from env vars or auto-detection.\n */\nfunction resolveBase(workspaceRoot: string): string | undefined {\n const envBase = process.env['NX_BASE'];\n if (envBase) return envBase;\n return detectBase(workspaceRoot) ?? undefined;\n}\n\n/**\n * Collect all violations from converter and non-converter files.\n */\nfunction collectAllViolations(\n changedFiles: string[],\n convertersPaths: string[],\n workspaceRoot: string,\n prismaModels: Set<string>,\n disableAllowed: boolean\n): PrismaConverterViolation[] {\n const converterFiles = changedFiles.filter((f) =>\n convertersPaths.some((cp) => f.startsWith(cp))\n );\n const nonConverterFiles = changedFiles.filter((f) =>\n !convertersPaths.some((cp) => f.startsWith(cp))\n );\n\n const allViolations: PrismaConverterViolation[] = [];\n\n if (converterFiles.length > 0) {\n console.log(`📂 Checking ${converterFiles.length} converter file(s)...`);\n for (const file of converterFiles) {\n allViolations.push(...findConverterViolationsInFile(file, workspaceRoot, prismaModels, disableAllowed));\n }\n }\n\n if (nonConverterFiles.length > 0) {\n console.log(`📂 Checking ${nonConverterFiles.length} non-converter file(s) for Dto creation...`);\n for (const file of nonConverterFiles) {\n allViolations.push(...findDtoCreationOutsideConverters(file, workspaceRoot, prismaModels, convertersPaths, disableAllowed));\n }\n }\n\n return allViolations;\n}\n\n/**\n * Run validation after early-exit checks have passed.\n */\nfunction validateChangedFiles(\n workspaceRoot: string,\n schemaPath: string,\n convertersPaths: string[],\n base: string,\n mode: PrismaConverterMode,\n disableAllowed: boolean\n): ExecutorResult {\n const head = process.env['NX_HEAD'];\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log('');\n\n const fullSchemaPath = path.join(workspaceRoot, schemaPath);\n const prismaModels = parsePrismaModels(fullSchemaPath);\n\n if (prismaModels.size === 0) {\n console.log('⏭️ No models found in schema.prisma');\n console.log('');\n return { success: true };\n }\n\n console.log(` Found ${prismaModels.size} model(s) in schema.prisma`);\n\n const changedFiles = getChangedTypeScriptFiles(workspaceRoot, base, head);\n\n if (changedFiles.length === 0) {\n console.log('✅ No TypeScript files changed');\n return { success: true };\n }\n\n const allViolations = collectAllViolations(changedFiles, convertersPaths, workspaceRoot, prismaModels, disableAllowed);\n\n if (allViolations.length === 0) {\n console.log('✅ All converter patterns are valid');\n return { success: true };\n }\n\n reportViolations(allViolations, mode);\n return { success: false };\n}\n\n/**\n * Resolve mode considering ignoreModifiedUntilEpoch override.\n * When active, downgrades to OFF. When expired, logs a warning.\n */\nfunction resolvePrismaConverterMode(\n normalMode: PrismaConverterMode,\n epoch: number | undefined\n): PrismaConverterMode {\n if (epoch === undefined || normalMode === 'OFF') {\n return normalMode;\n }\n const nowSeconds = Date.now() / 1000;\n if (nowSeconds < epoch) {\n const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];\n console.log(`\\n⏭️ Skipping prisma-converter validation (ignoreModifiedUntilEpoch active, expires: ${expiresDate})`);\n console.log('');\n return 'OFF';\n }\n const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];\n console.log(`\\n⚠️ prismaConverter.ignoreModifiedUntilEpoch (${epoch}) has expired (${expiresDate}). Remove it from nx.json. Using normal mode: ${normalMode}\\n`);\n return normalMode;\n}\n\nexport default async function runExecutor(\n options: ValidatePrismaConvertersOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const workspaceRoot = context.root;\n const mode = resolvePrismaConverterMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch);\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping prisma-converter validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n const schemaPath = options.schemaPath;\n const convertersPaths = options.convertersPaths ?? [];\n\n if (!schemaPath || convertersPaths.length === 0) {\n const reason = !schemaPath ? 'no schemaPath configured' : 'no convertersPaths configured';\n console.log(`\\n⏭️ Skipping prisma-converter validation (${reason})`);\n console.log('');\n return { success: true };\n }\n\n console.log('\\n📏 Validating Prisma Converters\\n');\n console.log(` Mode: ${mode}`);\n console.log(` Schema: ${schemaPath}`);\n console.log(` Converter paths: ${convertersPaths.join(', ')}`);\n\n const base = resolveBase(workspaceRoot);\n\n if (!base) {\n console.log('\\n⏭️ Skipping prisma-converter validation (could not detect base branch)');\n console.log('');\n return { success: true };\n }\n\n const disableAllowed = options.disableAllowed ?? true;\n return validateChangedFiles(workspaceRoot, schemaPath, convertersPaths, base, mode, disableAllowed);\n}\n"]}
|
|
@@ -54,6 +54,7 @@ export type PrismaConverterMode = 'OFF' | 'MODIFIED_FILES';
|
|
|
54
54
|
|
|
55
55
|
export interface ValidatePrismaConvertersOptions {
|
|
56
56
|
mode?: PrismaConverterMode;
|
|
57
|
+
disableAllowed?: boolean;
|
|
57
58
|
schemaPath?: string;
|
|
58
59
|
convertersPaths?: string[];
|
|
59
60
|
ignoreModifiedUntilEpoch?: number;
|
|
@@ -79,6 +80,7 @@ interface FileContext {
|
|
|
79
80
|
fileLines: string[];
|
|
80
81
|
sourceFile: ts.SourceFile;
|
|
81
82
|
prismaModels: Set<string>;
|
|
83
|
+
disableAllowed: boolean;
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
/**
|
|
@@ -266,7 +268,7 @@ function checkStandaloneFunction(
|
|
|
266
268
|
const pos = ctx.sourceFile.getLineAndCharacterOfPosition(startPos);
|
|
267
269
|
const line = pos.line + 1;
|
|
268
270
|
|
|
269
|
-
if (hasDisableComment(ctx.fileLines, line) || isDeprecated(node)) return null;
|
|
271
|
+
if ((ctx.disableAllowed && hasDisableComment(ctx.fileLines, line)) || isDeprecated(node)) return null;
|
|
270
272
|
|
|
271
273
|
return {
|
|
272
274
|
file: ctx.filePath,
|
|
@@ -344,7 +346,7 @@ function checkConverterMethod(
|
|
|
344
346
|
const pos = ctx.sourceFile.getLineAndCharacterOfPosition(startPos);
|
|
345
347
|
const line = pos.line + 1;
|
|
346
348
|
|
|
347
|
-
if (hasDisableComment(ctx.fileLines, line) || isDeprecated(node)) return [];
|
|
349
|
+
if ((ctx.disableAllowed && hasDisableComment(ctx.fileLines, line)) || isDeprecated(node)) return [];
|
|
348
350
|
|
|
349
351
|
const returnTypeText = getTypeText(node.type, ctx.sourceFile);
|
|
350
352
|
const { inner: innerType, isAsync } = unwrapPromise(returnTypeText);
|
|
@@ -371,7 +373,8 @@ function checkConverterMethod(
|
|
|
371
373
|
function findConverterViolationsInFile(
|
|
372
374
|
filePath: string,
|
|
373
375
|
workspaceRoot: string,
|
|
374
|
-
prismaModels: Set<string
|
|
376
|
+
prismaModels: Set<string>,
|
|
377
|
+
disableAllowed: boolean
|
|
375
378
|
): PrismaConverterViolation[] {
|
|
376
379
|
const fullPath = path.join(workspaceRoot, filePath);
|
|
377
380
|
if (!fs.existsSync(fullPath)) return [];
|
|
@@ -382,6 +385,7 @@ function findConverterViolationsInFile(
|
|
|
382
385
|
fileLines: content.split('\n'),
|
|
383
386
|
sourceFile: ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true),
|
|
384
387
|
prismaModels,
|
|
388
|
+
disableAllowed,
|
|
385
389
|
};
|
|
386
390
|
|
|
387
391
|
const violations: PrismaConverterViolation[] = [];
|
|
@@ -412,7 +416,8 @@ function findDtoCreationOutsideConverters(
|
|
|
412
416
|
filePath: string,
|
|
413
417
|
workspaceRoot: string,
|
|
414
418
|
prismaModels: Set<string>,
|
|
415
|
-
convertersPaths: string[]
|
|
419
|
+
convertersPaths: string[],
|
|
420
|
+
disableAllowed: boolean
|
|
416
421
|
): PrismaConverterViolation[] {
|
|
417
422
|
const fullPath = path.join(workspaceRoot, filePath);
|
|
418
423
|
if (!fs.existsSync(fullPath)) return [];
|
|
@@ -434,7 +439,7 @@ function findDtoCreationOutsideConverters(
|
|
|
434
439
|
const pos = sourceFile.getLineAndCharacterOfPosition(startPos);
|
|
435
440
|
const line = pos.line + 1;
|
|
436
441
|
|
|
437
|
-
if (!hasDisableComment(fileLines, line)) {
|
|
442
|
+
if (!disableAllowed || !hasDisableComment(fileLines, line)) {
|
|
438
443
|
const dirs = convertersPaths.map((p) => `"${p}"`).join(', ');
|
|
439
444
|
violations.push({
|
|
440
445
|
file: filePath,
|
|
@@ -503,7 +508,8 @@ function collectAllViolations(
|
|
|
503
508
|
changedFiles: string[],
|
|
504
509
|
convertersPaths: string[],
|
|
505
510
|
workspaceRoot: string,
|
|
506
|
-
prismaModels: Set<string
|
|
511
|
+
prismaModels: Set<string>,
|
|
512
|
+
disableAllowed: boolean
|
|
507
513
|
): PrismaConverterViolation[] {
|
|
508
514
|
const converterFiles = changedFiles.filter((f) =>
|
|
509
515
|
convertersPaths.some((cp) => f.startsWith(cp))
|
|
@@ -517,14 +523,14 @@ function collectAllViolations(
|
|
|
517
523
|
if (converterFiles.length > 0) {
|
|
518
524
|
console.log(`📂 Checking ${converterFiles.length} converter file(s)...`);
|
|
519
525
|
for (const file of converterFiles) {
|
|
520
|
-
allViolations.push(...findConverterViolationsInFile(file, workspaceRoot, prismaModels));
|
|
526
|
+
allViolations.push(...findConverterViolationsInFile(file, workspaceRoot, prismaModels, disableAllowed));
|
|
521
527
|
}
|
|
522
528
|
}
|
|
523
529
|
|
|
524
530
|
if (nonConverterFiles.length > 0) {
|
|
525
531
|
console.log(`📂 Checking ${nonConverterFiles.length} non-converter file(s) for Dto creation...`);
|
|
526
532
|
for (const file of nonConverterFiles) {
|
|
527
|
-
allViolations.push(...findDtoCreationOutsideConverters(file, workspaceRoot, prismaModels, convertersPaths));
|
|
533
|
+
allViolations.push(...findDtoCreationOutsideConverters(file, workspaceRoot, prismaModels, convertersPaths, disableAllowed));
|
|
528
534
|
}
|
|
529
535
|
}
|
|
530
536
|
|
|
@@ -539,7 +545,8 @@ function validateChangedFiles(
|
|
|
539
545
|
schemaPath: string,
|
|
540
546
|
convertersPaths: string[],
|
|
541
547
|
base: string,
|
|
542
|
-
mode: PrismaConverterMode
|
|
548
|
+
mode: PrismaConverterMode,
|
|
549
|
+
disableAllowed: boolean
|
|
543
550
|
): ExecutorResult {
|
|
544
551
|
const head = process.env['NX_HEAD'];
|
|
545
552
|
|
|
@@ -565,7 +572,7 @@ function validateChangedFiles(
|
|
|
565
572
|
return { success: true };
|
|
566
573
|
}
|
|
567
574
|
|
|
568
|
-
const allViolations = collectAllViolations(changedFiles, convertersPaths, workspaceRoot, prismaModels);
|
|
575
|
+
const allViolations = collectAllViolations(changedFiles, convertersPaths, workspaceRoot, prismaModels, disableAllowed);
|
|
569
576
|
|
|
570
577
|
if (allViolations.length === 0) {
|
|
571
578
|
console.log('✅ All converter patterns are valid');
|
|
@@ -635,5 +642,6 @@ export default async function runExecutor(
|
|
|
635
642
|
return { success: true };
|
|
636
643
|
}
|
|
637
644
|
|
|
638
|
-
|
|
645
|
+
const disableAllowed = options.disableAllowed ?? true;
|
|
646
|
+
return validateChangedFiles(workspaceRoot, schemaPath, convertersPaths, base, mode, disableAllowed);
|
|
639
647
|
}
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"items": { "type": "string" },
|
|
20
20
|
"description": "Array of directories (relative to workspace root) containing converter files"
|
|
21
21
|
},
|
|
22
|
+
"disableAllowed": {
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"description": "Whether disable comments work. When false, no escape hatch.",
|
|
25
|
+
"default": true
|
|
26
|
+
},
|
|
22
27
|
"ignoreModifiedUntilEpoch": {
|
|
23
28
|
"type": "number",
|
|
24
29
|
"description": "Epoch seconds. Until this time, skip prisma-converter validation entirely. When expired, normal mode resumes. Omit when not needed."
|
|
@@ -20,6 +20,8 @@ import type { ExecutorContext } from '@nx/devkit';
|
|
|
20
20
|
export type ReturnTypeMode = 'OFF' | 'NEW_METHODS' | 'MODIFIED_AND_NEW_METHODS' | 'MODIFIED_FILES';
|
|
21
21
|
export interface ValidateReturnTypesOptions {
|
|
22
22
|
mode?: ReturnTypeMode;
|
|
23
|
+
disableAllowed?: boolean;
|
|
24
|
+
ignoreModifiedUntilEpoch?: number;
|
|
23
25
|
}
|
|
24
26
|
export interface ExecutorResult {
|
|
25
27
|
success: boolean;
|
|
@@ -241,7 +241,7 @@ function methodHasChanges(method, changedLines) {
|
|
|
241
241
|
* Find NEW methods without explicit return types (NEW_METHODS mode).
|
|
242
242
|
*/
|
|
243
243
|
// webpieces-disable max-lines-new-methods -- File iteration with diff parsing and method matching
|
|
244
|
-
function findViolationsForNewMethods(workspaceRoot, changedFiles, base, head) {
|
|
244
|
+
function findViolationsForNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed) {
|
|
245
245
|
const violations = [];
|
|
246
246
|
for (const file of changedFiles) {
|
|
247
247
|
const diff = getFileDiff(workspaceRoot, file, base, head);
|
|
@@ -254,7 +254,7 @@ function findViolationsForNewMethods(workspaceRoot, changedFiles, base, head) {
|
|
|
254
254
|
continue;
|
|
255
255
|
if (method.hasReturnType)
|
|
256
256
|
continue;
|
|
257
|
-
if (method.hasDisableComment)
|
|
257
|
+
if (disableAllowed && method.hasDisableComment)
|
|
258
258
|
continue;
|
|
259
259
|
violations.push({
|
|
260
260
|
file,
|
|
@@ -269,7 +269,7 @@ function findViolationsForNewMethods(workspaceRoot, changedFiles, base, head) {
|
|
|
269
269
|
* Find NEW methods AND methods with changes (MODIFIED_AND_NEW_METHODS mode).
|
|
270
270
|
*/
|
|
271
271
|
// webpieces-disable max-lines-new-methods -- Combines new method detection with change detection
|
|
272
|
-
function findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, base, head) {
|
|
272
|
+
function findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed) {
|
|
273
273
|
const violations = [];
|
|
274
274
|
for (const file of changedFiles) {
|
|
275
275
|
const diff = getFileDiff(workspaceRoot, file, base, head);
|
|
@@ -279,7 +279,7 @@ function findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, bas
|
|
|
279
279
|
for (const method of methods) {
|
|
280
280
|
if (method.hasReturnType)
|
|
281
281
|
continue;
|
|
282
|
-
if (method.hasDisableComment)
|
|
282
|
+
if (disableAllowed && method.hasDisableComment)
|
|
283
283
|
continue;
|
|
284
284
|
const isNewMethod = newMethodNames.has(method.name);
|
|
285
285
|
const isModifiedMethod = methodHasChanges(method, changedLines);
|
|
@@ -297,14 +297,14 @@ function findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, bas
|
|
|
297
297
|
/**
|
|
298
298
|
* Find all methods without explicit return types in modified files (MODIFIED_FILES mode).
|
|
299
299
|
*/
|
|
300
|
-
function findViolationsForModifiedFiles(workspaceRoot, changedFiles) {
|
|
300
|
+
function findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed) {
|
|
301
301
|
const violations = [];
|
|
302
302
|
for (const file of changedFiles) {
|
|
303
303
|
const methods = findMethodsInFile(file, workspaceRoot);
|
|
304
304
|
for (const method of methods) {
|
|
305
305
|
if (method.hasReturnType)
|
|
306
306
|
continue;
|
|
307
|
-
if (method.hasDisableComment)
|
|
307
|
+
if (disableAllowed && method.hasDisableComment)
|
|
308
308
|
continue;
|
|
309
309
|
violations.push({
|
|
310
310
|
file,
|
|
@@ -372,9 +372,29 @@ function reportViolations(violations, mode) {
|
|
|
372
372
|
console.error(` Current mode: ${mode}`);
|
|
373
373
|
console.error('');
|
|
374
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* Resolve mode considering ignoreModifiedUntilEpoch override.
|
|
377
|
+
* When active, downgrades to OFF. When expired, logs a warning.
|
|
378
|
+
*/
|
|
379
|
+
function resolveMode(normalMode, epoch) {
|
|
380
|
+
if (epoch === undefined || normalMode === 'OFF') {
|
|
381
|
+
return normalMode;
|
|
382
|
+
}
|
|
383
|
+
const nowSeconds = Date.now() / 1000;
|
|
384
|
+
if (nowSeconds < epoch) {
|
|
385
|
+
const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];
|
|
386
|
+
console.log(`\n⏭️ Skipping require-return-type validation (ignoreModifiedUntilEpoch active, expires: ${expiresDate})`);
|
|
387
|
+
console.log('');
|
|
388
|
+
return 'OFF';
|
|
389
|
+
}
|
|
390
|
+
const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];
|
|
391
|
+
console.log(`\n⚠️ requireReturnType.ignoreModifiedUntilEpoch (${epoch}) has expired (${expiresDate}). Remove it from nx.json. Using normal mode: ${normalMode}\n`);
|
|
392
|
+
return normalMode;
|
|
393
|
+
}
|
|
375
394
|
async function runExecutor(options, context) {
|
|
376
395
|
const workspaceRoot = context.root;
|
|
377
|
-
const mode = options.mode ?? 'NEW_METHODS';
|
|
396
|
+
const mode = resolveMode(options.mode ?? 'NEW_METHODS', options.ignoreModifiedUntilEpoch);
|
|
397
|
+
const disableAllowed = options.disableAllowed ?? true;
|
|
378
398
|
if (mode === 'OFF') {
|
|
379
399
|
console.log('\n⏭️ Skipping return type validation (mode: OFF)');
|
|
380
400
|
console.log('');
|
|
@@ -403,13 +423,13 @@ async function runExecutor(options, context) {
|
|
|
403
423
|
console.log(`📂 Checking ${changedFiles.length} changed file(s)...`);
|
|
404
424
|
let violations = [];
|
|
405
425
|
if (mode === 'NEW_METHODS') {
|
|
406
|
-
violations = findViolationsForNewMethods(workspaceRoot, changedFiles, base, head);
|
|
426
|
+
violations = findViolationsForNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed);
|
|
407
427
|
}
|
|
408
428
|
else if (mode === 'MODIFIED_AND_NEW_METHODS') {
|
|
409
|
-
violations = findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, base, head);
|
|
429
|
+
violations = findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed);
|
|
410
430
|
}
|
|
411
431
|
else if (mode === 'MODIFIED_FILES') {
|
|
412
|
-
violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles);
|
|
432
|
+
violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);
|
|
413
433
|
}
|
|
414
434
|
if (violations.length === 0) {
|
|
415
435
|
console.log('✅ All methods have explicit return types');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/architecture/executors/validate-return-types/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAuaH,8BA4DC;;AAheD,iDAAyC;AACzC,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AAkBjC;;GAEG;AACH,oHAAoH;AACpH,SAAS,yBAAyB,CAAC,aAAqB,EAAE,IAAY,EAAE,IAAa;IACjF,IAAI,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACnD,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,wBAAwB,UAAU,oBAAoB,EAAE;YAC5E,GAAG,EAAE,aAAa;YAClB,QAAQ,EAAE,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AC,GAAG,CAAC,eAAe,YAAY,CAAC,MAAM,qBAAqB,CAAC,CAAC;IAErE,IAAI,UAAU,GAAsB,EAAE,CAAC;IAEvC,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;QACzB,UAAU,GAAG,2BAA2B,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACtF,CAAC;SAAM,IAAI,IAAI,KAAK,0BAA0B,EAAE,CAAC;QAC7C,UAAU,GAAG,sCAAsC,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACjG,CAAC;SAAM,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACnC,UAAU,GAAG,8BAA8B,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;QACxD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAEnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * Validate Return Types Executor\n *\n * Validates that methods have explicit return type annotations for better code readability.\n * Instead of relying on TypeScript's type inference, explicit return types make code clearer:\n *\n * BAD: method() { return new MyClass(); }\n * GOOD: method(): MyClass { return new MyClass(); }\n * GOOD: async method(): Promise<MyType> { ... }\n *\n * Modes:\n * - OFF: Skip validation entirely\n * - NEW_METHODS: Only validate new methods (detected via git diff)\n * - MODIFIED_AND_NEW_METHODS: Validate new methods + methods with changes in their line range\n * - MODIFIED_FILES: Validate all methods in modified files\n *\n * Escape hatch: Add webpieces-disable require-return-type comment with justification\n */\n\nimport type { ExecutorContext } from '@nx/devkit';\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\n\nexport type ReturnTypeMode = 'OFF' | 'NEW_METHODS' | 'MODIFIED_AND_NEW_METHODS' | 'MODIFIED_FILES';\n\nexport interface ValidateReturnTypesOptions {\n mode?: ReturnTypeMode;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\ninterface MethodViolation {\n file: string;\n methodName: string;\n line: number;\n}\n\n/**\n * Get changed TypeScript files between base and head (or working tree if head not specified).\n */\n// webpieces-disable max-lines-new-methods -- Git command handling with untracked files requires multiple code paths\nfunction getChangedTypeScriptFiles(workspaceRoot: string, base: string, head?: string): string[] {\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const output = execSync(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const changedFiles = output\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n\n if (!head) {\n try {\n const untrackedOutput = execSync(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const untrackedFiles = untrackedOutput\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n const allFiles = new Set([...changedFiles, ...untrackedFiles]);\n return Array.from(allFiles);\n } catch {\n return changedFiles;\n }\n }\n\n return changedFiles;\n } catch {\n return [];\n }\n}\n\n/**\n * Get the diff content for a specific file.\n */\nfunction getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const diff = execSync(`git diff ${diffTarget} -- \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n\n if (!diff && !head) {\n const fullPath = path.join(workspaceRoot, file);\n if (fs.existsSync(fullPath)) {\n const isUntracked = execSync(`git ls-files --others --exclude-standard \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n }).trim();\n\n if (isUntracked) {\n const content = fs.readFileSync(fullPath, 'utf-8');\n const lines = content.split('\\n');\n return lines.map((line) => `+${line}`).join('\\n');\n }\n }\n }\n\n return diff;\n } catch {\n return '';\n }\n}\n\n/**\n * Parse diff to find newly added method signatures.\n */\nfunction findNewMethodSignaturesInDiff(diffContent: string): Set<string> {\n const newMethods = new Set<string>();\n const lines = diffContent.split('\\n');\n\n const patterns = [\n /^\\+\\s*(?:export\\s+)?(?:async\\s+)?function\\s+(\\w+)\\s*\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s*)?\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s+)?function/,\n /^\\+\\s*(?:(?:public|private|protected)\\s+)?(?:static\\s+)?(?:async\\s+)?(\\w+)\\s*\\(/,\n ];\n\n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n for (const pattern of patterns) {\n const match = line.match(pattern);\n if (match) {\n const methodName = match[1];\n if (methodName && !['if', 'for', 'while', 'switch', 'catch', 'constructor'].includes(methodName)) {\n newMethods.add(methodName);\n }\n break;\n }\n }\n }\n }\n\n return newMethods;\n}\n\n/**\n * Check if a line contains a webpieces-disable comment for return type.\n */\nfunction hasDisableComment(lines: string[], lineNumber: number): boolean {\n const startCheck = Math.max(0, lineNumber - 5);\n for (let i = lineNumber - 2; i >= startCheck; i--) {\n const line = lines[i]?.trim() ?? '';\n if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {\n break;\n }\n if (line.includes('webpieces-disable') && line.includes('require-return-type')) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if a method has an explicit return type annotation.\n */\nfunction hasExplicitReturnType(node: ts.MethodDeclaration | ts.FunctionDeclaration | ts.ArrowFunction): boolean {\n return node.type !== undefined;\n}\n\ninterface MethodInfo {\n name: string;\n line: number;\n endLine: number;\n hasReturnType: boolean;\n hasDisableComment: boolean;\n}\n\n/**\n * Parse a TypeScript file and find methods with their return type status.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal requires inline visitor function\nfunction findMethodsInFile(filePath: string, workspaceRoot: string): MethodInfo[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const fileLines = content.split('\\n');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n\n const methods: MethodInfo[] = [];\n\n // webpieces-disable max-lines-new-methods -- AST visitor pattern requires handling multiple node types\n function visit(node: ts.Node): void {\n let methodName: string | undefined;\n let startLine: number | undefined;\n let endLine: number | undefined;\n let hasReturnType = false;\n\n if (ts.isMethodDeclaration(node) && node.name) {\n methodName = node.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n hasReturnType = hasExplicitReturnType(node);\n } else if (ts.isFunctionDeclaration(node) && node.name) {\n methodName = node.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n hasReturnType = hasExplicitReturnType(node);\n } else if (ts.isArrowFunction(node)) {\n if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) {\n methodName = node.parent.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n hasReturnType = hasExplicitReturnType(node);\n }\n }\n\n if (methodName && startLine !== undefined && endLine !== undefined) {\n methods.push({\n name: methodName,\n line: startLine,\n endLine,\n hasReturnType,\n hasDisableComment: hasDisableComment(fileLines, startLine),\n });\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return methods;\n}\n\n/**\n * Parse diff to extract changed line numbers (both additions and modifications).\n */\nfunction getChangedLineNumbers(diffContent: string): Set<number> {\n const changedLines = new Set<number>();\n const lines = diffContent.split('\\n');\n let currentLine = 0;\n\n for (const line of lines) {\n const hunkMatch = line.match(/^@@ -\\d+(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/);\n if (hunkMatch) {\n currentLine = parseInt(hunkMatch[1], 10);\n continue;\n }\n\n if (line.startsWith('+') && !line.startsWith('+++')) {\n changedLines.add(currentLine);\n currentLine++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n // Deletions don't increment line number\n } else {\n currentLine++;\n }\n }\n\n return changedLines;\n}\n\n/**\n * Check if a method has any changed lines within its range.\n */\nfunction methodHasChanges(method: MethodInfo, changedLines: Set<number>): boolean {\n for (let line = method.line; line <= method.endLine; line++) {\n if (changedLines.has(line)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Find NEW methods without explicit return types (NEW_METHODS mode).\n */\n// webpieces-disable max-lines-new-methods -- File iteration with diff parsing and method matching\nfunction findViolationsForNewMethods(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head?: string\n): MethodViolation[] {\n const violations: MethodViolation[] = [];\n\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const newMethodNames = findNewMethodSignaturesInDiff(diff);\n\n if (newMethodNames.size === 0) continue;\n\n const methods = findMethodsInFile(file, workspaceRoot);\n\n for (const method of methods) {\n if (!newMethodNames.has(method.name)) continue;\n if (method.hasReturnType) continue;\n if (method.hasDisableComment) continue;\n\n violations.push({\n file,\n methodName: method.name,\n line: method.line,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Find NEW methods AND methods with changes (MODIFIED_AND_NEW_METHODS mode).\n */\n// webpieces-disable max-lines-new-methods -- Combines new method detection with change detection\nfunction findViolationsForModifiedAndNewMethods(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head?: string\n): MethodViolation[] {\n const violations: MethodViolation[] = [];\n\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const newMethodNames = findNewMethodSignaturesInDiff(diff);\n const changedLines = getChangedLineNumbers(diff);\n\n const methods = findMethodsInFile(file, workspaceRoot);\n\n for (const method of methods) {\n if (method.hasReturnType) continue;\n if (method.hasDisableComment) continue;\n\n const isNewMethod = newMethodNames.has(method.name);\n const isModifiedMethod = methodHasChanges(method, changedLines);\n\n if (!isNewMethod && !isModifiedMethod) continue;\n\n violations.push({\n file,\n methodName: method.name,\n line: method.line,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Find all methods without explicit return types in modified files (MODIFIED_FILES mode).\n */\nfunction findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[]): MethodViolation[] {\n const violations: MethodViolation[] = [];\n\n for (const file of changedFiles) {\n const methods = findMethodsInFile(file, workspaceRoot);\n\n for (const method of methods) {\n if (method.hasReturnType) continue;\n if (method.hasDisableComment) continue;\n\n violations.push({\n file,\n methodName: method.name,\n line: method.line,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Auto-detect the base branch by finding the merge-base with origin/main.\n */\nfunction detectBase(workspaceRoot: string): string | null {\n try {\n const mergeBase = execSync('git merge-base HEAD origin/main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n try {\n const mergeBase = execSync('git merge-base HEAD main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n // Ignore\n }\n }\n return null;\n}\n\n/**\n * Report violations to console.\n */\nfunction reportViolations(violations: MethodViolation[], mode: ReturnTypeMode): void {\n console.error('');\n console.error('❌ Methods missing explicit return types!');\n console.error('');\n console.error('📚 Explicit return types improve code readability:');\n console.error('');\n console.error(' BAD: method() { return new MyClass(); }');\n console.error(' GOOD: method(): MyClass { return new MyClass(); }');\n console.error(' GOOD: async method(): Promise<MyType> { ... }');\n console.error('');\n\n for (const v of violations) {\n console.error(` ❌ ${v.file}:${v.line}`);\n console.error(` Method: ${v.methodName} - missing return type annotation`);\n }\n console.error('');\n\n console.error(' To fix: Add explicit return type after the parameter list');\n console.error('');\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable require-return-type -- [your reason]');\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\nexport default async function runExecutor(\n options: ValidateReturnTypesOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const workspaceRoot = context.root;\n const mode: ReturnTypeMode = options.mode ?? 'NEW_METHODS';\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping return type validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n console.log('\\n📏 Validating Return Types\\n');\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n\n if (!base) {\n console.log('\\n⏭️ Skipping return type validation (could not detect base branch)');\n console.log('');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log('');\n\n const changedFiles = getChangedTypeScriptFiles(workspaceRoot, base, head);\n\n if (changedFiles.length === 0) {\n console.log('✅ No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`📂 Checking ${changedFiles.length} changed file(s)...`);\n\n let violations: MethodViolation[] = [];\n\n if (mode === 'NEW_METHODS') {\n violations = findViolationsForNewMethods(workspaceRoot, changedFiles, base, head);\n } else if (mode === 'MODIFIED_AND_NEW_METHODS') {\n violations = findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, base, head);\n } else if (mode === 'MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles);\n }\n\n if (violations.length === 0) {\n console.log('✅ All methods have explicit return types');\n return { success: true };\n }\n\n reportViolations(violations, mode);\n\n return { success: false };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/architecture/executors/validate-return-types/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AA+bH,8BA6DC;;AAzfD,iDAAyC;AACzC,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AAoBjC;;GAEG;AACH,oHAAoH;AACpH,SAAS,yBAAyB,CAAC,aAAqB,EAAE,IAAY,EAAE,IAAa;IACjF,IAAI,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACnD,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,wBAAwB,UAAU,oBAAoB,EAAE;YAC5E,GAAG,EAAE,aAAa;YAClB,QAAQ,EAAE,OAAO;SACpB,CAAC,CAAC;QACH,MAAM,YAAY,GAAG,MAAM;aACtB,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;aACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QAE5E,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,IAAI,CAAC;gBACD,MAAM,eAAe,GAAG,IAAA,wBAAQ,EAAC,yDAAyD,EAAE;oBACxF,GAAG,EAAE,aAAa;oBAClB,QAAQ,EAAE,OAAO;iBACpB,CAAC,CAAC;gBACH,MAAM,cAAc,GAAG,eAAe;qBACjC,IAAI,EAAE;qBACN,KAAK,CAAC,IAAI,CAAC;qBACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CA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Y,IAAI,IAAI,6CAA6C,EAAE,CAAC,CAAC;IACjF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEhB,MAAM,YAAY,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAE1E,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;QAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,eAAe,YAAY,CAAC,MAAM,qBAAqB,CAAC,CAAC;IAErE,IAAI,UAAU,GAAsB,EAAE,CAAC;IAEvC,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;QACzB,UAAU,GAAG,2BAA2B,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACtG,CAAC;SAAM,IAAI,IAAI,KAAK,0BAA0B,EAAE,CAAC;QAC7C,UAAU,GAAG,sCAAsC,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACjH,CAAC;SAAM,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACnC,UAAU,GAAG,8BAA8B,CAAC,aAAa,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;IAC7F,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;QACxD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAEnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * Validate Return Types Executor\n *\n * Validates that methods have explicit return type annotations for better code readability.\n * Instead of relying on TypeScript's type inference, explicit return types make code clearer:\n *\n * BAD: method() { return new MyClass(); }\n * GOOD: method(): MyClass { return new MyClass(); }\n * GOOD: async method(): Promise<MyType> { ... }\n *\n * Modes:\n * - OFF: Skip validation entirely\n * - NEW_METHODS: Only validate new methods (detected via git diff)\n * - MODIFIED_AND_NEW_METHODS: Validate new methods + methods with changes in their line range\n * - MODIFIED_FILES: Validate all methods in modified files\n *\n * Escape hatch: Add webpieces-disable require-return-type comment with justification\n */\n\nimport type { ExecutorContext } from '@nx/devkit';\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\n\nexport type ReturnTypeMode = 'OFF' | 'NEW_METHODS' | 'MODIFIED_AND_NEW_METHODS' | 'MODIFIED_FILES';\n\nexport interface ValidateReturnTypesOptions {\n mode?: ReturnTypeMode;\n disableAllowed?: boolean;\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\ninterface MethodViolation {\n file: string;\n methodName: string;\n line: number;\n}\n\n/**\n * Get changed TypeScript files between base and head (or working tree if head not specified).\n */\n// webpieces-disable max-lines-new-methods -- Git command handling with untracked files requires multiple code paths\nfunction getChangedTypeScriptFiles(workspaceRoot: string, base: string, head?: string): string[] {\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const output = execSync(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const changedFiles = output\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n\n if (!head) {\n try {\n const untrackedOutput = execSync(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const untrackedFiles = untrackedOutput\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n const allFiles = new Set([...changedFiles, ...untrackedFiles]);\n return Array.from(allFiles);\n } catch {\n return changedFiles;\n }\n }\n\n return changedFiles;\n } catch {\n return [];\n }\n}\n\n/**\n * Get the diff content for a specific file.\n */\nfunction getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const diff = execSync(`git diff ${diffTarget} -- \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n\n if (!diff && !head) {\n const fullPath = path.join(workspaceRoot, file);\n if (fs.existsSync(fullPath)) {\n const isUntracked = execSync(`git ls-files --others --exclude-standard \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n }).trim();\n\n if (isUntracked) {\n const content = fs.readFileSync(fullPath, 'utf-8');\n const lines = content.split('\\n');\n return lines.map((line) => `+${line}`).join('\\n');\n }\n }\n }\n\n return diff;\n } catch {\n return '';\n }\n}\n\n/**\n * Parse diff to find newly added method signatures.\n */\nfunction findNewMethodSignaturesInDiff(diffContent: string): Set<string> {\n const newMethods = new Set<string>();\n const lines = diffContent.split('\\n');\n\n const patterns = [\n /^\\+\\s*(?:export\\s+)?(?:async\\s+)?function\\s+(\\w+)\\s*\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s*)?\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s+)?function/,\n /^\\+\\s*(?:(?:public|private|protected)\\s+)?(?:static\\s+)?(?:async\\s+)?(\\w+)\\s*\\(/,\n ];\n\n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n for (const pattern of patterns) {\n const match = line.match(pattern);\n if (match) {\n const methodName = match[1];\n if (methodName && !['if', 'for', 'while', 'switch', 'catch', 'constructor'].includes(methodName)) {\n newMethods.add(methodName);\n }\n break;\n }\n }\n }\n }\n\n return newMethods;\n}\n\n/**\n * Check if a line contains a webpieces-disable comment for return type.\n */\nfunction hasDisableComment(lines: string[], lineNumber: number): boolean {\n const startCheck = Math.max(0, lineNumber - 5);\n for (let i = lineNumber - 2; i >= startCheck; i--) {\n const line = lines[i]?.trim() ?? '';\n if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {\n break;\n }\n if (line.includes('webpieces-disable') && line.includes('require-return-type')) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if a method has an explicit return type annotation.\n */\nfunction hasExplicitReturnType(node: ts.MethodDeclaration | ts.FunctionDeclaration | ts.ArrowFunction): boolean {\n return node.type !== undefined;\n}\n\ninterface MethodInfo {\n name: string;\n line: number;\n endLine: number;\n hasReturnType: boolean;\n hasDisableComment: boolean;\n}\n\n/**\n * Parse a TypeScript file and find methods with their return type status.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal requires inline visitor function\nfunction findMethodsInFile(filePath: string, workspaceRoot: string): MethodInfo[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const fileLines = content.split('\\n');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n\n const methods: MethodInfo[] = [];\n\n // webpieces-disable max-lines-new-methods -- AST visitor pattern requires handling multiple node types\n function visit(node: ts.Node): void {\n let methodName: string | undefined;\n let startLine: number | undefined;\n let endLine: number | undefined;\n let hasReturnType = false;\n\n if (ts.isMethodDeclaration(node) && node.name) {\n methodName = node.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n hasReturnType = hasExplicitReturnType(node);\n } else if (ts.isFunctionDeclaration(node) && node.name) {\n methodName = node.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n hasReturnType = hasExplicitReturnType(node);\n } else if (ts.isArrowFunction(node)) {\n if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) {\n methodName = node.parent.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n hasReturnType = hasExplicitReturnType(node);\n }\n }\n\n if (methodName && startLine !== undefined && endLine !== undefined) {\n methods.push({\n name: methodName,\n line: startLine,\n endLine,\n hasReturnType,\n hasDisableComment: hasDisableComment(fileLines, startLine),\n });\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return methods;\n}\n\n/**\n * Parse diff to extract changed line numbers (both additions and modifications).\n */\nfunction getChangedLineNumbers(diffContent: string): Set<number> {\n const changedLines = new Set<number>();\n const lines = diffContent.split('\\n');\n let currentLine = 0;\n\n for (const line of lines) {\n const hunkMatch = line.match(/^@@ -\\d+(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/);\n if (hunkMatch) {\n currentLine = parseInt(hunkMatch[1], 10);\n continue;\n }\n\n if (line.startsWith('+') && !line.startsWith('+++')) {\n changedLines.add(currentLine);\n currentLine++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n // Deletions don't increment line number\n } else {\n currentLine++;\n }\n }\n\n return changedLines;\n}\n\n/**\n * Check if a method has any changed lines within its range.\n */\nfunction methodHasChanges(method: MethodInfo, changedLines: Set<number>): boolean {\n for (let line = method.line; line <= method.endLine; line++) {\n if (changedLines.has(line)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Find NEW methods without explicit return types (NEW_METHODS mode).\n */\n// webpieces-disable max-lines-new-methods -- File iteration with diff parsing and method matching\nfunction findViolationsForNewMethods(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head: string | undefined,\n disableAllowed: boolean\n): MethodViolation[] {\n const violations: MethodViolation[] = [];\n\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const newMethodNames = findNewMethodSignaturesInDiff(diff);\n\n if (newMethodNames.size === 0) continue;\n\n const methods = findMethodsInFile(file, workspaceRoot);\n\n for (const method of methods) {\n if (!newMethodNames.has(method.name)) continue;\n if (method.hasReturnType) continue;\n if (disableAllowed && method.hasDisableComment) continue;\n\n violations.push({\n file,\n methodName: method.name,\n line: method.line,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Find NEW methods AND methods with changes (MODIFIED_AND_NEW_METHODS mode).\n */\n// webpieces-disable max-lines-new-methods -- Combines new method detection with change detection\nfunction findViolationsForModifiedAndNewMethods(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head: string | undefined,\n disableAllowed: boolean\n): MethodViolation[] {\n const violations: MethodViolation[] = [];\n\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const newMethodNames = findNewMethodSignaturesInDiff(diff);\n const changedLines = getChangedLineNumbers(diff);\n\n const methods = findMethodsInFile(file, workspaceRoot);\n\n for (const method of methods) {\n if (method.hasReturnType) continue;\n if (disableAllowed && method.hasDisableComment) continue;\n\n const isNewMethod = newMethodNames.has(method.name);\n const isModifiedMethod = methodHasChanges(method, changedLines);\n\n if (!isNewMethod && !isModifiedMethod) continue;\n\n violations.push({\n file,\n methodName: method.name,\n line: method.line,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Find all methods without explicit return types in modified files (MODIFIED_FILES mode).\n */\nfunction findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[], disableAllowed: boolean): MethodViolation[] {\n const violations: MethodViolation[] = [];\n\n for (const file of changedFiles) {\n const methods = findMethodsInFile(file, workspaceRoot);\n\n for (const method of methods) {\n if (method.hasReturnType) continue;\n if (disableAllowed && method.hasDisableComment) continue;\n\n violations.push({\n file,\n methodName: method.name,\n line: method.line,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Auto-detect the base branch by finding the merge-base with origin/main.\n */\nfunction detectBase(workspaceRoot: string): string | null {\n try {\n const mergeBase = execSync('git merge-base HEAD origin/main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n try {\n const mergeBase = execSync('git merge-base HEAD main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n // Ignore\n }\n }\n return null;\n}\n\n/**\n * Report violations to console.\n */\nfunction reportViolations(violations: MethodViolation[], mode: ReturnTypeMode): void {\n console.error('');\n console.error('❌ Methods missing explicit return types!');\n console.error('');\n console.error('📚 Explicit return types improve code readability:');\n console.error('');\n console.error(' BAD: method() { return new MyClass(); }');\n console.error(' GOOD: method(): MyClass { return new MyClass(); }');\n console.error(' GOOD: async method(): Promise<MyType> { ... }');\n console.error('');\n\n for (const v of violations) {\n console.error(` ❌ ${v.file}:${v.line}`);\n console.error(` Method: ${v.methodName} - missing return type annotation`);\n }\n console.error('');\n\n console.error(' To fix: Add explicit return type after the parameter list');\n console.error('');\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable require-return-type -- [your reason]');\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\n/**\n * Resolve mode considering ignoreModifiedUntilEpoch override.\n * When active, downgrades to OFF. When expired, logs a warning.\n */\nfunction resolveMode(normalMode: ReturnTypeMode, epoch: number | undefined): ReturnTypeMode {\n if (epoch === undefined || normalMode === 'OFF') {\n return normalMode;\n }\n const nowSeconds = Date.now() / 1000;\n if (nowSeconds < epoch) {\n const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];\n console.log(`\\n⏭️ Skipping require-return-type validation (ignoreModifiedUntilEpoch active, expires: ${expiresDate})`);\n console.log('');\n return 'OFF';\n }\n const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];\n console.log(`\\n⚠️ requireReturnType.ignoreModifiedUntilEpoch (${epoch}) has expired (${expiresDate}). Remove it from nx.json. Using normal mode: ${normalMode}\\n`);\n return normalMode;\n}\n\nexport default async function runExecutor(\n options: ValidateReturnTypesOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const workspaceRoot = context.root;\n const mode: ReturnTypeMode = resolveMode(options.mode ?? 'NEW_METHODS', options.ignoreModifiedUntilEpoch);\n const disableAllowed = options.disableAllowed ?? true;\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping return type validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n console.log('\\n📏 Validating Return Types\\n');\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n\n if (!base) {\n console.log('\\n⏭️ Skipping return type validation (could not detect base branch)');\n console.log('');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log('');\n\n const changedFiles = getChangedTypeScriptFiles(workspaceRoot, base, head);\n\n if (changedFiles.length === 0) {\n console.log('✅ No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`📂 Checking ${changedFiles.length} changed file(s)...`);\n\n let violations: MethodViolation[] = [];\n\n if (mode === 'NEW_METHODS') {\n violations = findViolationsForNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed);\n } else if (mode === 'MODIFIED_AND_NEW_METHODS') {\n violations = findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed);\n } else if (mode === 'MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);\n }\n\n if (violations.length === 0) {\n console.log('✅ All methods have explicit return types');\n return { success: true };\n }\n\n reportViolations(violations, mode);\n\n return { success: false };\n}\n"]}
|