@terra-symposium/hygiene 0.0.0-stage → 2.4.4
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/README.md +70 -2
- package/dist/accessibility.d.ts +39 -0
- package/dist/accessibility.d.ts.map +1 -0
- package/dist/accessibility.js +524 -0
- package/dist/accessibility.js.map +1 -0
- package/dist/app/workspace-test-runner.d.ts +6 -0
- package/dist/app/workspace-test-runner.d.ts.map +1 -0
- package/dist/app/workspace-test-runner.js +39 -0
- package/dist/app/workspace-test-runner.js.map +1 -0
- package/dist/capabilities/core/analysis.d.ts +22 -0
- package/dist/capabilities/core/analysis.d.ts.map +1 -0
- package/dist/capabilities/core/analysis.js +44 -0
- package/dist/capabilities/core/analysis.js.map +1 -0
- package/dist/capabilities/core/cli.d.ts +19 -0
- package/dist/capabilities/core/cli.d.ts.map +1 -0
- package/dist/capabilities/core/cli.js +58 -0
- package/dist/capabilities/core/cli.js.map +1 -0
- package/dist/capabilities/core/config.d.ts +49 -0
- package/dist/capabilities/core/config.d.ts.map +1 -0
- package/dist/capabilities/core/config.js +88 -0
- package/dist/capabilities/core/config.js.map +1 -0
- package/dist/capabilities/core/index.d.ts +11 -0
- package/dist/capabilities/core/index.d.ts.map +1 -0
- package/dist/capabilities/core/index.js +11 -0
- package/dist/capabilities/core/index.js.map +1 -0
- package/dist/capabilities/core/lib/files.d.ts +55 -0
- package/dist/capabilities/core/lib/files.d.ts.map +1 -0
- package/dist/capabilities/core/lib/files.js +287 -0
- package/dist/capabilities/core/lib/files.js.map +1 -0
- package/dist/capabilities/core/lib/progress.d.ts +25 -0
- package/dist/capabilities/core/lib/progress.d.ts.map +1 -0
- package/dist/capabilities/core/lib/progress.js +40 -0
- package/dist/capabilities/core/lib/progress.js.map +1 -0
- package/dist/capabilities/core/lib/source-kind.d.ts +14 -0
- package/dist/capabilities/core/lib/source-kind.d.ts.map +1 -0
- package/dist/capabilities/core/lib/source-kind.js +29 -0
- package/dist/capabilities/core/lib/source-kind.js.map +1 -0
- package/dist/capabilities/core/types.d.ts +156 -0
- package/dist/capabilities/core/types.d.ts.map +1 -0
- package/dist/capabilities/core/types.js +35 -0
- package/dist/capabilities/core/types.js.map +1 -0
- package/dist/capabilities/documentation/cli.d.ts +3 -0
- package/dist/capabilities/documentation/cli.d.ts.map +1 -0
- package/dist/capabilities/documentation/cli.js +14 -0
- package/dist/capabilities/documentation/cli.js.map +1 -0
- package/dist/capabilities/documentation/index.d.ts +5 -0
- package/dist/capabilities/documentation/index.d.ts.map +1 -0
- package/dist/capabilities/documentation/index.js +5 -0
- package/dist/capabilities/documentation/index.js.map +1 -0
- package/dist/capabilities/documentation/lib/documentation.d.ts +108 -0
- package/dist/capabilities/documentation/lib/documentation.d.ts.map +1 -0
- package/dist/capabilities/documentation/lib/documentation.js +1007 -0
- package/dist/capabilities/documentation/lib/documentation.js.map +1 -0
- package/dist/capabilities/formatting/cli.d.ts +3 -0
- package/dist/capabilities/formatting/cli.d.ts.map +1 -0
- package/dist/capabilities/formatting/cli.js +15 -0
- package/dist/capabilities/formatting/cli.js.map +1 -0
- package/dist/capabilities/formatting/index.d.ts +8 -0
- package/dist/capabilities/formatting/index.d.ts.map +1 -0
- package/dist/capabilities/formatting/index.js +8 -0
- package/dist/capabilities/formatting/index.js.map +1 -0
- package/dist/capabilities/formatting/lib/collapse.d.ts +13 -0
- package/dist/capabilities/formatting/lib/collapse.d.ts.map +1 -0
- package/dist/capabilities/formatting/lib/collapse.js +179 -0
- package/dist/capabilities/formatting/lib/collapse.js.map +1 -0
- package/dist/capabilities/formatting/lib/inline-if.d.ts +13 -0
- package/dist/capabilities/formatting/lib/inline-if.d.ts.map +1 -0
- package/dist/capabilities/formatting/lib/inline-if.js +49 -0
- package/dist/capabilities/formatting/lib/inline-if.js.map +1 -0
- package/dist/capabilities/formatting/lib/run-formatting.d.ts +14 -0
- package/dist/capabilities/formatting/lib/run-formatting.d.ts.map +1 -0
- package/dist/capabilities/formatting/lib/run-formatting.js +134 -0
- package/dist/capabilities/formatting/lib/run-formatting.js.map +1 -0
- package/dist/capabilities/imports/cli.d.ts +3 -0
- package/dist/capabilities/imports/cli.d.ts.map +1 -0
- package/dist/capabilities/imports/cli.js +9 -0
- package/dist/capabilities/imports/cli.js.map +1 -0
- package/dist/capabilities/imports/index.d.ts +6 -0
- package/dist/capabilities/imports/index.d.ts.map +1 -0
- package/dist/capabilities/imports/index.js +6 -0
- package/dist/capabilities/imports/index.js.map +1 -0
- package/dist/capabilities/imports/lib/imports.d.ts +19 -0
- package/dist/capabilities/imports/lib/imports.d.ts.map +1 -0
- package/dist/capabilities/imports/lib/imports.js +88 -0
- package/dist/capabilities/imports/lib/imports.js.map +1 -0
- package/dist/capabilities/languages/cli.d.ts +3 -0
- package/dist/capabilities/languages/cli.d.ts.map +1 -0
- package/dist/capabilities/languages/cli.js +9 -0
- package/dist/capabilities/languages/cli.js.map +1 -0
- package/dist/capabilities/languages/index.d.ts +6 -0
- package/dist/capabilities/languages/index.d.ts.map +1 -0
- package/dist/capabilities/languages/index.js +6 -0
- package/dist/capabilities/languages/index.js.map +1 -0
- package/dist/capabilities/languages/lib/language-profiles.d.ts +110 -0
- package/dist/capabilities/languages/lib/language-profiles.d.ts.map +1 -0
- package/dist/capabilities/languages/lib/language-profiles.js +509 -0
- package/dist/capabilities/languages/lib/language-profiles.js.map +1 -0
- package/dist/capabilities/languages/lib/run-language-checks.d.ts +12 -0
- package/dist/capabilities/languages/lib/run-language-checks.d.ts.map +1 -0
- package/dist/capabilities/languages/lib/run-language-checks.js +109 -0
- package/dist/capabilities/languages/lib/run-language-checks.js.map +1 -0
- package/dist/capabilities/naming/cli.d.ts +3 -0
- package/dist/capabilities/naming/cli.d.ts.map +1 -0
- package/dist/capabilities/naming/cli.js +15 -0
- package/dist/capabilities/naming/cli.js.map +1 -0
- package/dist/capabilities/naming/index.d.ts +5 -0
- package/dist/capabilities/naming/index.d.ts.map +1 -0
- package/dist/capabilities/naming/index.js +5 -0
- package/dist/capabilities/naming/index.js.map +1 -0
- package/dist/capabilities/naming/lib/naming.d.ts +169 -0
- package/dist/capabilities/naming/lib/naming.d.ts.map +1 -0
- package/dist/capabilities/naming/lib/naming.js +908 -0
- package/dist/capabilities/naming/lib/naming.js.map +1 -0
- package/dist/capabilities/patterns/cli.d.ts +3 -0
- package/dist/capabilities/patterns/cli.d.ts.map +1 -0
- package/dist/capabilities/patterns/cli.js +30 -0
- package/dist/capabilities/patterns/cli.js.map +1 -0
- package/dist/capabilities/patterns/index.d.ts +5 -0
- package/dist/capabilities/patterns/index.d.ts.map +1 -0
- package/dist/capabilities/patterns/index.js +5 -0
- package/dist/capabilities/patterns/index.js.map +1 -0
- package/dist/capabilities/patterns/lib/patterns.d.ts +102 -0
- package/dist/capabilities/patterns/lib/patterns.d.ts.map +1 -0
- package/dist/capabilities/patterns/lib/patterns.js +1584 -0
- package/dist/capabilities/patterns/lib/patterns.js.map +1 -0
- package/dist/capabilities/refactoring/cli.d.ts +3 -0
- package/dist/capabilities/refactoring/cli.d.ts.map +1 -0
- package/dist/capabilities/refactoring/cli.js +15 -0
- package/dist/capabilities/refactoring/cli.js.map +1 -0
- package/dist/capabilities/refactoring/index.d.ts +6 -0
- package/dist/capabilities/refactoring/index.d.ts.map +1 -0
- package/dist/capabilities/refactoring/index.js +6 -0
- package/dist/capabilities/refactoring/index.js.map +1 -0
- package/dist/capabilities/refactoring/lib/object-forwarding.d.ts +42 -0
- package/dist/capabilities/refactoring/lib/object-forwarding.d.ts.map +1 -0
- package/dist/capabilities/refactoring/lib/object-forwarding.js +166 -0
- package/dist/capabilities/refactoring/lib/object-forwarding.js.map +1 -0
- package/dist/capabilities/refactoring/lib/single-use.d.ts +61 -0
- package/dist/capabilities/refactoring/lib/single-use.d.ts.map +1 -0
- package/dist/capabilities/refactoring/lib/single-use.js +1791 -0
- package/dist/capabilities/refactoring/lib/single-use.js.map +1 -0
- package/dist/capabilities/reports/cli.d.ts +3 -0
- package/dist/capabilities/reports/cli.d.ts.map +1 -0
- package/dist/capabilities/reports/cli.js +34 -0
- package/dist/capabilities/reports/cli.js.map +1 -0
- package/dist/capabilities/reports/index.d.ts +10 -0
- package/dist/capabilities/reports/index.d.ts.map +1 -0
- package/dist/capabilities/reports/index.js +10 -0
- package/dist/capabilities/reports/index.js.map +1 -0
- package/dist/capabilities/reports/lib/github-report.d.ts +94 -0
- package/dist/capabilities/reports/lib/github-report.d.ts.map +1 -0
- package/dist/capabilities/reports/lib/github-report.js +499 -0
- package/dist/capabilities/reports/lib/github-report.js.map +1 -0
- package/dist/capabilities/reports/lib/history-report.d.ts +58 -0
- package/dist/capabilities/reports/lib/history-report.d.ts.map +1 -0
- package/dist/capabilities/reports/lib/history-report.js +300 -0
- package/dist/capabilities/reports/lib/history-report.js.map +1 -0
- package/dist/capabilities/reports/lib/node-reporter.d.ts +79 -0
- package/dist/capabilities/reports/lib/node-reporter.d.ts.map +1 -0
- package/dist/capabilities/reports/lib/node-reporter.js +244 -0
- package/dist/capabilities/reports/lib/node-reporter.js.map +1 -0
- package/dist/capabilities/reports/lib/playwright-reporter.d.ts +100 -0
- package/dist/capabilities/reports/lib/playwright-reporter.d.ts.map +1 -0
- package/dist/capabilities/reports/lib/playwright-reporter.js +122 -0
- package/dist/capabilities/reports/lib/playwright-reporter.js.map +1 -0
- package/dist/capabilities/security/cli.d.ts +3 -0
- package/dist/capabilities/security/cli.d.ts.map +1 -0
- package/dist/capabilities/security/cli.js +9 -0
- package/dist/capabilities/security/cli.js.map +1 -0
- package/dist/capabilities/security/index.d.ts +5 -0
- package/dist/capabilities/security/index.d.ts.map +1 -0
- package/dist/capabilities/security/index.js +5 -0
- package/dist/capabilities/security/index.js.map +1 -0
- package/dist/capabilities/security/lib/security.d.ts +19 -0
- package/dist/capabilities/security/lib/security.d.ts.map +1 -0
- package/dist/capabilities/security/lib/security.js +115 -0
- package/dist/capabilities/security/lib/security.js.map +1 -0
- package/dist/capabilities/ui/cli.d.ts +3 -0
- package/dist/capabilities/ui/cli.d.ts.map +1 -0
- package/dist/capabilities/ui/cli.js +22 -0
- package/dist/capabilities/ui/cli.js.map +1 -0
- package/dist/capabilities/ui/index.d.ts +8 -0
- package/dist/capabilities/ui/index.d.ts.map +1 -0
- package/dist/capabilities/ui/index.js +8 -0
- package/dist/capabilities/ui/index.js.map +1 -0
- package/dist/capabilities/ui/lib/accessibility.d.ts +37 -0
- package/dist/capabilities/ui/lib/accessibility.d.ts.map +1 -0
- package/dist/capabilities/ui/lib/accessibility.js +676 -0
- package/dist/capabilities/ui/lib/accessibility.js.map +1 -0
- package/dist/capabilities/ui/lib/display-name.d.ts +42 -0
- package/dist/capabilities/ui/lib/display-name.d.ts.map +1 -0
- package/dist/capabilities/ui/lib/display-name.js +277 -0
- package/dist/capabilities/ui/lib/display-name.js.map +1 -0
- package/dist/capabilities/ui/lib/error-boundaries.d.ts +30 -0
- package/dist/capabilities/ui/lib/error-boundaries.d.ts.map +1 -0
- package/dist/capabilities/ui/lib/error-boundaries.js +401 -0
- package/dist/capabilities/ui/lib/error-boundaries.js.map +1 -0
- package/dist/capabilities/ui/lib/ui-recommendations.d.ts +45 -0
- package/dist/capabilities/ui/lib/ui-recommendations.d.ts.map +1 -0
- package/dist/capabilities/ui/lib/ui-recommendations.js +183 -0
- package/dist/capabilities/ui/lib/ui-recommendations.js.map +1 -0
- package/dist/display-name.d.ts +44 -0
- package/dist/display-name.d.ts.map +1 -0
- package/dist/display-name.js +256 -0
- package/dist/display-name.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/accessibility.d.ts +5 -0
- package/dist/lib/accessibility.d.ts.map +1 -0
- package/dist/lib/accessibility.js +5 -0
- package/dist/lib/accessibility.js.map +1 -0
- package/dist/lib/collapse.d.ts +5 -0
- package/dist/lib/collapse.d.ts.map +1 -0
- package/dist/lib/collapse.js +5 -0
- package/dist/lib/collapse.js.map +1 -0
- package/dist/lib/dev.d.ts +3 -0
- package/dist/lib/dev.d.ts.map +1 -0
- package/dist/lib/dev.js +126 -0
- package/dist/lib/dev.js.map +1 -0
- package/dist/lib/display-name.d.ts +5 -0
- package/dist/lib/display-name.d.ts.map +1 -0
- package/dist/lib/display-name.js +5 -0
- package/dist/lib/display-name.js.map +1 -0
- package/dist/lib/documentation.d.ts +5 -0
- package/dist/lib/documentation.d.ts.map +1 -0
- package/dist/lib/documentation.js +5 -0
- package/dist/lib/documentation.js.map +1 -0
- package/dist/lib/error-boundaries-astro.d.ts +6 -0
- package/dist/lib/error-boundaries-astro.d.ts.map +1 -0
- package/dist/lib/error-boundaries-astro.js +6 -0
- package/dist/lib/error-boundaries-astro.js.map +1 -0
- package/dist/lib/error-boundaries-react.d.ts +6 -0
- package/dist/lib/error-boundaries-react.d.ts.map +1 -0
- package/dist/lib/error-boundaries-react.js +6 -0
- package/dist/lib/error-boundaries-react.js.map +1 -0
- package/dist/lib/error-boundaries.d.ts +5 -0
- package/dist/lib/error-boundaries.d.ts.map +1 -0
- package/dist/lib/error-boundaries.js +5 -0
- package/dist/lib/error-boundaries.js.map +1 -0
- package/dist/lib/eslint-api.d.ts +13 -0
- package/dist/lib/eslint-api.d.ts.map +1 -0
- package/dist/lib/eslint-api.js +24 -0
- package/dist/lib/eslint-api.js.map +1 -0
- package/dist/lib/files.d.ts +5 -0
- package/dist/lib/files.d.ts.map +1 -0
- package/dist/lib/files.js +5 -0
- package/dist/lib/files.js.map +1 -0
- package/dist/lib/formatting.d.ts +5 -0
- package/dist/lib/formatting.d.ts.map +1 -0
- package/dist/lib/formatting.js +5 -0
- package/dist/lib/formatting.js.map +1 -0
- package/dist/lib/github-report.d.ts +5 -0
- package/dist/lib/github-report.d.ts.map +1 -0
- package/dist/lib/github-report.js +5 -0
- package/dist/lib/github-report.js.map +1 -0
- package/dist/lib/history-report.d.ts +5 -0
- package/dist/lib/history-report.d.ts.map +1 -0
- package/dist/lib/history-report.js +5 -0
- package/dist/lib/history-report.js.map +1 -0
- package/dist/lib/imports.d.ts +5 -0
- package/dist/lib/imports.d.ts.map +1 -0
- package/dist/lib/imports.js +5 -0
- package/dist/lib/imports.js.map +1 -0
- package/dist/lib/index.d.ts +20 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +20 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/inline-if.d.ts +5 -0
- package/dist/lib/inline-if.d.ts.map +1 -0
- package/dist/lib/inline-if.js +5 -0
- package/dist/lib/inline-if.js.map +1 -0
- package/dist/lib/language-checks.d.ts +5 -0
- package/dist/lib/language-checks.d.ts.map +1 -0
- package/dist/lib/language-checks.js +5 -0
- package/dist/lib/language-checks.js.map +1 -0
- package/dist/lib/language-profiles.d.ts +5 -0
- package/dist/lib/language-profiles.d.ts.map +1 -0
- package/dist/lib/language-profiles.js +5 -0
- package/dist/lib/language-profiles.js.map +1 -0
- package/dist/lib/naming.d.ts +5 -0
- package/dist/lib/naming.d.ts.map +1 -0
- package/dist/lib/naming.js +5 -0
- package/dist/lib/naming.js.map +1 -0
- package/dist/lib/node-reporter.d.ts +6 -0
- package/dist/lib/node-reporter.d.ts.map +1 -0
- package/dist/lib/node-reporter.js +6 -0
- package/dist/lib/node-reporter.js.map +1 -0
- package/dist/lib/object-forwarding.d.ts +5 -0
- package/dist/lib/object-forwarding.d.ts.map +1 -0
- package/dist/lib/object-forwarding.js +5 -0
- package/dist/lib/object-forwarding.js.map +1 -0
- package/dist/lib/patterns.d.ts +5 -0
- package/dist/lib/patterns.d.ts.map +1 -0
- package/dist/lib/patterns.js +5 -0
- package/dist/lib/patterns.js.map +1 -0
- package/dist/lib/playwright-reporter.d.ts +6 -0
- package/dist/lib/playwright-reporter.d.ts.map +1 -0
- package/dist/lib/playwright-reporter.js +6 -0
- package/dist/lib/playwright-reporter.js.map +1 -0
- package/dist/lib/port.d.ts +21 -0
- package/dist/lib/port.d.ts.map +1 -0
- package/dist/lib/port.js +81 -0
- package/dist/lib/port.js.map +1 -0
- package/dist/lib/progress.d.ts +5 -0
- package/dist/lib/progress.d.ts.map +1 -0
- package/dist/lib/progress.js +5 -0
- package/dist/lib/progress.js.map +1 -0
- package/dist/lib/reports.d.ts +5 -0
- package/dist/lib/reports.d.ts.map +1 -0
- package/dist/lib/reports.js +5 -0
- package/dist/lib/reports.js.map +1 -0
- package/dist/lib/runner.d.ts +150 -0
- package/dist/lib/runner.d.ts.map +1 -0
- package/dist/lib/runner.js +4522 -0
- package/dist/lib/runner.js.map +1 -0
- package/dist/lib/security.d.ts +5 -0
- package/dist/lib/security.d.ts.map +1 -0
- package/dist/lib/security.js +5 -0
- package/dist/lib/security.js.map +1 -0
- package/dist/lib/single-use.d.ts +6 -0
- package/dist/lib/single-use.d.ts.map +1 -0
- package/dist/lib/single-use.js +5 -0
- package/dist/lib/single-use.js.map +1 -0
- package/dist/lib/source-kind.d.ts +5 -0
- package/dist/lib/source-kind.d.ts.map +1 -0
- package/dist/lib/source-kind.js +5 -0
- package/dist/lib/source-kind.js.map +1 -0
- package/dist/lib/spinner-worker.d.ts +6 -0
- package/dist/lib/spinner-worker.d.ts.map +1 -0
- package/dist/lib/spinner-worker.js +33 -0
- package/dist/lib/spinner-worker.js.map +1 -0
- package/dist/lib/ui-quality.d.ts +5 -0
- package/dist/lib/ui-quality.d.ts.map +1 -0
- package/dist/lib/ui-quality.js +5 -0
- package/dist/lib/ui-quality.js.map +1 -0
- package/dist/lib/ui-recommendations.d.ts +5 -0
- package/dist/lib/ui-recommendations.d.ts.map +1 -0
- package/dist/lib/ui-recommendations.js +5 -0
- package/dist/lib/ui-recommendations.js.map +1 -0
- package/dist/spinner-worker.d.ts +6 -0
- package/dist/spinner-worker.d.ts.map +1 -0
- package/dist/spinner-worker.js +39 -0
- package/dist/spinner-worker.js.map +1 -0
- package/package.json +160 -5
- package/quality-configs/checkstyle.xml +29 -0
- package/quality-configs/pmd-rules.xml +11 -0
- package/quality.schema.json +392 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/hygiene/src/capabilities/reports/lib/history-report.ts
|
|
3
|
+
*/
|
|
4
|
+
/*//////////////////////////////////////////////////
|
|
5
|
+
IMPORTS
|
|
6
|
+
//////////////////////////////////////////////////*/
|
|
7
|
+
// API
|
|
8
|
+
import { execFileSync } from 'node:child_process';
|
|
9
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import { resolve } from 'node:path';
|
|
11
|
+
/*//////////////////////////////////////////////////
|
|
12
|
+
REGEX
|
|
13
|
+
//////////////////////////////////////////////////*/
|
|
14
|
+
const S_REGEX = /\s+/;
|
|
15
|
+
const GIT_I_REGEX = /\.git$/i;
|
|
16
|
+
const A_F_D_40_I_REGEX = /^[a-f\d]{40}$/i;
|
|
17
|
+
// hygiene-ignore single-use -- Compile the source-extension matcher once for every history entry.
|
|
18
|
+
const SRC_EXT = /\.(?:astro|c|cc|cpp|cs|css|go|html|java|js|jsx|jsonl|kt|less|m|mdx|php|py|rb|rs|scss|sh|sql|svelte|swift|ts|tsx|vue)$/i;
|
|
19
|
+
const EXCLUDED_DIR = /^(?:\.git|\.github|\.next|\.nuxt|\.output|\.turbo|\.vercel|\.netlify|\.astro|\.cache|build|coverage|dist|docs?|documentation|generated|vendor|node_modules|bower_components|target|out|public|static|storybook-static|test-results|results)$/i;
|
|
20
|
+
// hygiene-ignore single-use -- Compile the excluded-file matcher once for every history entry.
|
|
21
|
+
const EXCLUDED_FILE = /^(?:package(?:-lock)?\.json|pnpm-lock\.yaml|yarn\.lock|tsconfig(?:\.[^.]+)?\.json|(?:astro|eslint|prettier|vite|vitest|webpack|rollup|tailwind|postcss|jest|playwright|babel|next|netlify)\.config\.[^.]+|Dockerfile|Makefile)$/i;
|
|
22
|
+
const HISTORY_BATCH_SIZE = 50;
|
|
23
|
+
const BLOB_BATCH_SIZE = 250;
|
|
24
|
+
const GIT_OUTPUT_LIMIT = 128 * 1024 * 1024;
|
|
25
|
+
/**
|
|
26
|
+
* Return whether a tracked path belongs to the dashboard's source and test scope.
|
|
27
|
+
*
|
|
28
|
+
* @param path Repository-relative tracked file path.
|
|
29
|
+
*
|
|
30
|
+
* @return Whether the path contributes to history metrics.
|
|
31
|
+
*/
|
|
32
|
+
export function isHistorySourcePath(path) {
|
|
33
|
+
const parts = path.split('/');
|
|
34
|
+
if (!parts.length || parts.some(p => p === '..' || p === ''))
|
|
35
|
+
return false;
|
|
36
|
+
if (parts.slice(0, -1).some(p => EXCLUDED_DIR.test(p)))
|
|
37
|
+
return false;
|
|
38
|
+
const file = parts.at(-1) ?? '';
|
|
39
|
+
return SRC_EXT.test(file) && !EXCLUDED_FILE.test(file) && !/\.(?:config|generated|gen|min|map|snap|lock)\.[^.]+$/i.test(file) && !/^\./.test(file);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Run Git in the selected checkout and return UTF-8 output.
|
|
43
|
+
*
|
|
44
|
+
* @param root Git checkout path.
|
|
45
|
+
* @param args Git command arguments.
|
|
46
|
+
* @param input Optional standard input for the command.
|
|
47
|
+
*
|
|
48
|
+
* @return The command's UTF-8 output.
|
|
49
|
+
*/
|
|
50
|
+
function git(root, args, input) {
|
|
51
|
+
return execFileSync('git', args, { cwd: root, encoding: 'utf8', input, maxBuffer: GIT_OUTPUT_LIMIT, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Run Git in the selected checkout and preserve binary object output.
|
|
55
|
+
*
|
|
56
|
+
* @param root Git checkout path.
|
|
57
|
+
* @param args Git command arguments.
|
|
58
|
+
* @param input Standard input for the command.
|
|
59
|
+
*
|
|
60
|
+
* @return The command's binary output.
|
|
61
|
+
*/
|
|
62
|
+
function gitBuffer(root, args, input) {
|
|
63
|
+
return execFileSync('git', args, { cwd: root, input, maxBuffer: GIT_OUTPUT_LIMIT, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
64
|
+
}
|
|
65
|
+
// hygiene-ignore single-use -- Keep the documented pushBase declaration so its parameter and return contract remains attached.
|
|
66
|
+
/**
|
|
67
|
+
* Read the before SHA from a GitHub push event when it is available.
|
|
68
|
+
*
|
|
69
|
+
* @return The push base SHA, or null when no usable base is present.
|
|
70
|
+
*/
|
|
71
|
+
function pushBase() {
|
|
72
|
+
const ePath = process.env.GITHUB_EVENT_PATH;
|
|
73
|
+
if (!ePath)
|
|
74
|
+
return null;
|
|
75
|
+
try {
|
|
76
|
+
const e = JSON.parse(readFileSync(ePath, 'utf8'));
|
|
77
|
+
return typeof e.before === 'string' && A_F_D_40_I_REGEX.test(e.before) && !/^0{40}$/.test(e.before) ? e.before : null;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Calculate source-line additions and deletions against a commit's first parent.
|
|
85
|
+
*
|
|
86
|
+
* @param root Git checkout path.
|
|
87
|
+
* @param head Commit whose source changes are measured.
|
|
88
|
+
* @param parents Commit parent SHAs.
|
|
89
|
+
* @param stats Per-commit source line totals to update.
|
|
90
|
+
*/
|
|
91
|
+
function srcChanges(root, head, parents, stats) {
|
|
92
|
+
if (!parents.length)
|
|
93
|
+
return;
|
|
94
|
+
for (const line of git(root, ['diff', '--numstat', '--no-renames', '--no-ext-diff', parents[0], head, '--']).split('\n')) {
|
|
95
|
+
if (!line)
|
|
96
|
+
continue;
|
|
97
|
+
const firstTab = line.indexOf('\t');
|
|
98
|
+
const secondTab = line.indexOf('\t', firstTab + 1);
|
|
99
|
+
if (firstTab < 0 || secondTab < 0)
|
|
100
|
+
continue;
|
|
101
|
+
if (!isHistorySourcePath(line.slice(secondTab + 1)))
|
|
102
|
+
continue;
|
|
103
|
+
const curr = stats.get(head) ?? { additions: 0, deletions: 0 };
|
|
104
|
+
curr.additions += line.slice(0, firstTab) === '-' ? 0 : Number(line.slice(0, firstTab));
|
|
105
|
+
curr.deletions += line.slice(firstTab + 1, secondTab) === '-' ? 0 : Number(line.slice(firstTab + 1, secondTab));
|
|
106
|
+
stats.set(head, curr);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// hygiene-ignore single-use -- Keep the documented readNumstatLog declaration so its parameter and return contract remains attached.
|
|
110
|
+
/**
|
|
111
|
+
* Read source-line stats for each commit and return merge commits for first-parent handling.
|
|
112
|
+
*
|
|
113
|
+
* @param root Git checkout path.
|
|
114
|
+
* @param range Git revision range to inspect.
|
|
115
|
+
* @param stats Per-commit source line totals to update.
|
|
116
|
+
*
|
|
117
|
+
* @return Merge commit SHAs requiring first-parent stats.
|
|
118
|
+
*/
|
|
119
|
+
function readNumstatLog(root, range, stats) {
|
|
120
|
+
const output = git(root, ['log', '-z', '--format=%x1e%H%x00%P%x00', '--numstat', '--no-renames', '--root', '--reverse', '--topo-order', range]);
|
|
121
|
+
const merges = new Set();
|
|
122
|
+
for (const block of output.split('\x1e')) {
|
|
123
|
+
if (!block)
|
|
124
|
+
continue;
|
|
125
|
+
const headerEnd = block.indexOf('\n');
|
|
126
|
+
const [sha, parents = ''] = (headerEnd < 0 ? block : block.slice(0, headerEnd)).replace(/^\n/, '').split('\x00');
|
|
127
|
+
if (!A_F_D_40_I_REGEX.test(sha))
|
|
128
|
+
continue;
|
|
129
|
+
if (parents.trim().split(S_REGEX).filter(Boolean).length > 1) {
|
|
130
|
+
merges.add(sha);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const curr = { additions: 0, deletions: 0 };
|
|
134
|
+
for (const entry of (headerEnd < 0 ? '' : block.slice(headerEnd + 1)).split('\x00')) {
|
|
135
|
+
const firstTab = entry.indexOf('\t');
|
|
136
|
+
const secondTab = entry.indexOf('\t', firstTab + 1);
|
|
137
|
+
if (firstTab < 0 || secondTab < 0 || !isHistorySourcePath(entry.slice(secondTab + 1)))
|
|
138
|
+
continue;
|
|
139
|
+
const added = entry.slice(0, firstTab);
|
|
140
|
+
const removed = entry.slice(firstTab + 1, secondTab);
|
|
141
|
+
curr.additions += added === '-' ? 0 : Number(added);
|
|
142
|
+
curr.deletions += removed === '-' ? 0 : Number(removed);
|
|
143
|
+
}
|
|
144
|
+
stats.set(sha, curr);
|
|
145
|
+
}
|
|
146
|
+
return merges;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Return eligible source blob IDs from a commit's tree.
|
|
150
|
+
*
|
|
151
|
+
* @param root Git checkout path.
|
|
152
|
+
* @param sha Commit SHA to inspect.
|
|
153
|
+
*
|
|
154
|
+
* @return Eligible blob IDs in the commit tree.
|
|
155
|
+
*/
|
|
156
|
+
function parseTree(root, sha) {
|
|
157
|
+
const tree = git(root, ['ls-tree', '-r', '-z', '--full-tree', sha]);
|
|
158
|
+
const blobs = [];
|
|
159
|
+
for (const entry of tree.split('\0')) {
|
|
160
|
+
const tab = entry.indexOf('\t');
|
|
161
|
+
if (tab < 0)
|
|
162
|
+
continue;
|
|
163
|
+
const [mode, type, blob] = entry.slice(0, tab).split(' ');
|
|
164
|
+
if (type === 'blob' && mode !== '120000' && isHistorySourcePath(entry.slice(tab + 1)))
|
|
165
|
+
blobs.push(blob);
|
|
166
|
+
}
|
|
167
|
+
return blobs;
|
|
168
|
+
}
|
|
169
|
+
// hygiene-ignore single-use -- Keep the documented isAncestor declaration so its parameter and return contract remains attached.
|
|
170
|
+
/**
|
|
171
|
+
* Check whether a push base is reachable from the checked-out head.
|
|
172
|
+
*
|
|
173
|
+
* @param root Git checkout path.
|
|
174
|
+
* @param base Push base SHA.
|
|
175
|
+
* @param head Checked-out head SHA.
|
|
176
|
+
*
|
|
177
|
+
* @return Whether base is an ancestor of head.
|
|
178
|
+
*/
|
|
179
|
+
function isAncestor(root, base, head) {
|
|
180
|
+
try {
|
|
181
|
+
execFileSync('git', ['merge-base', '--is-ancestor', base, head], { cwd: root, stdio: 'ignore' });
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Build a complete snapshot or push delta from the local Git object database.
|
|
190
|
+
*
|
|
191
|
+
* @param root Path to the full Git checkout.
|
|
192
|
+
* @param opts Optional repository, branch, or push-base overrides.
|
|
193
|
+
*
|
|
194
|
+
* @return A versioned history report with normalized commit counts.
|
|
195
|
+
*/
|
|
196
|
+
export function createHistoryReport(root, opts = {}) {
|
|
197
|
+
const headSha = git(root, ['rev-parse', 'HEAD']).trim();
|
|
198
|
+
const branch = opts.branch ?? process.env.GITHUB_REF_NAME ?? git(root, ['branch', '--show-current']).trim();
|
|
199
|
+
if (!branch)
|
|
200
|
+
throw new Error('Set GITHUB_REF_NAME or pass a checked-out branch to generate a history report.');
|
|
201
|
+
const base = opts.baseSha === undefined ? pushBase() : opts.baseSha;
|
|
202
|
+
const delta = !!base && isAncestor(root, base, headSha);
|
|
203
|
+
const range = delta ? `${base}..${headSha}` : headSha;
|
|
204
|
+
const commits = (function commitMetadata(root, range) {
|
|
205
|
+
return git(root, ['log', '--format=%H%x00%aI%x00%P', '--reverse', '--topo-order', range])
|
|
206
|
+
.trim()
|
|
207
|
+
.split('\n')
|
|
208
|
+
.filter(Boolean)
|
|
209
|
+
.map(l => {
|
|
210
|
+
const [sha, authorDate, parents = ''] = l.split('\x00');
|
|
211
|
+
if (!A_F_D_40_I_REGEX.test(sha) || !Number.isFinite(Date.parse(authorDate)))
|
|
212
|
+
throw new Error('Git returned invalid commit metadata.');
|
|
213
|
+
return { sha, authorDate, parents: parents.trim().split(S_REGEX).filter(Boolean) };
|
|
214
|
+
});
|
|
215
|
+
})(root, range);
|
|
216
|
+
const changes = new Map();
|
|
217
|
+
const merges = readNumstatLog(root, range, changes);
|
|
218
|
+
for (const commit of commits)
|
|
219
|
+
if (merges.has(commit.sha))
|
|
220
|
+
srcChanges(root, commit.sha, commit.parents, changes);
|
|
221
|
+
const lineCounts = new Map();
|
|
222
|
+
const reportCommits = [];
|
|
223
|
+
for (let start = 0; start < commits.length; start += HISTORY_BATCH_SIZE) {
|
|
224
|
+
const batch = commits.slice(start, start + HISTORY_BATCH_SIZE).map(c => ({ commit: c, blobs: parseTree(root, c.sha) }));
|
|
225
|
+
(function blobLineCounts(root, blobs, cache) {
|
|
226
|
+
const unknown = [...new Set(blobs)].filter(s => !cache.has(s));
|
|
227
|
+
for (let start = 0; start < unknown.length; start += BLOB_BATCH_SIZE) {
|
|
228
|
+
const batch = unknown.slice(start, start + BLOB_BATCH_SIZE);
|
|
229
|
+
const output = gitBuffer(root, ['cat-file', '--batch'], `${batch.join('\n')}\n`);
|
|
230
|
+
let offset = 0;
|
|
231
|
+
for (const sha of batch) {
|
|
232
|
+
const headerEnd = output.indexOf(10, offset);
|
|
233
|
+
if (headerEnd < 0)
|
|
234
|
+
throw new Error(`Git did not return blob ${sha}.`);
|
|
235
|
+
const header = output.toString('utf8', offset, headerEnd).split(' ');
|
|
236
|
+
if (header[0] !== sha || header[1] !== 'blob')
|
|
237
|
+
throw new Error(`Git returned an invalid object for ${sha}.`);
|
|
238
|
+
const contentStart = headerEnd + 1;
|
|
239
|
+
const contentEnd = contentStart + Number(header[2]);
|
|
240
|
+
cache.set(sha, (function lineCount(content) {
|
|
241
|
+
if (!content.length)
|
|
242
|
+
return 0;
|
|
243
|
+
let lines = 0;
|
|
244
|
+
for (const byte of content)
|
|
245
|
+
if (byte === 10)
|
|
246
|
+
lines++;
|
|
247
|
+
return content.at(-1) === 10 ? lines : lines + 1;
|
|
248
|
+
})(output.subarray(contentStart, contentEnd)));
|
|
249
|
+
offset = contentEnd + 1;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
})(root, batch.flatMap(i => i.blobs), lineCounts);
|
|
253
|
+
for (const { commit, blobs } of batch) {
|
|
254
|
+
const changed = changes.get(commit.sha) ?? { additions: 0, deletions: 0 };
|
|
255
|
+
reportCommits.push({
|
|
256
|
+
sha: commit.sha,
|
|
257
|
+
authorDate: commit.authorDate,
|
|
258
|
+
additions: changed.additions,
|
|
259
|
+
deletions: changed.deletions,
|
|
260
|
+
sourceLines: blobs.reduce((t, b) => t + (lineCounts.get(b) ?? 0), 0),
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
schemaVersion: 1,
|
|
266
|
+
mode: delta ? 'delta' : 'snapshot',
|
|
267
|
+
repository: opts.repository ??
|
|
268
|
+
(function repoName(root) {
|
|
269
|
+
const fromEnv = process.env.GITHUB_REPOSITORY;
|
|
270
|
+
if (fromEnv && /^[^/]+\/[^/]+$/.test(fromEnv))
|
|
271
|
+
return fromEnv.replace(GIT_I_REGEX, '');
|
|
272
|
+
const match = git(root, ['config', '--get', 'remote.origin.url'])
|
|
273
|
+
.trim()
|
|
274
|
+
.match(/(?:github\.com[:/])([^/]+\/[^/]+?)(?:\.git)?$/i);
|
|
275
|
+
if (!match)
|
|
276
|
+
throw new Error('Set GITHUB_REPOSITORY or use a GitHub origin remote to generate a history report.');
|
|
277
|
+
return match[1].replace(GIT_I_REGEX, '');
|
|
278
|
+
})(root),
|
|
279
|
+
branch,
|
|
280
|
+
headSha,
|
|
281
|
+
baseSha: delta ? base : null,
|
|
282
|
+
generatedAt: new Date().toISOString(),
|
|
283
|
+
commits: reportCommits,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Write a generated report to a JSON file in the checkout.
|
|
288
|
+
*
|
|
289
|
+
* @param root Path to the full Git checkout.
|
|
290
|
+
* @param path Output path relative to the checkout.
|
|
291
|
+
* @param opts Optional repository, branch, or push-base overrides.
|
|
292
|
+
*
|
|
293
|
+
* @return The generated history report.
|
|
294
|
+
*/
|
|
295
|
+
export function writeHistoryReport(root, path, opts) {
|
|
296
|
+
const report = createHistoryReport(root, opts);
|
|
297
|
+
writeFileSync(resolve(root, path), `${JSON.stringify(report, null, 2)}\n`);
|
|
298
|
+
return report;
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=history-report.js.map
|
|
@@ -0,0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
+
* Per-case progress reporter for the Node.js test runner.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Describes the subset of Node test events used for progress and case summaries.
|
|
7
|
+
*/
|
|
8
|
+
type NodeTestE = {
|
|
9
|
+
type: string;
|
|
10
|
+
data?: {
|
|
11
|
+
name?: string;
|
|
12
|
+
nesting?: number;
|
|
13
|
+
type?: string;
|
|
14
|
+
testId?: number;
|
|
15
|
+
testNumber?: number;
|
|
16
|
+
file?: string;
|
|
17
|
+
line?: number;
|
|
18
|
+
skip?: boolean | string;
|
|
19
|
+
todo?: boolean | string;
|
|
20
|
+
counts?: {
|
|
21
|
+
tests?: number;
|
|
22
|
+
passed?: number;
|
|
23
|
+
failed?: number;
|
|
24
|
+
skipped?: number;
|
|
25
|
+
todo?: number;
|
|
26
|
+
cancelled?: number;
|
|
27
|
+
};
|
|
28
|
+
details?: {
|
|
29
|
+
type?: string;
|
|
30
|
+
passed?: boolean;
|
|
31
|
+
skip?: boolean | string;
|
|
32
|
+
todo?: boolean | string;
|
|
33
|
+
error?: {
|
|
34
|
+
message?: string;
|
|
35
|
+
} | string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Replaces any inherited Node test reporter with the shared quality reporter.
|
|
41
|
+
*
|
|
42
|
+
* @param curr Existing `NODE_OPTIONS`, if set.
|
|
43
|
+
* @param reporterUrl URL of the compiled shared reporter.
|
|
44
|
+
*
|
|
45
|
+
* @return Node options that retain unrelated flags and select one quality reporter.
|
|
46
|
+
*/
|
|
47
|
+
export declare function qualityNodeReporterOptions(curr: string | undefined, reporterUrl: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Node.js custom test reporter with one progress unit per non-suite test.
|
|
50
|
+
*
|
|
51
|
+
* Node 24's `test:complete` events provide execution-order progress and
|
|
52
|
+
* file-scoped test IDs. The reporter also handles Node 18's older enqueue
|
|
53
|
+
* events, which omit test IDs and suite types, by correlating source metadata
|
|
54
|
+
* with terminal events. Discovery can continue while earlier files finish, so
|
|
55
|
+
* live updates leave the line open and finalize once the event stream ends.
|
|
56
|
+
* Test stdout, stderr, and diagnostics are intentionally ignored to avoid
|
|
57
|
+
* replaying output already written by child processes.
|
|
58
|
+
*
|
|
59
|
+
* @param src Node.js test event stream.
|
|
60
|
+
* @param opts Optional writer used by focused tests; opaque reporter arguments are ignored.
|
|
61
|
+
*
|
|
62
|
+
* @return The per-case result lines accepted by the Node reporter API.
|
|
63
|
+
*/
|
|
64
|
+
export declare function qualityNodeReporter(src: AsyncIterable<NodeTestE>, opts?: unknown): AsyncGenerator<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Uses the shared reporter once in each test-runner process tree.
|
|
67
|
+
*
|
|
68
|
+
* Node propagates NODE_OPTIONS to isolated test workers and nested child
|
|
69
|
+
* processes. The first runner owns progress; nested runners drain their event
|
|
70
|
+
* streams so they cannot replay the same suite output.
|
|
71
|
+
*
|
|
72
|
+
* @param src Node.js test event stream.
|
|
73
|
+
* @param opts Optional writer used by focused tests; opaque reporter arguments are ignored.
|
|
74
|
+
*
|
|
75
|
+
* @return The per-case result lines accepted by the Node reporter API.
|
|
76
|
+
*/
|
|
77
|
+
declare function defaultQualityNodeReporter(src: AsyncIterable<NodeTestE>, opts?: unknown): AsyncGenerator<string>;
|
|
78
|
+
export default defaultQualityNodeReporter;
|
|
79
|
+
//# sourceMappingURL=node-reporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-reporter.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/reports/lib/node-reporter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH;;GAEG;AACH,KAAK,SAAS,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC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,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/hygiene/src/capabilities/reports/lib/node-reporter.ts
|
|
3
|
+
* Per-case progress reporter for the Node.js test runner.
|
|
4
|
+
*/
|
|
5
|
+
/*//////////////////////////////////////////////////
|
|
6
|
+
IMPORTS
|
|
7
|
+
//////////////////////////////////////////////////*/
|
|
8
|
+
// API
|
|
9
|
+
import { qualityProgress } from '@terra-symposium/hygiene/core';
|
|
10
|
+
/*//////////////////////////////////////////////////
|
|
11
|
+
OPTIONS
|
|
12
|
+
//////////////////////////////////////////////////*/
|
|
13
|
+
/**
|
|
14
|
+
* Replaces any inherited Node test reporter with the shared quality reporter.
|
|
15
|
+
*
|
|
16
|
+
* @param curr Existing `NODE_OPTIONS`, if set.
|
|
17
|
+
* @param reporterUrl URL of the compiled shared reporter.
|
|
18
|
+
*
|
|
19
|
+
* @return Node options that retain unrelated flags and select one quality reporter.
|
|
20
|
+
*/
|
|
21
|
+
export function qualityNodeReporterOptions(curr, reporterUrl) {
|
|
22
|
+
const opts = curr?.match(/(?:[^\s"'=]+=)?(?:"[^"]*"|'[^']*'|[^\s]+)/gu) ?? [];
|
|
23
|
+
const retained = [];
|
|
24
|
+
for (let idx = 0; idx < opts.length; idx++) {
|
|
25
|
+
const opt = opts[idx];
|
|
26
|
+
if (opt === '--test-reporter' || opt === '--test-reporter-destination') {
|
|
27
|
+
idx++;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (opt.startsWith('--test-reporter=') || opt.startsWith('--test-reporter-destination='))
|
|
31
|
+
continue;
|
|
32
|
+
retained.push(opt);
|
|
33
|
+
}
|
|
34
|
+
return [...retained, `--test-reporter=${reporterUrl}`, '--test-reporter-destination=stdout'].join(' ');
|
|
35
|
+
}
|
|
36
|
+
/*//////////////////////////////////////////////////
|
|
37
|
+
HELPERS
|
|
38
|
+
//////////////////////////////////////////////////*/
|
|
39
|
+
/*//////////////////////////////////////////////////
|
|
40
|
+
REPORTER
|
|
41
|
+
//////////////////////////////////////////////////*/
|
|
42
|
+
/**
|
|
43
|
+
* Node.js custom test reporter with one progress unit per non-suite test.
|
|
44
|
+
*
|
|
45
|
+
* Node 24's `test:complete` events provide execution-order progress and
|
|
46
|
+
* file-scoped test IDs. The reporter also handles Node 18's older enqueue
|
|
47
|
+
* events, which omit test IDs and suite types, by correlating source metadata
|
|
48
|
+
* with terminal events. Discovery can continue while earlier files finish, so
|
|
49
|
+
* live updates leave the line open and finalize once the event stream ends.
|
|
50
|
+
* Test stdout, stderr, and diagnostics are intentionally ignored to avoid
|
|
51
|
+
* replaying output already written by child processes.
|
|
52
|
+
*
|
|
53
|
+
* @param src Node.js test event stream.
|
|
54
|
+
* @param opts Optional writer used by focused tests; opaque reporter arguments are ignored.
|
|
55
|
+
*
|
|
56
|
+
* @return The per-case result lines accepted by the Node reporter API.
|
|
57
|
+
*/
|
|
58
|
+
export async function* qualityNodeReporter(src, opts) {
|
|
59
|
+
const reportProgress = typeof opts === 'function' ? opts : (text) => void process.stderr.write(text);
|
|
60
|
+
let enqueued = 0;
|
|
61
|
+
let completed = 0;
|
|
62
|
+
const counts = { PASS: 0, FAIL: 0, SKIP: 0 };
|
|
63
|
+
let hasProgress = false;
|
|
64
|
+
let lastProgressCompleted = -1;
|
|
65
|
+
let lastProgressTotal = -1;
|
|
66
|
+
let terminalProtocol;
|
|
67
|
+
let summaryCounts;
|
|
68
|
+
const pendingByIdentity = new Map();
|
|
69
|
+
const seenTerminal = new Set();
|
|
70
|
+
/**
|
|
71
|
+
* Builds a stable key shared by matching enqueue and terminal test events.
|
|
72
|
+
*
|
|
73
|
+
* @param data Event metadata used to identify the test.
|
|
74
|
+
* @param terminal Whether terminal-only event numbers may identify the test.
|
|
75
|
+
*
|
|
76
|
+
* @return Serialized identity key for the pending event queues.
|
|
77
|
+
*/
|
|
78
|
+
const identity = (data, terminal = false) => {
|
|
79
|
+
const file = data?.file ?? '';
|
|
80
|
+
if (data?.testId !== undefined)
|
|
81
|
+
return JSON.stringify([file, 'id', data.testId]) ?? '';
|
|
82
|
+
if (terminal && data?.testNumber !== undefined)
|
|
83
|
+
return JSON.stringify([file, 'number', data.testNumber]) ?? '';
|
|
84
|
+
return JSON.stringify([file, 'source', data?.line ?? null, data?.nesting ?? 0, data?.name ?? 'unnamed test']) ?? '';
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Recognizes top-level test-file suite events that must not count as cases.
|
|
88
|
+
*
|
|
89
|
+
* @param data Event metadata to classify.
|
|
90
|
+
*
|
|
91
|
+
* @return Whether the event describes a test file rather than an individual case.
|
|
92
|
+
*/
|
|
93
|
+
const isFileSuite = (data) => {
|
|
94
|
+
if (data?.nesting !== 0 || !data.name)
|
|
95
|
+
return false;
|
|
96
|
+
/**
|
|
97
|
+
* Extracts the last path segment after file URL and separator normalization.
|
|
98
|
+
*
|
|
99
|
+
* @param path File path or URL from test-runner metadata.
|
|
100
|
+
*
|
|
101
|
+
* @return Final path component, or an empty string for an empty path.
|
|
102
|
+
*/
|
|
103
|
+
const basename = (path) => path
|
|
104
|
+
.replace(/^file:\/\//u, '')
|
|
105
|
+
.replace(/\\/gu, '/')
|
|
106
|
+
.split('/')
|
|
107
|
+
.at(-1) ?? '';
|
|
108
|
+
return (data.name === data.file ||
|
|
109
|
+
(data.file !== undefined && basename(data.name) === basename(data.file)) ||
|
|
110
|
+
(/(?:^|[/\\])[^/\\]+\.(?:test|spec)\.(?:[cm]?js|tsx?)$/u.test(data.name) && (data.file === undefined || data.line === 1)));
|
|
111
|
+
};
|
|
112
|
+
/** Updates displayed test progress from the current event counts. */
|
|
113
|
+
const liveProgress = () => {
|
|
114
|
+
lastProgressCompleted = completed;
|
|
115
|
+
lastProgressTotal = Math.max(completed, enqueued);
|
|
116
|
+
qualityProgress('Cases', lastProgressCompleted, lastProgressTotal, reportProgress, { finalize: false });
|
|
117
|
+
};
|
|
118
|
+
const rememberPending = (data, counted) => {
|
|
119
|
+
const key = identity(data);
|
|
120
|
+
pendingByIdentity.set(key, [...(pendingByIdentity.get(key) ?? []), { counted }]);
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Removes and returns the oldest enqueue record matching a terminal event.
|
|
124
|
+
*
|
|
125
|
+
* @param data Event metadata used to build the matching identity key.
|
|
126
|
+
*
|
|
127
|
+
* @return Pending enqueue record, or `undefined` when none is waiting.
|
|
128
|
+
*/
|
|
129
|
+
const takePending = (data) => {
|
|
130
|
+
const key = identity(data);
|
|
131
|
+
const entries = pendingByIdentity.get(key) ?? [];
|
|
132
|
+
const [pending] = entries.splice(0, 1);
|
|
133
|
+
if (entries.length)
|
|
134
|
+
pendingByIdentity.set(key, entries);
|
|
135
|
+
else
|
|
136
|
+
pendingByIdentity.delete(key);
|
|
137
|
+
return pending;
|
|
138
|
+
};
|
|
139
|
+
for await (const e of src) {
|
|
140
|
+
if (e.type === 'test:summary') {
|
|
141
|
+
const data = e.data;
|
|
142
|
+
if (data?.file === undefined && data?.counts)
|
|
143
|
+
summaryCounts = data.counts;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (e.type === 'test:enqueue') {
|
|
147
|
+
if (isFileSuite(e.data))
|
|
148
|
+
continue;
|
|
149
|
+
const counted = e.data?.type !== 'suite';
|
|
150
|
+
if (counted)
|
|
151
|
+
enqueued += 1;
|
|
152
|
+
rememberPending(e.data, counted);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (e.type !== 'test:complete' && e.type !== 'test:pass' && e.type !== 'test:fail')
|
|
156
|
+
continue;
|
|
157
|
+
const protocol = e.type === 'test:complete' ? 'complete' : 'legacy';
|
|
158
|
+
terminalProtocol ??= protocol;
|
|
159
|
+
if (protocol !== terminalProtocol)
|
|
160
|
+
continue;
|
|
161
|
+
const data = e.data;
|
|
162
|
+
if (isFileSuite(data))
|
|
163
|
+
continue;
|
|
164
|
+
const details = data?.details;
|
|
165
|
+
// hygiene-ignore single-use -- Classify the event before identity and pending-state updates.
|
|
166
|
+
const isSuite = details?.type === 'suite' || data?.type === 'suite';
|
|
167
|
+
const terminalKey = identity(data, true);
|
|
168
|
+
if (seenTerminal.has(terminalKey))
|
|
169
|
+
continue;
|
|
170
|
+
seenTerminal.add(terminalKey);
|
|
171
|
+
const pending = takePending(data);
|
|
172
|
+
if (isSuite) {
|
|
173
|
+
if (pending?.counted) {
|
|
174
|
+
enqueued = Math.max(completed, enqueued - 1);
|
|
175
|
+
if (hasProgress)
|
|
176
|
+
liveProgress();
|
|
177
|
+
}
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (pending && !pending.counted)
|
|
181
|
+
enqueued += 1;
|
|
182
|
+
completed += 1;
|
|
183
|
+
liveProgress();
|
|
184
|
+
hasProgress = true;
|
|
185
|
+
const failed = e.type === 'test:fail' || (e.type === 'test:complete' && details?.passed === false);
|
|
186
|
+
// hygiene-ignore single-use -- Read skip before todo even when skip alone determines the status.
|
|
187
|
+
const skip = details?.skip ?? data?.skip;
|
|
188
|
+
// hygiene-ignore single-use -- Read todo before status selection even when skip is already set.
|
|
189
|
+
const todo = details?.todo ?? data?.todo;
|
|
190
|
+
const status = skip || (todo && failed) ? 'SKIP' : failed ? 'FAIL' : 'PASS';
|
|
191
|
+
counts[status] += 1;
|
|
192
|
+
if (status !== 'PASS')
|
|
193
|
+
yield (function fmtNodeResult(e, status) {
|
|
194
|
+
const data = e.data;
|
|
195
|
+
const err = data?.details?.error;
|
|
196
|
+
const msg = typeof err === 'string' ? err : err?.message;
|
|
197
|
+
return `${' '.repeat(Math.max(0, data?.nesting ?? 0))}[${status}] ${data?.name ?? 'unnamed test'}${status === 'FAIL' && msg ? ` — ${msg.replace(/\s+/gu, ' ').trim()}` : ''}\n`;
|
|
198
|
+
})(e, status);
|
|
199
|
+
}
|
|
200
|
+
const total = summaryCounts?.tests ?? enqueued;
|
|
201
|
+
const finalCompleted = summaryCounts?.tests ?? completed;
|
|
202
|
+
if (summaryCounts) {
|
|
203
|
+
counts.PASS = summaryCounts.passed ?? counts.PASS;
|
|
204
|
+
counts.FAIL = summaryCounts.failed ?? counts.FAIL;
|
|
205
|
+
counts.SKIP = (summaryCounts.skipped ?? 0) + (summaryCounts.todo ?? 0) + (summaryCounts.cancelled ?? 0);
|
|
206
|
+
}
|
|
207
|
+
if (!hasProgress && total === 0)
|
|
208
|
+
qualityProgress('Cases', 0, 0, reportProgress, { finalize: true });
|
|
209
|
+
else if (lastProgressCompleted === finalCompleted && lastProgressTotal === total)
|
|
210
|
+
reportProgress('\n');
|
|
211
|
+
else
|
|
212
|
+
qualityProgress('Cases', finalCompleted, total, reportProgress, { finalize: true });
|
|
213
|
+
if (finalCompleted < total)
|
|
214
|
+
yield `Node tests incomplete: ${total - finalCompleted} enqueued cases did not report a result\n`;
|
|
215
|
+
yield `Node tests: ${counts.PASS} passed, ${counts.FAIL} failed, ${counts.SKIP} skipped\n`;
|
|
216
|
+
}
|
|
217
|
+
// hygiene-ignore single-use -- Keep the documented defaultQualityNodeReporter declaration so its parameter and return contract remains attached.
|
|
218
|
+
/**
|
|
219
|
+
* Uses the shared reporter once in each test-runner process tree.
|
|
220
|
+
*
|
|
221
|
+
* Node propagates NODE_OPTIONS to isolated test workers and nested child
|
|
222
|
+
* processes. The first runner owns progress; nested runners drain their event
|
|
223
|
+
* streams so they cannot replay the same suite output.
|
|
224
|
+
*
|
|
225
|
+
* @param src Node.js test event stream.
|
|
226
|
+
* @param opts Optional writer used by focused tests; opaque reporter arguments are ignored.
|
|
227
|
+
*
|
|
228
|
+
* @return The per-case result lines accepted by the Node reporter API.
|
|
229
|
+
*/
|
|
230
|
+
async function* defaultQualityNodeReporter(src, opts) {
|
|
231
|
+
const isTestWorker = process.env.NODE_TEST_CONTEXT === 'child-v8';
|
|
232
|
+
// hygiene-ignore single-use -- Capture ownership before clearing the environment marker in test workers.
|
|
233
|
+
const ownsReporter = process.env.TERRA_QUALITY_NODE_REPORTER_OWNER === '1' && !isTestWorker;
|
|
234
|
+
if (isTestWorker)
|
|
235
|
+
delete process.env.TERRA_QUALITY_NODE_REPORTER_OWNER;
|
|
236
|
+
if (!ownsReporter) {
|
|
237
|
+
for await (const _event of src)
|
|
238
|
+
void _event;
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
yield* qualityNodeReporter(src, opts);
|
|
242
|
+
}
|
|
243
|
+
export default defaultQualityNodeReporter;
|
|
244
|
+
//# sourceMappingURL=node-reporter.js.map
|