@repometry/cli 0.0.0-stage → 0.1.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 +77 -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 +534 -0
- package/target/main/resources/report/json/repository-summary-v1.schema.json +341 -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 +132 -0
- package/target/main/ts/compose/analysis-results.d.ts +46 -0
- package/target/main/ts/compose/analysis-results.js +119 -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 +126 -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 +82 -0
- package/target/main/ts/report/json/validation/summary-validation.d.ts +4 -0
- package/target/main/ts/report/json/validation/summary-validation.js +30 -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 +37 -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,306 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { firstParentRange, gitRoot, gitTreeFiles, resolveGitCommit } from '../api/git/git.js';
|
|
4
|
+
import { gitReportObjects } from '../api/git/git-reader.js';
|
|
5
|
+
import { cacheRoot, clearCaches } from '../api/cache/root.js';
|
|
6
|
+
import { gitHubPullRequest, writeGitHubReview } from '../api/gh/github.js';
|
|
7
|
+
import { attachFindings, inspectWithOptions } from '../compose/inspect.js';
|
|
8
|
+
import { detectMissingLanguages, missingLanguageNotice } from '../compose/language-discovery.js';
|
|
9
|
+
import { review as reviewChange, reviewExitCode, reviewReason } from '../compose/review.js';
|
|
10
|
+
import { effectivePlugins } from '../compose/plugin-list.js';
|
|
11
|
+
import { validSubjectId } from '@repometry/core/internal/model/report.js';
|
|
12
|
+
import { isExcludedDirectory } from '@repometry/core/internal/model/snapshot.js';
|
|
13
|
+
import { sourceExclusionMatcher } from '@repometry/core/internal/profile/exclusions.js';
|
|
14
|
+
import { exportProjects } from '../report/html/site/projects.js';
|
|
15
|
+
import { fileMetrics } from '../report/json/projections/file-metrics.js';
|
|
16
|
+
import { pullReviewMarkdown } from '../report/markdown/pull-review.js';
|
|
17
|
+
import { LocalObjectStore } from '../report/json/store/object-store.js';
|
|
18
|
+
import { checkStore } from '../report/json/store/store-check.js';
|
|
19
|
+
import { dispatch, flag, option } from './arguments.js';
|
|
20
|
+
import { configFile, listOption, loadConfig, readConfig, readConfigValue, readDisplayConfig } from './config.js';
|
|
21
|
+
import { analyzeCommits, isSaved } from './range-jobs.js';
|
|
22
|
+
import { importerIds, readInputs } from './imports.js';
|
|
23
|
+
import { displayLanguages, outputReports, reporterIds, viewTarget } from './reporting.js';
|
|
24
|
+
import { parseRange } from './revisions.js';
|
|
25
|
+
import { findRepository, invocationDirectory, selectStore, writableStore } from './store.js';
|
|
26
|
+
const configOptions = { config: option('FILE', 'Read a different JSON configuration.'), 'no-config': flag('Skip configuration.') };
|
|
27
|
+
const importOption = option('FORMAT=PATH', 'Import a report produced by another tool. Repeatable.', { multiple: true });
|
|
28
|
+
const excludeOption = option('PATTERN', 'Exclude a path or glob. Repeatable.', { multiple: true });
|
|
29
|
+
const ciOption = option('PROVIDER', 'Send CI output to github or none.');
|
|
30
|
+
const repoOption = option('DIR', 'Run in the given repository.', { short: 'C' });
|
|
31
|
+
const storeOption = option('PATH|git:REF', 'Select a report store.');
|
|
32
|
+
const storageOptions = { repo: repoOption, store: storeOption };
|
|
33
|
+
const displayOptions = {
|
|
34
|
+
...configOptions, branch: option('NAME', 'Name the branch shown in the report.'), title: option('NAME', 'Set the report title.'),
|
|
35
|
+
};
|
|
36
|
+
function commands(distribution) {
|
|
37
|
+
return {
|
|
38
|
+
analyze: {
|
|
39
|
+
description: 'Analyze and save one revision or a range of commits.', parameters: '[REVISION | BASE..[HEAD]]', max: 1,
|
|
40
|
+
options: { ...configOptions, ...storageOptions, 'working-tree': flag('Analyze the working directory.'),
|
|
41
|
+
'skip-saved': flag('Keep commits that already have a saved inspection.'),
|
|
42
|
+
concurrency: option('N', 'Maximum local analysis workers for a range. Defaults to the available cores.'),
|
|
43
|
+
import: importOption,
|
|
44
|
+
exclude: excludeOption, 'import-root': option('DIR', 'Resolve scanner locations relative to this directory.') },
|
|
45
|
+
run: input => runAnalysis(input, distribution),
|
|
46
|
+
},
|
|
47
|
+
show: {
|
|
48
|
+
description: 'Print a saved report.', parameters: 'REVISION|DIGEST', min: 1, max: 1,
|
|
49
|
+
options: { ...storageOptions, files: flag('Print file metrics.') }, run: input => show(input, distribution),
|
|
50
|
+
},
|
|
51
|
+
history: { description: 'List saved inspections.', options: storageOptions, async run(input) {
|
|
52
|
+
const { store } = await context(input);
|
|
53
|
+
print({ schema: 'urn:repometry:schema:inspection-history:1', inspections: (await store.reader.list()).map(inspectionSummary) });
|
|
54
|
+
} },
|
|
55
|
+
review: {
|
|
56
|
+
description: 'Report the issues a change adds or makes worse on the lines it changes.', parameters: 'BASE [HEAD]', min: 1, max: 2,
|
|
57
|
+
options: { ...configOptions, repo: repoOption, import: importOption, exclude: excludeOption, ci: ciOption,
|
|
58
|
+
pull: option('NUMBER', 'Name the pull request in the result.'),
|
|
59
|
+
markdown: option('PATH', 'Also write the result as Markdown, for a pull request comment.') }, run: input => review(input, distribution),
|
|
60
|
+
},
|
|
61
|
+
report: {
|
|
62
|
+
description: 'Render HTML or JSON from saved reports.', parameters: '[FORMAT[=PATH]]...', max: Infinity,
|
|
63
|
+
options: { ...displayOptions, ...storageOptions, source: option('auto|none|ID[:SPEC]', 'Select where the report reads source files.') },
|
|
64
|
+
async run(input) {
|
|
65
|
+
const { root, store } = await context(input);
|
|
66
|
+
const config = await readDisplayConfig(root, input, distribution);
|
|
67
|
+
print({ schema: 'urn:repometry:schema:render-result:1', reports: await outputReports(root, store, input, config, distribution) });
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
view: {
|
|
71
|
+
description: 'Open a repository, store or exported site locally.', parameters: '[TARGET]', max: 1,
|
|
72
|
+
options: { ...displayOptions, store: storeOption, port: option('PORT', 'Listen on this localhost port.') },
|
|
73
|
+
async run(input) { announce(await viewTarget(input, port(input.text('port') ?? '0'), distribution)); },
|
|
74
|
+
},
|
|
75
|
+
projects: {
|
|
76
|
+
description: 'Generate a projects index.', parameters: '[DIR]', max: 1,
|
|
77
|
+
async run(input) {
|
|
78
|
+
const destination = resolve(input.args[0] ?? '.');
|
|
79
|
+
print({ schema: 'urn:repometry:schema:projects-result:1', destination, projects: await exportProjects(destination) });
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
plugins: { description: 'List effective plugins and supported formats.', options: { ...configOptions, repo: repoOption },
|
|
83
|
+
async run(input) {
|
|
84
|
+
const { root, repository } = await repositoryContext(input);
|
|
85
|
+
const config = await readConfig(root, input, true, distribution);
|
|
86
|
+
const missingLanguagePlugins = repository === undefined ? [] : await discoverHead(repository, config);
|
|
87
|
+
print({ schema: 'urn:repometry:schema:plugin-list:2', plugins: effectivePlugins(config.plugins, config.parsers),
|
|
88
|
+
importers: importerIds, reporters: reporterIds, ci: ['github'], stores: ['local', 'git'], missingLanguagePlugins });
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
cache: {
|
|
92
|
+
description: 'Find or clear the system cache.', parameters: 'path|clear', min: 1, max: 1,
|
|
93
|
+
async run(input) {
|
|
94
|
+
const action = input.args[0];
|
|
95
|
+
if (action !== 'path' && action !== 'clear')
|
|
96
|
+
throw new Error('Use cache path or cache clear');
|
|
97
|
+
const path = cacheRoot();
|
|
98
|
+
const cleared = action === 'clear' ? await clearCaches(path) : undefined;
|
|
99
|
+
print({ schema: 'urn:repometry:schema:cache-result:1', path, cleared });
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
store: {
|
|
103
|
+
description: 'Check saved inspections and repair what can be restored.', parameters: 'check', min: 1, max: 1,
|
|
104
|
+
options: {
|
|
105
|
+
...storageOptions, repair: flag('Restore missing data from a copy.'),
|
|
106
|
+
from: option('PATH|git:REF', 'The copy: another store or a storage branch.'),
|
|
107
|
+
},
|
|
108
|
+
async run(input) {
|
|
109
|
+
if (input.args[0] !== 'check')
|
|
110
|
+
throw new Error('Use store check');
|
|
111
|
+
const from = input.text('from');
|
|
112
|
+
if (from !== undefined && !input.flag('repair'))
|
|
113
|
+
throw new Error('--from requires --repair');
|
|
114
|
+
const { directory, root, store } = await context(input);
|
|
115
|
+
const path = writableStore(store);
|
|
116
|
+
const source = from === undefined ? undefined
|
|
117
|
+
: from.startsWith('git:') ? await gitReportObjects(root, from.slice(4)) : new LocalObjectStore(resolve(directory, from)).source();
|
|
118
|
+
const result = await checkStore(path, input.flag('repair') ? { from: source } : undefined);
|
|
119
|
+
print({ ...result, store: path });
|
|
120
|
+
return result.problems.length ? 3 : 0;
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async function repositoryContext(input) {
|
|
126
|
+
const directory = invocationDirectory(input);
|
|
127
|
+
const repository = await findRepository(directory);
|
|
128
|
+
return { directory, root: repository ?? directory, repository };
|
|
129
|
+
}
|
|
130
|
+
async function context(input) {
|
|
131
|
+
const { directory, root } = await repositoryContext(input);
|
|
132
|
+
return { directory, root, store: selectStore(root, input.text('store'), directory) };
|
|
133
|
+
}
|
|
134
|
+
function runAnalysis(input, distribution) {
|
|
135
|
+
const range = input.args[0] === undefined ? undefined : parseRange(input.args[0]);
|
|
136
|
+
if (range)
|
|
137
|
+
return analyzeRange(input, range, distribution);
|
|
138
|
+
if (input.text('concurrency') !== undefined)
|
|
139
|
+
throw new Error('--concurrency requires a revision range');
|
|
140
|
+
return analyze(input, distribution);
|
|
141
|
+
}
|
|
142
|
+
async function analyze(input, distribution) {
|
|
143
|
+
const { directory, root, store } = await context(input);
|
|
144
|
+
const output = writableStore(store);
|
|
145
|
+
const workingTree = input.flag('working-tree');
|
|
146
|
+
if (workingTree && input.args.length)
|
|
147
|
+
throw new Error('Choose a revision or --working-tree');
|
|
148
|
+
if (workingTree && input.flag('skip-saved'))
|
|
149
|
+
throw new Error('--skip-saved applies to commits, not --working-tree');
|
|
150
|
+
const config = await readConfig(root, input, false, distribution);
|
|
151
|
+
const revision = input.args[0] ?? 'HEAD';
|
|
152
|
+
const imports = input.many('import');
|
|
153
|
+
const { findings, ...coverage } = imports.length ? readInputs(directory, imports) : readInputs(root, config.imports);
|
|
154
|
+
const importRoot = input.text('import-root');
|
|
155
|
+
if (importRoot && findings.length === 0)
|
|
156
|
+
throw new Error('--import-root requires a scanner report');
|
|
157
|
+
const savedId = input.flag('skip-saved') ? await resolveGitCommit(root, revision) : undefined;
|
|
158
|
+
const skipped = savedId !== undefined && await isSaved(output, savedId);
|
|
159
|
+
const inventory = detectMissingLanguages(config.plugins);
|
|
160
|
+
const report = skipped ? await store.reader.read({ kind: 'commit', id: savedId })
|
|
161
|
+
: await inspectWithOptions({ directory, output, source: workingTree ? { workingTree: true } : { revision },
|
|
162
|
+
...coverage, exclude: listOption(input, 'exclude', config.exclude), ignore: config.ignore, plugins: config.plugins, parsers: config.parsers,
|
|
163
|
+
findingInputs: findings, findingRoot: importRoot ? resolve(directory, importRoot) : undefined }, { inventory });
|
|
164
|
+
announceMissingLanguages(inventory.results());
|
|
165
|
+
print({ schema: 'urn:repometry:schema:analysis-result:1', ...inspectionSummary(report), ...(skipped ? { skipped: true } : {}),
|
|
166
|
+
store: output });
|
|
167
|
+
return report.status === 'partial' ? 2 : 0;
|
|
168
|
+
}
|
|
169
|
+
async function analyzeRange(input, range, distribution) {
|
|
170
|
+
const { directory, root, store } = await context(input);
|
|
171
|
+
const output = writableStore(store);
|
|
172
|
+
if (input.flag('working-tree'))
|
|
173
|
+
throw new Error('Choose a range or --working-tree');
|
|
174
|
+
if (input.many('import').length)
|
|
175
|
+
throw new Error('--import describes one checkout and cannot be used with a range');
|
|
176
|
+
if (input.text('import-root'))
|
|
177
|
+
throw new Error('--import-root requires a scanner report');
|
|
178
|
+
const concurrency = count(input.text('concurrency'), '--concurrency', 1);
|
|
179
|
+
const configValue = await readConfigValue(root, input);
|
|
180
|
+
const settingsFile = configFile(root, input);
|
|
181
|
+
const config = await loadConfig(configValue, root, settingsFile, false, distribution);
|
|
182
|
+
if (config.imports.length)
|
|
183
|
+
process.stderr.write('Imports from the config describe one checkout and are skipped for a range.\n');
|
|
184
|
+
const { base, head, commits } = await firstParentRange(root, range.base, range.head);
|
|
185
|
+
if (!commits.length)
|
|
186
|
+
process.stderr.write(`No commits in ${range.base}..${range.head}.\n`);
|
|
187
|
+
const inspection = { directory, output, exclude: listOption(input, 'exclude', config.exclude) };
|
|
188
|
+
const { interrupted, missingLanguagePlugins, ...results } = await analyzeCommits(commits, {
|
|
189
|
+
inspection, config, configuration: { value: configValue, root, file: settingsFile, distributionModule: distribution?.moduleUrl },
|
|
190
|
+
// Workers need the distribution module to recreate its executable plugins.
|
|
191
|
+
concurrency: distribution !== undefined && distribution.moduleUrl === undefined ? 1 : concurrency,
|
|
192
|
+
skipSaved: input.flag('skip-saved'),
|
|
193
|
+
});
|
|
194
|
+
announceMissingLanguages(missingLanguagePlugins);
|
|
195
|
+
print({ schema: 'urn:repometry:schema:analyze-range:1', range: `${base}..${head}`,
|
|
196
|
+
...results, store: output });
|
|
197
|
+
return interrupted ? 130 : results.failed.length || results.partial.length ? 2 : 0;
|
|
198
|
+
}
|
|
199
|
+
function announceMissingLanguages(hints) {
|
|
200
|
+
for (const hint of hints)
|
|
201
|
+
process.stderr.write(missingLanguageNotice(hint) + '\n');
|
|
202
|
+
}
|
|
203
|
+
async function discoverHead(repository, config) {
|
|
204
|
+
const head = await resolveGitCommit(repository, 'HEAD').catch(() => undefined);
|
|
205
|
+
if (head === undefined)
|
|
206
|
+
return [];
|
|
207
|
+
const inventory = detectMissingLanguages(config.plugins);
|
|
208
|
+
const excludes = sourceExclusionMatcher(config.exclude);
|
|
209
|
+
for (const { path } of await gitTreeFiles(repository, head)) {
|
|
210
|
+
if (!excludes(path) && !path.split('/').slice(0, -1).some(isExcludedDirectory))
|
|
211
|
+
inventory.record(path);
|
|
212
|
+
}
|
|
213
|
+
return inventory.results();
|
|
214
|
+
}
|
|
215
|
+
async function show(input, distribution) {
|
|
216
|
+
const { root, store } = await context(input);
|
|
217
|
+
const ref = input.args[0];
|
|
218
|
+
const id = await commitId(root, ref);
|
|
219
|
+
let report;
|
|
220
|
+
try {
|
|
221
|
+
report = await store.reader.read({ kind: 'commit', id });
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
if (!validSubjectId('working-tree', ref) || store.path === undefined || !(error instanceof Error)
|
|
225
|
+
|| !('code' in error) || error.code !== 'ENOENT')
|
|
226
|
+
throw error;
|
|
227
|
+
report = await store.reader.read({ kind: 'working-tree', id: ref });
|
|
228
|
+
}
|
|
229
|
+
print(input.flag('files') ? fileMetrics(report, displayLanguages(distribution)) : report);
|
|
230
|
+
}
|
|
231
|
+
async function review(input, distribution) {
|
|
232
|
+
const { directory, root } = await repositoryContext(input);
|
|
233
|
+
const github = useGitHub(input);
|
|
234
|
+
const config = await readConfig(root, input, false, distribution);
|
|
235
|
+
const imports = input.many('import');
|
|
236
|
+
const { findings, ...coverage } = imports.length ? readInputs(directory, imports) : readInputs(root, config.imports);
|
|
237
|
+
if (findings.length && imports.length)
|
|
238
|
+
throw new Error('review compares both sides of a change; scanner imports apply to full inspections only');
|
|
239
|
+
if (findings.length)
|
|
240
|
+
process.stderr.write('Scanner imports from the config are skipped: review compares both sides of a change.\n');
|
|
241
|
+
const profileFile = configFile(root, input);
|
|
242
|
+
const { plugins, ...profile } = config;
|
|
243
|
+
const report = await reviewChange({ directory: root, base: input.args[0], revision: input.args[1] ?? 'HEAD', ...coverage,
|
|
244
|
+
exclude: listOption(input, 'exclude', config.exclude), ignore: config.ignore, plugins, parsers: config.parsers, profile,
|
|
245
|
+
profilePath: profileFile === undefined ? undefined : relative(root, profileFile).split(sep).join('/'),
|
|
246
|
+
number: count(input.text('pull'), '--pull', 1) ?? (github ? await gitHubPullRequest() : undefined),
|
|
247
|
+
minimumPercent: config.minCoverage, minimumLines: config.minLines, maxNewIssues: config.maxNewIssues });
|
|
248
|
+
const markdown = pullReviewMarkdown(report);
|
|
249
|
+
if (github)
|
|
250
|
+
await writeGitHubReview(report, markdown, await gitRoot(root));
|
|
251
|
+
const markdownPath = input.text('markdown');
|
|
252
|
+
if (markdownPath !== undefined)
|
|
253
|
+
await writeFile(resolve(directory, markdownPath), markdown);
|
|
254
|
+
print(report);
|
|
255
|
+
const code = reviewExitCode(report);
|
|
256
|
+
if (code !== 0)
|
|
257
|
+
process.stderr.write(`${reviewReason(report)}\n`);
|
|
258
|
+
return code;
|
|
259
|
+
}
|
|
260
|
+
function commitId(root, revision) {
|
|
261
|
+
return validSubjectId('commit', revision) ? Promise.resolve(revision) : resolveGitCommit(root, revision);
|
|
262
|
+
}
|
|
263
|
+
function useGitHub(input) {
|
|
264
|
+
const provider = input.text('ci') ?? 'none';
|
|
265
|
+
if (provider !== 'none' && provider !== 'github')
|
|
266
|
+
throw new Error('--ci must be github or none');
|
|
267
|
+
return provider === 'github';
|
|
268
|
+
}
|
|
269
|
+
function count(value, name, minimum = 0) {
|
|
270
|
+
if (value === undefined)
|
|
271
|
+
return undefined;
|
|
272
|
+
const number = Number(value);
|
|
273
|
+
if (!/^\d+$/.test(value) || !Number.isSafeInteger(number) || number < minimum)
|
|
274
|
+
throw new Error(`${name} must be an integer of at least ${minimum}`);
|
|
275
|
+
return number;
|
|
276
|
+
}
|
|
277
|
+
function port(value) {
|
|
278
|
+
const number = count(value, '--port');
|
|
279
|
+
if (number > 65535)
|
|
280
|
+
throw new Error('--port must be an integer from 0 to 65535');
|
|
281
|
+
return number;
|
|
282
|
+
}
|
|
283
|
+
function announce(server) {
|
|
284
|
+
process.once('SIGINT', () => { process.exitCode = 130; server.close(); });
|
|
285
|
+
process.once('SIGTERM', server.close);
|
|
286
|
+
process.stderr.write(`Serving${server.label ? ' ' + server.label : ''} at ${server.url}\n`);
|
|
287
|
+
}
|
|
288
|
+
function inspectionSummary(report) {
|
|
289
|
+
return { subject: report.subject, generatedAt: report.generatedAt, status: report.status, scope: report.scope,
|
|
290
|
+
measurements: report.measurements.length, diagnostics: report.diagnostics.length };
|
|
291
|
+
}
|
|
292
|
+
function print(value) {
|
|
293
|
+
process.stdout.write(JSON.stringify(value, null, 2) + '\n');
|
|
294
|
+
}
|
|
295
|
+
export async function runCli(distribution) {
|
|
296
|
+
try {
|
|
297
|
+
const packageUrl = new URL(distribution?.packageUrl ?? '../../../../package.json', import.meta.url);
|
|
298
|
+
const manifest = JSON.parse(await readFile(packageUrl, 'utf8'));
|
|
299
|
+
process.exitCode = await dispatch(commands(distribution), process.argv.slice(2), manifest.version);
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
process.stderr.write(`repometry: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
303
|
+
process.exitCode = 1;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Invocation } from './arguments.js';
|
|
2
|
+
import type { ReportReader } from '../report/json/validation/report.js';
|
|
3
|
+
export type Store = {
|
|
4
|
+
readonly reader: ReportReader;
|
|
5
|
+
readonly path?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function findRepository(directory: string): Promise<string | undefined>;
|
|
8
|
+
/** Where relative paths typed on the command line resolve: --repo/-C, like git -C, or else the current directory. */
|
|
9
|
+
export declare function invocationDirectory(input: Invocation): string;
|
|
10
|
+
/** A typed path resolves against `base`; the default store resolves against the repository root. */
|
|
11
|
+
export declare function selectStore(root: string, value?: string, base?: string): Store;
|
|
12
|
+
export declare function writableStore(store: Store): string;
|
|
13
|
+
export declare function isDirectory(path: string): Promise<boolean>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { lstat } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { GitReportReader } from '../api/git/git-reader.js';
|
|
4
|
+
import { gitRoot } from '../api/git/git.js';
|
|
5
|
+
import { LocalReportStore } from '../report/json/store/local-store.js';
|
|
6
|
+
export async function findRepository(directory) {
|
|
7
|
+
return gitRoot(directory).catch(() => undefined);
|
|
8
|
+
}
|
|
9
|
+
/** Where relative paths typed on the command line resolve: --repo/-C, like git -C, or else the current directory. */
|
|
10
|
+
export function invocationDirectory(input) {
|
|
11
|
+
return resolve(input.text('repo') ?? '.');
|
|
12
|
+
}
|
|
13
|
+
/** A typed path resolves against `base`; the default store resolves against the repository root. */
|
|
14
|
+
export function selectStore(root, value, base = root) {
|
|
15
|
+
if (value?.startsWith('git:')) {
|
|
16
|
+
const ref = value.slice(4);
|
|
17
|
+
if (!ref)
|
|
18
|
+
throw new Error('--store git: requires a ref');
|
|
19
|
+
return { reader: new GitReportReader(root, ref) };
|
|
20
|
+
}
|
|
21
|
+
const path = value === undefined ? resolve(root, '.repometry') : resolve(base, value);
|
|
22
|
+
return { path, reader: new LocalReportStore(path) };
|
|
23
|
+
}
|
|
24
|
+
export function writableStore(store) {
|
|
25
|
+
if (store.path === undefined)
|
|
26
|
+
throw new Error('Use a local store when writing inspections or reviews');
|
|
27
|
+
return store.path;
|
|
28
|
+
}
|
|
29
|
+
export async function isDirectory(path) {
|
|
30
|
+
try {
|
|
31
|
+
return (await lstat(path)).isDirectory();
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error instanceof Error && 'code' in error && (error.code === 'ENOENT' || error.code === 'ENOTDIR'))
|
|
35
|
+
return false;
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Report } from '@repometry/core/internal/model/report.js';
|
|
2
|
+
import type { AnalysisInput } from '@repometry/core/internal/usecases/inspect.js';
|
|
3
|
+
import type { AnalysisResults } from './analysis-results.js';
|
|
4
|
+
import type { AnalysisSources } from './phases.js';
|
|
5
|
+
export declare const analysisProfile = "repository/v4";
|
|
6
|
+
export declare function assembleAnalysisReport(input: AnalysisInput, sources: AnalysisSources, results: AnalysisResults): Report;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { codeStructure, codeStructures, structureMeasures } from '@repometry/core/internal/model/code-structure.js';
|
|
2
|
+
import { pluginRegistration } from './registered-plugin.js';
|
|
3
|
+
import { pluginScope } from './plugin-scope.js';
|
|
4
|
+
import { definitions } from '@repometry/core/internal/model/measurement.js';
|
|
5
|
+
import { debtModel } from '@repometry/core/internal/model/quality-summary.js';
|
|
6
|
+
import { reportSchema } from '@repometry/core/internal/model/report.js';
|
|
7
|
+
import { comparePaths, digest, sourceDirectoriesExcluded, textLineCount } from '@repometry/core/internal/model/snapshot.js';
|
|
8
|
+
import { defaultSourceExclusions, generatedSourcePolicy } from '@repometry/core/internal/profile/exclusions.js';
|
|
9
|
+
import { duplicationSettings, structuralRules } from '@repometry/core/internal/profile/maintainability.js';
|
|
10
|
+
import { fileTypeId } from '@repometry/core/internal/model/file-types.js';
|
|
11
|
+
export const analysisProfile = 'repository/v4';
|
|
12
|
+
const measurementDefinitions = {
|
|
13
|
+
[definitions.lines]: 'Physical lines including blank lines and comments. A final line terminator does not add a line.',
|
|
14
|
+
[definitions.functions]: 'Functions, methods and function literals recognized by the language provider, including nested functions.',
|
|
15
|
+
[definitions.complexity]: 'One plus decision points in the function body. The language provider defines its decision rules and column units. Nested functions are measured separately.',
|
|
16
|
+
[definitions.coverage]: 'Distinct covered lines divided by the distinct lines listed in LCOV DA records, filtered to code where classifications are available. Hit counts are summed across records. A zero denominator has no ratio.',
|
|
17
|
+
[definitions.codeLines]: 'Nonblank physical lines after removing comment spans and the interpreter directive. A line containing both code and a comment counts as code.',
|
|
18
|
+
[definitions.comments]: 'Physical lines containing only a comment or interpreter directive.',
|
|
19
|
+
[definitions.classes]: 'Class declarations and expressions recognized by the language provider.',
|
|
20
|
+
[definitions.cognitiveComplexity]: 'Flow breaks plus nesting weight and logical operator sequences. Nested functions are measured separately. File complexity sums functions and module-level flow breaks.',
|
|
21
|
+
[definitions.duplicatedLines]: 'Distinct code lines inside repeated Babel syntax subtrees, including original and repeated occurrences. Identifier and literal spellings are ignored for similar-code matches.',
|
|
22
|
+
};
|
|
23
|
+
export function assembleAnalysisReport(input, sources, results) {
|
|
24
|
+
const pluginData = results.pluginData();
|
|
25
|
+
const { snapshot } = input;
|
|
26
|
+
const selected = new Set([...sources.providersByPath.values()].map(provider => provider.plugin.id));
|
|
27
|
+
const selectors = sources.languages.reportSelection(selected);
|
|
28
|
+
const fileCount = sources.sourceFiles.length + sources.unavailableFiles.size;
|
|
29
|
+
return {
|
|
30
|
+
schema: reportSchema,
|
|
31
|
+
subject: snapshot.subject,
|
|
32
|
+
generatedAt: new Date().toISOString(),
|
|
33
|
+
appliedConfig: appliedConfiguration(input, sources, results, selectors),
|
|
34
|
+
definitions: { ...Object.fromEntries((pluginData?.metrics ?? []).map(metric => [metric.id, metric.description ?? metric.label])),
|
|
35
|
+
...measurementDefinitions },
|
|
36
|
+
scope: { files: fileCount, parsed: results.parsed.size,
|
|
37
|
+
...(results.recovered.size ? { recovered: results.recovered.size } : {}) },
|
|
38
|
+
status: inspectionStatus(fileCount > 0, results),
|
|
39
|
+
measurements: results.measurements,
|
|
40
|
+
diagnostics: results.diagnostics,
|
|
41
|
+
findings: results.findings,
|
|
42
|
+
...(results.ruleSkips.length === 0 ? {} : { ruleSkips: results.ruleSkips }),
|
|
43
|
+
...(pluginData === undefined ? {} : { pluginData: { ...pluginData, languages: selectors.catalog,
|
|
44
|
+
inventory: reportInventory(snapshot, sources, results) } }),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function appliedConfiguration({ snapshot, excludedOutput, excludedPaths = [], coverage }, sources, results, selectors) {
|
|
48
|
+
const { languages, plugins, providersByPath } = sources;
|
|
49
|
+
const securityScanners = results.securityScanners(plugins);
|
|
50
|
+
const active = new Set(plugins.map(plugin => plugin.id));
|
|
51
|
+
const parsed = languagesForPaths(results.parsed, providersByPath);
|
|
52
|
+
const provenance = languages.plugins.flatMap(plugin => {
|
|
53
|
+
if (plugin.unavailableReason !== undefined && pluginRegistration(plugin))
|
|
54
|
+
return [pluginProvenance(plugin)];
|
|
55
|
+
if (!plugin.kinds.includes('language'))
|
|
56
|
+
return active.has(plugin.id) ? [pluginProvenance(plugin)] : [];
|
|
57
|
+
const used = parsed.get(plugin.id);
|
|
58
|
+
const ranOther = plugin.operations.some(({ id, output }) => output.id !== codeStructure.id && output.id !== codeStructures.id
|
|
59
|
+
&& results.ran.has(plugin.id + '/' + id));
|
|
60
|
+
if (!used && !ranOther)
|
|
61
|
+
return [];
|
|
62
|
+
return [pluginProvenance(languages.describe(plugin))];
|
|
63
|
+
});
|
|
64
|
+
const defaultParser = languages.providers[0]?.plugin;
|
|
65
|
+
return {
|
|
66
|
+
profile: analysisProfile, mode: snapshot.subject.kind,
|
|
67
|
+
source: { extensions: selectors.extensions, ...(selectors.globs.length ? { globs: selectors.globs } : {}),
|
|
68
|
+
excludedDirectories: sourceDirectoriesExcluded, excludedOutput, excludedPaths,
|
|
69
|
+
defaultExclusions: defaultSourceExclusions, generatedSourcePolicy, generatedExcluded: snapshot.generatedExcluded ?? [] },
|
|
70
|
+
parser: defaultParser && parsed.has(defaultParser.id) ? defaultParser.settings : undefined,
|
|
71
|
+
maintainability: { structuralRules, duplication: duplicationSettings, debtModel, remediation: 'nonoverlapping-complexity/v1' },
|
|
72
|
+
coverage: coverage === undefined ? null : { inputDigest: digest(coverage.text), pathBase: coverage.sourceRoot,
|
|
73
|
+
merge: 'any-hit', hitCounts: 'sum',
|
|
74
|
+
lines: [...results.unmeasured.values()].some(measures => measures.includes('codeLines')) ? 'code-when-classified' : 'code-only' },
|
|
75
|
+
...(securityScanners.length ? { securityScanners } : {}),
|
|
76
|
+
plugins: provenance,
|
|
77
|
+
operations: inspectionOperations(sources, results.operationRecords()),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function inspectionOperations({ languages, providersByPath }, operations) {
|
|
81
|
+
const present = languagesForPaths(providersByPath.keys(), providersByPath);
|
|
82
|
+
const parsers = new Map(languages.providers.map(provider => [provider.key, provider]));
|
|
83
|
+
return operations.map(row => {
|
|
84
|
+
const parser = parsers.get(row.key);
|
|
85
|
+
if (!parser)
|
|
86
|
+
return row;
|
|
87
|
+
const { implementation: _all, ...operation } = row;
|
|
88
|
+
const implementation = parser.implementationFor(present.get(parser.plugin.id) ?? new Set());
|
|
89
|
+
return implementation === undefined ? operation : { ...operation, implementation };
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function languagesForPaths(paths, providersByPath) {
|
|
93
|
+
const parsed = new Map();
|
|
94
|
+
for (const path of paths) {
|
|
95
|
+
const provider = providersByPath.get(path);
|
|
96
|
+
if (!provider)
|
|
97
|
+
continue;
|
|
98
|
+
const { id } = provider.plugin;
|
|
99
|
+
const used = parsed.get(id) ?? new Set();
|
|
100
|
+
used.add(provider.language(path) ?? fileTypeId(path));
|
|
101
|
+
parsed.set(id, used);
|
|
102
|
+
}
|
|
103
|
+
return parsed;
|
|
104
|
+
}
|
|
105
|
+
function pluginProvenance(plugin) {
|
|
106
|
+
const { id, version, api, tools, kinds, claims, settings, providesLanguages, unavailableReason } = plugin;
|
|
107
|
+
const image = pluginRegistration(plugin)?.image;
|
|
108
|
+
return { id, version, api, tools: tools ?? {}, kinds, ...pluginScope(plugin),
|
|
109
|
+
...(image === undefined ? {} : { image }),
|
|
110
|
+
...(claims === undefined ? {} : { claims }), ...(settings === undefined ? {} : { settings }),
|
|
111
|
+
...(providesLanguages === undefined ? {} : { providesLanguages: providesLanguages.map(({ syntax, ...language }) => language) }), ...(unavailableReason === undefined ? {} : { unavailableReason }) };
|
|
112
|
+
}
|
|
113
|
+
function inspectionStatus(hasSources, results) {
|
|
114
|
+
if (results.hasBlockingDiagnostics())
|
|
115
|
+
return 'partial';
|
|
116
|
+
return !hasSources && !results.completedInspection ? 'not-applicable' : 'complete';
|
|
117
|
+
}
|
|
118
|
+
function reportInventory(snapshot, sources, results) {
|
|
119
|
+
const inventory = new Map((snapshot.inventory ?? []).map(({ path, lines, bytes }) => [path, { lines, bytes }]));
|
|
120
|
+
for (const { path, bytes } of snapshot.files) {
|
|
121
|
+
if (!inventory.has(path))
|
|
122
|
+
inventory.set(path, { lines: textLineCount(bytes), bytes: bytes.length });
|
|
123
|
+
}
|
|
124
|
+
return [...inventory].sort(([left], [right]) => comparePaths(left, right)).map(([path, { lines, bytes }]) => {
|
|
125
|
+
const provider = sources.providersByPath.get(path);
|
|
126
|
+
const unmeasured = sources.unavailableFiles.has(path) ? structureMeasures : results.unmeasured.get(path);
|
|
127
|
+
return { path, lines, ...(bytes === undefined ? {} : { bytes }), language: provider?.language(path) ?? fileTypeId(path),
|
|
128
|
+
analysed: results.parsed.has(path) || results.inspected.has(path), ...(provider === undefined ? {} : { provider: provider.key }),
|
|
129
|
+
...(unmeasured === undefined ? {} : { unmeasured }) };
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=analysis-report.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Outcome } from '@repometry/core/internal/engine/execute.js';
|
|
2
|
+
import type { PlannedOperation } from '@repometry/core/internal/engine/plan.js';
|
|
3
|
+
import type { Plugin } from '@repometry/core/internal/engine/plugin.js';
|
|
4
|
+
import type { Finding } from '@repometry/core/internal/model/finding.js';
|
|
5
|
+
import type { Measurement } from '@repometry/core/internal/model/measurement.js';
|
|
6
|
+
import type { Diagnostic, Report } from '@repometry/core/internal/model/report.js';
|
|
7
|
+
export declare class AnalysisResults {
|
|
8
|
+
readonly measurements: Measurement[];
|
|
9
|
+
readonly findings: Finding[];
|
|
10
|
+
readonly diagnostics: Diagnostic[];
|
|
11
|
+
readonly parsed: Set<string>;
|
|
12
|
+
readonly recovered: Map<string, Diagnostic>;
|
|
13
|
+
readonly ran: Set<string>;
|
|
14
|
+
readonly ruleSkips: NonNullable<Report['ruleSkips']>[number][];
|
|
15
|
+
readonly unmeasured: Map<string, readonly ("classes" | "codeLines" | "cognitiveComplexity" | "commentLines" | "cyclomaticComplexity" | "duplication" | "functions" | "structuralRules")[]>;
|
|
16
|
+
readonly inspected: Set<string>;
|
|
17
|
+
completedInspection: boolean;
|
|
18
|
+
private readonly products;
|
|
19
|
+
private readonly scanned;
|
|
20
|
+
private readonly scanOnly;
|
|
21
|
+
private readonly securityOperations;
|
|
22
|
+
private readonly recoveryOperations;
|
|
23
|
+
private readonly usedPlans;
|
|
24
|
+
constructor(plugins: readonly Plugin[], oversized: readonly string[]);
|
|
25
|
+
remember(task: PlannedOperation, syntaxProvider?: string): void;
|
|
26
|
+
operationRecords(): readonly ReturnType<typeof operationProvenance>[];
|
|
27
|
+
pluginData(): import("@repometry/core/internal/model/plugin-data.js").PluginData | undefined;
|
|
28
|
+
securityScanners(plugins: readonly Plugin[]): {
|
|
29
|
+
name: string;
|
|
30
|
+
version: string;
|
|
31
|
+
}[];
|
|
32
|
+
record(task: PlannedOperation, outcome: Outcome, path?: string, paths?: readonly string[]): void;
|
|
33
|
+
hasBlockingDiagnostics(): boolean;
|
|
34
|
+
private recordRecovery;
|
|
35
|
+
private recordInspection;
|
|
36
|
+
}
|
|
37
|
+
export declare function operationProvenance(task: PlannedOperation, syntaxProvider?: string): {
|
|
38
|
+
key: string;
|
|
39
|
+
inputs: {
|
|
40
|
+
[k: string]: import("@repometry/core/internal/engine/plan.js").InputBinding;
|
|
41
|
+
};
|
|
42
|
+
implementation?: string | undefined;
|
|
43
|
+
scope?: "repository" | undefined;
|
|
44
|
+
syntaxProvider?: string | undefined;
|
|
45
|
+
};
|
|
46
|
+
export declare function oversizedClaim(path: string): Diagnostic;
|