@repometry/cli 0.0.0-stage → 0.0.0
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/LICENSE +21 -0
- package/README.md +70 -2
- package/package.json +75 -4
- package/target/main/resources/language-catalog.json +61 -0
- package/target/main/resources/report/json/compact-json-v1.schema.json +24 -0
- package/target/main/resources/report/json/comparison-v1.schema.json +65 -0
- package/target/main/resources/report/json/config-v2.schema.json +224 -0
- package/target/main/resources/report/json/diff-coverage-v1.schema.json +55 -0
- package/target/main/resources/report/json/file-metrics-v1.schema.json +157 -0
- package/target/main/resources/report/json/metabranch-v1.schema.json +9 -0
- package/target/main/resources/report/json/metric-catalog-v1.schema.json +31 -0
- package/target/main/resources/report/json/pull-review-v1.schema.json +97 -0
- package/target/main/resources/report/json/pull-review-v2.schema.json +100 -0
- package/target/main/resources/report/json/report-v2.schema.json +530 -0
- package/target/main/resources/report/json/repository-summary-v1.schema.json +337 -0
- package/target/main/resources/report/json/viewer-inspection-v1.schema.json +534 -0
- package/target/main/resources/viewer/files.css +616 -0
- package/target/main/resources/viewer/index.html +120 -0
- package/target/main/resources/viewer/projects.html +52 -0
- package/target/main/resources/viewer/styles.css +579 -0
- package/target/main/resources/viewer/viewer-pulls.css +64 -0
- package/target/main/ts/api/cache/root.d.ts +2 -0
- package/target/main/ts/api/cache/root.js +21 -0
- package/target/main/ts/api/gh/github.d.ts +4 -0
- package/target/main/ts/api/gh/github.js +47 -0
- package/target/main/ts/api/git/blob-batch.d.ts +10 -0
- package/target/main/ts/api/git/blob-batch.js +107 -0
- package/target/main/ts/api/git/blob-history.d.ts +20 -0
- package/target/main/ts/api/git/blob-history.js +54 -0
- package/target/main/ts/api/git/changes.d.ts +27 -0
- package/target/main/ts/api/git/changes.js +117 -0
- package/target/main/ts/api/git/commit-metadata.d.ts +2 -0
- package/target/main/ts/api/git/commit-metadata.js +46 -0
- package/target/main/ts/api/git/git-churn.d.ts +9 -0
- package/target/main/ts/api/git/git-churn.js +72 -0
- package/target/main/ts/api/git/git-executable.d.ts +1 -0
- package/target/main/ts/api/git/git-executable.js +31 -0
- package/target/main/ts/api/git/git-reader.d.ts +24 -0
- package/target/main/ts/api/git/git-reader.js +113 -0
- package/target/main/ts/api/git/git.d.ts +47 -0
- package/target/main/ts/api/git/git.js +289 -0
- package/target/main/ts/api/git/inspection-source.d.ts +17 -0
- package/target/main/ts/api/git/inspection-source.js +36 -0
- package/target/main/ts/api/git/line-changes.d.ts +6 -0
- package/target/main/ts/api/git/line-changes.js +57 -0
- package/target/main/ts/api/git/local-sources.d.ts +5 -0
- package/target/main/ts/api/git/local-sources.js +48 -0
- package/target/main/ts/api/git/local.d.ts +7 -0
- package/target/main/ts/api/git/local.js +106 -0
- package/target/main/ts/api/git/source-cache.d.ts +1 -0
- package/target/main/ts/api/git/source-cache.js +42 -0
- package/target/main/ts/api/import/cobertura.d.ts +2 -0
- package/target/main/ts/api/import/cobertura.js +160 -0
- package/target/main/ts/api/import/coverage-xml.d.ts +7 -0
- package/target/main/ts/api/import/coverage-xml.js +135 -0
- package/target/main/ts/api/import/finding-import.d.ts +9 -0
- package/target/main/ts/api/import/finding-import.js +227 -0
- package/target/main/ts/api/import/go-cover.d.ts +13 -0
- package/target/main/ts/api/import/go-cover.js +150 -0
- package/target/main/ts/api/import/lcov-files.d.ts +12 -0
- package/target/main/ts/api/import/lcov-files.js +53 -0
- package/target/main/ts/api/import/profile-file.d.ts +4 -0
- package/target/main/ts/api/import/profile-file.js +17 -0
- package/target/main/ts/api/process/docker-tool-runner.d.ts +13 -0
- package/target/main/ts/api/process/docker-tool-runner.js +92 -0
- package/target/main/ts/api/process/failure.d.ts +1 -0
- package/target/main/ts/api/process/failure.js +12 -0
- package/target/main/ts/api/process/plugin.d.ts +13 -0
- package/target/main/ts/api/process/plugin.js +100 -0
- package/target/main/ts/api/process/tool-snapshot.d.ts +3 -0
- package/target/main/ts/api/process/tool-snapshot.js +26 -0
- package/target/main/ts/cli/arguments.d.ts +28 -0
- package/target/main/ts/cli/arguments.js +109 -0
- package/target/main/ts/cli/config.d.ts +63 -0
- package/target/main/ts/cli/config.js +165 -0
- package/target/main/ts/cli/imports.d.ts +9 -0
- package/target/main/ts/cli/imports.js +37 -0
- package/target/main/ts/cli/main.d.ts +2 -0
- package/target/main/ts/cli/main.js +4 -0
- package/target/main/ts/cli/range-inspection.d.ts +38 -0
- package/target/main/ts/cli/range-inspection.js +34 -0
- package/target/main/ts/cli/range-jobs.d.ts +23 -0
- package/target/main/ts/cli/range-jobs.js +152 -0
- package/target/main/ts/cli/range-worker.d.ts +1 -0
- package/target/main/ts/cli/range-worker.js +40 -0
- package/target/main/ts/cli/reporting.d.ts +42 -0
- package/target/main/ts/cli/reporting.js +98 -0
- package/target/main/ts/cli/revisions.d.ts +6 -0
- package/target/main/ts/cli/revisions.js +16 -0
- package/target/main/ts/cli/run.d.ts +2 -0
- package/target/main/ts/cli/run.js +306 -0
- package/target/main/ts/cli/store.d.ts +13 -0
- package/target/main/ts/cli/store.js +39 -0
- package/target/main/ts/compose/analysis-report.d.ts +6 -0
- package/target/main/ts/compose/analysis-report.js +131 -0
- package/target/main/ts/compose/analysis-results.d.ts +42 -0
- package/target/main/ts/compose/analysis-results.js +84 -0
- package/target/main/ts/compose/analysis-steps.d.ts +23 -0
- package/target/main/ts/compose/analysis-steps.js +217 -0
- package/target/main/ts/compose/analyze-snapshot.d.ts +7 -0
- package/target/main/ts/compose/analyze-snapshot.js +21 -0
- package/target/main/ts/compose/attach-churn.d.ts +2 -0
- package/target/main/ts/compose/attach-churn.js +50 -0
- package/target/main/ts/compose/built-ins.d.ts +6 -0
- package/target/main/ts/compose/built-ins.js +12 -0
- package/target/main/ts/compose/diff-coverage.d.ts +25 -0
- package/target/main/ts/compose/diff-coverage.js +82 -0
- package/target/main/ts/compose/distribution.d.ts +17 -0
- package/target/main/ts/compose/distribution.js +13 -0
- package/target/main/ts/compose/docker-image.d.ts +5 -0
- package/target/main/ts/compose/docker-image.js +49 -0
- package/target/main/ts/compose/file-selection.d.ts +9 -0
- package/target/main/ts/compose/file-selection.js +38 -0
- package/target/main/ts/compose/history-cache.d.ts +31 -0
- package/target/main/ts/compose/history-cache.js +62 -0
- package/target/main/ts/compose/inspect.d.ts +34 -0
- package/target/main/ts/compose/inspect.js +51 -0
- package/target/main/ts/compose/inspection-coverage.d.ts +9 -0
- package/target/main/ts/compose/inspection-coverage.js +9 -0
- package/target/main/ts/compose/js-plugin.d.ts +113 -0
- package/target/main/ts/compose/js-plugin.js +99 -0
- package/target/main/ts/compose/language-discovery.d.ts +12 -0
- package/target/main/ts/compose/language-discovery.js +51 -0
- package/target/main/ts/compose/languages.d.ts +64 -0
- package/target/main/ts/compose/languages.js +98 -0
- package/target/main/ts/compose/load-plugins.d.ts +6 -0
- package/target/main/ts/compose/load-plugins.js +71 -0
- package/target/main/ts/compose/parser-order.d.ts +20 -0
- package/target/main/ts/compose/parser-order.js +90 -0
- package/target/main/ts/compose/phases.d.ts +140 -0
- package/target/main/ts/compose/phases.js +147 -0
- package/target/main/ts/compose/plugin-list.d.ts +37 -0
- package/target/main/ts/compose/plugin-list.js +30 -0
- package/target/main/ts/compose/plugin-manifest.d.ts +14 -0
- package/target/main/ts/compose/plugin-manifest.js +50 -0
- package/target/main/ts/compose/plugin-options.d.ts +2 -0
- package/target/main/ts/compose/plugin-options.js +29 -0
- package/target/main/ts/compose/plugin-reference.d.ts +9 -0
- package/target/main/ts/compose/plugin-reference.js +40 -0
- package/target/main/ts/compose/plugin-requirements.d.ts +5 -0
- package/target/main/ts/compose/plugin-requirements.js +83 -0
- package/target/main/ts/compose/plugin-scope.d.ts +9 -0
- package/target/main/ts/compose/plugin-scope.js +60 -0
- package/target/main/ts/compose/process-plugins.d.ts +89 -0
- package/target/main/ts/compose/process-plugins.js +74 -0
- package/target/main/ts/compose/registered-plugin.d.ts +17 -0
- package/target/main/ts/compose/registered-plugin.js +8 -0
- package/target/main/ts/compose/review.d.ts +26 -0
- package/target/main/ts/compose/review.js +54 -0
- package/target/main/ts/compose/schema-error.d.ts +2 -0
- package/target/main/ts/compose/schema-error.js +16 -0
- package/target/main/ts/compose/sources.d.ts +2 -0
- package/target/main/ts/compose/sources.js +32 -0
- package/target/main/ts/compose/structure-measures.d.ts +9 -0
- package/target/main/ts/compose/structure-measures.js +63 -0
- package/target/main/ts/index.d.ts +8 -0
- package/target/main/ts/index.js +5 -0
- package/target/main/ts/plugin.d.ts +2 -0
- package/target/main/ts/plugin.js +2 -0
- package/target/main/ts/plugins/built-in.d.ts +3 -0
- package/target/main/ts/plugins/built-in.js +19 -0
- package/target/main/ts/plugins/coverage/coverage.d.ts +11 -0
- package/target/main/ts/plugins/coverage/coverage.js +289 -0
- package/target/main/ts/plugins/coverage/diff-coverage.d.ts +3 -0
- package/target/main/ts/plugins/coverage/diff-coverage.js +85 -0
- package/target/main/ts/plugins/duplication/duplication.d.ts +2 -0
- package/target/main/ts/plugins/duplication/duplication.js +95 -0
- package/target/main/ts/plugins/language-js/babel-provider.d.ts +10 -0
- package/target/main/ts/plugins/language-js/babel-provider.js +54 -0
- package/target/main/ts/plugins/language-js/clone-candidates.d.ts +3 -0
- package/target/main/ts/plugins/language-js/clone-candidates.js +65 -0
- package/target/main/ts/plugins/language-js/code-lines.d.ts +6 -0
- package/target/main/ts/plugins/language-js/code-lines.js +36 -0
- package/target/main/ts/plugins/language-js/extensions.d.ts +1 -0
- package/target/main/ts/plugins/language-js/extensions.js +3 -0
- package/target/main/ts/plugins/language-js/function-facts.d.ts +9 -0
- package/target/main/ts/plugins/language-js/function-facts.js +74 -0
- package/target/main/ts/plugins/language-js/js-security.d.ts +4 -0
- package/target/main/ts/plugins/language-js/js-security.js +497 -0
- package/target/main/ts/plugins/language-js/qualified-names.d.ts +11 -0
- package/target/main/ts/plugins/language-js/qualified-names.js +63 -0
- package/target/main/ts/plugins/language-js/structural-observations.d.ts +9 -0
- package/target/main/ts/plugins/language-js/structural-observations.js +85 -0
- package/target/main/ts/plugins/language-js/syntax.d.ts +2 -0
- package/target/main/ts/plugins/language-js/syntax.js +11 -0
- package/target/main/ts/plugins/maintainability/maintainability.d.ts +2 -0
- package/target/main/ts/plugins/maintainability/maintainability.js +38 -0
- package/target/main/ts/plugins/maintainability/structural-smells.d.ts +3 -0
- package/target/main/ts/plugins/maintainability/structural-smells.js +17 -0
- package/target/main/ts/plugins/security/actions-security.d.ts +2 -0
- package/target/main/ts/plugins/security/actions-security.js +581 -0
- package/target/main/ts/plugins/security/dockerfile.d.ts +2 -0
- package/target/main/ts/plugins/security/dockerfile.js +487 -0
- package/target/main/ts/plugins/security/npm-supply-chain.d.ts +4 -0
- package/target/main/ts/plugins/security/npm-supply-chain.js +368 -0
- package/target/main/ts/plugins/security/secrets.d.ts +12 -0
- package/target/main/ts/plugins/security/secrets.js +254 -0
- package/target/main/ts/plugins/source/forges.d.ts +4 -0
- package/target/main/ts/plugins/source/forges.js +80 -0
- package/target/main/ts/plugins/structure/structure.d.ts +2 -0
- package/target/main/ts/plugins/structure/structure.js +42 -0
- package/target/main/ts/report/html/app/viewer-chart-bars.d.ts +13 -0
- package/target/main/ts/report/html/app/viewer-chart-bars.js +59 -0
- package/target/main/ts/report/html/app/viewer-chart-label.d.ts +15 -0
- package/target/main/ts/report/html/app/viewer-chart-label.js +43 -0
- package/target/main/ts/report/html/app/viewer-chart-line.d.ts +33 -0
- package/target/main/ts/report/html/app/viewer-chart-line.js +88 -0
- package/target/main/ts/report/html/app/viewer-chart-points.d.ts +52 -0
- package/target/main/ts/report/html/app/viewer-chart-points.js +65 -0
- package/target/main/ts/report/html/app/viewer-chart-scale.d.ts +21 -0
- package/target/main/ts/report/html/app/viewer-chart-scale.js +93 -0
- package/target/main/ts/report/html/app/viewer-chart-svg.d.ts +28 -0
- package/target/main/ts/report/html/app/viewer-chart-svg.js +41 -0
- package/target/main/ts/report/html/app/viewer-chart-time.d.ts +26 -0
- package/target/main/ts/report/html/app/viewer-chart-time.js +150 -0
- package/target/main/ts/report/html/app/viewer-chart-tip.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-chart-tip.js +210 -0
- package/target/main/ts/report/html/app/viewer-chart-x.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-chart-x.js +50 -0
- package/target/main/ts/report/html/app/viewer-chart.d.ts +7 -0
- package/target/main/ts/report/html/app/viewer-chart.js +50 -0
- package/target/main/ts/report/html/app/viewer-code-map.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-code-map.js +176 -0
- package/target/main/ts/report/html/app/viewer-columns.d.ts +40 -0
- package/target/main/ts/report/html/app/viewer-columns.js +97 -0
- package/target/main/ts/report/html/app/viewer-commit-picker.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-commit-picker.js +229 -0
- package/target/main/ts/report/html/app/viewer-commits.d.ts +32 -0
- package/target/main/ts/report/html/app/viewer-commits.js +81 -0
- package/target/main/ts/report/html/app/viewer-controls.d.ts +43 -0
- package/target/main/ts/report/html/app/viewer-controls.js +141 -0
- package/target/main/ts/report/html/app/viewer-copy.d.ts +17 -0
- package/target/main/ts/report/html/app/viewer-copy.js +64 -0
- package/target/main/ts/report/html/app/viewer-data.d.ts +24 -0
- package/target/main/ts/report/html/app/viewer-data.js +78 -0
- package/target/main/ts/report/html/app/viewer-diagnostics.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-diagnostics.js +60 -0
- package/target/main/ts/report/html/app/viewer-dom.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-dom.js +99 -0
- package/target/main/ts/report/html/app/viewer-file-aside.d.ts +15 -0
- package/target/main/ts/report/html/app/viewer-file-aside.js +134 -0
- package/target/main/ts/report/html/app/viewer-file-figures.d.ts +17 -0
- package/target/main/ts/report/html/app/viewer-file-figures.js +65 -0
- package/target/main/ts/report/html/app/viewer-file-source.d.ts +7 -0
- package/target/main/ts/report/html/app/viewer-file-source.js +119 -0
- package/target/main/ts/report/html/app/viewer-files.d.ts +11 -0
- package/target/main/ts/report/html/app/viewer-files.js +40 -0
- package/target/main/ts/report/html/app/viewer-filter.d.ts +65 -0
- package/target/main/ts/report/html/app/viewer-filter.js +161 -0
- package/target/main/ts/report/html/app/viewer-hotspots.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-hotspots.js +133 -0
- package/target/main/ts/report/html/app/viewer-inspection.d.ts +69 -0
- package/target/main/ts/report/html/app/viewer-inspection.js +38 -0
- package/target/main/ts/report/html/app/viewer-issue-group.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-issue-group.js +174 -0
- package/target/main/ts/report/html/app/viewer-issues.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-issues.js +173 -0
- package/target/main/ts/report/html/app/viewer-language-bar.d.ts +11 -0
- package/target/main/ts/report/html/app/viewer-language-bar.js +76 -0
- package/target/main/ts/report/html/app/viewer-languages.d.ts +35 -0
- package/target/main/ts/report/html/app/viewer-languages.js +97 -0
- package/target/main/ts/report/html/app/viewer-layout.d.ts +14 -0
- package/target/main/ts/report/html/app/viewer-layout.js +134 -0
- package/target/main/ts/report/html/app/viewer-line-coverage.d.ts +47 -0
- package/target/main/ts/report/html/app/viewer-line-coverage.js +108 -0
- package/target/main/ts/report/html/app/viewer-locations.d.ts +16 -0
- package/target/main/ts/report/html/app/viewer-locations.js +31 -0
- package/target/main/ts/report/html/app/viewer-map-scale.d.ts +26 -0
- package/target/main/ts/report/html/app/viewer-map-scale.js +147 -0
- package/target/main/ts/report/html/app/viewer-map-shape.d.ts +42 -0
- package/target/main/ts/report/html/app/viewer-map-shape.js +102 -0
- package/target/main/ts/report/html/app/viewer-metric-format.d.ts +23 -0
- package/target/main/ts/report/html/app/viewer-metric-format.js +93 -0
- package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +47 -0
- package/target/main/ts/report/html/app/viewer-metric-registry.js +138 -0
- package/target/main/ts/report/html/app/viewer-metrics-view.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-metrics-view.js +159 -0
- package/target/main/ts/report/html/app/viewer-metrics.d.ts +51 -0
- package/target/main/ts/report/html/app/viewer-metrics.js +195 -0
- package/target/main/ts/report/html/app/viewer-overview-cards.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-overview-cards.js +121 -0
- package/target/main/ts/report/html/app/viewer-overview-hotspots.d.ts +9 -0
- package/target/main/ts/report/html/app/viewer-overview-hotspots.js +173 -0
- package/target/main/ts/report/html/app/viewer-overview-lead.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-overview-lead.js +116 -0
- package/target/main/ts/report/html/app/viewer-profile-badges.d.ts +11 -0
- package/target/main/ts/report/html/app/viewer-profile-badges.js +119 -0
- package/target/main/ts/report/html/app/viewer-profile-table.d.ts +29 -0
- package/target/main/ts/report/html/app/viewer-profile-table.js +124 -0
- package/target/main/ts/report/html/app/viewer-profile.d.ts +13 -0
- package/target/main/ts/report/html/app/viewer-profile.js +180 -0
- package/target/main/ts/report/html/app/viewer-projects.d.ts +1 -0
- package/target/main/ts/report/html/app/viewer-projects.js +90 -0
- package/target/main/ts/report/html/app/viewer-pull-sections.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-pull-sections.js +118 -0
- package/target/main/ts/report/html/app/viewer-pull-trend.d.ts +5 -0
- package/target/main/ts/report/html/app/viewer-pull-trend.js +63 -0
- package/target/main/ts/report/html/app/viewer-pulls.d.ts +2 -0
- package/target/main/ts/report/html/app/viewer-pulls.js +92 -0
- package/target/main/ts/report/html/app/viewer-query-field.d.ts +19 -0
- package/target/main/ts/report/html/app/viewer-query-field.js +203 -0
- package/target/main/ts/report/html/app/viewer-route.d.ts +34 -0
- package/target/main/ts/report/html/app/viewer-route.js +55 -0
- package/target/main/ts/report/html/app/viewer-shell.d.ts +20 -0
- package/target/main/ts/report/html/app/viewer-shell.js +113 -0
- package/target/main/ts/report/html/app/viewer-source-view.d.ts +49 -0
- package/target/main/ts/report/html/app/viewer-source-view.js +150 -0
- package/target/main/ts/report/html/app/viewer-source.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-source.js +57 -0
- package/target/main/ts/report/html/app/viewer-suggest.d.ts +13 -0
- package/target/main/ts/report/html/app/viewer-suggest.js +91 -0
- package/target/main/ts/report/html/app/viewer-sunburst.d.ts +5 -0
- package/target/main/ts/report/html/app/viewer-sunburst.js +40 -0
- package/target/main/ts/report/html/app/viewer-table-cells.d.ts +25 -0
- package/target/main/ts/report/html/app/viewer-table-cells.js +135 -0
- package/target/main/ts/report/html/app/viewer-table-rows.d.ts +56 -0
- package/target/main/ts/report/html/app/viewer-table-rows.js +97 -0
- package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +15 -0
- package/target/main/ts/report/html/app/viewer-tokenizer.js +241 -0
- package/target/main/ts/report/html/app/viewer-totals.d.ts +20 -0
- package/target/main/ts/report/html/app/viewer-totals.js +100 -0
- package/target/main/ts/report/html/app/viewer-treemap.d.ts +24 -0
- package/target/main/ts/report/html/app/viewer-treemap.js +112 -0
- package/target/main/ts/report/html/app/viewer-trend-data.d.ts +54 -0
- package/target/main/ts/report/html/app/viewer-trend-data.js +109 -0
- package/target/main/ts/report/html/app/viewer-trend-nav.d.ts +5 -0
- package/target/main/ts/report/html/app/viewer-trend-nav.js +86 -0
- package/target/main/ts/report/html/app/viewer-trend-points.d.ts +30 -0
- package/target/main/ts/report/html/app/viewer-trend-points.js +128 -0
- package/target/main/ts/report/html/app/viewer-trend-series.d.ts +32 -0
- package/target/main/ts/report/html/app/viewer-trend-series.js +128 -0
- package/target/main/ts/report/html/app/viewer-trends.d.ts +5 -0
- package/target/main/ts/report/html/app/viewer-trends.js +89 -0
- package/target/main/ts/report/html/app/viewer.d.ts +1 -0
- package/target/main/ts/report/html/app/viewer.js +222 -0
- package/target/main/ts/report/html/site/badges.d.ts +11 -0
- package/target/main/ts/report/html/site/badges.js +72 -0
- package/target/main/ts/report/html/site/export-site.d.ts +16 -0
- package/target/main/ts/report/html/site/export-site.js +129 -0
- package/target/main/ts/report/html/site/exported-server.d.ts +6 -0
- package/target/main/ts/report/html/site/exported-server.js +72 -0
- package/target/main/ts/report/html/site/local-server.d.ts +7 -0
- package/target/main/ts/report/html/site/local-server.js +59 -0
- package/target/main/ts/report/html/site/projects.d.ts +1 -0
- package/target/main/ts/report/html/site/projects.js +69 -0
- package/target/main/ts/report/html/site/server.d.ts +4 -0
- package/target/main/ts/report/html/site/server.js +65 -0
- package/target/main/ts/report/html/site/source-route.d.ts +6 -0
- package/target/main/ts/report/html/site/source-route.js +23 -0
- package/target/main/ts/report/json/projections/commit-summary.d.ts +13 -0
- package/target/main/ts/report/json/projections/commit-summary.js +125 -0
- package/target/main/ts/report/json/projections/components.d.ts +4 -0
- package/target/main/ts/report/json/projections/components.js +30 -0
- package/target/main/ts/report/json/projections/file-metrics.d.ts +4 -0
- package/target/main/ts/report/json/projections/file-metrics.js +260 -0
- package/target/main/ts/report/json/projections/ignore-view.d.ts +2 -0
- package/target/main/ts/report/json/projections/ignore-view.js +13 -0
- package/target/main/ts/report/json/projections/inspection-context.d.ts +5 -0
- package/target/main/ts/report/json/projections/inspection-context.js +104 -0
- package/target/main/ts/report/json/projections/inspection-details.d.ts +14 -0
- package/target/main/ts/report/json/projections/inspection-details.js +98 -0
- package/target/main/ts/report/json/projections/metric-values.d.ts +14 -0
- package/target/main/ts/report/json/projections/metric-values.js +104 -0
- package/target/main/ts/report/json/projections/profile-selectors.d.ts +8 -0
- package/target/main/ts/report/json/projections/profile-selectors.js +34 -0
- package/target/main/ts/report/json/projections/security-summary.d.ts +11 -0
- package/target/main/ts/report/json/projections/security-summary.js +22 -0
- package/target/main/ts/report/json/store/directory.d.ts +3 -0
- package/target/main/ts/report/json/store/directory.js +19 -0
- package/target/main/ts/report/json/store/local-store.d.ts +25 -0
- package/target/main/ts/report/json/store/local-store.js +214 -0
- package/target/main/ts/report/json/store/object-store.d.ts +14 -0
- package/target/main/ts/report/json/store/object-store.js +73 -0
- package/target/main/ts/report/json/store/operation-cache.d.ts +8 -0
- package/target/main/ts/report/json/store/operation-cache.js +32 -0
- package/target/main/ts/report/json/store/pull-review-store.d.ts +2 -0
- package/target/main/ts/report/json/store/pull-review-store.js +33 -0
- package/target/main/ts/report/json/store/replace-file.d.ts +1 -0
- package/target/main/ts/report/json/store/replace-file.js +35 -0
- package/target/main/ts/report/json/store/report-tree.d.ts +46 -0
- package/target/main/ts/report/json/store/report-tree.js +295 -0
- package/target/main/ts/report/json/store/store-check.d.ts +32 -0
- package/target/main/ts/report/json/store/store-check.js +153 -0
- package/target/main/ts/report/json/validation/metabranch.d.ts +4 -0
- package/target/main/ts/report/json/validation/metabranch.js +11 -0
- package/target/main/ts/report/json/validation/report.d.ts +20 -0
- package/target/main/ts/report/json/validation/report.js +77 -0
- package/target/main/ts/report/json/validation/summary-validation.d.ts +4 -0
- package/target/main/ts/report/json/validation/summary-validation.js +26 -0
- package/target/main/ts/report/json/wire/compact-json.d.ts +11 -0
- package/target/main/ts/report/json/wire/compact-json.js +76 -0
- package/target/main/ts/report/json/wire/component-model.d.ts +9 -0
- package/target/main/ts/report/json/wire/component-model.js +1 -0
- package/target/main/ts/report/json/wire/domain-types.d.ts +2 -0
- package/target/main/ts/report/json/wire/domain-types.js +1 -0
- package/target/main/ts/report/json/wire/file-metrics-model.d.ts +81 -0
- package/target/main/ts/report/json/wire/file-metrics-model.js +1 -0
- package/target/main/ts/report/json/wire/inspection-context-model.d.ts +31 -0
- package/target/main/ts/report/json/wire/inspection-context-model.js +1 -0
- package/target/main/ts/report/json/wire/inspection-details-model.d.ts +87 -0
- package/target/main/ts/report/json/wire/inspection-details-model.js +1 -0
- package/target/main/ts/report/json/wire/project-model.d.ts +7 -0
- package/target/main/ts/report/json/wire/project-model.js +1 -0
- package/target/main/ts/report/json/wire/public-history-model.d.ts +36 -0
- package/target/main/ts/report/json/wire/public-history-model.js +5 -0
- package/target/main/ts/report/json/wire/pull-review-model.d.ts +54 -0
- package/target/main/ts/report/json/wire/pull-review-model.js +3 -0
- package/target/main/ts/report/json/wire/summary-model.d.ts +45 -0
- package/target/main/ts/report/json/wire/summary-model.js +1 -0
- package/target/main/ts/report/markdown/pull-review.d.ts +5 -0
- package/target/main/ts/report/markdown/pull-review.js +132 -0
- package/target/main/ts/report.d.ts +23 -0
- package/target/main/ts/report.js +12 -0
- package/target/main/ts/runtime.d.ts +17 -0
- package/target/main/ts/runtime.js +30 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { isRecord } from '@repometry/core/internal/model/plugin-data.js';
|
|
2
|
+
import { comparePaths, digest } from '@repometry/core/internal/model/snapshot.js';
|
|
3
|
+
/**
|
|
4
|
+
* A saved report keeps per-file rows in content-addressed objects, so an unchanged file version is stored once
|
|
5
|
+
* however many commits share it. The commit file keeps the rest of the report and the row order.
|
|
6
|
+
*/
|
|
7
|
+
export const storedReportSchema = 'urn:repometry:schema:report-store:1';
|
|
8
|
+
/** Applied configuration that describes one commit rather than the profile, kept in the commit file. */
|
|
9
|
+
const commitConfig = ['churnWindow'];
|
|
10
|
+
const idPattern = /^[a-f0-9]{32}-[a-f0-9]{8}$/;
|
|
11
|
+
export function objectId(text) {
|
|
12
|
+
return digest(text).slice(0, 32);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* An object's name: the ID of its content, then a hint from the path it describes. Objects stay plain JSON, so Git
|
|
16
|
+
* compresses them and stores a new version as a small difference from the last. Git finds the last version by the
|
|
17
|
+
* end of the file name and by its folder, so every version of one path's object ends alike and shares a folder.
|
|
18
|
+
*/
|
|
19
|
+
function objectName(text, path) {
|
|
20
|
+
return `${objectId(text)}-${digest(path).slice(0, 8)}`;
|
|
21
|
+
}
|
|
22
|
+
export function objectPath(id) {
|
|
23
|
+
if (!idPattern.test(id))
|
|
24
|
+
throw new Error(`Invalid report object ID: ${id}`);
|
|
25
|
+
return `objects/${id.slice(33, 35)}/${id}.json`;
|
|
26
|
+
}
|
|
27
|
+
export class ObjectError extends Error {
|
|
28
|
+
id;
|
|
29
|
+
reason;
|
|
30
|
+
constructor(id, reason) {
|
|
31
|
+
super(`Report object ${id} is ${reason}. Run repometry store check --repair, or analyze the commit again.`);
|
|
32
|
+
this.id = id;
|
|
33
|
+
this.reason = reason;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Reads an object and checks its content against its ID. */
|
|
37
|
+
export function objectText(id, bytes) {
|
|
38
|
+
const text = present(id, bytes);
|
|
39
|
+
if (objectId(text) !== id.slice(0, 32))
|
|
40
|
+
throw new ObjectError(id, 'corrupt');
|
|
41
|
+
return text;
|
|
42
|
+
}
|
|
43
|
+
function present(id, bytes) {
|
|
44
|
+
if (bytes === undefined)
|
|
45
|
+
throw new ObjectError(id, 'missing');
|
|
46
|
+
return Buffer.from(bytes).toString('utf8');
|
|
47
|
+
}
|
|
48
|
+
function parsed(id, text) {
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(text);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new ObjectError(id, 'corrupt');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Object texts read recently, up to `limit` characters; the oldest go first. Objects never change, so any reader may share it. */
|
|
57
|
+
export class ObjectCache {
|
|
58
|
+
limit;
|
|
59
|
+
texts = new Map();
|
|
60
|
+
size = 0;
|
|
61
|
+
constructor(limit = 64 * 1024 * 1024) {
|
|
62
|
+
this.limit = limit;
|
|
63
|
+
}
|
|
64
|
+
get(id) {
|
|
65
|
+
return this.texts.get(id);
|
|
66
|
+
}
|
|
67
|
+
set(id, text) {
|
|
68
|
+
if (this.texts.has(id))
|
|
69
|
+
return;
|
|
70
|
+
this.texts.set(id, text);
|
|
71
|
+
this.size += text.length;
|
|
72
|
+
for (const [oldest, value] of this.texts) {
|
|
73
|
+
if (this.size <= this.limit)
|
|
74
|
+
break;
|
|
75
|
+
this.texts.delete(oldest);
|
|
76
|
+
this.size -= value.length;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* An object source over stored bytes, for reading reports: each report's revision check covers the content of its
|
|
82
|
+
* objects, so reads skip hashing them. Values are parsed per read, so reports never share mutable rows.
|
|
83
|
+
*/
|
|
84
|
+
export function storedObjects(load, cache = new ObjectCache(0)) {
|
|
85
|
+
return {
|
|
86
|
+
async read(ids) {
|
|
87
|
+
const cached = new Map(ids.flatMap(id => {
|
|
88
|
+
const text = cache.get(id);
|
|
89
|
+
return text === undefined ? [] : [[id, text]];
|
|
90
|
+
}));
|
|
91
|
+
const wanted = [...new Set(ids)].filter(id => !cached.has(id));
|
|
92
|
+
const bytes = await load(wanted);
|
|
93
|
+
const loaded = new Map(wanted.map((id, position) => [id, present(id, bytes[position])]));
|
|
94
|
+
const values = ids.map(id => parsed(id, cached.get(id) ?? loaded.get(id)));
|
|
95
|
+
// Only texts that parsed are kept, so a damaged object is read afresh once repaired.
|
|
96
|
+
for (const [id, text] of loaded)
|
|
97
|
+
cache.set(id, text);
|
|
98
|
+
return values;
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Splits a report into the commit record and the objects it references. */
|
|
103
|
+
export function splitReport(report) {
|
|
104
|
+
const objects = new Map();
|
|
105
|
+
const put = (value, path) => {
|
|
106
|
+
const text = JSON.stringify(value);
|
|
107
|
+
const id = objectName(text, path);
|
|
108
|
+
objects.set(id, text);
|
|
109
|
+
return id;
|
|
110
|
+
};
|
|
111
|
+
const lists = [];
|
|
112
|
+
const catalog = {};
|
|
113
|
+
mapParts(report, {
|
|
114
|
+
list: (slot, rows) => Array.isArray(rows) && lists.push([slot, rows]),
|
|
115
|
+
config: () => undefined, definitions: () => undefined, catalog: (key, value) => catalog[key] = value,
|
|
116
|
+
});
|
|
117
|
+
const namedPaths = new Set();
|
|
118
|
+
for (const [, rows] of lists) {
|
|
119
|
+
for (const { path } of rows)
|
|
120
|
+
if (typeof path === 'string')
|
|
121
|
+
namedPaths.add(path);
|
|
122
|
+
}
|
|
123
|
+
const paths = [...namedPaths].sort(comparePaths);
|
|
124
|
+
const index = new Map(paths.map((path, position) => [path, position]));
|
|
125
|
+
const nodes = paths.map(() => ({}));
|
|
126
|
+
const entries = new Map(lists.map(([slot, rows]) => [slot, liftRows(rows, slot, index, nodes)]));
|
|
127
|
+
const config = isRecord(report.appliedConfig) ? report.appliedConfig : {};
|
|
128
|
+
const profile = put({
|
|
129
|
+
appliedConfig: mapEntries(config, (key, value) => commitConfig.includes(key) ? null : value),
|
|
130
|
+
definitions: report.definitions,
|
|
131
|
+
...(isRecord(report.pluginData) ? { catalog } : {}),
|
|
132
|
+
}, '');
|
|
133
|
+
const stored = mapParts(report, {
|
|
134
|
+
list: (slot, rows) => entries.get(slot) ?? rows,
|
|
135
|
+
config: () => Object.fromEntries(Object.entries(config).filter(([key]) => commitConfig.includes(key))),
|
|
136
|
+
definitions: () => null, catalog: () => null,
|
|
137
|
+
});
|
|
138
|
+
return { stored: { profile, tree: writeDirectory(directoryOf(paths, nodes), put, '/'), report: stored }, objects };
|
|
139
|
+
}
|
|
140
|
+
/** Rebuilds the exact report a commit record was split from. */
|
|
141
|
+
export async function rebuildReport(stored, source) {
|
|
142
|
+
if (!isRecord(stored) || typeof stored.profile !== 'string' || typeof stored.tree !== 'string' || !isRecord(stored.report)) {
|
|
143
|
+
throw new Error('Invalid stored report');
|
|
144
|
+
}
|
|
145
|
+
const [[profile], files] = await Promise.all([source.read([stored.profile]), readTree(stored.tree, source)]);
|
|
146
|
+
const config = isRecord(profile) ? profile.appliedConfig : undefined;
|
|
147
|
+
if (!isRecord(profile) || !isRecord(config))
|
|
148
|
+
throw new Error('Invalid stored report profile');
|
|
149
|
+
const catalog = isRecord(profile.catalog) ? profile.catalog : {};
|
|
150
|
+
return mapParts(stored.report, {
|
|
151
|
+
list: rowExpander(files),
|
|
152
|
+
config: value => ({ ...config, ...(isRecord(value) ? value : {}) }),
|
|
153
|
+
definitions: () => profile.definitions,
|
|
154
|
+
catalog: (key, value) => Object.hasOwn(catalog, key) ? catalog[key] : value,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/** The one place that knows which parts of a report are per file, per profile or per commit. */
|
|
158
|
+
function mapParts(report, parts) {
|
|
159
|
+
return mapEntries(report, (key, value) => {
|
|
160
|
+
if (key === 'appliedConfig')
|
|
161
|
+
return parts.config(value);
|
|
162
|
+
if (key === 'definitions')
|
|
163
|
+
return parts.definitions(value);
|
|
164
|
+
if (key === 'measurements' || key === 'findings' || key === 'ruleSkips')
|
|
165
|
+
return parts.list(key, value);
|
|
166
|
+
if (key !== 'pluginData' || !isRecord(value))
|
|
167
|
+
return value;
|
|
168
|
+
return mapEntries(value, (name, item) => name === 'products'
|
|
169
|
+
? isRecord(item) ? mapEntries(item, (contract, rows) => parts.list(`products/${contract}`, rows)) : item
|
|
170
|
+
: name === 'inventory' ? parts.list(name, item) : parts.catalog(name, item));
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/** Moves file rows into their file nodes. Each run of one file's rows becomes a [file, count] range entry. */
|
|
174
|
+
function liftRows(rows, slot, index, nodes) {
|
|
175
|
+
const entries = [];
|
|
176
|
+
let last;
|
|
177
|
+
for (const row of rows) {
|
|
178
|
+
const file = typeof row.path === 'string' ? index.get(row.path) : undefined;
|
|
179
|
+
if (file === undefined) {
|
|
180
|
+
entries.push(row);
|
|
181
|
+
last = undefined;
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const runs = nodes[file][slot] ??= [];
|
|
185
|
+
if (file !== last) {
|
|
186
|
+
runs.push([]);
|
|
187
|
+
const previous = entries.at(-1);
|
|
188
|
+
if (Array.isArray(previous) && previous[0] + previous[1] === file)
|
|
189
|
+
previous[1]++;
|
|
190
|
+
else
|
|
191
|
+
entries.push([file, 1]);
|
|
192
|
+
last = file;
|
|
193
|
+
}
|
|
194
|
+
// Keep the key order of the row; the path comes back from the tree.
|
|
195
|
+
runs.at(-1).push({ ...row, path: 0 });
|
|
196
|
+
}
|
|
197
|
+
return entries;
|
|
198
|
+
}
|
|
199
|
+
function rowExpander(files) {
|
|
200
|
+
const paths = [...files.keys()].sort(comparePaths);
|
|
201
|
+
const cursors = new Map();
|
|
202
|
+
const run = (file, slot) => {
|
|
203
|
+
const key = `${slot}\n${file}`;
|
|
204
|
+
const position = cursors.get(key) ?? 0;
|
|
205
|
+
cursors.set(key, position + 1);
|
|
206
|
+
const path = paths[file];
|
|
207
|
+
const rows = files.get(path)?.[slot]?.[position];
|
|
208
|
+
if (!Array.isArray(rows) || !rows.every(isRecord))
|
|
209
|
+
throw new Error('Invalid stored report rows');
|
|
210
|
+
// Rows come freshly parsed for this report; the path takes the place its placeholder holds.
|
|
211
|
+
for (const row of rows)
|
|
212
|
+
row.path = path;
|
|
213
|
+
return rows;
|
|
214
|
+
};
|
|
215
|
+
return (slot, entries) => {
|
|
216
|
+
if (!Array.isArray(entries))
|
|
217
|
+
return entries;
|
|
218
|
+
return entries.flatMap(entry => {
|
|
219
|
+
if (!Array.isArray(entry))
|
|
220
|
+
return [entry];
|
|
221
|
+
const [first, count] = entry;
|
|
222
|
+
if (!Number.isSafeInteger(first) || !Number.isSafeInteger(count) || first < 0 || count < 1
|
|
223
|
+
|| first + count > paths.length)
|
|
224
|
+
throw new Error('Invalid stored report rows');
|
|
225
|
+
return Array.from({ length: count }, (_, offset) => run(first + offset, slot)).flat();
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function directoryOf(paths, nodes) {
|
|
230
|
+
const root = new Map();
|
|
231
|
+
paths.forEach((path, position) => {
|
|
232
|
+
const parts = path.split('/');
|
|
233
|
+
const name = parts.pop();
|
|
234
|
+
let directory = root;
|
|
235
|
+
for (const part of parts) {
|
|
236
|
+
let child = directory.get(`${part}/`);
|
|
237
|
+
if (!(child instanceof Map))
|
|
238
|
+
directory.set(`${part}/`, child = new Map());
|
|
239
|
+
directory = child;
|
|
240
|
+
}
|
|
241
|
+
directory.set(name, nodes[position]);
|
|
242
|
+
});
|
|
243
|
+
return root;
|
|
244
|
+
}
|
|
245
|
+
/** Writes a directory as sorted [name, entry] pairs. A file keeps its inventory inline and its other rows in one object. */
|
|
246
|
+
function writeDirectory(directory, put, path) {
|
|
247
|
+
return put([...directory].sort(([a], [b]) => comparePaths(a, b)).map(([name, value]) => {
|
|
248
|
+
if (value instanceof Map)
|
|
249
|
+
return [name, writeDirectory(value, put, path + name)];
|
|
250
|
+
const { inventory, ...rows } = value;
|
|
251
|
+
return [name, { ...(inventory ? { inventory } : {}), ...(Object.keys(rows).length ? { data: put(rows, path + name) } : {}) }];
|
|
252
|
+
}), path);
|
|
253
|
+
}
|
|
254
|
+
async function readTree(root, source) {
|
|
255
|
+
const files = new Map();
|
|
256
|
+
const data = [];
|
|
257
|
+
let level = [['', root]];
|
|
258
|
+
while (level.length) {
|
|
259
|
+
const directories = await source.read(level.map(([, id]) => id));
|
|
260
|
+
const next = [];
|
|
261
|
+
level.forEach(([prefix], position) => {
|
|
262
|
+
const entries = directories[position];
|
|
263
|
+
if (!Array.isArray(entries))
|
|
264
|
+
throw new Error('Invalid stored report tree');
|
|
265
|
+
for (const entry of entries) {
|
|
266
|
+
const [name, value] = Array.isArray(entry) ? entry : [];
|
|
267
|
+
if (typeof name !== 'string')
|
|
268
|
+
throw new Error('Invalid stored report tree');
|
|
269
|
+
const path = prefix + name;
|
|
270
|
+
if (name.endsWith('/') && typeof value === 'string')
|
|
271
|
+
next.push([path, value]);
|
|
272
|
+
else if (!name.endsWith('/') && isRecord(value)) {
|
|
273
|
+
files.set(path, Array.isArray(value.inventory) ? { inventory: value.inventory } : {});
|
|
274
|
+
if (typeof value.data === 'string')
|
|
275
|
+
data.push([path, value.data]);
|
|
276
|
+
}
|
|
277
|
+
else
|
|
278
|
+
throw new Error('Invalid stored report tree');
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
level = next;
|
|
282
|
+
}
|
|
283
|
+
const loaded = await source.read(data.map(([, id]) => id));
|
|
284
|
+
data.forEach(([path], position) => {
|
|
285
|
+
const rows = loaded[position];
|
|
286
|
+
if (!isRecord(rows))
|
|
287
|
+
throw new Error('Invalid stored report file');
|
|
288
|
+
files.set(path, { ...files.get(path), ...rows });
|
|
289
|
+
});
|
|
290
|
+
return files;
|
|
291
|
+
}
|
|
292
|
+
function mapEntries(value, map) {
|
|
293
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, map(key, item)]));
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=report-tree.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Subject } from '@repometry/core/internal/model/source.js';
|
|
2
|
+
import type { ObjectSource } from './report-tree.js';
|
|
3
|
+
export declare const storeCheckSchema = "urn:repometry:schema:store-check:1";
|
|
4
|
+
export interface StoreProblem {
|
|
5
|
+
readonly subject: Subject;
|
|
6
|
+
readonly problem: 'missing-objects' | 'corrupt-objects' | 'unreadable';
|
|
7
|
+
readonly objects?: readonly string[];
|
|
8
|
+
readonly message: string;
|
|
9
|
+
}
|
|
10
|
+
export interface StoreCheck {
|
|
11
|
+
readonly schema: typeof storeCheckSchema;
|
|
12
|
+
readonly reports: number;
|
|
13
|
+
readonly objects: number;
|
|
14
|
+
readonly unreferenced: number;
|
|
15
|
+
readonly summary: 'current' | 'stale';
|
|
16
|
+
readonly problems: readonly StoreProblem[];
|
|
17
|
+
readonly repaired?: {
|
|
18
|
+
readonly restored: number;
|
|
19
|
+
readonly removed: number;
|
|
20
|
+
readonly summary: boolean;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface StoreRepair {
|
|
24
|
+
/** Another copy of the objects, such as the storage branch, to restore missing or corrupt ones from. */
|
|
25
|
+
readonly from?: ObjectSource;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Verifies every saved report: its objects exist and match their IDs, and the report rebuilds to the revision
|
|
29
|
+
* in its header. With `repair`, restores objects from `from`, removes old unreferenced objects and refreshes
|
|
30
|
+
* summary.json. A report that stays broken needs `repometry analyze` again.
|
|
31
|
+
*/
|
|
32
|
+
export declare function checkStore(directory: string, repair?: StoreRepair): Promise<StoreCheck>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { lstat, readFile, stat } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { repositorySummary } from '../projections/commit-summary.js';
|
|
4
|
+
import { readStoredReport } from '../validation/report.js';
|
|
5
|
+
import { hasCode } from './directory.js';
|
|
6
|
+
import { LocalReportStore } from './local-store.js';
|
|
7
|
+
import { ObjectError, objectId, objectPath, objectText } from './report-tree.js';
|
|
8
|
+
export const storeCheckSchema = 'urn:repometry:schema:store-check:1';
|
|
9
|
+
/** Objects this recent may belong to a save that has not published its report yet. */
|
|
10
|
+
const unreferencedGraceMs = 60 * 60 * 1000;
|
|
11
|
+
/**
|
|
12
|
+
* Verifies every saved report: its objects exist and match their IDs, and the report rebuilds to the revision
|
|
13
|
+
* in its header. With `repair`, restores objects from `from`, removes old unreferenced objects and refreshes
|
|
14
|
+
* summary.json. A report that stays broken needs `repometry analyze` again.
|
|
15
|
+
*/
|
|
16
|
+
export async function checkStore(directory, repair) {
|
|
17
|
+
const target = await stat(directory).catch((error) => {
|
|
18
|
+
if (hasCode(error, 'ENOENT') || hasCode(error, 'ENOTDIR'))
|
|
19
|
+
return undefined;
|
|
20
|
+
throw error;
|
|
21
|
+
});
|
|
22
|
+
if (target === undefined)
|
|
23
|
+
throw new Error(`No report store at ${directory}. Run repometry analyze first.`);
|
|
24
|
+
if (!target.isDirectory())
|
|
25
|
+
throw new Error(`Expected a report store directory: ${directory}`);
|
|
26
|
+
const store = new LocalReportStore(directory);
|
|
27
|
+
const reachable = new Set();
|
|
28
|
+
const problems = [];
|
|
29
|
+
const counts = { restored: 0, removed: 0 };
|
|
30
|
+
const subjects = await store.subjects();
|
|
31
|
+
for (const subject of subjects) {
|
|
32
|
+
const result = await checkReport(store, subject, repair);
|
|
33
|
+
for (const id of result.ids)
|
|
34
|
+
reachable.add(id);
|
|
35
|
+
if (result.problem)
|
|
36
|
+
problems.push(result.problem);
|
|
37
|
+
counts.restored += result.restored;
|
|
38
|
+
}
|
|
39
|
+
const unreferenced = (await store.objects.ids()).filter(id => !reachable.has(id));
|
|
40
|
+
// While a report is broken, objects under its missing directories look unreferenced: keep them.
|
|
41
|
+
if (repair && problems.length === 0)
|
|
42
|
+
counts.removed = await removeOld(store, directory, unreferenced);
|
|
43
|
+
const stale = await summaryStale(store, directory);
|
|
44
|
+
if (repair && stale)
|
|
45
|
+
await store.refreshSummary();
|
|
46
|
+
return {
|
|
47
|
+
schema: storeCheckSchema, reports: subjects.length, objects: reachable.size, unreferenced: unreferenced.length - counts.removed,
|
|
48
|
+
summary: stale && !repair ? 'stale' : 'current', problems,
|
|
49
|
+
...(repair ? { repaired: { ...counts, summary: stale } } : {}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Single-file reports saved before objects have no objects to check; reading them verifies their revision. */
|
|
53
|
+
async function checkReport(store, subject, repair) {
|
|
54
|
+
let text;
|
|
55
|
+
try {
|
|
56
|
+
text = await store.text(subject);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return { ids: new Set(), restored: 0, problem: unreadable(subject, error) };
|
|
60
|
+
}
|
|
61
|
+
let restored = 0;
|
|
62
|
+
for (;;) {
|
|
63
|
+
const { ids, failed, error } = await verify(store, text, subject);
|
|
64
|
+
const count = failed.size && repair?.from ? await restore(store, repair.from, [...failed.keys()]) : 0;
|
|
65
|
+
restored += count;
|
|
66
|
+
if (count)
|
|
67
|
+
continue;
|
|
68
|
+
const problem = failed.size ? objectProblem(subject, failed) : error === undefined ? undefined : unreadable(subject, error);
|
|
69
|
+
return { ids, restored, ...(problem ? { problem } : {}) };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Reads a report through objects checked against their IDs, noting each object it reaches and each it cannot read. */
|
|
73
|
+
async function verify(store, text, subject) {
|
|
74
|
+
const ids = new Set();
|
|
75
|
+
const failed = new Map();
|
|
76
|
+
const reads = [];
|
|
77
|
+
const objects = {
|
|
78
|
+
async read(list) {
|
|
79
|
+
const pending = list.map(async (id) => {
|
|
80
|
+
ids.add(id);
|
|
81
|
+
try {
|
|
82
|
+
return JSON.parse(objectText(id, await store.objects.bytes(id)));
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (!(error instanceof ObjectError))
|
|
86
|
+
throw error;
|
|
87
|
+
failed.set(id, error.reason);
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
reads.push(...pending);
|
|
92
|
+
const values = await Promise.all(pending);
|
|
93
|
+
if (failed.size)
|
|
94
|
+
throw new ObjectError([...failed.keys()][0], [...failed.values()][0]);
|
|
95
|
+
return values;
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
try {
|
|
99
|
+
await readStoredReport(text, subject, objects);
|
|
100
|
+
return { ids, failed };
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
// Let reads already under way finish, so every damaged object they reach is reported.
|
|
104
|
+
await Promise.allSettled(reads);
|
|
105
|
+
return { ids, failed, error };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function restore(store, from, ids) {
|
|
109
|
+
const copies = new Map();
|
|
110
|
+
for (const id of ids) {
|
|
111
|
+
try {
|
|
112
|
+
const text = JSON.stringify((await from.read([id]))[0]);
|
|
113
|
+
if (objectId(text) === id.slice(0, 32))
|
|
114
|
+
copies.set(id, text);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (!(error instanceof ObjectError))
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
await store.objects.write(copies);
|
|
122
|
+
return copies.size;
|
|
123
|
+
}
|
|
124
|
+
async function removeOld(store, directory, ids) {
|
|
125
|
+
let removed = 0;
|
|
126
|
+
for (const id of ids) {
|
|
127
|
+
if (Date.now() - (await lstat(join(directory, objectPath(id)))).mtimeMs < unreferencedGraceMs)
|
|
128
|
+
continue;
|
|
129
|
+
await store.objects.remove(id);
|
|
130
|
+
removed++;
|
|
131
|
+
}
|
|
132
|
+
return removed;
|
|
133
|
+
}
|
|
134
|
+
async function summaryStale(store, directory) {
|
|
135
|
+
const expected = `${JSON.stringify(repositorySummary(await store.listSummaries()))}\n`;
|
|
136
|
+
try {
|
|
137
|
+
return await readFile(join(directory, 'summary.json'), 'utf8') !== expected;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
if (hasCode(error, 'ENOENT'))
|
|
141
|
+
return (await store.listSummaries()).length > 0;
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function objectProblem(subject, failed) {
|
|
146
|
+
const missing = [...failed.values()].includes('missing');
|
|
147
|
+
return { subject, problem: missing ? 'missing-objects' : 'corrupt-objects', objects: [...failed.keys()],
|
|
148
|
+
message: `Restore with repometry store check --repair --from git:repometry, or run repometry analyze ${subject.kind === 'commit' ? subject.id : '--working-tree'}.` };
|
|
149
|
+
}
|
|
150
|
+
function unreadable(subject, error) {
|
|
151
|
+
return { subject, problem: 'unreadable', message: error instanceof Error ? error.message : String(error) };
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=store-check.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
2
|
+
import schema from '../../../../resources/report/json/metabranch-v1.schema.json' with { type: 'json' };
|
|
3
|
+
export const metaManifest = { schema: schema.$id };
|
|
4
|
+
let validate;
|
|
5
|
+
export function checkMetaManifest(text) {
|
|
6
|
+
const value = JSON.parse(text);
|
|
7
|
+
const check = validate ??= new Ajv2020().compile(schema);
|
|
8
|
+
if (!check(value))
|
|
9
|
+
throw new Error('Unsupported metabranch manifest');
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=metabranch.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Subject } from '@repometry/core/internal/model/source.js';
|
|
2
|
+
import type { ObjectSource } from '../store/report-tree.js';
|
|
3
|
+
import type { CommitSummary } from '../wire/summary-model.js';
|
|
4
|
+
import type { Report } from '@repometry/core/internal/model/report.js';
|
|
5
|
+
import type { ReportReader as DomainReportReader, ReportWriter } from '@repometry/core/internal/ports/report.js';
|
|
6
|
+
export { reportSchema, validSubjectId } from '@repometry/core/internal/model/report.js';
|
|
7
|
+
export type { Diagnostic, Report } from '@repometry/core/internal/model/report.js';
|
|
8
|
+
export interface ReportReader extends DomainReportReader {
|
|
9
|
+
listSummaries?(): Promise<readonly CommitSummary[]>;
|
|
10
|
+
}
|
|
11
|
+
export interface ReportStore extends ReportReader, ReportWriter {
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Reads a saved report file: a commit file whose rows live in `objects`, or a single-file report saved before
|
|
15
|
+
* objects existed, which is read as it is. Both give the same report.
|
|
16
|
+
*/
|
|
17
|
+
export declare function readStoredReport(text: string, subject: Subject, objects: ObjectSource): Promise<Report>;
|
|
18
|
+
export declare function reportRevision(report: Report): string;
|
|
19
|
+
export declare function compareReports(a: Report, b: Report): number;
|
|
20
|
+
export declare function readReport(value: unknown): Report;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
2
|
+
import metricCatalog from '../../../../resources/report/json/metric-catalog-v1.schema.json' with { type: 'json' };
|
|
3
|
+
import schemaV2 from '../../../../resources/report/json/report-v2.schema.json' with { type: 'json' };
|
|
4
|
+
import { isRecord } from '@repometry/core/internal/engine/plugin.js';
|
|
5
|
+
import { isMetricDescriptor } from '@repometry/core/internal/engine/manifest.js';
|
|
6
|
+
import { isFinding } from '@repometry/core/internal/model/finding.js';
|
|
7
|
+
import { canonicalMetricId } from '@repometry/core/internal/model/measurement.js';
|
|
8
|
+
import { lcovLines } from '@repometry/core/internal/model/line-coverage.js';
|
|
9
|
+
import { digest } from '@repometry/core/internal/model/snapshot.js';
|
|
10
|
+
import { unpackJson } from '../wire/compact-json.js';
|
|
11
|
+
import { rebuildReport, storedReportSchema } from '../store/report-tree.js';
|
|
12
|
+
import { reportSchema } from '@repometry/core/internal/model/report.js';
|
|
13
|
+
export { reportSchema, validSubjectId } from '@repometry/core/internal/model/report.js';
|
|
14
|
+
/**
|
|
15
|
+
* Reads a saved report file: a commit file whose rows live in `objects`, or a single-file report saved before
|
|
16
|
+
* objects existed, which is read as it is. Both give the same report.
|
|
17
|
+
*/
|
|
18
|
+
export async function readStoredReport(text, subject, objects) {
|
|
19
|
+
const envelope = JSON.parse(text);
|
|
20
|
+
const value = isRecord(envelope) && envelope.schema === storedReportSchema ? await rebuildReport(envelope, objects) : unpackJson(envelope);
|
|
21
|
+
const report = readReport(value);
|
|
22
|
+
if (report.subject.kind !== subject.kind || report.subject.id !== subject.id)
|
|
23
|
+
throw new Error(`Report subject mismatch: ${subject.id}`);
|
|
24
|
+
if (isRecord(envelope) && isRecord(envelope.summary)
|
|
25
|
+
&& envelope.summary.revision !== undefined && envelope.summary.revision !== reportRevision(report)) {
|
|
26
|
+
throw new Error(`Report revision mismatch: ${subject.id}`);
|
|
27
|
+
}
|
|
28
|
+
return report;
|
|
29
|
+
}
|
|
30
|
+
export function reportRevision(report) {
|
|
31
|
+
return digest(JSON.stringify(report));
|
|
32
|
+
}
|
|
33
|
+
export function compareReports(a, b) {
|
|
34
|
+
return b.generatedAt.localeCompare(a.generatedAt) || a.subject.id.localeCompare(b.subject.id);
|
|
35
|
+
}
|
|
36
|
+
const ajv = new Ajv2020({ schemas: [metricCatalog] });
|
|
37
|
+
const validate = ajv.compile(schemaV2);
|
|
38
|
+
export function readReport(value) {
|
|
39
|
+
if (!isRecord(value) || value.schema !== reportSchema) {
|
|
40
|
+
throw new Error('Unsupported or missing report schema');
|
|
41
|
+
}
|
|
42
|
+
if (!validate(value))
|
|
43
|
+
throw new Error(`Invalid report: ${ajv.errorsText(validate.errors)}`);
|
|
44
|
+
const definitionIds = Object.keys(value.definitions);
|
|
45
|
+
if (new Set(definitionIds.map(canonicalMetricId)).size !== definitionIds.length) {
|
|
46
|
+
throw new Error('Invalid report: the same measurement uses multiple IDs');
|
|
47
|
+
}
|
|
48
|
+
if (value.pluginData) {
|
|
49
|
+
const { metrics, measured, privateMetrics } = value.pluginData;
|
|
50
|
+
const ids = new Set(metrics.map(metric => metric.id));
|
|
51
|
+
if (new Set([...ids].map(canonicalMetricId)).size !== metrics.length || !metrics.every(isMetricDescriptor)
|
|
52
|
+
|| [...measured, ...privateMetrics ?? []].some(id => !ids.has(id)))
|
|
53
|
+
throw new Error('Invalid report: inconsistent metric catalog');
|
|
54
|
+
const lines = value.pluginData.products[lcovLines.id];
|
|
55
|
+
if (lines && !lcovLines.accepts(lines[0]?.value))
|
|
56
|
+
throw new Error('Invalid report: LCOV line ranges must be sorted and merged');
|
|
57
|
+
}
|
|
58
|
+
if (value.scope.parsed > value.scope.files)
|
|
59
|
+
throw new Error('Invalid report: parsed count exceeds source count');
|
|
60
|
+
if (value.findings?.some(finding => !isFinding(finding)))
|
|
61
|
+
throw new Error('Invalid report: inconsistent finding location');
|
|
62
|
+
const ignore = value.appliedConfig.findingIgnore;
|
|
63
|
+
if (value.ignoredFindings?.some(({ finding, matchedRule }) => !isFinding(finding)
|
|
64
|
+
|| !Array.isArray(ignore) || matchedRule >= ignore.length))
|
|
65
|
+
throw new Error('Invalid report: inconsistent ignored finding');
|
|
66
|
+
for (const item of value.measurements) {
|
|
67
|
+
if (!Object.hasOwn(value.definitions, item.definition))
|
|
68
|
+
throw new Error(`Unknown measurement definition: ${item.definition}`);
|
|
69
|
+
if (item.covered === undefined || item.total === undefined)
|
|
70
|
+
continue;
|
|
71
|
+
if (item.covered > item.total || item.value !== (item.total === 0 ? null : item.covered / item.total)) {
|
|
72
|
+
throw new Error('Invalid report: inconsistent coverage counts');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CommitSummary, RepositorySummary } from '../wire/summary-model.js';
|
|
2
|
+
export declare const validateSummary: import("ajv/dist/2020.js").ValidateFunction<RepositorySummary>;
|
|
3
|
+
export declare function validateSummaryIndex(value: unknown): value is RepositorySummary;
|
|
4
|
+
export declare function validateSummaryRow(value: unknown): value is CommitSummary;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
2
|
+
import metricCatalog from '../../../../resources/report/json/metric-catalog-v1.schema.json' with { type: 'json' };
|
|
3
|
+
import summaryContract from '../../../../resources/report/json/repository-summary-v1.schema.json' with { type: 'json' };
|
|
4
|
+
import { summarySchema } from '../wire/summary-model.js';
|
|
5
|
+
import { isMetricDescriptor } from '@repometry/core/internal/engine/manifest.js';
|
|
6
|
+
const validator = new Ajv2020({ schemas: [metricCatalog, summaryContract] });
|
|
7
|
+
export const validateSummary = validator.compile(summaryContract);
|
|
8
|
+
const rowShape = validator.compile({ $ref: `${summarySchema}#/$defs/commit` });
|
|
9
|
+
export function validateSummaryIndex(value) {
|
|
10
|
+
return validateSummary(value) && validCatalog(value.metrics, value.privateMetrics)
|
|
11
|
+
&& value.commits.every(row => validCatalog(row.metrics, row.privateMetrics) && validPositions(row, value.metrics));
|
|
12
|
+
}
|
|
13
|
+
export function validateSummaryRow(value) {
|
|
14
|
+
return rowShape(value) && validCatalog(value.metrics, value.privateMetrics) && validPositions(value);
|
|
15
|
+
}
|
|
16
|
+
function validCatalog(catalog, privateMetrics = []) {
|
|
17
|
+
if (catalog && !catalog.every(isMetricDescriptor))
|
|
18
|
+
return false;
|
|
19
|
+
const ids = new Set(catalog?.map(metric => metric.id));
|
|
20
|
+
return ids.size === (catalog?.length ?? 0) && privateMetrics.every(id => ids.has(id));
|
|
21
|
+
}
|
|
22
|
+
function validPositions(row, fallback) {
|
|
23
|
+
const count = (row.metrics ?? fallback)?.length ?? 0;
|
|
24
|
+
return Object.keys(row.values ?? {}).every(key => Number(key) < count);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=summary-validation.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const compactJsonSchema = "urn:repometry:schema:compact-json:1";
|
|
2
|
+
type Node = null | boolean | number | readonly Node[];
|
|
3
|
+
export interface CompactJson {
|
|
4
|
+
readonly schema: typeof compactJsonSchema;
|
|
5
|
+
readonly strings: readonly string[];
|
|
6
|
+
readonly shapes: readonly (readonly string[])[];
|
|
7
|
+
readonly data: Node;
|
|
8
|
+
}
|
|
9
|
+
export declare function packJson(value: unknown): CompactJson;
|
|
10
|
+
export declare function unpackJson(value: unknown): unknown;
|
|
11
|
+
export {};
|