@repometry/cli 0.0.0-dev.0 → 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 -3
- package/package.json +65 -2
- 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,214 @@
|
|
|
1
|
+
import { lstat, mkdir, open, readFile, readdir } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
4
|
+
import { isRecord } from '@repometry/core/internal/engine/plugin.js';
|
|
5
|
+
import { commitSummary, needsMaintainabilityRefresh, orderSummaries, repositorySummary } from '../projections/commit-summary.js';
|
|
6
|
+
import { summarySchema } from '../wire/summary-model.js';
|
|
7
|
+
import { compactJsonSchema } from '../wire/compact-json.js';
|
|
8
|
+
import { compareReports, readReport, readStoredReport, validSubjectId } from '../validation/report.js';
|
|
9
|
+
import { metaManifest } from '../validation/metabranch.js';
|
|
10
|
+
import { validateSummaryRow } from '../validation/summary-validation.js';
|
|
11
|
+
import { checkDirectory, ensureDirectory, hasCode } from './directory.js';
|
|
12
|
+
import { LocalObjectStore } from './object-store.js';
|
|
13
|
+
import { replaceFile } from './replace-file.js';
|
|
14
|
+
import { ObjectCache, rebuildReport, splitReport, storedReportSchema } from './report-tree.js';
|
|
15
|
+
const headerStart = `{"schema":"${storedReportSchema}"`;
|
|
16
|
+
// Reports saved before objects carried the same summary header under the compact JSON schema.
|
|
17
|
+
const summaryHeaders = [headerStart, `{"schema":"${compactJsonSchema}"`].map(start => `${start},"summary":`);
|
|
18
|
+
async function checkedReportObjects(report) {
|
|
19
|
+
const packed = splitReport({ ...report });
|
|
20
|
+
if (sameReport(report, await restore(packed)))
|
|
21
|
+
return packed;
|
|
22
|
+
// A custom JSON representation can change how a value is split.
|
|
23
|
+
const expected = JSON.stringify(report);
|
|
24
|
+
const normalized = splitReport(JSON.parse(expected));
|
|
25
|
+
if (JSON.stringify(await restore(normalized)) === expected)
|
|
26
|
+
return normalized;
|
|
27
|
+
throw new Error(`The store cannot keep report ${report.subject.id} exactly`);
|
|
28
|
+
}
|
|
29
|
+
function restore({ stored, objects }) {
|
|
30
|
+
const source = { read: async (ids) => ids.map(id => JSON.parse(objects.get(id))) };
|
|
31
|
+
return rebuildReport(stored, source);
|
|
32
|
+
}
|
|
33
|
+
function sameReport(report, restored) {
|
|
34
|
+
const rows = report.measurements;
|
|
35
|
+
const restoredRows = restored.measurements;
|
|
36
|
+
const customJson = (value) => typeof value.toJSON === 'function';
|
|
37
|
+
if (customJson(report) || customJson(rows) || rows.some(customJson))
|
|
38
|
+
return false;
|
|
39
|
+
if (!Array.isArray(restoredRows) || restoredRows.length !== rows.length)
|
|
40
|
+
return false;
|
|
41
|
+
// Arrays with equal JSON chunks have equal JSON as a whole. The placeholder preserves the field order.
|
|
42
|
+
if (JSON.stringify({ ...report, measurements: null }) !== JSON.stringify({ ...restored, measurements: null }))
|
|
43
|
+
return false;
|
|
44
|
+
const chunk = 4096;
|
|
45
|
+
for (let start = 0; start < rows.length; start += chunk) {
|
|
46
|
+
if (JSON.stringify(rows.slice(start, start + chunk)) !== JSON.stringify(restoredRows.slice(start, start + chunk)))
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
export class LocalReportStore {
|
|
52
|
+
directory;
|
|
53
|
+
objects;
|
|
54
|
+
cache = new ObjectCache();
|
|
55
|
+
constructor(directory) {
|
|
56
|
+
this.directory = directory;
|
|
57
|
+
this.objects = new LocalObjectStore(directory);
|
|
58
|
+
}
|
|
59
|
+
async save(report, { deferSummary = false } = {}) {
|
|
60
|
+
readReport(report);
|
|
61
|
+
const base = join(this.directory, subjectFolder(report.subject.kind));
|
|
62
|
+
const folder = this.folder(report.subject);
|
|
63
|
+
await mkdir(this.directory, { mode: 0o700, recursive: true });
|
|
64
|
+
await ensureDirectory(base);
|
|
65
|
+
await ensureDirectory(folder);
|
|
66
|
+
const { stored, objects } = await checkedReportObjects(report);
|
|
67
|
+
const row = report.subject.kind === 'commit' ? commitSummary(report) : undefined;
|
|
68
|
+
if (row && !validateSummaryRow(row))
|
|
69
|
+
throw new Error(`Invalid report summary: ${report.subject.id}`);
|
|
70
|
+
await replaceFile(this.directory, 'manifest.json', `${JSON.stringify(metaManifest, null, 2)}\n`, true);
|
|
71
|
+
// Objects go first, so a published commit file never names a missing object.
|
|
72
|
+
await this.objects.write(objects);
|
|
73
|
+
// Keep the small index row on the first line of the same atomic file as the report.
|
|
74
|
+
const body = JSON.stringify(stored).slice(1);
|
|
75
|
+
await replaceFile(folder, 'report.json', row ? `${headerStart},"summary":${JSON.stringify(row)},\n${body}\n` : `${headerStart},${body}\n`);
|
|
76
|
+
if (report.subject.kind === 'commit' && !deferSummary)
|
|
77
|
+
await this.refreshSummary();
|
|
78
|
+
}
|
|
79
|
+
read(subject) {
|
|
80
|
+
return this.readWith(subject, this.objects.source(this.cache));
|
|
81
|
+
}
|
|
82
|
+
async list() {
|
|
83
|
+
const objects = this.objects.source(this.cache);
|
|
84
|
+
const reports = [];
|
|
85
|
+
for (const subject of await this.subjects()) {
|
|
86
|
+
try {
|
|
87
|
+
reports.push(await this.readWith(subject, objects));
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
// A writer may have created the directory but not published its report yet.
|
|
91
|
+
if (!hasCode(error, 'ENOENT'))
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return reports.sort(compareReports);
|
|
96
|
+
}
|
|
97
|
+
/** Saved subjects by folder name, whether or not their report is published yet. */
|
|
98
|
+
async subjects() {
|
|
99
|
+
const subjects = [];
|
|
100
|
+
for (const kind of ['commit', 'working-tree']) {
|
|
101
|
+
const base = join(this.directory, subjectFolder(kind));
|
|
102
|
+
try {
|
|
103
|
+
await checkDirectory(base);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (hasCode(error, 'ENOENT'))
|
|
107
|
+
continue;
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
for (const entry of await readdir(base, { withFileTypes: true })) {
|
|
111
|
+
if (entry.isDirectory() && validSubjectId(kind, entry.name))
|
|
112
|
+
subjects.push({ kind, id: entry.name });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return subjects;
|
|
116
|
+
}
|
|
117
|
+
/** The saved report file of a subject. */
|
|
118
|
+
async text(subject) {
|
|
119
|
+
const folder = this.folder(subject);
|
|
120
|
+
const path = join(folder, 'report.json');
|
|
121
|
+
await checkDirectory(join(this.directory, subjectFolder(subject.kind)));
|
|
122
|
+
await checkDirectory(folder);
|
|
123
|
+
if (!(await lstat(path)).isFile())
|
|
124
|
+
throw new Error(`Expected a report file: ${path}`);
|
|
125
|
+
return readFile(path, 'utf8');
|
|
126
|
+
}
|
|
127
|
+
async listSummaries() {
|
|
128
|
+
const base = join(this.directory, 'commits');
|
|
129
|
+
try {
|
|
130
|
+
await checkDirectory(base);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
if (hasCode(error, 'ENOENT'))
|
|
134
|
+
return [];
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
const entries = await readdir(base, { withFileTypes: true });
|
|
138
|
+
const summaries = [];
|
|
139
|
+
for (const entry of entries) {
|
|
140
|
+
if (!entry.isDirectory() || !validSubjectId('commit', entry.name))
|
|
141
|
+
continue;
|
|
142
|
+
const subject = { kind: 'commit', id: entry.name };
|
|
143
|
+
const path = join(base, entry.name, 'report.json');
|
|
144
|
+
try {
|
|
145
|
+
if (!(await lstat(path)).isFile())
|
|
146
|
+
throw new Error(`Expected a report file: ${path}`);
|
|
147
|
+
summaries.push((await readSummaryHeader(path, subject.id)) ?? commitSummary(await this.read(subject)));
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
if (!hasCode(error, 'ENOENT'))
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return orderSummaries(summaries);
|
|
155
|
+
}
|
|
156
|
+
async refreshSummary() {
|
|
157
|
+
const path = join(this.directory, 'summary.json');
|
|
158
|
+
try {
|
|
159
|
+
if (!(await lstat(path)).isFile())
|
|
160
|
+
throw new Error('Expected a regular summary.json file');
|
|
161
|
+
const current = JSON.parse(await readFile(path, 'utf8'));
|
|
162
|
+
if (!isRecord(current) || current.schema !== summarySchema)
|
|
163
|
+
throw new Error('Existing summary.json is not a Repometry summary');
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
if (!hasCode(error, 'ENOENT'))
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
for (let attempt = 0; attempt < 8; attempt++) {
|
|
170
|
+
const commits = await this.listSummaries();
|
|
171
|
+
await replaceFile(this.directory, 'summary.json', `${JSON.stringify(repositorySummary(commits))}\n`);
|
|
172
|
+
if (isDeepStrictEqual(commits, await this.listSummaries()))
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
throw new Error('Reports kept changing during summary publication. The inspection is saved and the summary can be refreshed by retrying.');
|
|
176
|
+
}
|
|
177
|
+
async readWith(subject, objects) {
|
|
178
|
+
return readStoredReport(await this.text(subject), subject, objects);
|
|
179
|
+
}
|
|
180
|
+
folder(subject) {
|
|
181
|
+
if (!validSubjectId(subject.kind, subject.id))
|
|
182
|
+
throw new Error(`Invalid ${subject.kind} ID: ${subject.id}`);
|
|
183
|
+
return join(this.directory, subjectFolder(subject.kind), subject.id);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async function readSummaryHeader(path, sha) {
|
|
187
|
+
const file = await open(path, 'r');
|
|
188
|
+
try {
|
|
189
|
+
const buffer = Buffer.alloc(64 * 1024);
|
|
190
|
+
const { bytesRead } = await file.read(buffer, 0, buffer.length, 0);
|
|
191
|
+
return headerSummary(buffer.toString('utf8', 0, bytesRead), sha);
|
|
192
|
+
}
|
|
193
|
+
finally {
|
|
194
|
+
await file.close();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/** The summary row a saved report keeps on its first line, unless it has none or it needs recalculating. */
|
|
198
|
+
export function headerSummary(text, sha) {
|
|
199
|
+
const end = text.indexOf('\n');
|
|
200
|
+
if (end < 0)
|
|
201
|
+
return undefined;
|
|
202
|
+
const first = text.slice(0, end);
|
|
203
|
+
if (!summaryHeaders.some(start => first.startsWith(start)) || !first.endsWith(','))
|
|
204
|
+
return undefined;
|
|
205
|
+
const envelope = JSON.parse(first.slice(0, -1) + '}');
|
|
206
|
+
if (!isRecord(envelope) || !validateSummaryRow(envelope.summary) || envelope.summary.sha !== sha
|
|
207
|
+
|| !envelope.summary.revision || envelope.summary.detail !== undefined)
|
|
208
|
+
throw new Error(`Invalid report summary: ${sha}`);
|
|
209
|
+
return needsMaintainabilityRefresh(envelope.summary) ? undefined : envelope.summary;
|
|
210
|
+
}
|
|
211
|
+
function subjectFolder(kind) {
|
|
212
|
+
return kind === 'commit' ? 'commits' : 'working-trees';
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=local-store.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ObjectCache } from './report-tree.js';
|
|
2
|
+
import type { ObjectSource } from './report-tree.js';
|
|
3
|
+
/** Content-addressed report objects under `<store>/objects`. Objects are immutable: a valid one is never rewritten. */
|
|
4
|
+
export declare class LocalObjectStore {
|
|
5
|
+
private readonly directory;
|
|
6
|
+
constructor(directory: string);
|
|
7
|
+
source(cache?: ObjectCache): ObjectSource;
|
|
8
|
+
/** Writes each object that is missing or fails its check. */
|
|
9
|
+
write(objects: ReadonlyMap<string, string>): Promise<void>;
|
|
10
|
+
valid(id: string): Promise<boolean>;
|
|
11
|
+
bytes(id: string): Promise<Buffer | undefined>;
|
|
12
|
+
ids(): Promise<readonly string[]>;
|
|
13
|
+
remove(id: string): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { readFile, readdir, rm } from 'node:fs/promises';
|
|
2
|
+
import { basename, dirname, join } from 'node:path';
|
|
3
|
+
import { checkDirectory, ensureDirectory, hasCode } from './directory.js';
|
|
4
|
+
import { replaceFile } from './replace-file.js';
|
|
5
|
+
import { ObjectError, objectPath, objectText, storedObjects } from './report-tree.js';
|
|
6
|
+
/** Content-addressed report objects under `<store>/objects`. Objects are immutable: a valid one is never rewritten. */
|
|
7
|
+
export class LocalObjectStore {
|
|
8
|
+
directory;
|
|
9
|
+
constructor(directory) {
|
|
10
|
+
this.directory = directory;
|
|
11
|
+
}
|
|
12
|
+
source(cache) {
|
|
13
|
+
return storedObjects(ids => Promise.all(ids.map(id => this.bytes(id))), cache);
|
|
14
|
+
}
|
|
15
|
+
/** Writes each object that is missing or fails its check. */
|
|
16
|
+
async write(objects) {
|
|
17
|
+
await ensureDirectory(join(this.directory, 'objects'));
|
|
18
|
+
await Promise.all([...objects].map(async ([id, text]) => {
|
|
19
|
+
if (await this.valid(id))
|
|
20
|
+
return;
|
|
21
|
+
const path = join(this.directory, objectPath(id));
|
|
22
|
+
await ensureDirectory(dirname(path));
|
|
23
|
+
await replaceFile(dirname(path), basename(path), text);
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
async valid(id) {
|
|
27
|
+
try {
|
|
28
|
+
objectText(id, await this.bytes(id));
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error instanceof ObjectError)
|
|
33
|
+
return false;
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async bytes(id) {
|
|
38
|
+
try {
|
|
39
|
+
return await readFile(join(this.directory, objectPath(id)));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (hasCode(error, 'ENOENT'))
|
|
43
|
+
return undefined;
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async ids() {
|
|
48
|
+
const root = join(this.directory, 'objects');
|
|
49
|
+
try {
|
|
50
|
+
await checkDirectory(root);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (hasCode(error, 'ENOENT'))
|
|
54
|
+
return [];
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
const ids = [];
|
|
58
|
+
for (const fanout of await readdir(root)) {
|
|
59
|
+
if (!/^[a-f0-9]{2}$/.test(fanout))
|
|
60
|
+
continue;
|
|
61
|
+
for (const name of await readdir(join(root, fanout))) {
|
|
62
|
+
const match = /^([a-f0-9]{32}-[a-f0-9]{8})\.json$/.exec(name);
|
|
63
|
+
if (match?.[1])
|
|
64
|
+
ids.push(match[1]);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return ids;
|
|
68
|
+
}
|
|
69
|
+
async remove(id) {
|
|
70
|
+
await rm(join(this.directory, objectPath(id)), { force: true });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=object-store.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OperationCache } from '@repometry/core/internal/engine/operation-cache.js';
|
|
2
|
+
export declare class LocalOperationCache implements OperationCache {
|
|
3
|
+
private readonly directory;
|
|
4
|
+
constructor(directory: string);
|
|
5
|
+
read(key: string): Promise<Uint8Array | undefined>;
|
|
6
|
+
write(key: string, bytes: Uint8Array): Promise<void>;
|
|
7
|
+
private folder;
|
|
8
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { lstat, mkdir, readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { replaceFile } from './replace-file.js';
|
|
4
|
+
const digestPattern = /^[a-f0-9]{64}$/;
|
|
5
|
+
export class LocalOperationCache {
|
|
6
|
+
directory;
|
|
7
|
+
constructor(directory) {
|
|
8
|
+
this.directory = directory;
|
|
9
|
+
}
|
|
10
|
+
async read(key) {
|
|
11
|
+
const path = join(this.folder(key), key);
|
|
12
|
+
try {
|
|
13
|
+
return (await lstat(path)).isFile() ? await readFile(path) : undefined;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
|
|
17
|
+
return undefined;
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async write(key, bytes) {
|
|
22
|
+
const folder = this.folder(key);
|
|
23
|
+
await mkdir(folder, { recursive: true, mode: 0o700 });
|
|
24
|
+
await replaceFile(folder, key, bytes);
|
|
25
|
+
}
|
|
26
|
+
folder(key) {
|
|
27
|
+
if (!digestPattern.test(key))
|
|
28
|
+
throw new Error('Invalid operation cache key');
|
|
29
|
+
return join(this.directory, key.slice(0, 2));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=operation-cache.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { lstat, readFile, readdir } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
4
|
+
import metricCatalog from '../../../../resources/report/json/metric-catalog-v1.schema.json' with { type: 'json' };
|
|
5
|
+
import comparison from '../../../../resources/report/json/comparison-v1.schema.json' with { type: 'json' };
|
|
6
|
+
import diffCoverage from '../../../../resources/report/json/diff-coverage-v1.schema.json' with { type: 'json' };
|
|
7
|
+
import currentInspection from '../../../../resources/report/json/report-v2.schema.json' with { type: 'json' };
|
|
8
|
+
import schema from '../../../../resources/report/json/pull-review-v1.schema.json' with { type: 'json' };
|
|
9
|
+
const ajv = new Ajv2020({ schemas: [metricCatalog, currentInspection, comparison, diffCoverage] });
|
|
10
|
+
/** Reviews saved before 0.9 stay readable for the viewer; review no longer saves them. */
|
|
11
|
+
const validate = ajv.compile(schema);
|
|
12
|
+
export async function listPullReviews(output) {
|
|
13
|
+
const directory = join(output, 'reviews');
|
|
14
|
+
try {
|
|
15
|
+
if (!(await lstat(directory)).isDirectory())
|
|
16
|
+
throw new Error('Expected a directory for PR reviews');
|
|
17
|
+
const files = (await readdir(directory, { withFileTypes: true })).filter(entry => entry.isFile() && /^[1-9]\d*\.json$/.test(entry.name));
|
|
18
|
+
const reviews = await Promise.all(files.map(async ({ name }) => {
|
|
19
|
+
const value = JSON.parse(await readFile(join(directory, name), 'utf8'));
|
|
20
|
+
if (!validate(value) || `${value.number}.json` !== name || !Number.isFinite(Date.parse(value.generatedAt))) {
|
|
21
|
+
throw new Error(`Invalid pull request review: ${name}`);
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}));
|
|
25
|
+
return reviews.sort((left, right) => right.generatedAt.localeCompare(left.generatedAt) || (right.number ?? 0) - (left.number ?? 0));
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
|
|
29
|
+
return [];
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=pull-review-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function replaceFile(directory: string, name: string, contents: string | Uint8Array, onlyIfMissing?: boolean): Promise<void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { link, lstat, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { hasCode } from './directory.js';
|
|
5
|
+
export async function replaceFile(directory, name, contents, onlyIfMissing = false) {
|
|
6
|
+
const destination = join(directory, name);
|
|
7
|
+
if (onlyIfMissing && await exists(destination))
|
|
8
|
+
return;
|
|
9
|
+
const temporary = join(directory, `.repometry-${randomUUID()}.tmp`);
|
|
10
|
+
try {
|
|
11
|
+
await writeFile(temporary, contents, { flag: 'wx', mode: 0o600 });
|
|
12
|
+
if (onlyIfMissing)
|
|
13
|
+
await link(temporary, destination).catch(error => {
|
|
14
|
+
if (!hasCode(error, 'EEXIST'))
|
|
15
|
+
throw error;
|
|
16
|
+
});
|
|
17
|
+
else
|
|
18
|
+
await rename(temporary, destination);
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
await rm(temporary, { force: true });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function exists(path) {
|
|
25
|
+
try {
|
|
26
|
+
await lstat(path);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (hasCode(error, 'ENOENT'))
|
|
31
|
+
return false;
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=replace-file.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A saved report keeps per-file rows in content-addressed objects, so an unchanged file version is stored once
|
|
3
|
+
* however many commits share it. The commit file keeps the rest of the report and the row order.
|
|
4
|
+
*/
|
|
5
|
+
export declare const storedReportSchema = "urn:repometry:schema:report-store:1";
|
|
6
|
+
type Row = Readonly<Record<string, unknown>>;
|
|
7
|
+
/** Reads verified, parsed objects in the order of `ids`. */
|
|
8
|
+
export interface ObjectSource {
|
|
9
|
+
read(ids: readonly string[]): Promise<readonly unknown[]>;
|
|
10
|
+
}
|
|
11
|
+
export interface StoredReport {
|
|
12
|
+
readonly profile: string;
|
|
13
|
+
readonly tree: string;
|
|
14
|
+
readonly report: Readonly<Record<string, unknown>>;
|
|
15
|
+
}
|
|
16
|
+
export declare function objectId(text: string): string;
|
|
17
|
+
export declare function objectPath(id: string): string;
|
|
18
|
+
export declare class ObjectError extends Error {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly reason: 'missing' | 'corrupt';
|
|
21
|
+
constructor(id: string, reason: 'missing' | 'corrupt');
|
|
22
|
+
}
|
|
23
|
+
/** Reads an object and checks its content against its ID. */
|
|
24
|
+
export declare function objectText(id: string, bytes: Uint8Array | undefined): string;
|
|
25
|
+
/** Object texts read recently, up to `limit` characters; the oldest go first. Objects never change, so any reader may share it. */
|
|
26
|
+
export declare class ObjectCache {
|
|
27
|
+
private readonly limit;
|
|
28
|
+
private readonly texts;
|
|
29
|
+
private size;
|
|
30
|
+
constructor(limit?: number);
|
|
31
|
+
get(id: string): string | undefined;
|
|
32
|
+
set(id: string, text: string): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* An object source over stored bytes, for reading reports: each report's revision check covers the content of its
|
|
36
|
+
* objects, so reads skip hashing them. Values are parsed per read, so reports never share mutable rows.
|
|
37
|
+
*/
|
|
38
|
+
export declare function storedObjects(load: (ids: readonly string[]) => Promise<readonly (Uint8Array | undefined)[]>, cache?: ObjectCache): ObjectSource;
|
|
39
|
+
/** Splits a report into the commit record and the objects it references. */
|
|
40
|
+
export declare function splitReport(report: Row): {
|
|
41
|
+
readonly stored: StoredReport;
|
|
42
|
+
readonly objects: ReadonlyMap<string, string>;
|
|
43
|
+
};
|
|
44
|
+
/** Rebuilds the exact report a commit record was split from. */
|
|
45
|
+
export declare function rebuildReport(stored: unknown, source: ObjectSource): Promise<Readonly<Record<string, unknown>>>;
|
|
46
|
+
export {};
|