dart-decimate 0.0.61 → 0.0.63

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 CHANGED
@@ -35,9 +35,9 @@ dependencies = [
35
35
 
36
36
  [[package]]
37
37
  name = "cc"
38
- version = "1.4.6"
38
+ version = "1.5.1"
39
39
  source = "registry+https://github.com/rust-lang/crates.io-index"
40
- checksum = "a3eb0f42d6c360dc3f8a821f6bf2fdea7f72bfd36b3076eb0e6d1e9e0752fff4"
40
+ checksum = "f360145194ee8e21db5ee7f3fcd4fe52210864c75c985dae33218202c8bbe040"
41
41
  dependencies = [
42
42
  "find-msvc-tools",
43
43
  "shlex",
@@ -45,9 +45,9 @@ dependencies = [
45
45
 
46
46
  [[package]]
47
47
  name = "cfg-if"
48
- version = "1.0.4"
48
+ version = "1.0.5"
49
49
  source = "registry+https://github.com/rust-lang/crates.io-index"
50
- checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
50
+ checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
51
51
 
52
52
  [[package]]
53
53
  name = "clap"
@@ -71,9 +71,9 @@ dependencies = [
71
71
 
72
72
  [[package]]
73
73
  name = "clap_lex"
74
- version = "1.1.0"
74
+ version = "1.1.1"
75
75
  source = "registry+https://github.com/rust-lang/crates.io-index"
76
- checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
76
+ checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"
77
77
 
78
78
  [[package]]
79
79
  name = "crossbeam-deque"
@@ -102,7 +102,7 @@ checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
102
102
 
103
103
  [[package]]
104
104
  name = "dart-decimate"
105
- version = "0.0.61"
105
+ version = "0.0.63"
106
106
  dependencies = [
107
107
  "clap",
108
108
  "glob",
@@ -149,9 +149,9 @@ checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
149
149
 
150
150
  [[package]]
151
151
  name = "find-msvc-tools"
152
- version = "0.1.12"
152
+ version = "0.1.14"
153
153
  source = "registry+https://github.com/rust-lang/crates.io-index"
154
- checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d"
154
+ checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"
155
155
 
156
156
  [[package]]
157
157
  name = "fixedbitset"
@@ -359,9 +359,9 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
359
359
 
360
360
  [[package]]
361
361
  name = "rustix"
362
- version = "1.1.4"
362
+ version = "1.1.5"
363
363
  source = "registry+https://github.com/rust-lang/crates.io-index"
364
- checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
364
+ checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d"
365
365
  dependencies = [
366
366
  "bitflags",
367
367
  "errno",
@@ -471,9 +471,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
471
471
 
472
472
  [[package]]
473
473
  name = "syn"
474
- version = "3.0.5"
474
+ version = "3.0.6"
475
475
  source = "registry+https://github.com/rust-lang/crates.io-index"
476
- checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9"
476
+ checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
477
477
  dependencies = [
478
478
  "proc-macro2",
479
479
  "quote",
@@ -495,18 +495,18 @@ dependencies = [
495
495
 
496
496
  [[package]]
497
497
  name = "thiserror"
498
- version = "2.0.20"
498
+ version = "2.0.21"
499
499
  source = "registry+https://github.com/rust-lang/crates.io-index"
500
- checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f"
500
+ checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
501
501
  dependencies = [
502
502
  "thiserror-impl",
503
503
  ]
504
504
 
505
505
  [[package]]
506
506
  name = "thiserror-impl"
507
- version = "2.0.20"
507
+ version = "2.0.21"
508
508
  source = "registry+https://github.com/rust-lang/crates.io-index"
509
- checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af"
509
+ checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
510
510
  dependencies = [
511
511
  "proc-macro2",
512
512
  "quote",
@@ -583,9 +583,9 @@ checksum = "ca0d1bf6fdd806e43ae5198f82f527056d359def39e54e67a0f478ac09dac081"
583
583
 
584
584
  [[package]]
585
585
  name = "unicode-ident"
586
- version = "1.0.24"
586
+ version = "1.0.26"
587
587
  source = "registry+https://github.com/rust-lang/crates.io-index"
588
- checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
588
+ checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
589
589
 
590
590
  [[package]]
591
591
  name = "unsafe-libyaml"
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "dart-decimate"
3
- version = "0.0.61"
3
+ version = "0.0.63"
4
4
  edition = "2024"
5
5
  rust-version = "1.90"
6
6
  description = "Rust-native codebase intelligence for Dart and Flutter module graphs."
package/README.md CHANGED
@@ -90,7 +90,7 @@ You do not need to install anything permanently. Use the command above.
90
90
  For repeatable automation, pin the version:
91
91
 
92
92
  ```bash
93
- pnpm dlx dart-decimate@0.0.61
93
+ pnpm dlx dart-decimate@0.0.63
94
94
  ```
95
95
 
96
96
  Add this to `package.json` if you want a short project command:
@@ -101,7 +101,7 @@ Add this to `package.json` if you want a short project command:
101
101
  "dart-decimate": "dart-decimate json ."
102
102
  },
103
103
  "devDependencies": {
104
- "dart-decimate": "0.0.61"
104
+ "dart-decimate": "0.0.63"
105
105
  }
106
106
  }
107
107
  ```
@@ -117,7 +117,7 @@ pnpm run dart-decimate
117
117
  If you prefer Cargo, install the matching tagged source:
118
118
 
119
119
  ```bash
120
- cargo install --git https://github.com/sgaabdu4/dart-decimate.git --tag v0.0.61 --locked
120
+ cargo install --git https://github.com/sgaabdu4/dart-decimate.git --tag v0.0.63 --locked
121
121
  ```
122
122
 
123
123
  The npm release `X.Y.Z` and Cargo tag `vX.Y.Z` are verified against each other
@@ -128,7 +128,7 @@ Confirm a Cargo build's version with:
128
128
 
129
129
  ```bash
130
130
  dart-decimate --version
131
- # dart-decimate 0.0.61
131
+ # dart-decimate 0.0.63
132
132
  ```
133
133
 
134
134
  ## pnpm dlx
@@ -346,7 +346,8 @@ imports and owner-local path dependencies local. Workspace members and copied
346
346
  nested packages with the same package name are resolved by owner. Non-Dart
347
347
  tooling references in Flutter config files, including launcher and splash
348
348
  config, workflow files, Makefiles, and `tool/` scripts can count as dependency
349
- usage. Envied annotations count `envied_generator`/`build_runner`, FlutterGen
349
+ usage. Shell scripts anywhere in a package count a dependency they invoke with
350
+ `dart run <pkg>`, `dart pub run <pkg>`, or `flutter pub run <pkg>`. Envied annotations count `envied_generator`/`build_runner`, FlutterGen
350
351
  configuration counts `flutter_gen_runner`, and Dart tests count the `test`
351
352
  runner. Known generator-internal imports from generated Dart, such as
352
353
  `package:slang/generated.dart`, are not reported as unlisted dependencies.
@@ -538,7 +539,7 @@ Example shape:
538
539
  {
539
540
  "schema_version": "dart-decimate.report.v1",
540
541
  "kind": "combined",
541
- "tool": "dart-decimate 0.0.61",
542
+ "tool": "dart-decimate 0.0.63",
542
543
  "command": "check",
543
544
  "verdict": "fail",
544
545
  "summary": {
@@ -554,7 +555,7 @@ Example shape:
554
555
 
555
556
  The `dart-decimate.report.v1` field layout is unchanged. Its existing `tool`
556
557
  string includes the producing version so saved reports identify the exact
557
- build, for example `dart-decimate 0.0.61`.
558
+ build, for example `dart-decimate 0.0.63`.
558
559
 
559
560
  When grouped security findings hide additional occurrences, `next_steps` can
560
561
  include `review-security-surface`, which reruns
@@ -642,7 +643,7 @@ you need the installed binary's exact list.
642
643
  For a complete repository check, including discovered local packages:
643
644
 
644
645
  ```bash
645
- pnpm dlx dart-decimate@0.0.61 --strict
646
+ pnpm dlx dart-decimate@0.0.63 --strict
646
647
  ```
647
648
 
648
649
  This runs every enabled check from the repository root. The default duplication
@@ -685,11 +686,14 @@ This repository forbids `unsafe_code`.
685
686
 
686
687
  ## Release Flow
687
688
 
688
- Current source version: `0.0.61`.
689
+ Current source version: `0.0.63`.
689
690
 
690
- After the first public release, changes should go through pull requests. Every
691
- PR to `main` must bump both `Cargo.toml` and `package.json` above the base
692
- branch and to an unpublished npm version.
691
+ After the first public release, changes should go through pull requests. PRs to
692
+ `main` must bump both `Cargo.toml` and `package.json` above the base branch and to
693
+ an unpublished npm version. The sole exception is a canonical, committed Hard
694
+ Eng scaffold update verified by its native check. That verification keeps the
695
+ required Rust and npm check active while skipping unchanged release artifacts;
696
+ mixed product, configuration, or documentation changes take the normal path.
693
697
 
694
698
  To release a new version:
695
699
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dart-decimate",
3
- "version": "0.0.61",
3
+ "version": "0.0.63",
4
4
  "description": "Rust-native codebase intelligence for Dart and Flutter module graphs.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -55,7 +55,6 @@
55
55
  "test:postinstall:prebuilt": "node tests/npm/test-postinstall-prebuilt.js",
56
56
  "test:npx:prebuilt": "node tests/npm/test-npx-prebuilt.js",
57
57
  "test:release:parity": "node tests/npm/test-release-install-parity.js",
58
- "test:npx:local": "node tests/npm/test-npx-local.js",
59
- "test:npx:mcp:local": "node tests/npm/test-npx-mcp-local.js"
58
+ "test:npx:local": "node tests/npm/test-npx-local.js"
60
59
  }
61
60
  }
@@ -1,7 +1,7 @@
1
1
  use std::collections::{BTreeMap, BTreeSet};
2
2
  use std::path::{Path, PathBuf};
3
3
 
4
- use crate::dependency_scripts::package_used_in_tooling;
4
+ use crate::dependency_scripts::{package_used_in_tooling, shell_script_packages};
5
5
  use crate::generated::is_generated_dart_path;
6
6
  use crate::graph::resolve_local_uri;
7
7
  use crate::package_map::PackageMap;
@@ -24,8 +24,6 @@ struct ImportUsage {
24
24
  private_src_imports: Vec<PrivateSrcImport>,
25
25
  }
26
26
 
27
- /// Analyze Dart `package:` imports against pubspec dependency declarations.
28
- ///
29
27
  /// # Errors
30
28
  ///
31
29
  /// Returns [`DependencyHygieneError`] if pubspec discovery or parsing fails.
@@ -233,8 +231,9 @@ fn unused_dependencies(
233
231
  let mut unused_dependencies = Vec::new();
234
232
  for package in packages {
235
233
  let used = used_by_package.get(&package.root);
234
+ let script_packages = shell_script_packages(&package.root);
236
235
  for dependency in &package.dependencies {
237
- if let Some(unused) = unused_dependency(package, dependency, used) {
236
+ if let Some(unused) = unused_dependency(package, dependency, used, &script_packages) {
238
237
  unused_dependencies.push(unused);
239
238
  }
240
239
  }
@@ -246,6 +245,7 @@ fn unused_dependency(
246
245
  package: &PubPackage,
247
246
  dependency: &super::DeclaredDependency,
248
247
  used: Option<&BTreeMap<String, DependencyUsage>>,
248
+ script_packages: &BTreeSet<String>,
249
249
  ) -> Option<UnusedPackageDependency> {
250
250
  if dependency.name == package.name {
251
251
  return None;
@@ -260,7 +260,7 @@ fn unused_dependency(
260
260
  .and_then(|used| used.get(&dependency.name))
261
261
  .copied()
262
262
  .unwrap_or_default();
263
- if package_used_in_tooling(&package.root, &dependency.name) {
263
+ if package_used_in_tooling(&package.root, &dependency.name, script_packages) {
264
264
  usage.record_tooling();
265
265
  }
266
266
  let usage = usage.any().then_some(usage);
@@ -1,8 +1,16 @@
1
+ use std::collections::BTreeSet;
1
2
  use std::fs;
2
3
  use std::path::{Path, PathBuf};
3
4
 
4
- pub(crate) fn package_used_in_tooling(package_root: &Path, dependency: &str) -> bool {
5
- pubspec_has_top_level_key(package_root, dependency)
5
+ use crate::scan::{IgnoreMatcher, project_walk};
6
+
7
+ pub(crate) fn package_used_in_tooling(
8
+ package_root: &Path,
9
+ dependency: &str,
10
+ script_packages: &BTreeSet<String>,
11
+ ) -> bool {
12
+ script_packages.contains(dependency)
13
+ || pubspec_has_top_level_key(package_root, dependency)
6
14
  || known_tooling_convention(package_root, dependency)
7
15
  || tooling_files(package_root).into_iter().any(|path| {
8
16
  fs::read_to_string(path)
@@ -87,13 +95,75 @@ fn collect_matching_files(dir: &Path, paths: &mut Vec<PathBuf>) {
87
95
  }
88
96
 
89
97
  fn is_tooling_file(path: &Path) -> bool {
98
+ is_shell_script(path)
99
+ || matches!(
100
+ path.extension().and_then(|extension| extension.to_str()),
101
+ Some("yaml" | "yml")
102
+ )
103
+ || path
104
+ .file_name()
105
+ .and_then(|name| name.to_str())
106
+ .is_some_and(|name| name == "Makefile")
107
+ }
108
+
109
+ fn is_shell_script(path: &Path) -> bool {
90
110
  matches!(
91
111
  path.extension().and_then(|extension| extension.to_str()),
92
- Some("yaml" | "yml" | "sh" | "bash" | "zsh")
93
- ) || path
94
- .file_name()
95
- .and_then(|name| name.to_str())
96
- .is_some_and(|name| name == "Makefile")
112
+ Some("sh" | "bash" | "zsh")
113
+ )
114
+ }
115
+
116
+ pub(crate) fn shell_script_packages(package_root: &Path) -> BTreeSet<String> {
117
+ let mut packages = BTreeSet::new();
118
+ for entry in project_walk(package_root, package_root, &IgnoreMatcher::default()).flatten() {
119
+ let path = entry.path();
120
+ if entry
121
+ .file_type()
122
+ .is_some_and(|file_type| file_type.is_file())
123
+ && is_shell_script(path)
124
+ && owned_by_package(package_root, path)
125
+ && let Ok(source) = fs::read_to_string(path)
126
+ {
127
+ collect_run_packages(&source, &mut packages);
128
+ }
129
+ }
130
+ packages
131
+ }
132
+
133
+ fn owned_by_package(package_root: &Path, path: &Path) -> bool {
134
+ path.ancestors()
135
+ .skip(1)
136
+ .take_while(|dir| *dir != package_root)
137
+ .all(|dir| !dir.join("pubspec.yaml").is_file())
138
+ }
139
+
140
+ fn collect_run_packages(source: &str, packages: &mut BTreeSet<String>) {
141
+ for line in source.replace("\\\n", " ").lines() {
142
+ let words = line
143
+ .split(|ch: char| ch.is_whitespace() || ";&|()`\"'".contains(ch))
144
+ .filter(|word| !word.is_empty())
145
+ .take_while(|word| !word.starts_with('#'))
146
+ .collect::<Vec<_>>();
147
+ for (index, word) in words.iter().enumerate() {
148
+ let arguments = match (
149
+ word.rsplit('/').next(),
150
+ words.get(index + 1),
151
+ words.get(index + 2),
152
+ ) {
153
+ (Some("dart"), Some(&"run"), _) => &words[index + 2..],
154
+ (Some("dart" | "flutter"), Some(&"pub"), Some(&"run")) => &words[index + 3..],
155
+ _ => continue,
156
+ };
157
+ if let Some(package) = arguments
158
+ .iter()
159
+ .find(|argument| !argument.starts_with('-'))
160
+ .and_then(|target| target.split(':').next())
161
+ .filter(|package| !package.is_empty())
162
+ {
163
+ packages.insert(package.to_owned());
164
+ }
165
+ }
166
+ }
97
167
  }
98
168
 
99
169
  fn source_mentions_dependency(source: &str, dependency: &str) -> bool {
@@ -105,7 +175,33 @@ fn source_mentions_dependency(source: &str, dependency: &str) -> bool {
105
175
 
106
176
  #[cfg(test)]
107
177
  mod tests {
108
- use super::source_mentions_dependency;
178
+ use std::collections::BTreeSet;
179
+
180
+ use super::{collect_run_packages, source_mentions_dependency};
181
+
182
+ #[test]
183
+ fn collects_packages_only_from_run_commands() {
184
+ let mut packages = BTreeSet::new();
185
+ collect_run_packages(
186
+ "set -e\n\
187
+ dart run sentry_dart_plugin\n\
188
+ fvm flutter pub run flutter_launcher_icons:main\n\
189
+ \"$FLUTTER_ROOT/bin/dart\" pub run --verbose build_runner build\n\
190
+ dart run \\\n --enable-asserts melos:melos bootstrap\n\
191
+ # dart run commented_out\n\
192
+ echo dart pub get mentioned_package\n",
193
+ &mut packages,
194
+ );
195
+ assert_eq!(
196
+ packages.into_iter().collect::<Vec<_>>(),
197
+ [
198
+ "build_runner",
199
+ "flutter_launcher_icons",
200
+ "melos",
201
+ "sentry_dart_plugin"
202
+ ]
203
+ );
204
+ }
109
205
 
110
206
  #[test]
111
207
  fn matches_dependency_tokens_without_substrings() {
package/src/trace.rs CHANGED
@@ -7,7 +7,7 @@ use crate::dependencies::{
7
7
  DeclaredPackageDependency, LocalPubPackage, declared_package_dependencies,
8
8
  file_uses_codegen_dependency, local_pub_packages,
9
9
  };
10
- use crate::dependency_scripts::package_used_in_tooling;
10
+ use crate::dependency_scripts::{package_used_in_tooling, shell_script_packages};
11
11
  use crate::graph::normalize_against;
12
12
  use crate::output::TRACE_SCHEMA_VERSION;
13
13
  use crate::semantic::{SemanticDecision, SemanticIdentity};
@@ -331,8 +331,6 @@ pub fn trace_symbol(
331
331
  }
332
332
  }
333
333
 
334
- /// Build a read-only trace for one pub dependency.
335
- ///
336
334
  /// # Errors
337
335
  ///
338
336
  /// Returns [`DependencyHygieneError`] if local pubspec discovery or parsing fails.
@@ -365,9 +363,13 @@ pub fn trace_dependency(
365
363
  .collect::<Vec<_>>();
366
364
  let declared = !declared_in.is_empty();
367
365
  let total_import_count = importing_files.len();
368
- let used_in_scripts = packages
369
- .iter()
370
- .any(|package| package_used_in_tooling(&package.root, dependency));
366
+ let used_in_scripts = packages.iter().any(|package| {
367
+ package_used_in_tooling(
368
+ &package.root,
369
+ dependency,
370
+ &shell_script_packages(&package.root),
371
+ )
372
+ });
371
373
  let used_in_codegen = project
372
374
  .files
373
375
  .iter()
@@ -442,7 +442,10 @@ fn function_expression_body_constructor_name(node: Node<'_>, source: &str) -> Op
442
442
  return None;
443
443
  }
444
444
  let body = function.child_by_field_name("body")?;
445
- let expression = body.named_child(0)?;
445
+ let mut expression = body.named_child(0)?;
446
+ while expression.kind() == "conditional_expression" {
447
+ expression = expression.named_children(&mut expression.walk()).last()?;
448
+ }
446
449
  constructor_call_type_name(expression, source)
447
450
  .or_else(|| split_closure_body_constructor_name(node, expression, source))
448
451
  }