dart-decimate 0.0.1
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/Cargo.lock +572 -0
- package/Cargo.toml +41 -0
- package/LICENSE +21 -0
- package/README.md +617 -0
- package/assets/dart-decimate-banner.png +0 -0
- package/npm/bin/dart-decimate-mcp.js +48 -0
- package/npm/bin/dart-decimate.js +48 -0
- package/npm/scripts/postinstall.js +46 -0
- package/npm/scripts/test-npx-local.js +54 -0
- package/npm/scripts/test-npx-mcp-local.js +56 -0
- package/package.json +45 -0
- package/src/baseline.rs +643 -0
- package/src/bin/dart-decimate-mcp.rs +11 -0
- package/src/boundaries/tests.rs +60 -0
- package/src/boundaries.rs +317 -0
- package/src/changed_scope.rs +117 -0
- package/src/ci_template.rs +399 -0
- package/src/cli/analyze.rs +462 -0
- package/src/cli/analyzer_options.rs +82 -0
- package/src/cli/audit_run.rs +327 -0
- package/src/cli/boundary_args.rs +44 -0
- package/src/cli/ci_template_run.rs +196 -0
- package/src/cli/command_name.rs +20 -0
- package/src/cli/common_args.rs +167 -0
- package/src/cli/config_run.rs +78 -0
- package/src/cli/coverage_run.rs +393 -0
- package/src/cli/decision_surface_run.rs +99 -0
- package/src/cli/default_command.rs +69 -0
- package/src/cli/dupes_args.rs +150 -0
- package/src/cli/entry_points.rs +121 -0
- package/src/cli/error.rs +149 -0
- package/src/cli/error_output.rs +68 -0
- package/src/cli/explain_run.rs +72 -0
- package/src/cli/fix_run.rs +162 -0
- package/src/cli/flags_args.rs +23 -0
- package/src/cli/health_args.rs +200 -0
- package/src/cli/hooks_run.rs +191 -0
- package/src/cli/impact_run.rs +95 -0
- package/src/cli/init_run.rs +49 -0
- package/src/cli/inspect_args.rs +20 -0
- package/src/cli/inspect_run.rs +66 -0
- package/src/cli/issue_filter_args.rs +240 -0
- package/src/cli/list_run.rs +311 -0
- package/src/cli/mode_args.rs +72 -0
- package/src/cli/output_format.rs +62 -0
- package/src/cli/regression_args.rs +156 -0
- package/src/cli/request_args.rs +175 -0
- package/src/cli/schema_commands.rs +72 -0
- package/src/cli/scope_args.rs +174 -0
- package/src/cli/security_args.rs +175 -0
- package/src/cli/security_gate_run.rs +66 -0
- package/src/cli/security_summary_run.rs +43 -0
- package/src/cli/summary_args.rs +12 -0
- package/src/cli/tests.rs +516 -0
- package/src/cli/trace_args.rs +67 -0
- package/src/cli/trace_run.rs +131 -0
- package/src/cli/trace_tests.rs +235 -0
- package/src/cli/unsupported_run.rs +116 -0
- package/src/cli/watch_run.rs +153 -0
- package/src/cli.rs +603 -0
- package/src/config/boundary_config.rs +235 -0
- package/src/config/cache.rs +25 -0
- package/src/config/dependencies.rs +114 -0
- package/src/config/health.rs +237 -0
- package/src/config/jsonc.rs +66 -0
- package/src/config/policy.rs +91 -0
- package/src/config/rule_aliases.rs +487 -0
- package/src/config/rules.rs +339 -0
- package/src/config.rs +635 -0
- package/src/coverage.rs +469 -0
- package/src/dart_parser.rs +673 -0
- package/src/decision_surface.rs +405 -0
- package/src/dependencies/analyze.rs +218 -0
- package/src/dependencies/codegen.rs +118 -0
- package/src/dependencies/discovery.rs +60 -0
- package/src/dependencies/overrides.rs +76 -0
- package/src/dependencies/private_src_imports.rs +32 -0
- package/src/dependencies/pubspec_document.rs +86 -0
- package/src/dependencies/pubspec_entry.rs +96 -0
- package/src/dependencies/tests.rs +544 -0
- package/src/dependencies/usage.rs +33 -0
- package/src/dependencies.rs +553 -0
- package/src/dependency_scripts.rs +91 -0
- package/src/dupes/lex.rs +236 -0
- package/src/dupes/tests.rs +119 -0
- package/src/dupes.rs +625 -0
- package/src/explain.rs +692 -0
- package/src/extract/directives.rs +252 -0
- package/src/extract/error_tests.rs +25 -0
- package/src/extract/members.rs +210 -0
- package/src/extract/primary_constructors.rs +421 -0
- package/src/extract/references.rs +151 -0
- package/src/extract/routes.rs +691 -0
- package/src/extract/signatures.rs +266 -0
- package/src/extract/string_tests.rs +18 -0
- package/src/extract/strings.rs +107 -0
- package/src/extract/tests.rs +697 -0
- package/src/extract.rs +680 -0
- package/src/feature_flags/tests.rs +76 -0
- package/src/feature_flags.rs +453 -0
- package/src/finding_identity.rs +60 -0
- package/src/fix.rs +551 -0
- package/src/generated.rs +53 -0
- package/src/graph/augment_tests.rs +212 -0
- package/src/graph/conditionals.rs +74 -0
- package/src/graph/package_config_tests.rs +100 -0
- package/src/graph/parts.rs +248 -0
- package/src/graph/pubspec_tests.rs +119 -0
- package/src/graph/tests.rs +837 -0
- package/src/graph/uri_tests.rs +102 -0
- package/src/graph.rs +644 -0
- package/src/health/coverage.rs +309 -0
- package/src/health/ownership.rs +175 -0
- package/src/health/runtime_coverage.rs +616 -0
- package/src/health/runtime_intelligence.rs +511 -0
- package/src/health/scores.rs +296 -0
- package/src/health/tests.rs +240 -0
- package/src/health/threshold_types.rs +163 -0
- package/src/health/thresholds.rs +229 -0
- package/src/health/types.rs +636 -0
- package/src/health.rs +597 -0
- package/src/hooks/agent_settings.rs +175 -0
- package/src/hooks/templates.rs +51 -0
- package/src/hooks.rs +569 -0
- package/src/impact.rs +287 -0
- package/src/init.rs +237 -0
- package/src/inspect.rs +142 -0
- package/src/intelligence/tests.rs +232 -0
- package/src/intelligence.rs +305 -0
- package/src/lib.rs +198 -0
- package/src/main.rs +5 -0
- package/src/manifest/mcp.rs +565 -0
- package/src/manifest.rs +552 -0
- package/src/mcp/cli_args/value_args.rs +175 -0
- package/src/mcp/cli_args.rs +658 -0
- package/src/mcp/cli_args_tests.rs +522 -0
- package/src/mcp/code_execute.rs +671 -0
- package/src/mcp/tools.rs +660 -0
- package/src/mcp.rs +325 -0
- package/src/output/audit_risk.rs +135 -0
- package/src/output/dependency_findings.rs +327 -0
- package/src/output/duplication_findings.rs +114 -0
- package/src/output/feature_flag_findings.rs +122 -0
- package/src/output/format.rs +31 -0
- package/src/output/graph_findings.rs +461 -0
- package/src/output/health_findings.rs +612 -0
- package/src/output/human.rs +27 -0
- package/src/output/next_steps.rs +92 -0
- package/src/output/route_findings.rs +76 -0
- package/src/output/runtime_coverage.rs +515 -0
- package/src/output/scope.rs +183 -0
- package/src/output/security_findings.rs +390 -0
- package/src/output/security_sarif.rs +150 -0
- package/src/output/suppressions.rs +323 -0
- package/src/output/symbol_findings.rs +257 -0
- package/src/output/tests.rs +114 -0
- package/src/output/types.rs +604 -0
- package/src/output/widget_findings.rs +213 -0
- package/src/output.rs +682 -0
- package/src/package_map.rs +495 -0
- package/src/policy/packs.rs +232 -0
- package/src/policy/tests.rs +134 -0
- package/src/policy.rs +640 -0
- package/src/project_list.rs +376 -0
- package/src/report_schema/inventory.rs +418 -0
- package/src/report_schema.rs +488 -0
- package/src/routes.rs +354 -0
- package/src/scan/tests.rs +250 -0
- package/src/scan.rs +275 -0
- package/src/security/detect.rs +639 -0
- package/src/security/tests.rs +178 -0
- package/src/security.rs +373 -0
- package/src/security_gate.rs +555 -0
- package/src/symbols/path_filters.rs +27 -0
- package/src/symbols/private_type_leaks.rs +125 -0
- package/src/symbols/riverpod.rs +113 -0
- package/src/symbols/tests.rs +692 -0
- package/src/symbols.rs +693 -0
- package/src/trace/tests.rs +225 -0
- package/src/trace.rs +690 -0
- package/src/unsupported.rs +47 -0
- package/src/widgets/lifecycle.rs +484 -0
- package/src/widgets/params.rs +236 -0
- package/src/widgets/tests.rs +430 -0
- package/src/widgets/top_level.rs +110 -0
- package/src/widgets/unrendered.rs +374 -0
- package/src/widgets.rs +590 -0
- package/src/workspace_scope.rs +358 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
use std::collections::BTreeSet;
|
|
2
|
+
use std::fs;
|
|
3
|
+
use std::path::{Path, PathBuf};
|
|
4
|
+
|
|
5
|
+
use serde::{Deserialize, Serialize};
|
|
6
|
+
|
|
7
|
+
use crate::{
|
|
8
|
+
BoundaryInventory, BoundaryPreset, BoundaryRule, DartFile, LocalPubPackage, ScannedProject,
|
|
9
|
+
boundary_inventory,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/// Stable JSON schema version for project-list reports.
|
|
13
|
+
pub const PROJECT_LIST_SCHEMA_VERSION: &str = "dart-decimate.list.v1";
|
|
14
|
+
|
|
15
|
+
/// Sections included in a project-list report.
|
|
16
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
17
|
+
pub struct ProjectListOptions {
|
|
18
|
+
sections: BTreeSet<ProjectListSection>,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/// Project-list report section.
|
|
22
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
|
23
|
+
pub enum ProjectListSection {
|
|
24
|
+
/// Parsed Dart files.
|
|
25
|
+
Files,
|
|
26
|
+
/// Effective entry points.
|
|
27
|
+
EntryPoints,
|
|
28
|
+
/// Discovered local pub packages.
|
|
29
|
+
Workspaces,
|
|
30
|
+
/// Active Dart Decimate adapters.
|
|
31
|
+
Plugins,
|
|
32
|
+
/// Architecture boundary zones and rules.
|
|
33
|
+
Boundaries,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
impl ProjectListOptions {
|
|
37
|
+
/// Include all list sections.
|
|
38
|
+
#[must_use]
|
|
39
|
+
pub fn all() -> Self {
|
|
40
|
+
Self::from_sections([
|
|
41
|
+
ProjectListSection::Files,
|
|
42
|
+
ProjectListSection::EntryPoints,
|
|
43
|
+
ProjectListSection::Workspaces,
|
|
44
|
+
ProjectListSection::Plugins,
|
|
45
|
+
ProjectListSection::Boundaries,
|
|
46
|
+
])
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/// Include selected list sections.
|
|
50
|
+
#[must_use]
|
|
51
|
+
pub fn from_sections(sections: impl IntoIterator<Item = ProjectListSection>) -> Self {
|
|
52
|
+
Self {
|
|
53
|
+
sections: sections.into_iter().collect(),
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fn includes(&self, section: ProjectListSection) -> bool {
|
|
58
|
+
self.sections.contains(§ion)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// Project metadata report.
|
|
63
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
64
|
+
pub struct ProjectListReport {
|
|
65
|
+
/// Schema identifier.
|
|
66
|
+
pub schema_version: String,
|
|
67
|
+
/// Tool name.
|
|
68
|
+
pub tool: String,
|
|
69
|
+
/// Command that produced this report.
|
|
70
|
+
pub command: String,
|
|
71
|
+
/// Numeric rollup.
|
|
72
|
+
pub summary: ProjectListSummary,
|
|
73
|
+
/// Parsed Dart files.
|
|
74
|
+
pub files: Vec<ListedFile>,
|
|
75
|
+
/// Effective entry points.
|
|
76
|
+
pub entry_points: Vec<ListedEntryPoint>,
|
|
77
|
+
/// Discovered local pub packages.
|
|
78
|
+
pub workspaces: Vec<ListedWorkspace>,
|
|
79
|
+
/// Active Dart Decimate adapters.
|
|
80
|
+
pub plugins: Vec<ListedPlugin>,
|
|
81
|
+
/// Configured architecture boundaries.
|
|
82
|
+
pub boundaries: ListedBoundaries,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/// Numeric project-list rollup.
|
|
86
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
87
|
+
pub struct ProjectListSummary {
|
|
88
|
+
/// Dart files parsed.
|
|
89
|
+
pub files: usize,
|
|
90
|
+
/// Resolved graph edges.
|
|
91
|
+
pub edges: usize,
|
|
92
|
+
/// Local dependencies that did not resolve to parsed files.
|
|
93
|
+
pub unresolved_dependencies: usize,
|
|
94
|
+
/// Effective entry points.
|
|
95
|
+
pub entry_points: usize,
|
|
96
|
+
/// Discovered local pub packages.
|
|
97
|
+
pub workspaces: usize,
|
|
98
|
+
/// Active adapters.
|
|
99
|
+
pub plugins: usize,
|
|
100
|
+
/// Configured architecture boundary zones.
|
|
101
|
+
pub boundary_zones: usize,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/// Parsed Dart file metadata.
|
|
105
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
106
|
+
pub struct ListedFile {
|
|
107
|
+
/// Dart file path, root-relative where possible.
|
|
108
|
+
pub path: String,
|
|
109
|
+
/// Import directive count.
|
|
110
|
+
pub imports: usize,
|
|
111
|
+
/// Export directive count.
|
|
112
|
+
pub exports: usize,
|
|
113
|
+
/// Part directive count.
|
|
114
|
+
pub parts: usize,
|
|
115
|
+
/// Top-level declaration count.
|
|
116
|
+
pub declarations: usize,
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/// Entry-point metadata.
|
|
120
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
121
|
+
pub struct ListedEntryPoint {
|
|
122
|
+
/// Entry-point path, root-relative where possible.
|
|
123
|
+
pub path: String,
|
|
124
|
+
/// Whether this came from config/CLI or Dart Decimate heuristics.
|
|
125
|
+
pub source: String,
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/// Local pub package metadata.
|
|
129
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
130
|
+
pub struct ListedWorkspace {
|
|
131
|
+
/// Pub package name.
|
|
132
|
+
pub name: String,
|
|
133
|
+
/// Package root, root-relative where possible.
|
|
134
|
+
pub root: String,
|
|
135
|
+
/// Pubspec path, root-relative where possible.
|
|
136
|
+
pub pubspec_path: String,
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// Dart Decimate adapter metadata.
|
|
140
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
141
|
+
pub struct ListedPlugin {
|
|
142
|
+
/// Adapter name.
|
|
143
|
+
pub name: String,
|
|
144
|
+
/// Whether the adapter is active for this project.
|
|
145
|
+
pub active: bool,
|
|
146
|
+
/// Why Dart Decimate selected or skipped it.
|
|
147
|
+
pub reason: String,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// Architecture boundary inventory.
|
|
151
|
+
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
|
152
|
+
pub struct ListedBoundaries {
|
|
153
|
+
/// Whether any boundaries are configured.
|
|
154
|
+
pub configured: bool,
|
|
155
|
+
/// Built-in presets contributing boundary rules.
|
|
156
|
+
pub presets: Vec<String>,
|
|
157
|
+
/// Root-relative globs exempt from boundary coverage gaps.
|
|
158
|
+
pub allow_unmatched: Vec<String>,
|
|
159
|
+
/// Configured zones.
|
|
160
|
+
pub zones: Vec<ListedBoundaryZone>,
|
|
161
|
+
/// Configured access rules.
|
|
162
|
+
pub rules: Vec<ListedBoundaryRule>,
|
|
163
|
+
/// Dart library files outside every configured zone.
|
|
164
|
+
pub uncovered_files: Vec<String>,
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/// One listed architecture boundary zone.
|
|
168
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
169
|
+
pub struct ListedBoundaryZone {
|
|
170
|
+
/// Zone path.
|
|
171
|
+
pub path: String,
|
|
172
|
+
/// Dart library file count under this zone.
|
|
173
|
+
pub file_count: usize,
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/// One listed architecture boundary access rule.
|
|
177
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
178
|
+
pub struct ListedBoundaryRule {
|
|
179
|
+
/// Source zone.
|
|
180
|
+
pub from: String,
|
|
181
|
+
/// Disallowed target zone.
|
|
182
|
+
pub disallow: String,
|
|
183
|
+
/// Dart library files covered by the source zone.
|
|
184
|
+
pub covered_files: usize,
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/// Effective architecture boundary settings for project-list reports.
|
|
188
|
+
#[derive(Debug, Clone, Copy)]
|
|
189
|
+
pub struct ProjectListBoundaryConfig<'a> {
|
|
190
|
+
/// Configured access rules.
|
|
191
|
+
pub rules: &'a [BoundaryRule],
|
|
192
|
+
/// Built-in presets contributing rules.
|
|
193
|
+
pub presets: &'a [BoundaryPreset],
|
|
194
|
+
/// Root-relative coverage exceptions.
|
|
195
|
+
pub allow_unmatched: &'a [String],
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/// Build a project-list report.
|
|
199
|
+
#[must_use]
|
|
200
|
+
pub fn project_list_report(
|
|
201
|
+
project: &ScannedProject,
|
|
202
|
+
packages: &[LocalPubPackage],
|
|
203
|
+
entry_points: &[PathBuf],
|
|
204
|
+
entry_source: &str,
|
|
205
|
+
boundaries: ProjectListBoundaryConfig<'_>,
|
|
206
|
+
options: &ProjectListOptions,
|
|
207
|
+
) -> ProjectListReport {
|
|
208
|
+
let plugins = list_plugins(packages);
|
|
209
|
+
let boundary_inventory = boundary_inventory(
|
|
210
|
+
project,
|
|
211
|
+
boundaries.rules,
|
|
212
|
+
boundaries.presets,
|
|
213
|
+
boundaries.allow_unmatched,
|
|
214
|
+
);
|
|
215
|
+
ProjectListReport {
|
|
216
|
+
schema_version: PROJECT_LIST_SCHEMA_VERSION.to_owned(),
|
|
217
|
+
tool: "dart-decimate".to_owned(),
|
|
218
|
+
command: "list".to_owned(),
|
|
219
|
+
summary: ProjectListSummary {
|
|
220
|
+
files: project.files.len(),
|
|
221
|
+
edges: project.graph.edge_count(),
|
|
222
|
+
unresolved_dependencies: project.graph.unresolved().len(),
|
|
223
|
+
entry_points: entry_points.len(),
|
|
224
|
+
workspaces: packages.len(),
|
|
225
|
+
plugins: plugins.iter().filter(|plugin| plugin.active).count(),
|
|
226
|
+
boundary_zones: boundary_inventory.zones.len(),
|
|
227
|
+
},
|
|
228
|
+
files: if options.includes(ProjectListSection::Files) {
|
|
229
|
+
list_files(&project.root, &project.files)
|
|
230
|
+
} else {
|
|
231
|
+
Vec::new()
|
|
232
|
+
},
|
|
233
|
+
entry_points: if options.includes(ProjectListSection::EntryPoints) {
|
|
234
|
+
list_entry_points(&project.root, entry_points, entry_source)
|
|
235
|
+
} else {
|
|
236
|
+
Vec::new()
|
|
237
|
+
},
|
|
238
|
+
workspaces: if options.includes(ProjectListSection::Workspaces) {
|
|
239
|
+
list_workspaces(&project.root, packages)
|
|
240
|
+
} else {
|
|
241
|
+
Vec::new()
|
|
242
|
+
},
|
|
243
|
+
plugins: if options.includes(ProjectListSection::Plugins) {
|
|
244
|
+
plugins
|
|
245
|
+
} else {
|
|
246
|
+
Vec::new()
|
|
247
|
+
},
|
|
248
|
+
boundaries: if options.includes(ProjectListSection::Boundaries) {
|
|
249
|
+
list_boundaries(&project.root, &boundary_inventory)
|
|
250
|
+
} else {
|
|
251
|
+
ListedBoundaries::default()
|
|
252
|
+
},
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
fn list_files(root: &Path, files: &[DartFile]) -> Vec<ListedFile> {
|
|
257
|
+
files
|
|
258
|
+
.iter()
|
|
259
|
+
.map(|file| ListedFile {
|
|
260
|
+
path: display_path(root, &file.path),
|
|
261
|
+
imports: file.imports.len(),
|
|
262
|
+
exports: file.exports.len(),
|
|
263
|
+
parts: file.parts.len(),
|
|
264
|
+
declarations: file.declarations.len(),
|
|
265
|
+
})
|
|
266
|
+
.collect()
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
fn list_entry_points(
|
|
270
|
+
root: &Path,
|
|
271
|
+
entry_points: &[PathBuf],
|
|
272
|
+
entry_source: &str,
|
|
273
|
+
) -> Vec<ListedEntryPoint> {
|
|
274
|
+
entry_points
|
|
275
|
+
.iter()
|
|
276
|
+
.map(|path| ListedEntryPoint {
|
|
277
|
+
path: display_path(root, path),
|
|
278
|
+
source: entry_source.to_owned(),
|
|
279
|
+
})
|
|
280
|
+
.collect()
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
fn list_workspaces(root: &Path, packages: &[LocalPubPackage]) -> Vec<ListedWorkspace> {
|
|
284
|
+
packages
|
|
285
|
+
.iter()
|
|
286
|
+
.map(|package| ListedWorkspace {
|
|
287
|
+
name: package.name.clone(),
|
|
288
|
+
root: display_path(root, &package.root),
|
|
289
|
+
pubspec_path: display_path(root, &package.pubspec_path),
|
|
290
|
+
})
|
|
291
|
+
.collect()
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
fn list_plugins(packages: &[LocalPubPackage]) -> Vec<ListedPlugin> {
|
|
295
|
+
let flutter = packages.iter().any(is_flutter_package);
|
|
296
|
+
vec![
|
|
297
|
+
ListedPlugin {
|
|
298
|
+
name: "dart".to_owned(),
|
|
299
|
+
active: true,
|
|
300
|
+
reason: "Dart files are parsed with tree-sitter-dart".to_owned(),
|
|
301
|
+
},
|
|
302
|
+
ListedPlugin {
|
|
303
|
+
name: "flutter".to_owned(),
|
|
304
|
+
active: flutter,
|
|
305
|
+
reason: if flutter {
|
|
306
|
+
"A local pubspec declares the Flutter SDK".to_owned()
|
|
307
|
+
} else {
|
|
308
|
+
"No local pubspec declares the Flutter SDK".to_owned()
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
ListedPlugin {
|
|
312
|
+
name: "pub-workspace".to_owned(),
|
|
313
|
+
active: packages.len() > 1,
|
|
314
|
+
reason: if packages.len() > 1 {
|
|
315
|
+
"Multiple local pub packages were discovered".to_owned()
|
|
316
|
+
} else {
|
|
317
|
+
"Only one local pub package was discovered".to_owned()
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
]
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
fn list_boundaries(root: &Path, inventory: &BoundaryInventory) -> ListedBoundaries {
|
|
324
|
+
ListedBoundaries {
|
|
325
|
+
configured: inventory.configured,
|
|
326
|
+
presets: inventory
|
|
327
|
+
.presets
|
|
328
|
+
.iter()
|
|
329
|
+
.map(|preset| preset.as_str().to_owned())
|
|
330
|
+
.collect(),
|
|
331
|
+
allow_unmatched: inventory.allow_unmatched.clone(),
|
|
332
|
+
zones: inventory
|
|
333
|
+
.zones
|
|
334
|
+
.iter()
|
|
335
|
+
.map(|zone| ListedBoundaryZone {
|
|
336
|
+
path: display_path(root, &zone.path),
|
|
337
|
+
file_count: zone.file_count,
|
|
338
|
+
})
|
|
339
|
+
.collect(),
|
|
340
|
+
rules: inventory
|
|
341
|
+
.rules
|
|
342
|
+
.iter()
|
|
343
|
+
.map(|rule| ListedBoundaryRule {
|
|
344
|
+
from: display_path(root, &rule.from),
|
|
345
|
+
disallow: display_path(root, &rule.disallow),
|
|
346
|
+
covered_files: rule.covered_files,
|
|
347
|
+
})
|
|
348
|
+
.collect(),
|
|
349
|
+
uncovered_files: inventory
|
|
350
|
+
.uncovered_files
|
|
351
|
+
.iter()
|
|
352
|
+
.map(|path| display_path(root, path))
|
|
353
|
+
.collect(),
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
fn is_flutter_package(package: &LocalPubPackage) -> bool {
|
|
358
|
+
fs::read_to_string(&package.pubspec_path).is_ok_and(|source| {
|
|
359
|
+
source
|
|
360
|
+
.lines()
|
|
361
|
+
.any(|line| line.trim_start().starts_with("flutter:"))
|
|
362
|
+
})
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
fn display_path(root: &Path, path: &Path) -> String {
|
|
366
|
+
path.strip_prefix(root)
|
|
367
|
+
.unwrap_or(path)
|
|
368
|
+
.components()
|
|
369
|
+
.filter_map(|component| match component {
|
|
370
|
+
std::path::Component::Normal(value) => value.to_str(),
|
|
371
|
+
std::path::Component::RootDir => Some(""),
|
|
372
|
+
_ => None,
|
|
373
|
+
})
|
|
374
|
+
.collect::<Vec<_>>()
|
|
375
|
+
.join("/")
|
|
376
|
+
}
|