@next-vibe/checker 1.0.11 → 1.0.12
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/.dist/bin/vibe-runtime.js +10 -19
- package/.dist/bin/vibe-runtime.js.map +3 -3
- package/check.config.ts +4 -4
- package/package.json +2 -9
- package/src/app/api/[locale]/LICENSE +674 -0
- package/src/app/api/[locale]/i18n/de/index.ts +13 -0
- package/src/app/api/[locale]/i18n/en/index.ts +12 -0
- package/src/app/api/[locale]/i18n/pl/index.ts +11 -0
- package/src/app/api/[locale]/shared/i18n/de/index.ts +85 -0
- package/src/app/api/[locale]/shared/i18n/en/index.ts +83 -0
- package/src/app/api/[locale]/shared/i18n/pl/index.ts +85 -0
- package/src/app/api/[locale]/shared/stats-filtering.ts +202 -0
- package/src/app/api/[locale]/shared/types/common.schema.ts +55 -0
- package/src/app/api/[locale]/shared/types/response.schema.ts +372 -0
- package/src/app/api/[locale]/shared/types/stats-filtering.schema.ts +375 -0
- package/src/app/api/[locale]/shared/types/utils.ts +190 -0
- package/src/app/api/[locale]/shared/utils/base64.ts +49 -0
- package/src/app/api/[locale]/shared/utils/env-util.ts +40 -0
- package/src/app/api/[locale]/shared/utils/i18n/de/index.ts +21 -0
- package/src/app/api/[locale]/shared/utils/i18n/en/index.ts +19 -0
- package/src/app/api/[locale]/shared/utils/i18n/pl/index.ts +21 -0
- package/src/app/api/[locale]/shared/utils/index.ts +11 -0
- package/src/app/api/[locale]/shared/utils/object-path.ts +41 -0
- package/src/app/api/[locale]/shared/utils/object.test.ts +82 -0
- package/src/app/api/[locale]/shared/utils/object.ts +75 -0
- package/src/app/api/[locale]/shared/utils/parse-error.ts +134 -0
- package/src/app/api/[locale]/shared/utils/parse-json.ts +70 -0
- package/src/app/api/[locale]/shared/utils/time.ts +53 -0
- package/src/app/api/[locale]/shared/utils/validation.ts +127 -0
- package/src/app/api/[locale]/shared/utils/zod-required-fields.ts +116 -0
- package/src/app/api/[locale]/system/builder/definition.ts +1942 -0
- package/src/app/api/[locale]/system/builder/enum.ts +77 -0
- package/src/app/api/[locale]/system/builder/i18n/de/index.ts +677 -0
- package/src/app/api/[locale]/system/builder/i18n/en/index.ts +665 -0
- package/src/app/api/[locale]/system/builder/i18n/pl/index.ts +668 -0
- package/src/app/api/[locale]/system/builder/repository/build-executor.test.ts +182 -0
- package/src/app/api/[locale]/system/builder/repository/build-executor.ts +583 -0
- package/src/app/api/[locale]/system/builder/repository/bun-compiler.ts +261 -0
- package/src/app/api/[locale]/system/builder/repository/bundle-analyzer.ts +197 -0
- package/src/app/api/[locale]/system/builder/repository/config-loader.ts +159 -0
- package/src/app/api/[locale]/system/builder/repository/config-validator.ts +97 -0
- package/src/app/api/[locale]/system/builder/repository/constants.ts +125 -0
- package/src/app/api/[locale]/system/builder/repository/error-suggester.ts +75 -0
- package/src/app/api/[locale]/system/builder/repository/file-copier.ts +98 -0
- package/src/app/api/[locale]/system/builder/repository/folder-cleaner.ts +80 -0
- package/src/app/api/[locale]/system/builder/repository/index.ts +2 -0
- package/src/app/api/[locale]/system/builder/repository/npm-package-generator.ts +146 -0
- package/src/app/api/[locale]/system/builder/repository/output-formatter.ts +104 -0
- package/src/app/api/[locale]/system/builder/repository/profile-service.ts +79 -0
- package/src/app/api/[locale]/system/builder/repository/report-generator.ts +125 -0
- package/src/app/api/[locale]/system/builder/repository/vite-compiler.ts +291 -0
- package/src/app/api/[locale]/system/builder/route.ts +21 -0
- package/src/app/api/[locale]/system/builder/test-files/file1.ts +2 -0
- package/src/app/api/[locale]/system/builder/test-files/file2.tsx +10 -0
- package/src/app/api/[locale]/system/builder/test-files/file3.tsx +16 -0
- package/src/app/api/[locale]/system/builder/test-files/folderToCopy/fileInFolder.ts +2 -0
- package/src/app/api/[locale]/system/builder/test-files/test-config.ts +38 -0
- package/src/app/api/[locale]/system/builder/test-files/test-delete-config.ts +8 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/package.json +24 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/src/constants.ts +6 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/src/greet.ts +18 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/src/index.ts +7 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/src/utils/calculate.ts +27 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/tsconfig.json +19 -0
- package/src/app/api/[locale]/system/builder/test-files/test-project/tsconfig.tsbuildinfo +1 -0
- package/src/app/api/[locale]/system/builder/test-files/test3.css +1 -0
- package/src/app/api/[locale]/system/check/config/repository.ts +819 -0
- package/src/app/api/[locale]/system/check/config/shared.ts +396 -0
- package/src/app/api/[locale]/system/check/config/types.ts +616 -0
- package/src/app/api/[locale]/system/check/config/utils.ts +171 -0
- package/src/app/api/[locale]/system/check/i18n/de/index.ts +15 -0
- package/src/app/api/[locale]/system/check/i18n/en/index.ts +14 -0
- package/src/app/api/[locale]/system/check/i18n/pl/index.ts +15 -0
- package/src/app/api/[locale]/system/check/lint/definition.ts +414 -0
- package/src/app/api/[locale]/system/check/lint/enum.ts +37 -0
- package/src/app/api/[locale]/system/check/lint/i18n/de/index.ts +164 -0
- package/src/app/api/[locale]/system/check/lint/i18n/en/index.ts +162 -0
- package/src/app/api/[locale]/system/check/lint/i18n/pl/index.ts +164 -0
- package/src/app/api/[locale]/system/check/lint/repository.ts +753 -0
- package/src/app/api/[locale]/system/check/lint/route.ts +21 -0
- package/src/app/api/[locale]/system/check/oxlint/README.md +190 -0
- package/src/app/api/[locale]/system/check/oxlint/definition.ts +414 -0
- package/src/app/api/[locale]/system/check/oxlint/enum.ts +37 -0
- package/src/app/api/[locale]/system/check/oxlint/i18n/de/index.ts +171 -0
- package/src/app/api/[locale]/system/check/oxlint/i18n/en/index.ts +168 -0
- package/src/app/api/[locale]/system/check/oxlint/i18n/pl/index.ts +172 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/i18n/src/index.ts +372 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/jsx-capitalization/README.md +246 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/jsx-capitalization/src/index.ts +583 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/restricted-syntax/src/index.ts +500 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/restricted-syntax/test.tsx +74 -0
- package/src/app/api/[locale]/system/check/oxlint/plugins/shared/config-loader.ts +305 -0
- package/src/app/api/[locale]/system/check/oxlint/repository.ts +959 -0
- package/src/app/api/[locale]/system/check/oxlint/route.ts +21 -0
- package/src/app/api/[locale]/system/check/oxlint/types.ts +193 -0
- package/src/app/api/[locale]/system/check/test-project/bun.lock +449 -0
- package/src/app/api/[locale]/system/check/test-project/check.config.ts +989 -0
- package/src/app/api/[locale]/system/check/test-project/package.json +20 -0
- package/src/app/api/[locale]/system/check/test-project/src/constants.ts +6 -0
- package/src/app/api/[locale]/system/check/test-project/src/greet.ts +18 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/a11y-issues.tsx +107 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/eslint-issues.tsx +37 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/general-issues.ts +137 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/i18n-issues.tsx +129 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/jsx-capitalization-issues.tsx +131 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/nextjs-issues.tsx +95 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/promise-issues.ts +76 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/react-issues.tsx +95 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/restricted-syntax-issues.tsx +61 -0
- package/src/app/api/[locale]/system/check/test-project/src/test-issues/typescript-issues.ts +80 -0
- package/src/app/api/[locale]/system/check/test-project/src/utils/calculate.ts +27 -0
- package/src/app/api/[locale]/system/check/test-project/tsconfig.json +38 -0
- package/src/app/api/[locale]/system/check/test-project/tsconfig.tsbuildinfo +1 -0
- package/src/app/api/[locale]/system/check/typecheck/definition.ts +369 -0
- package/src/app/api/[locale]/system/check/typecheck/enum.ts +37 -0
- package/src/app/api/[locale]/system/check/typecheck/i18n/de/index.ts +159 -0
- package/src/app/api/[locale]/system/check/typecheck/i18n/en/index.ts +150 -0
- package/src/app/api/[locale]/system/check/typecheck/i18n/pl/index.ts +155 -0
- package/src/app/api/[locale]/system/check/typecheck/repository.ts +919 -0
- package/src/app/api/[locale]/system/check/typecheck/route.ts +22 -0
- package/src/app/api/[locale]/system/check/typecheck/utils.ts +168 -0
- package/src/app/api/[locale]/system/check/vibe-check/definition.ts +568 -0
- package/src/app/api/[locale]/system/check/vibe-check/enum.ts +69 -0
- package/src/app/api/[locale]/system/check/vibe-check/i18n/de/index.ts +192 -0
- package/src/app/api/[locale]/system/check/vibe-check/i18n/en/index.ts +189 -0
- package/src/app/api/[locale]/system/check/vibe-check/i18n/pl/index.ts +192 -0
- package/src/app/api/[locale]/system/check/vibe-check/repository.ts +545 -0
- package/src/app/api/[locale]/system/check/vibe-check/route.test.ts +1142 -0
- package/src/app/api/[locale]/system/check/vibe-check/route.ts +21 -0
- package/src/app/api/[locale]/system/generated/endpoint.ts +313 -0
- package/src/app/api/[locale]/system/generated/endpoints.ts +156 -0
- package/src/app/api/[locale]/system/generated/route-handlers.ts +224 -0
- package/src/app/api/[locale]/system/generators/endpoint/definition.ts +193 -0
- package/src/app/api/[locale]/system/generators/endpoint/i18n/de/index.ts +48 -0
- package/src/app/api/[locale]/system/generators/endpoint/i18n/en/index.ts +48 -0
- package/src/app/api/[locale]/system/generators/endpoint/i18n/pl/index.ts +50 -0
- package/src/app/api/[locale]/system/generators/endpoint/repository.ts +291 -0
- package/src/app/api/[locale]/system/generators/endpoint/route.ts +21 -0
- package/src/app/api/[locale]/system/generators/endpoints/definition.ts +246 -0
- package/src/app/api/[locale]/system/generators/endpoints/i18n/de/index.ts +54 -0
- package/src/app/api/[locale]/system/generators/endpoints/i18n/en/index.ts +52 -0
- package/src/app/api/[locale]/system/generators/endpoints/i18n/pl/index.ts +54 -0
- package/src/app/api/[locale]/system/generators/endpoints/options-repository.ts +463 -0
- package/src/app/api/[locale]/system/generators/endpoints/repository.ts +383 -0
- package/src/app/api/[locale]/system/generators/endpoints/route.ts +18 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/definition.ts +194 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/i18n/de/index.ts +71 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/i18n/en/index.ts +69 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/i18n/pl/index.ts +71 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/repository.ts +294 -0
- package/src/app/api/[locale]/system/generators/endpoints-index/route.ts +18 -0
- package/src/app/api/[locale]/system/generators/generate-all/definition.ts +355 -0
- package/src/app/api/[locale]/system/generators/generate-all/i18n/de/index.ts +96 -0
- package/src/app/api/[locale]/system/generators/generate-all/i18n/en/index.ts +94 -0
- package/src/app/api/[locale]/system/generators/generate-all/i18n/pl/index.ts +96 -0
- package/src/app/api/[locale]/system/generators/generate-all/repository.ts +257 -0
- package/src/app/api/[locale]/system/generators/generate-all/route.ts +20 -0
- package/src/app/api/[locale]/system/generators/i18n/de/index.ts +15 -0
- package/src/app/api/[locale]/system/generators/i18n/en/index.ts +14 -0
- package/src/app/api/[locale]/system/generators/i18n/pl/index.ts +15 -0
- package/src/app/api/[locale]/system/generators/route-handlers/definition.ts +198 -0
- package/src/app/api/[locale]/system/generators/route-handlers/i18n/de/index.ts +48 -0
- package/src/app/api/[locale]/system/generators/route-handlers/i18n/en/index.ts +48 -0
- package/src/app/api/[locale]/system/generators/route-handlers/i18n/pl/index.ts +50 -0
- package/src/app/api/[locale]/system/generators/route-handlers/repository.ts +277 -0
- package/src/app/api/[locale]/system/generators/route-handlers/route.ts +17 -0
- package/src/app/api/[locale]/system/generators/shared/utils.ts +233 -0
- package/src/app/api/[locale]/system/help/definition.ts +445 -0
- package/src/app/api/[locale]/system/help/i18n/de/index.ts +267 -0
- package/src/app/api/[locale]/system/help/i18n/en/index.ts +262 -0
- package/src/app/api/[locale]/system/help/i18n/pl/index.ts +265 -0
- package/src/app/api/[locale]/system/help/interactive/definition.ts +125 -0
- package/src/app/api/[locale]/system/help/interactive/i18n/de/index.ts +22 -0
- package/src/app/api/[locale]/system/help/interactive/i18n/en/index.ts +19 -0
- package/src/app/api/[locale]/system/help/interactive/i18n/pl/index.ts +22 -0
- package/src/app/api/[locale]/system/help/interactive/repository.ts +1025 -0
- package/src/app/api/[locale]/system/help/interactive/route.ts +53 -0
- package/src/app/api/[locale]/system/help/list/definition.ts +372 -0
- package/src/app/api/[locale]/system/help/list/repository.ts +110 -0
- package/src/app/api/[locale]/system/help/list/route.ts +21 -0
- package/src/app/api/[locale]/system/help/repository.ts +212 -0
- package/src/app/api/[locale]/system/help/route.ts +16 -0
- package/src/app/api/[locale]/system/i18n/de/index.ts +68 -0
- package/src/app/api/[locale]/system/i18n/en/index.ts +65 -0
- package/src/app/api/[locale]/system/i18n/pl/index.ts +66 -0
- package/src/app/api/[locale]/system/release-tool/definition.ts +3104 -0
- package/src/app/api/[locale]/system/release-tool/i18n/de/index.ts +813 -0
- package/src/app/api/[locale]/system/release-tool/i18n/en/index.ts +797 -0
- package/src/app/api/[locale]/system/release-tool/i18n/pl/index.ts +810 -0
- package/src/app/api/[locale]/system/release-tool/repository/asset-zipper.ts +128 -0
- package/src/app/api/[locale]/system/release-tool/repository/changelog-generator.ts +212 -0
- package/src/app/api/[locale]/system/release-tool/repository/ci-detector.ts +566 -0
- package/src/app/api/[locale]/system/release-tool/repository/config.ts +113 -0
- package/src/app/api/[locale]/system/release-tool/repository/constants.ts +407 -0
- package/src/app/api/[locale]/system/release-tool/repository/dependency-manager.ts +527 -0
- package/src/app/api/[locale]/system/release-tool/repository/git-service.ts +403 -0
- package/src/app/api/[locale]/system/release-tool/repository/hook-runner.ts +100 -0
- package/src/app/api/[locale]/system/release-tool/repository/index.ts +1 -0
- package/src/app/api/[locale]/system/release-tool/repository/notification-service.ts +638 -0
- package/src/app/api/[locale]/system/release-tool/repository/package-service.ts +169 -0
- package/src/app/api/[locale]/system/release-tool/repository/publisher.ts +253 -0
- package/src/app/api/[locale]/system/release-tool/repository/quality-runner.ts +428 -0
- package/src/app/api/[locale]/system/release-tool/repository/release-creator.ts +293 -0
- package/src/app/api/[locale]/system/release-tool/repository/release-executor.ts +1198 -0
- package/src/app/api/[locale]/system/release-tool/repository/snyk-service.ts +136 -0
- package/src/app/api/[locale]/system/release-tool/repository/utils.ts +642 -0
- package/src/app/api/[locale]/system/release-tool/repository/validation.ts +288 -0
- package/src/app/api/[locale]/system/release-tool/repository/version-service.ts +297 -0
- package/src/app/api/[locale]/system/release-tool/route.ts +21 -0
- package/src/app/api/[locale]/system/unified-interface/README.md +328 -0
- package/src/app/api/[locale]/system/unified-interface/cli/README.md +349 -0
- package/src/app/api/[locale]/system/unified-interface/cli/auth/cli-handler.ts +95 -0
- package/src/app/api/[locale]/system/unified-interface/cli/auth/cli-user.ts +146 -0
- package/src/app/api/[locale]/system/unified-interface/cli/auth/session-file.ts +266 -0
- package/src/app/api/[locale]/system/unified-interface/cli/env.ts +26 -0
- package/src/app/api/[locale]/system/unified-interface/cli/i18n/de/index.ts +157 -0
- package/src/app/api/[locale]/system/unified-interface/cli/i18n/en/index.ts +155 -0
- package/src/app/api/[locale]/system/unified-interface/cli/i18n/pl/index.ts +158 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/debug.ts +595 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/entry-point.ts +129 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/environment.ts +155 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/execution-errors.ts +452 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/parsing.ts +297 -0
- package/src/app/api/[locale]/system/unified-interface/cli/runtime/route-executor.ts +859 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/i18n/de/index.ts +12 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/i18n/en/index.ts +11 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/i18n/pl/index.ts +12 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/definition.ts +262 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/i18n/de/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/i18n/en/index.ts +52 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/i18n/pl/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/repository.ts +421 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/install/route.ts +25 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/definition.ts +181 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/i18n/de/index.ts +61 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/i18n/en/index.ts +59 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/i18n/pl/index.ts +61 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/repository.ts +195 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/status/route.ts +22 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/definition.ts +188 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/i18n/de/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/i18n/en/index.ts +52 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/i18n/pl/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/repository.ts +209 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/uninstall/route.ts +24 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/definition.ts +200 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/i18n/de/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/i18n/en/index.ts +52 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/i18n/pl/index.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/repository.ts +113 -0
- package/src/app/api/[locale]/system/unified-interface/cli/setup/update/route.ts +22 -0
- package/src/app/api/[locale]/system/unified-interface/cli/vibe-runtime.ts +304 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/core/base-renderer.ts +270 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/core/registry.ts +309 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/core/types.ts +126 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/i18n/de/index.ts +67 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/i18n/en/index.ts +65 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/i18n/pl/index.ts +67 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/accordion.ts +74 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/avatar.ts +39 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/badge.ts +54 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/code-output.ts +298 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/code-quality-files.ts +89 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/code-quality-list.ts +298 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/code-quality-summary.ts +96 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/container.ts +186 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/data-card.ts +65 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/data-cards.ts +570 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/data-list.ts +80 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/data-table.ts +385 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/editable-text.ts +99 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/empty-state.ts +55 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/errors.ts +67 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/grouped-list.ts +729 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/link-card.ts +87 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/link-list.ts +112 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/link.ts +59 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/loading.ts +50 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/markdown.ts +131 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/metric.ts +291 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/section.ts +120 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/stats-grid.ts +149 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/tabs.ts +61 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/text.ts +78 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/implementations/title.ts +42 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/renderers/response-renderer.ts +418 -0
- package/src/app/api/[locale]/system/unified-interface/cli/widgets/renderers/schema-handler.ts +534 -0
- package/src/app/api/[locale]/system/unified-interface/i18n/de/index.ts +42 -0
- package/src/app/api/[locale]/system/unified-interface/i18n/en/index.ts +40 -0
- package/src/app/api/[locale]/system/unified-interface/i18n/pl/index.ts +43 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/README.md +114 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/converter.ts +146 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/i18n/de/index.ts +182 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/i18n/en/index.ts +179 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/i18n/pl/index.ts +181 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/registry.ts +343 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/serve/definition.ts +147 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/serve/repository.ts +38 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/serve/route.ts +14 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/server/protocol-handler.ts +309 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/server/server.ts +154 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/server/stdio-transport.ts +193 -0
- package/src/app/api/[locale]/system/unified-interface/mcp/types.ts +246 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/definition/create-form.ts +1510 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/definition/create.ts +581 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/definition/endpoint-to-metadata.ts +52 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/definition/loader.ts +152 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/definitions/registry.ts +265 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/permissions/registry.ts +680 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/route/executor.ts +220 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/route/handler.ts +325 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/route/multi.ts +184 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/route/request-validator.ts +201 -0
- package/src/app/api/[locale]/system/unified-interface/shared/endpoints/route/single.ts +58 -0
- package/src/app/api/[locale]/system/unified-interface/shared/env/define-env-client.ts +49 -0
- package/src/app/api/[locale]/system/unified-interface/shared/env/define-env.ts +47 -0
- package/src/app/api/[locale]/system/unified-interface/shared/env/validation-logger.ts +58 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field/enum.ts +110 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field/specialized.ts +339 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field/utils.test.ts +408 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field/utils.ts +1349 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field-config/endpoint-field-types.ts +107 -0
- package/src/app/api/[locale]/system/unified-interface/shared/field-config/field-config-types.ts +268 -0
- package/src/app/api/[locale]/system/unified-interface/shared/logger/colors.ts +114 -0
- package/src/app/api/[locale]/system/unified-interface/shared/logger/endpoint.ts +169 -0
- package/src/app/api/[locale]/system/unified-interface/shared/logger/file-logger.ts +88 -0
- package/src/app/api/[locale]/system/unified-interface/shared/logger/formatters.ts +177 -0
- package/src/app/api/[locale]/system/unified-interface/shared/server-only/auth/base-auth-handler.ts +82 -0
- package/src/app/api/[locale]/system/unified-interface/shared/server-only/auth/factory.ts +33 -0
- package/src/app/api/[locale]/system/unified-interface/shared/server-only/server-only.ts +4 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/actions.ts +289 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/endpoint.ts +1167 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/enums.ts +382 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/platform.ts +34 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/types.ts +80 -0
- package/src/app/api/[locale]/system/unified-interface/shared/types/ui-config.ts +76 -0
- package/src/app/api/[locale]/system/unified-interface/shared/utils/error-types.ts +27 -0
- package/src/app/api/[locale]/system/unified-interface/shared/utils/path.ts +63 -0
- package/src/app/api/[locale]/system/unified-interface/shared/utils/scanner.ts +241 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/actions.ts +256 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/configs.ts +1158 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/helpers.ts +80 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/accordion.ts +82 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/avatar.ts +75 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/badge.ts +89 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/code-output.ts +302 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/code-quality-list.ts +202 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/container.ts +129 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/data-card.ts +81 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/data-cards.ts +258 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/data-list.ts +123 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/data-table.ts +387 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/editable-text.ts +89 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/empty-state.ts +78 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/errors.ts +93 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/grouped-list.ts +448 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/index.ts +38 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/link-card.ts +130 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/link-list.ts +127 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/link.ts +68 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/loading.ts +81 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/markdown.ts +176 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/metric-card.ts +241 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/section.ts +90 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/stats-grid.ts +71 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/tabs.ts +80 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/text.ts +105 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/logic/title.ts +72 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/types.ts +240 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/utils/field-helpers.ts +137 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/utils/formatting.ts +437 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/utils/url.ts +40 -0
- package/src/app/api/[locale]/system/unified-interface/shared/widgets/utils/widget-helpers.ts +465 -0
- package/src/app/api/[locale]/user/auth/enum.ts +16 -0
- package/src/app/api/[locale]/user/auth/i18n/de/index.ts +227 -0
- package/src/app/api/[locale]/user/auth/i18n/en/index.ts +205 -0
- package/src/app/api/[locale]/user/auth/i18n/pl/index.ts +219 -0
- package/src/app/api/[locale]/user/auth/types.ts +110 -0
- package/src/app/api/[locale]/user/enum.ts +64 -0
- package/src/app/api/[locale]/user/private/i18n/de/index.ts +3 -0
- package/src/app/api/[locale]/user/private/i18n/en/index.ts +1 -0
- package/src/app/api/[locale]/user/private/i18n/pl/index.ts +3 -0
- package/src/app/api/[locale]/user/types.ts +118 -0
- package/src/app/api/[locale]/user/user-roles/enum.ts +112 -0
- package/src/app/api/[locale]/user/user-roles/i18n/de/index.ts +85 -0
- package/src/app/api/[locale]/user/user-roles/i18n/en/index.ts +83 -0
- package/src/app/api/[locale]/user/user-roles/i18n/pl/index.ts +86 -0
- package/src/app/api/[locale]/user/user-roles/types.ts +34 -0
- package/src/app/api/i18n/de/index.ts +6 -0
- package/src/app/api/i18n/en/index.ts +5 -0
- package/src/app/api/i18n/pl/index.ts +5 -0
- package/src/app/i18n/de/index.ts +6 -0
- package/src/app/i18n/en/index.ts +5 -0
- package/src/app/i18n/pl/index.ts +5 -0
|
@@ -0,0 +1,959 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Oxlint Repository (Parallel)
|
|
3
|
+
* Handles parallel oxlint operations using child_process.spawn with resource management
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { existsSync, promises as fs } from "node:fs";
|
|
7
|
+
import { relative, resolve } from "node:path";
|
|
8
|
+
|
|
9
|
+
import type { EndpointLogger } from "@/app/api/[locale]/system/unified-interface/shared/logger/endpoint";
|
|
10
|
+
|
|
11
|
+
import type { ResponseType as ApiResponseType } from "../../../shared/types/response.schema";
|
|
12
|
+
import { success } from "../../../shared/types/response.schema";
|
|
13
|
+
import { parseError } from "../../../shared/utils/parse-error";
|
|
14
|
+
import { ensureConfigReady } from "../config/repository";
|
|
15
|
+
import {
|
|
16
|
+
createWorkerExitCodeMessage,
|
|
17
|
+
createWorkerFailedMessage,
|
|
18
|
+
createWorkerTimeoutMessage,
|
|
19
|
+
discoverFiles,
|
|
20
|
+
distributeFilesAcrossWorkers,
|
|
21
|
+
sortIssuesByLocation,
|
|
22
|
+
} from "../config/shared";
|
|
23
|
+
import type { CheckConfig, PrettierConfig } from "../config/types";
|
|
24
|
+
import { getSystemResources } from "../config/utils";
|
|
25
|
+
import type {
|
|
26
|
+
OxlintIssue,
|
|
27
|
+
OxlintRequestOutput,
|
|
28
|
+
OxlintResponseOutput,
|
|
29
|
+
} from "./definition";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Worker task for parallel processing
|
|
33
|
+
*/
|
|
34
|
+
interface WorkerTask {
|
|
35
|
+
id: number;
|
|
36
|
+
files: string[];
|
|
37
|
+
fix: boolean;
|
|
38
|
+
timeout: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Worker result from parallel processing
|
|
43
|
+
*/
|
|
44
|
+
interface WorkerResult {
|
|
45
|
+
id: number;
|
|
46
|
+
success: boolean;
|
|
47
|
+
issues: Array<{
|
|
48
|
+
file: string;
|
|
49
|
+
line?: number;
|
|
50
|
+
column?: number;
|
|
51
|
+
rule?: string;
|
|
52
|
+
code?: string;
|
|
53
|
+
severity: "error" | "warning" | "info";
|
|
54
|
+
message: string;
|
|
55
|
+
type: "oxlint" | "lint" | "type";
|
|
56
|
+
}>;
|
|
57
|
+
duration: number;
|
|
58
|
+
error?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Run Oxlint Repository Interface
|
|
63
|
+
*/
|
|
64
|
+
export interface OxlintRepositoryInterface {
|
|
65
|
+
execute(
|
|
66
|
+
data: OxlintRequestOutput,
|
|
67
|
+
logger: EndpointLogger,
|
|
68
|
+
): Promise<ApiResponseType<OxlintResponseOutput>>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Run Oxlint Repository Implementation (Parallel)
|
|
73
|
+
*/
|
|
74
|
+
export class OxlintRepositoryImpl implements OxlintRepositoryInterface {
|
|
75
|
+
private config: CheckConfig | null = null;
|
|
76
|
+
|
|
77
|
+
async execute(
|
|
78
|
+
data: OxlintRequestOutput,
|
|
79
|
+
logger: EndpointLogger,
|
|
80
|
+
): Promise<ApiResponseType<OxlintResponseOutput>> {
|
|
81
|
+
try {
|
|
82
|
+
logger.debug("Starting parallel Oxlint execution", {
|
|
83
|
+
path: data.path,
|
|
84
|
+
fix: data.fix,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Use unified config management - checks, creates if needed, and regenerates
|
|
88
|
+
const configResult = await ensureConfigReady(logger, data.createConfig);
|
|
89
|
+
|
|
90
|
+
if (!configResult.ready) {
|
|
91
|
+
return success({
|
|
92
|
+
issues: {
|
|
93
|
+
items: [
|
|
94
|
+
{
|
|
95
|
+
file: configResult.configPath,
|
|
96
|
+
severity: "error" as const,
|
|
97
|
+
message: configResult.message,
|
|
98
|
+
type: "oxlint" as const,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
files: [
|
|
102
|
+
{
|
|
103
|
+
file: configResult.configPath,
|
|
104
|
+
errors: 1,
|
|
105
|
+
warnings: 0,
|
|
106
|
+
total: 1,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
summary: {
|
|
110
|
+
totalIssues: 1,
|
|
111
|
+
totalFiles: 1,
|
|
112
|
+
totalErrors: 1,
|
|
113
|
+
displayedIssues: 1,
|
|
114
|
+
displayedFiles: 1,
|
|
115
|
+
currentPage: 1,
|
|
116
|
+
totalPages: 1,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Config is ready - store it for use in methods
|
|
123
|
+
this.config = configResult.config;
|
|
124
|
+
|
|
125
|
+
// Check if oxlint is enabled
|
|
126
|
+
if (!this.config.oxlint.enabled) {
|
|
127
|
+
logger.info("Oxlint is disabled in check.config.ts");
|
|
128
|
+
return success({
|
|
129
|
+
issues: {
|
|
130
|
+
items: [],
|
|
131
|
+
files: [],
|
|
132
|
+
summary: {
|
|
133
|
+
totalIssues: 0,
|
|
134
|
+
totalFiles: 0,
|
|
135
|
+
totalErrors: 0,
|
|
136
|
+
displayedIssues: 0,
|
|
137
|
+
displayedFiles: 0,
|
|
138
|
+
currentPage: 1,
|
|
139
|
+
totalPages: 1,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Ensure cache directory exists
|
|
146
|
+
const cacheDir = this.config.oxlint.cachePath;
|
|
147
|
+
await fs.mkdir(cacheDir, { recursive: true });
|
|
148
|
+
|
|
149
|
+
// Get system resources and determine optimal worker count
|
|
150
|
+
const resources = getSystemResources();
|
|
151
|
+
logger.debug("System resources detected", {
|
|
152
|
+
cpus: resources.cpuCores,
|
|
153
|
+
memory: resources.availableMemoryMB,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Handle multiple paths
|
|
157
|
+
const targetPaths = data.path
|
|
158
|
+
? Array.isArray(data.path)
|
|
159
|
+
? data.path
|
|
160
|
+
: [data.path]
|
|
161
|
+
: ["./"];
|
|
162
|
+
|
|
163
|
+
logger.debug("Resolving target paths", { targetPaths });
|
|
164
|
+
|
|
165
|
+
// Discover files to lint from all paths
|
|
166
|
+
const filesToLint: string[] = [];
|
|
167
|
+
for (const targetPath of targetPaths) {
|
|
168
|
+
const pathFiles = await discoverFiles(targetPath, logger, {
|
|
169
|
+
extensions: this.config.oxlint.lintableExtensions,
|
|
170
|
+
ignores: this.config.oxlint.ignorePatterns || [],
|
|
171
|
+
});
|
|
172
|
+
filesToLint.push(...pathFiles);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
logger.debug(`Found ${filesToLint.length} files to lint`);
|
|
176
|
+
|
|
177
|
+
if (filesToLint.length === 0) {
|
|
178
|
+
return success({
|
|
179
|
+
issues: {
|
|
180
|
+
items: [],
|
|
181
|
+
files: [],
|
|
182
|
+
summary: {
|
|
183
|
+
totalIssues: 0,
|
|
184
|
+
totalFiles: 0,
|
|
185
|
+
totalErrors: 0,
|
|
186
|
+
displayedIssues: 0,
|
|
187
|
+
displayedFiles: 0,
|
|
188
|
+
currentPage: 1,
|
|
189
|
+
totalPages: 1,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Distribute files across workers
|
|
196
|
+
const workerTasks = this.distributeFiles(
|
|
197
|
+
filesToLint,
|
|
198
|
+
resources.maxWorkers,
|
|
199
|
+
data,
|
|
200
|
+
);
|
|
201
|
+
logger.debug(`Distributing work across ${workerTasks.length} workers`);
|
|
202
|
+
|
|
203
|
+
// Pre-create all cache directories in parallel
|
|
204
|
+
await this.createCacheDirectories(workerTasks, logger);
|
|
205
|
+
|
|
206
|
+
// Execute workers in parallel
|
|
207
|
+
const workerResults = await this.executeWorkersInParallel(
|
|
208
|
+
workerTasks,
|
|
209
|
+
logger,
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
// Merge results from all workers
|
|
213
|
+
const mergedResult = this.mergeWorkerResults(workerResults, data, logger);
|
|
214
|
+
|
|
215
|
+
logger.debug("Parallel Oxlint execution completed", {
|
|
216
|
+
totalIssues: mergedResult.issues.items.length,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
return success(mergedResult);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
const errorMessage = parseError(error).message;
|
|
222
|
+
logger.error("Parallel Oxlint execution failed", { error: errorMessage });
|
|
223
|
+
|
|
224
|
+
return success({
|
|
225
|
+
issues: {
|
|
226
|
+
items: [
|
|
227
|
+
{
|
|
228
|
+
file: "unknown",
|
|
229
|
+
severity: "error" as const,
|
|
230
|
+
message: errorMessage,
|
|
231
|
+
type: "oxlint" as const,
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
files: [
|
|
235
|
+
{
|
|
236
|
+
file: "unknown",
|
|
237
|
+
errors: 1,
|
|
238
|
+
warnings: 0,
|
|
239
|
+
total: 1,
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
summary: {
|
|
243
|
+
totalIssues: 1,
|
|
244
|
+
totalFiles: 1,
|
|
245
|
+
totalErrors: 1,
|
|
246
|
+
displayedIssues: 1,
|
|
247
|
+
displayedFiles: 1,
|
|
248
|
+
currentPage: 1,
|
|
249
|
+
totalPages: 1,
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Distribute files across workers evenly
|
|
258
|
+
*/
|
|
259
|
+
private distributeFiles(
|
|
260
|
+
files: string[],
|
|
261
|
+
workerCount: number,
|
|
262
|
+
data: OxlintRequestOutput,
|
|
263
|
+
): WorkerTask[] {
|
|
264
|
+
const distributed = distributeFilesAcrossWorkers(files, workerCount);
|
|
265
|
+
|
|
266
|
+
return distributed.map((workerFiles, index) => ({
|
|
267
|
+
id: index,
|
|
268
|
+
files: workerFiles,
|
|
269
|
+
fix: data.fix,
|
|
270
|
+
timeout: data.timeout,
|
|
271
|
+
}));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Create global cache directory
|
|
276
|
+
*/
|
|
277
|
+
private async createCacheDirectories(
|
|
278
|
+
tasks: WorkerTask[],
|
|
279
|
+
logger: EndpointLogger,
|
|
280
|
+
): Promise<void> {
|
|
281
|
+
if (tasks.length === 0) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
try {
|
|
286
|
+
// oxlint is guaranteed to be enabled when this method is called
|
|
287
|
+
// (this method is only invoked after config validation in execute())
|
|
288
|
+
if (this.config?.oxlint.enabled) {
|
|
289
|
+
await fs.mkdir(this.config.oxlint.cachePath, { recursive: true });
|
|
290
|
+
}
|
|
291
|
+
} catch (error) {
|
|
292
|
+
logger.warn("Failed to create global cache directory", {
|
|
293
|
+
error: parseError(error).message,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Execute workers in parallel using Bun.spawn
|
|
300
|
+
*/
|
|
301
|
+
private async executeWorkersInParallel(
|
|
302
|
+
tasks: WorkerTask[],
|
|
303
|
+
logger: EndpointLogger,
|
|
304
|
+
): Promise<WorkerResult[]> {
|
|
305
|
+
const results: WorkerResult[] = [];
|
|
306
|
+
|
|
307
|
+
// Execute all workers in parallel
|
|
308
|
+
const workerPromises = tasks.map((task) =>
|
|
309
|
+
this.executeWorker(task, logger),
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
const workerResults = await Promise.allSettled(workerPromises);
|
|
313
|
+
|
|
314
|
+
for (let i = 0; i < workerResults.length; i++) {
|
|
315
|
+
const result = workerResults[i];
|
|
316
|
+
if (result.status === "fulfilled") {
|
|
317
|
+
results.push(result.value);
|
|
318
|
+
} else {
|
|
319
|
+
// Handle failed worker
|
|
320
|
+
results.push({
|
|
321
|
+
id: tasks[i].id,
|
|
322
|
+
success: false,
|
|
323
|
+
issues: [
|
|
324
|
+
{
|
|
325
|
+
file: "worker-error",
|
|
326
|
+
severity: "error" as const,
|
|
327
|
+
message: createWorkerFailedMessage(
|
|
328
|
+
tasks[i].id,
|
|
329
|
+
String(result.reason),
|
|
330
|
+
),
|
|
331
|
+
type: "oxlint" as const,
|
|
332
|
+
},
|
|
333
|
+
],
|
|
334
|
+
duration: 0,
|
|
335
|
+
error: String(result.reason),
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return results;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Execute a single worker using Bun.spawn
|
|
345
|
+
*/
|
|
346
|
+
private async executeWorker(
|
|
347
|
+
task: WorkerTask,
|
|
348
|
+
logger: EndpointLogger,
|
|
349
|
+
): Promise<WorkerResult> {
|
|
350
|
+
const startTime = Date.now();
|
|
351
|
+
|
|
352
|
+
try {
|
|
353
|
+
// Cache directory already created in parallel during setup
|
|
354
|
+
|
|
355
|
+
// Build oxlint command arguments
|
|
356
|
+
// oxlint is guaranteed to be enabled when this method is called
|
|
357
|
+
// (this method is only invoked after config validation in execute())
|
|
358
|
+
if (!this.config?.oxlint.enabled) {
|
|
359
|
+
// eslint-disable-next-line oxlint-plugin-restricted/restricted-syntax
|
|
360
|
+
throw new Error("Oxlint config not available");
|
|
361
|
+
}
|
|
362
|
+
const oxlintConfigPath = resolve(this.config.oxlint.configPath);
|
|
363
|
+
|
|
364
|
+
// Check if config exists, if not use default settings
|
|
365
|
+
const configExists = existsSync(oxlintConfigPath);
|
|
366
|
+
|
|
367
|
+
/* eslint-disable i18next/no-literal-string */
|
|
368
|
+
const baseArgs = configExists
|
|
369
|
+
? [
|
|
370
|
+
"oxlint",
|
|
371
|
+
"--format=json",
|
|
372
|
+
"--config",
|
|
373
|
+
oxlintConfigPath,
|
|
374
|
+
"--tsconfig",
|
|
375
|
+
"./tsconfig.json",
|
|
376
|
+
...task.files,
|
|
377
|
+
]
|
|
378
|
+
: [
|
|
379
|
+
"oxlint",
|
|
380
|
+
"--format=json",
|
|
381
|
+
// Fallback: Enable plugins manually if no config
|
|
382
|
+
"--tsconfig",
|
|
383
|
+
"./tsconfig.json",
|
|
384
|
+
"--react-plugin",
|
|
385
|
+
"--jsx-a11y-plugin",
|
|
386
|
+
"--nextjs-plugin",
|
|
387
|
+
"-D",
|
|
388
|
+
"all",
|
|
389
|
+
...task.files,
|
|
390
|
+
];
|
|
391
|
+
/* eslint-enable i18next/no-literal-string */
|
|
392
|
+
|
|
393
|
+
// If fix is requested, run oxlint --fix and prettier in parallel
|
|
394
|
+
if (task.fix) {
|
|
395
|
+
const fixArgs = [...baseArgs, "--fix"];
|
|
396
|
+
|
|
397
|
+
// Run both oxlint --fix and prettier in parallel
|
|
398
|
+
const [fixResult, prettierResult] = await Promise.allSettled([
|
|
399
|
+
this.runOxlintCommand(fixArgs, task, logger),
|
|
400
|
+
this.runPrettierFix(task.files, logger),
|
|
401
|
+
]);
|
|
402
|
+
|
|
403
|
+
// Handle oxlint result
|
|
404
|
+
let issues: OxlintIssue[] = [];
|
|
405
|
+
|
|
406
|
+
if (fixResult.status === "fulfilled") {
|
|
407
|
+
issues = fixResult.value.issues;
|
|
408
|
+
} else {
|
|
409
|
+
logger.error("Oxlint fix failed", {
|
|
410
|
+
error: String(fixResult.reason),
|
|
411
|
+
});
|
|
412
|
+
issues = [
|
|
413
|
+
{
|
|
414
|
+
file: "oxlint-error",
|
|
415
|
+
severity: "error" as const,
|
|
416
|
+
// eslint-disable-next-line i18next/no-literal-string
|
|
417
|
+
message: `Oxlint failed: ${String(fixResult.reason)}`,
|
|
418
|
+
type: "oxlint" as const,
|
|
419
|
+
},
|
|
420
|
+
];
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// Handle prettier result
|
|
424
|
+
if (prettierResult.status === "rejected") {
|
|
425
|
+
logger.warn("Prettier formatting failed", {
|
|
426
|
+
error: String(prettierResult.reason),
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
return {
|
|
431
|
+
id: task.id,
|
|
432
|
+
success: fixResult.status === "fulfilled",
|
|
433
|
+
issues,
|
|
434
|
+
duration: Date.now() - startTime,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Just run normal check
|
|
439
|
+
const result = await this.runOxlintCommand(baseArgs, task, logger);
|
|
440
|
+
return {
|
|
441
|
+
id: task.id,
|
|
442
|
+
success: true,
|
|
443
|
+
issues: result.issues,
|
|
444
|
+
duration: Date.now() - startTime,
|
|
445
|
+
};
|
|
446
|
+
} catch (error) {
|
|
447
|
+
const errorMessage = parseError(error).message;
|
|
448
|
+
logger.error(`Worker ${task.id} failed`, { error: errorMessage });
|
|
449
|
+
|
|
450
|
+
return {
|
|
451
|
+
id: task.id,
|
|
452
|
+
success: false,
|
|
453
|
+
issues: [
|
|
454
|
+
{
|
|
455
|
+
file: "worker-error",
|
|
456
|
+
severity: "error" as const,
|
|
457
|
+
message: errorMessage,
|
|
458
|
+
type: "oxlint" as const,
|
|
459
|
+
},
|
|
460
|
+
],
|
|
461
|
+
duration: Date.now() - startTime,
|
|
462
|
+
error: errorMessage,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Build file statistics from issues
|
|
469
|
+
*/
|
|
470
|
+
private buildFileStats(
|
|
471
|
+
issues: OxlintIssue[],
|
|
472
|
+
): Map<string, { errors: number; warnings: number; total: number }> {
|
|
473
|
+
const fileStats = new Map<
|
|
474
|
+
string,
|
|
475
|
+
{ errors: number; warnings: number; total: number }
|
|
476
|
+
>();
|
|
477
|
+
|
|
478
|
+
for (const issue of issues) {
|
|
479
|
+
const stats = fileStats.get(issue.file) || {
|
|
480
|
+
errors: 0,
|
|
481
|
+
warnings: 0,
|
|
482
|
+
total: 0,
|
|
483
|
+
};
|
|
484
|
+
stats.total++;
|
|
485
|
+
if (issue.severity === "error") {
|
|
486
|
+
stats.errors++;
|
|
487
|
+
}
|
|
488
|
+
if (issue.severity === "warning") {
|
|
489
|
+
stats.warnings++;
|
|
490
|
+
}
|
|
491
|
+
fileStats.set(issue.file, stats);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
return fileStats;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Format file statistics for response
|
|
499
|
+
*/
|
|
500
|
+
private formatFileStats(
|
|
501
|
+
fileStats: Map<string, { errors: number; warnings: number; total: number }>,
|
|
502
|
+
): Array<{ file: string; errors: number; warnings: number; total: number }> {
|
|
503
|
+
return [...fileStats.entries()]
|
|
504
|
+
.map(([file, stats]) => ({
|
|
505
|
+
file,
|
|
506
|
+
errors: stats.errors,
|
|
507
|
+
warnings: stats.warnings,
|
|
508
|
+
total: stats.total,
|
|
509
|
+
}))
|
|
510
|
+
.toSorted((a, b) => a.file.localeCompare(b.file));
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Build response with pagination and statistics
|
|
515
|
+
*/
|
|
516
|
+
private buildResponse(
|
|
517
|
+
allIssues: OxlintIssue[],
|
|
518
|
+
data: OxlintRequestOutput,
|
|
519
|
+
): OxlintResponseOutput {
|
|
520
|
+
const totalIssues = allIssues.length;
|
|
521
|
+
const totalFiles = new Set(allIssues.map((issue) => issue.file)).size;
|
|
522
|
+
const totalErrors = allIssues.filter(
|
|
523
|
+
(issue) => issue.severity === "error",
|
|
524
|
+
).length;
|
|
525
|
+
|
|
526
|
+
const fileStats = this.buildFileStats(allIssues);
|
|
527
|
+
const allFiles = this.formatFileStats(fileStats);
|
|
528
|
+
const limitedFiles = data.maxFilesInSummary
|
|
529
|
+
? allFiles.slice(0, data.maxFilesInSummary)
|
|
530
|
+
: allFiles;
|
|
531
|
+
|
|
532
|
+
const limit = data.limit;
|
|
533
|
+
const currentPage = data.page;
|
|
534
|
+
const totalPages = Math.ceil(totalIssues / limit);
|
|
535
|
+
const startIndex = (currentPage - 1) * limit;
|
|
536
|
+
const endIndex = startIndex + limit;
|
|
537
|
+
const limitedIssues = allIssues.slice(startIndex, endIndex);
|
|
538
|
+
|
|
539
|
+
const displayedIssues = limitedIssues.length;
|
|
540
|
+
const displayedFiles = new Set(limitedIssues.map((issue) => issue.file))
|
|
541
|
+
.size;
|
|
542
|
+
|
|
543
|
+
return {
|
|
544
|
+
issues: {
|
|
545
|
+
items: limitedIssues,
|
|
546
|
+
files: limitedFiles,
|
|
547
|
+
summary: {
|
|
548
|
+
totalIssues,
|
|
549
|
+
totalFiles,
|
|
550
|
+
totalErrors,
|
|
551
|
+
displayedIssues,
|
|
552
|
+
displayedFiles,
|
|
553
|
+
truncatedMessage:
|
|
554
|
+
displayedIssues < totalIssues || displayedFiles < totalFiles
|
|
555
|
+
? `Showing ${displayedIssues} of ${totalIssues} issues from ${displayedFiles} of ${totalFiles} files`
|
|
556
|
+
: "",
|
|
557
|
+
currentPage,
|
|
558
|
+
totalPages,
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Merge results from all workers
|
|
566
|
+
*/
|
|
567
|
+
private mergeWorkerResults(
|
|
568
|
+
workerResults: WorkerResult[],
|
|
569
|
+
data: OxlintRequestOutput,
|
|
570
|
+
logger: EndpointLogger,
|
|
571
|
+
): OxlintResponseOutput {
|
|
572
|
+
const allIssues: OxlintIssue[] = [];
|
|
573
|
+
|
|
574
|
+
// Collect all issues from workers
|
|
575
|
+
for (const result of workerResults) {
|
|
576
|
+
allIssues.push(...result.issues);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// Sort issues by file, then by line number (unless skipSorting is true)
|
|
580
|
+
const issues = data.skipSorting
|
|
581
|
+
? allIssues
|
|
582
|
+
: sortIssuesByLocation(allIssues);
|
|
583
|
+
|
|
584
|
+
logger.debug("Merged worker results", {
|
|
585
|
+
totalWorkers: workerResults.length,
|
|
586
|
+
totalIssues: issues.length,
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
return this.buildResponse(issues, data);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Run oxlint command and return results
|
|
594
|
+
*/
|
|
595
|
+
private async runOxlintCommand(
|
|
596
|
+
args: string[],
|
|
597
|
+
task: WorkerTask,
|
|
598
|
+
logger: EndpointLogger,
|
|
599
|
+
): Promise<{
|
|
600
|
+
issues: OxlintIssue[];
|
|
601
|
+
}> {
|
|
602
|
+
logger.debug(`Worker ${task.id} starting with ${task.files.length} files`);
|
|
603
|
+
|
|
604
|
+
// Use spawn for parallel execution
|
|
605
|
+
const { spawn } = await import("node:child_process");
|
|
606
|
+
const stdout = await new Promise<string>((resolve, reject) => {
|
|
607
|
+
const child = spawn("bunx", args, {
|
|
608
|
+
cwd: process.cwd(),
|
|
609
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
610
|
+
shell: false,
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
let output = "";
|
|
614
|
+
let stderrOutput = "";
|
|
615
|
+
|
|
616
|
+
child.stdout?.on("data", (data: Buffer) => {
|
|
617
|
+
output += data.toString();
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
child.stderr?.on("data", (data: Buffer) => {
|
|
621
|
+
stderrOutput += data.toString();
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
child.on("close", (code) => {
|
|
625
|
+
// Oxlint exit codes: 0=no issues, 1=lint issues found, 2=fatal/config error
|
|
626
|
+
// Unlike ESLint, oxlint doesn't output valid results on fatal errors
|
|
627
|
+
// So we only accept 0 and 1, reject on code >= 2
|
|
628
|
+
if (code !== null && code >= 2) {
|
|
629
|
+
const errorMsg =
|
|
630
|
+
stderrOutput.trim() || createWorkerExitCodeMessage(task.id, code);
|
|
631
|
+
reject(new Error(errorMsg));
|
|
632
|
+
} else {
|
|
633
|
+
resolve(output);
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
child.on("error", (error) => {
|
|
638
|
+
reject(error);
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
// Set timeout
|
|
642
|
+
const timeoutId = setTimeout(() => {
|
|
643
|
+
child.kill("SIGTERM");
|
|
644
|
+
setTimeout(() => {
|
|
645
|
+
child.kill("SIGKILL");
|
|
646
|
+
}, 5000);
|
|
647
|
+
reject(new Error(createWorkerTimeoutMessage(task.id, task.timeout)));
|
|
648
|
+
}, task.timeout * 1000);
|
|
649
|
+
|
|
650
|
+
// Clear timeout when process completes
|
|
651
|
+
child.on("close", () => {
|
|
652
|
+
clearTimeout(timeoutId);
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
// Parse oxlint output
|
|
657
|
+
const result = await this.parseOxlintOutput(stdout, logger);
|
|
658
|
+
|
|
659
|
+
logger.debug(
|
|
660
|
+
`Worker ${task.id} completed with ${result.issues.length} issues`,
|
|
661
|
+
);
|
|
662
|
+
|
|
663
|
+
return result;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Parse oxlint JSON output
|
|
668
|
+
*/
|
|
669
|
+
private async parseOxlintOutput(
|
|
670
|
+
stdout: string,
|
|
671
|
+
logger: EndpointLogger,
|
|
672
|
+
): Promise<{
|
|
673
|
+
issues: OxlintIssue[];
|
|
674
|
+
}> {
|
|
675
|
+
const issues: OxlintIssue[] = [];
|
|
676
|
+
|
|
677
|
+
if (!stdout.trim()) {
|
|
678
|
+
return { issues };
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// Oxlint JSON output structure
|
|
682
|
+
interface OxlintLabel {
|
|
683
|
+
span: {
|
|
684
|
+
offset: number;
|
|
685
|
+
length: number;
|
|
686
|
+
line: number;
|
|
687
|
+
column: number;
|
|
688
|
+
};
|
|
689
|
+
message?: string;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
interface OxlintDiagnostic {
|
|
693
|
+
message: string;
|
|
694
|
+
code: string; // Rule ID like "eslint(func-style)"
|
|
695
|
+
severity: "error" | "warning" | "advice";
|
|
696
|
+
filename: string;
|
|
697
|
+
labels?: OxlintLabel[];
|
|
698
|
+
help?: string;
|
|
699
|
+
url?: string;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
interface OxlintOutput {
|
|
703
|
+
diagnostics: OxlintDiagnostic[];
|
|
704
|
+
number_of_files: number;
|
|
705
|
+
number_of_rules: number;
|
|
706
|
+
threads_count: number;
|
|
707
|
+
start_time: number;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
try {
|
|
711
|
+
let parsedOutput: OxlintOutput;
|
|
712
|
+
try {
|
|
713
|
+
parsedOutput = JSON.parse(stdout) as OxlintOutput;
|
|
714
|
+
} catch (parseError) {
|
|
715
|
+
// JSON parse failed - log the error and return empty results
|
|
716
|
+
logger.warn("Failed to parse oxlint JSON output", {
|
|
717
|
+
error:
|
|
718
|
+
parseError instanceof Error
|
|
719
|
+
? parseError.message
|
|
720
|
+
: String(parseError),
|
|
721
|
+
stdoutPreview: stdout.slice(0, 200),
|
|
722
|
+
});
|
|
723
|
+
return { issues };
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// Convert oxlint diagnostics to our issue format
|
|
727
|
+
for (const diagnostic of parsedOutput.diagnostics) {
|
|
728
|
+
// Map oxlint severity to our format
|
|
729
|
+
let severity: "error" | "warning" | "info" = "error";
|
|
730
|
+
if (diagnostic.severity === "warning") {
|
|
731
|
+
severity = "warning";
|
|
732
|
+
} else if (diagnostic.severity === "advice") {
|
|
733
|
+
severity = "info";
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
// Extract file path
|
|
737
|
+
const relativePath = relative(process.cwd(), diagnostic.filename);
|
|
738
|
+
|
|
739
|
+
// Extract line and column from labels if available
|
|
740
|
+
let line: number | undefined;
|
|
741
|
+
let column: number | undefined;
|
|
742
|
+
|
|
743
|
+
if (diagnostic.labels && diagnostic.labels.length > 0) {
|
|
744
|
+
const label = diagnostic.labels[0];
|
|
745
|
+
line = label.span.line;
|
|
746
|
+
column = label.span.column;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// Custom message for no-unused-vars
|
|
750
|
+
let message = diagnostic.message;
|
|
751
|
+
if (diagnostic.code?.includes("no-unused-vars")) {
|
|
752
|
+
const match = diagnostic.message.match(/'([^']+)'/);
|
|
753
|
+
const name = match ? match[1] : "Variable";
|
|
754
|
+
message = `'${name}' is unused. Either use it or remove it.`;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
issues.push({
|
|
758
|
+
file: relativePath,
|
|
759
|
+
line,
|
|
760
|
+
column,
|
|
761
|
+
rule: diagnostic.code,
|
|
762
|
+
code: diagnostic.code,
|
|
763
|
+
severity,
|
|
764
|
+
message,
|
|
765
|
+
type: "oxlint",
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
} catch (error) {
|
|
769
|
+
// Unexpected error during processing
|
|
770
|
+
logger.error("Unexpected error processing oxlint results", {
|
|
771
|
+
error: error instanceof Error ? error.message : String(error),
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
return { issues };
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Get prettier config from centralized config
|
|
780
|
+
*/
|
|
781
|
+
private getPrettierConfig(): PrettierConfig {
|
|
782
|
+
if (this.config?.prettier.enabled) {
|
|
783
|
+
return this.config.prettier;
|
|
784
|
+
}
|
|
785
|
+
// Return default enabled config
|
|
786
|
+
return {
|
|
787
|
+
enabled: true,
|
|
788
|
+
configPath: ".tmp/.oxfmtrc.json",
|
|
789
|
+
semi: true,
|
|
790
|
+
singleQuote: false,
|
|
791
|
+
trailingComma: "all",
|
|
792
|
+
tabWidth: 2,
|
|
793
|
+
printWidth: 80,
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Check if files need prettier formatting using --list-different
|
|
799
|
+
*/
|
|
800
|
+
private async checkPrettierNeeded(
|
|
801
|
+
files: string[],
|
|
802
|
+
prettierConfig: PrettierConfig,
|
|
803
|
+
logger: EndpointLogger,
|
|
804
|
+
): Promise<string[]> {
|
|
805
|
+
logger.debug(`Checking which files need prettier formatting`);
|
|
806
|
+
|
|
807
|
+
const { spawn } = await import("node:child_process");
|
|
808
|
+
|
|
809
|
+
return await new Promise((resolve) => {
|
|
810
|
+
/* eslint-disable i18next/no-literal-string */
|
|
811
|
+
const configArgs = Object.entries(prettierConfig)
|
|
812
|
+
.filter(
|
|
813
|
+
([key]) =>
|
|
814
|
+
key !== "enabled" &&
|
|
815
|
+
key !== "configPath" &&
|
|
816
|
+
key !== "jsxBracketSameLine",
|
|
817
|
+
)
|
|
818
|
+
.flatMap(([key, value]) => {
|
|
819
|
+
// Convert camelCase to kebab-case for CLI flags
|
|
820
|
+
const flagName = key.replaceAll(/([A-Z])/g, "-$1").toLowerCase();
|
|
821
|
+
if (typeof value === "boolean") {
|
|
822
|
+
return value ? [`--${flagName}`] : [`--no-${flagName}`];
|
|
823
|
+
}
|
|
824
|
+
return [`--${flagName}`, String(value)];
|
|
825
|
+
});
|
|
826
|
+
/* eslint-enable i18next/no-literal-string */
|
|
827
|
+
|
|
828
|
+
const child = spawn(
|
|
829
|
+
"bunx",
|
|
830
|
+
["prettier", "--list-different", ...configArgs, ...files],
|
|
831
|
+
{
|
|
832
|
+
cwd: process.cwd(),
|
|
833
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
834
|
+
shell: false,
|
|
835
|
+
},
|
|
836
|
+
);
|
|
837
|
+
|
|
838
|
+
let stdout = "";
|
|
839
|
+
|
|
840
|
+
child.stdout?.on("data", (data: Buffer) => {
|
|
841
|
+
stdout += data.toString();
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
child.stderr?.on("data", () => {
|
|
845
|
+
// Ignore stderr
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
child.on("close", () => {
|
|
849
|
+
// Parse list of files that need formatting from stdout
|
|
850
|
+
const needsFormatting = stdout
|
|
851
|
+
.trim()
|
|
852
|
+
.split("\n")
|
|
853
|
+
.filter((line) => line.length > 0);
|
|
854
|
+
|
|
855
|
+
logger.debug(
|
|
856
|
+
`${needsFormatting.length} files need prettier formatting`,
|
|
857
|
+
);
|
|
858
|
+
resolve(needsFormatting);
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
child.on("error", (error) => {
|
|
862
|
+
logger.warn("Prettier check failed, will skip formatting", {
|
|
863
|
+
error: error.message,
|
|
864
|
+
});
|
|
865
|
+
resolve([]); // Don't fail, just skip formatting
|
|
866
|
+
});
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Run prettier on files for formatting (only files that need it)
|
|
872
|
+
*/
|
|
873
|
+
private async runPrettierFix(
|
|
874
|
+
files: string[],
|
|
875
|
+
logger: EndpointLogger,
|
|
876
|
+
): Promise<void> {
|
|
877
|
+
// Get prettier config from check.config.ts
|
|
878
|
+
const prettierConfig = this.getPrettierConfig();
|
|
879
|
+
|
|
880
|
+
if (!prettierConfig.enabled) {
|
|
881
|
+
logger.debug("Prettier is disabled, skipping formatting");
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
// First check which files actually need formatting
|
|
886
|
+
const filesToFormat = await this.checkPrettierNeeded(
|
|
887
|
+
files,
|
|
888
|
+
prettierConfig,
|
|
889
|
+
logger,
|
|
890
|
+
);
|
|
891
|
+
|
|
892
|
+
if (filesToFormat.length === 0) {
|
|
893
|
+
logger.debug("No files need prettier formatting, skipping");
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
logger.debug(`Running prettier on ${filesToFormat.length} files`);
|
|
898
|
+
|
|
899
|
+
const { spawn } = await import("node:child_process");
|
|
900
|
+
|
|
901
|
+
// Convert prettier config to CLI flags (exclude internal config properties)
|
|
902
|
+
/* eslint-disable i18next/no-literal-string */
|
|
903
|
+
const configArgs = Object.entries(prettierConfig)
|
|
904
|
+
.filter(
|
|
905
|
+
([key]) =>
|
|
906
|
+
key !== "enabled" &&
|
|
907
|
+
key !== "configPath" &&
|
|
908
|
+
key !== "jsxBracketSameLine",
|
|
909
|
+
)
|
|
910
|
+
.flatMap(([key, value]) => {
|
|
911
|
+
// Convert camelCase to kebab-case for CLI flags
|
|
912
|
+
const flagName = key.replaceAll(/([A-Z])/g, "-$1").toLowerCase();
|
|
913
|
+
if (typeof value === "boolean") {
|
|
914
|
+
return value ? [`--${flagName}`] : [`--no-${flagName}`];
|
|
915
|
+
}
|
|
916
|
+
return [`--${flagName}`, String(value)];
|
|
917
|
+
});
|
|
918
|
+
/* eslint-enable i18next/no-literal-string */
|
|
919
|
+
|
|
920
|
+
return await new Promise((resolve, reject) => {
|
|
921
|
+
const child = spawn(
|
|
922
|
+
"bunx",
|
|
923
|
+
["prettier", "--write", ...configArgs, ...filesToFormat],
|
|
924
|
+
{
|
|
925
|
+
cwd: process.cwd(),
|
|
926
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
927
|
+
shell: false,
|
|
928
|
+
},
|
|
929
|
+
);
|
|
930
|
+
|
|
931
|
+
let stderr = "";
|
|
932
|
+
|
|
933
|
+
child.stderr?.on("data", (data: Buffer) => {
|
|
934
|
+
stderr += data.toString();
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
child.on("close", (code) => {
|
|
938
|
+
if (code === 0) {
|
|
939
|
+
logger.debug(`Prettier formatted ${filesToFormat.length} files`);
|
|
940
|
+
resolve();
|
|
941
|
+
} else {
|
|
942
|
+
// eslint-disable-next-line i18next/no-literal-string
|
|
943
|
+
reject(
|
|
944
|
+
new Error(`Prettier failed with exit code ${code}: ${stderr}`),
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
child.on("error", (error) => {
|
|
950
|
+
reject(error);
|
|
951
|
+
});
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Default repository instance
|
|
958
|
+
*/
|
|
959
|
+
export const oxlintRepository = new OxlintRepositoryImpl();
|