dart-decimate 0.0.13 → 0.0.15
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 +75 -1
- package/Cargo.toml +2 -1
- package/README.md +22 -27
- package/npm/scripts/postinstall.js +33 -12
- package/npm/scripts/test-npx-local.js +7 -2
- package/npm/scripts/test-npx-mcp-local.js +3 -1
- package/npm/scripts/test-npx-prebuilt.js +33 -13
- package/npm/scripts/test-postinstall-prebuilt.js +33 -13
- package/package.json +9 -3
- package/src/changed_scope.rs +4 -7
- package/src/cli/audit_run.rs +1 -3
- package/src/cli/decision_surface_run.rs +1 -3
- package/src/cli/entry_points.rs +75 -13
- package/src/dart_parser.rs +1 -3
- package/src/dependencies/analyze.rs +94 -11
- package/src/dependencies/codegen.rs +26 -0
- package/src/dependencies.rs +8 -1
- package/src/dependency_scripts.rs +42 -8
- package/src/extract.rs +6 -0
- package/src/git_command.rs +58 -0
- package/src/graph.rs +5 -0
- package/src/lib.rs +1 -0
- package/src/manifest.rs +1 -1
- package/src/output/route_cycle/navigation.rs +150 -22
- package/src/output/route_cycle.rs +4 -1
- package/src/scan/tests.rs +133 -0
- package/src/scan.rs +122 -47
- package/src/security/detect.rs +1275 -10
- package/src/security_gate.rs +3 -5
- package/src/trace.rs +22 -13
- package/src/widgets/inheritance.rs +250 -0
- package/src/widgets/params.rs +81 -1
- package/src/widgets/patterns.rs +32 -25
- package/src/widgets/reads.rs +61 -11
- package/src/widgets/resolution.rs +281 -0
- package/src/widgets/unrendered.rs +111 -47
- package/src/widgets.rs +69 -11
package/Cargo.lock
CHANGED
|
@@ -23,6 +23,16 @@ version = "2.13.0"
|
|
|
23
23
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
24
24
|
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
|
|
25
25
|
|
|
26
|
+
[[package]]
|
|
27
|
+
name = "bstr"
|
|
28
|
+
version = "1.12.3"
|
|
29
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
30
|
+
checksum = "5cee35f73844aa3014bb606320a6c1f010249dbdf43342fe54b5a4f6a8ed4b79"
|
|
31
|
+
dependencies = [
|
|
32
|
+
"memchr",
|
|
33
|
+
"serde_core",
|
|
34
|
+
]
|
|
35
|
+
|
|
26
36
|
[[package]]
|
|
27
37
|
name = "cc"
|
|
28
38
|
version = "1.2.65"
|
|
@@ -92,10 +102,11 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
|
|
92
102
|
|
|
93
103
|
[[package]]
|
|
94
104
|
name = "dart-decimate"
|
|
95
|
-
version = "0.0.
|
|
105
|
+
version = "0.0.15"
|
|
96
106
|
dependencies = [
|
|
97
107
|
"clap",
|
|
98
108
|
"glob",
|
|
109
|
+
"ignore",
|
|
99
110
|
"petgraph",
|
|
100
111
|
"rayon",
|
|
101
112
|
"serde",
|
|
@@ -171,6 +182,19 @@ version = "0.3.3"
|
|
|
171
182
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
172
183
|
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
|
|
173
184
|
|
|
185
|
+
[[package]]
|
|
186
|
+
name = "globset"
|
|
187
|
+
version = "0.4.18"
|
|
188
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
189
|
+
checksum = "52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3"
|
|
190
|
+
dependencies = [
|
|
191
|
+
"aho-corasick",
|
|
192
|
+
"bstr",
|
|
193
|
+
"log",
|
|
194
|
+
"regex-automata",
|
|
195
|
+
"regex-syntax",
|
|
196
|
+
]
|
|
197
|
+
|
|
174
198
|
[[package]]
|
|
175
199
|
name = "hashbrown"
|
|
176
200
|
version = "0.15.5"
|
|
@@ -186,6 +210,22 @@ version = "0.17.1"
|
|
|
186
210
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
187
211
|
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
|
188
212
|
|
|
213
|
+
[[package]]
|
|
214
|
+
name = "ignore"
|
|
215
|
+
version = "0.4.28"
|
|
216
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
217
|
+
checksum = "2adf14691c72bcfc1058740436a35bdd3ae9c07d1a941ef00b749e9ea16aefa7"
|
|
218
|
+
dependencies = [
|
|
219
|
+
"crossbeam-deque",
|
|
220
|
+
"globset",
|
|
221
|
+
"log",
|
|
222
|
+
"memchr",
|
|
223
|
+
"regex-automata",
|
|
224
|
+
"same-file",
|
|
225
|
+
"walkdir",
|
|
226
|
+
"winapi-util",
|
|
227
|
+
]
|
|
228
|
+
|
|
189
229
|
[[package]]
|
|
190
230
|
name = "indexmap"
|
|
191
231
|
version = "2.14.0"
|
|
@@ -214,6 +254,12 @@ version = "0.12.1"
|
|
|
214
254
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
215
255
|
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
|
216
256
|
|
|
257
|
+
[[package]]
|
|
258
|
+
name = "log"
|
|
259
|
+
version = "0.4.33"
|
|
260
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
261
|
+
checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
|
|
262
|
+
|
|
217
263
|
[[package]]
|
|
218
264
|
name = "memchr"
|
|
219
265
|
version = "2.8.2"
|
|
@@ -330,6 +376,15 @@ version = "1.0.23"
|
|
|
330
376
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
331
377
|
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
|
332
378
|
|
|
379
|
+
[[package]]
|
|
380
|
+
name = "same-file"
|
|
381
|
+
version = "1.0.6"
|
|
382
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
383
|
+
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
|
384
|
+
dependencies = [
|
|
385
|
+
"winapi-util",
|
|
386
|
+
]
|
|
387
|
+
|
|
333
388
|
[[package]]
|
|
334
389
|
name = "serde"
|
|
335
390
|
version = "1.0.228"
|
|
@@ -539,6 +594,25 @@ version = "0.2.11"
|
|
|
539
594
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
540
595
|
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
|
541
596
|
|
|
597
|
+
[[package]]
|
|
598
|
+
name = "walkdir"
|
|
599
|
+
version = "2.5.0"
|
|
600
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
601
|
+
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
|
602
|
+
dependencies = [
|
|
603
|
+
"same-file",
|
|
604
|
+
"winapi-util",
|
|
605
|
+
]
|
|
606
|
+
|
|
607
|
+
[[package]]
|
|
608
|
+
name = "winapi-util"
|
|
609
|
+
version = "0.1.11"
|
|
610
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
611
|
+
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
|
612
|
+
dependencies = [
|
|
613
|
+
"windows-sys",
|
|
614
|
+
]
|
|
615
|
+
|
|
542
616
|
[[package]]
|
|
543
617
|
name = "windows-link"
|
|
544
618
|
version = "0.2.1"
|
package/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "dart-decimate"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.15"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
rust-version = "1.85"
|
|
6
6
|
description = "Rust-native codebase intelligence for Dart and Flutter module graphs."
|
|
@@ -16,6 +16,7 @@ include = ["/Cargo.toml", "/Cargo.lock", "/README.md", "/LICENSE", "/src/**"]
|
|
|
16
16
|
[dependencies]
|
|
17
17
|
clap = { version = "4", default-features = false, features = ["std", "help", "usage", "error-context", "suggestions"] }
|
|
18
18
|
glob = "0.3"
|
|
19
|
+
ignore = "0.4"
|
|
19
20
|
petgraph = "0.8"
|
|
20
21
|
rayon = "1"
|
|
21
22
|
serde = { version = "1", features = ["derive"] }
|
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ Add this to `package.json` if you want a short project command:
|
|
|
91
91
|
"dart-decimate": "dart-decimate json ."
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
|
-
"dart-decimate": "^0.0.
|
|
94
|
+
"dart-decimate": "^0.0.15"
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
```
|
|
@@ -208,9 +208,11 @@ Default entry points are evaluated across the root and discovered local package
|
|
|
208
208
|
roots. They include public `lib/` Dart files outside `lib/src/`, `lib/main.dart`,
|
|
209
209
|
direct `bin/` scripts, and, outside production mode, direct `test/`,
|
|
210
210
|
`integration_test/`, `test_driver/`, `tool/`, `scripts/`, and `pigeon/`
|
|
211
|
-
scripts.
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
scripts. Nested `test/`, `integration_test/`, and `test_driver/` files with
|
|
212
|
+
`main()` are also roots, including files matching Patrol's configured
|
|
213
|
+
`test_file_suffix`. Git-ignored Dart files are excluded from source analysis.
|
|
214
|
+
Generated Dart companions, Flutter l10n outputs, and FlutterFire options are
|
|
215
|
+
protected from dead-file cleanup; generated-only cycles are also suppressed.
|
|
214
216
|
|
|
215
217
|
Unused-symbol checks count references from non-raw Dart string interpolation;
|
|
216
218
|
raw strings and escaped dollars stay literal.
|
|
@@ -337,7 +339,9 @@ imports and owner-local path dependencies local. Workspace members and copied
|
|
|
337
339
|
nested packages with the same package name are resolved by owner. Non-Dart
|
|
338
340
|
tooling references in Flutter config files, including launcher and splash
|
|
339
341
|
config, workflow files, Makefiles, and `tool/` scripts can count as dependency
|
|
340
|
-
usage.
|
|
342
|
+
usage. Envied annotations count `envied_generator`/`build_runner`, FlutterGen
|
|
343
|
+
configuration counts `flutter_gen_runner`, and Dart tests count the `test`
|
|
344
|
+
runner. Known generator-internal imports from generated Dart, such as
|
|
341
345
|
`package:slang/generated.dart`, are not reported as unlisted dependencies.
|
|
342
346
|
|
|
343
347
|
Useful commands:
|
|
@@ -361,10 +365,11 @@ Dart Decimate finds:
|
|
|
361
365
|
- widget classes that are never constructed
|
|
362
366
|
- missing `context.mounted` guards after awaited widget work
|
|
363
367
|
|
|
364
|
-
`unused-widget-param` counts normal field reads,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
+
`unused-widget-param` counts normal field reads, transformed constructor
|
|
369
|
+
initializer reads, inherited field reads, forwarding helpers, and Dart object
|
|
370
|
+
patterns that destructure the widget class itself. `unrendered-widget` counts
|
|
371
|
+
widgets constructed through builder callbacks and subclass construction, while
|
|
372
|
+
type-only references do not count as rendering.
|
|
368
373
|
|
|
369
374
|
### 8. Security Candidates
|
|
370
375
|
|
|
@@ -386,7 +391,12 @@ generates client config. To make them fail a gate, set
|
|
|
386
391
|
`"dart-decimate/security-firebase-api-key" = "error"` in `[rules]`. Common
|
|
387
392
|
authentication copy such as password reset and password requirement text is
|
|
388
393
|
filtered before reporting hardcoded-secret candidates unless it is bound to a
|
|
389
|
-
secret-like name or contains a concrete token-like segment.
|
|
394
|
+
secret-like name or contains a concrete token-like segment. OAuth authorization
|
|
395
|
+
and token endpoint URLs are excluded from secret candidates as public metadata,
|
|
396
|
+
while cleartext endpoint transport remains an insecure-transport candidate. Stripe secret-key names
|
|
397
|
+
and `sk_test_`/`sk_live_` values remain review candidates even when they look
|
|
398
|
+
like placeholders. A fixed `Process.start` of `Platform.resolvedExecutable`
|
|
399
|
+
with fixed list arguments is not classified as shell command injection.
|
|
390
400
|
|
|
391
401
|
Useful commands:
|
|
392
402
|
|
|
@@ -651,28 +661,13 @@ dart-decimate license status --format json
|
|
|
651
661
|
|
|
652
662
|
## Development
|
|
653
663
|
|
|
654
|
-
|
|
655
|
-
git diff --check
|
|
656
|
-
npm run lint
|
|
657
|
-
npm run version:bump:check -- origin/main
|
|
658
|
-
npm run release:check
|
|
659
|
-
cargo fmt --check
|
|
660
|
-
cargo clippy --all-targets -- -D warnings
|
|
661
|
-
npm ci --ignore-scripts
|
|
662
|
-
npx fallow audit --base origin/main --quiet
|
|
663
|
-
cargo test --all-targets
|
|
664
|
-
npm run pack:check
|
|
665
|
-
npm run test:postinstall:prebuilt
|
|
666
|
-
npm run test:npx:prebuilt
|
|
667
|
-
npm run test:npx:local
|
|
668
|
-
npm run test:npx:mcp:local
|
|
669
|
-
```
|
|
664
|
+
See [docs/ci.md](docs/ci.md) for the local verification commands and CI gates.
|
|
670
665
|
|
|
671
666
|
This repository forbids `unsafe_code`.
|
|
672
667
|
|
|
673
668
|
## Release Flow
|
|
674
669
|
|
|
675
|
-
Current version: `0.0.
|
|
670
|
+
Current version: `0.0.15`.
|
|
676
671
|
|
|
677
672
|
After the first public release, changes should go through pull requests. Every
|
|
678
673
|
PR to `main` must bump both `Cargo.toml` and `package.json` above the base
|
|
@@ -16,7 +16,9 @@ const root = path.resolve(__dirname, "../..");
|
|
|
16
16
|
const exeExt = process.platform === "win32" ? ".exe" : "";
|
|
17
17
|
const cargo = process.env.CARGO || "cargo";
|
|
18
18
|
const cacheDir = path.join(root, "npm", "bin-cache");
|
|
19
|
-
const packageJson = JSON.parse(
|
|
19
|
+
const packageJson = JSON.parse(
|
|
20
|
+
fs.readFileSync(path.join(root, "package.json"), "utf8"),
|
|
21
|
+
);
|
|
20
22
|
const releaseBaseUrl =
|
|
21
23
|
process.env.DART_DECIMATE_RELEASE_BASE_URL ||
|
|
22
24
|
`https://github.com/sgaabdu4/dart-decimate/releases/download/v${packageJson.version}`;
|
|
@@ -57,7 +59,7 @@ async function installPrebuilt() {
|
|
|
57
59
|
|
|
58
60
|
const extract = spawnSync("tar", ["-xzf", archivePath, "-C", cacheDir], {
|
|
59
61
|
stdio: "pipe",
|
|
60
|
-
windowsHide: false
|
|
62
|
+
windowsHide: false,
|
|
61
63
|
});
|
|
62
64
|
fs.rmSync(archivePath, { force: true });
|
|
63
65
|
|
|
@@ -66,7 +68,9 @@ async function installPrebuilt() {
|
|
|
66
68
|
}
|
|
67
69
|
if (extract.status !== 0) {
|
|
68
70
|
const stderr = extract.stderr?.toString().trim();
|
|
69
|
-
throw new Error(
|
|
71
|
+
throw new Error(
|
|
72
|
+
`could not extract ${assetName}${stderr ? `: ${stderr}` : ""}`,
|
|
73
|
+
);
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
for (const binary of ["dart-decimate", "dart-decimate-mcp"]) {
|
|
@@ -91,7 +95,8 @@ function prebuiltAssetName() {
|
|
|
91
95
|
: process.platform === "win32"
|
|
92
96
|
? "windows"
|
|
93
97
|
: null;
|
|
94
|
-
const arch =
|
|
98
|
+
const arch =
|
|
99
|
+
process.arch === "x64" ? "x64" : process.arch === "arm64" ? "arm64" : null;
|
|
95
100
|
|
|
96
101
|
if (!platform || !arch) {
|
|
97
102
|
return null;
|
|
@@ -108,7 +113,9 @@ function prebuiltAssetName() {
|
|
|
108
113
|
|
|
109
114
|
function download(url, destination, redirectCount) {
|
|
110
115
|
if (redirectCount > 5) {
|
|
111
|
-
return Promise.reject(
|
|
116
|
+
return Promise.reject(
|
|
117
|
+
new Error(`too many redirects while downloading ${url}`),
|
|
118
|
+
);
|
|
112
119
|
}
|
|
113
120
|
|
|
114
121
|
return new Promise((resolve, reject) => {
|
|
@@ -127,12 +134,17 @@ function download(url, destination, redirectCount) {
|
|
|
127
134
|
|
|
128
135
|
if (response.statusCode !== 200) {
|
|
129
136
|
response.resume();
|
|
130
|
-
reject(
|
|
137
|
+
reject(
|
|
138
|
+
new Error(`download ${url} returned HTTP ${response.statusCode}`),
|
|
139
|
+
);
|
|
131
140
|
return;
|
|
132
141
|
}
|
|
133
142
|
|
|
134
143
|
try {
|
|
135
|
-
await pipeline(
|
|
144
|
+
await pipeline(
|
|
145
|
+
response,
|
|
146
|
+
fs.createWriteStream(destination, { mode: 0o600 }),
|
|
147
|
+
);
|
|
136
148
|
resolve();
|
|
137
149
|
} catch (error) {
|
|
138
150
|
reject(error);
|
|
@@ -147,21 +159,25 @@ function buildFromSource(prebuiltError) {
|
|
|
147
159
|
const build = spawnSync(cargo, ["build", "--release", "--locked"], {
|
|
148
160
|
cwd: root,
|
|
149
161
|
stdio: "inherit",
|
|
150
|
-
windowsHide: false
|
|
162
|
+
windowsHide: false,
|
|
151
163
|
});
|
|
152
164
|
|
|
153
165
|
if (build.error) {
|
|
154
166
|
if (build.error.code === "ENOENT") {
|
|
155
167
|
if (prebuiltError) {
|
|
156
|
-
console.error(
|
|
168
|
+
console.error(
|
|
169
|
+
`dart-decimate: prebuilt install failed: ${prebuiltError.message}`,
|
|
170
|
+
);
|
|
157
171
|
}
|
|
158
172
|
console.error(
|
|
159
173
|
"dart-decimate: Rust/Cargo is required as a fallback because a prebuilt binary " +
|
|
160
|
-
"could not be installed for this platform. Install Rust from https://rustup.rs."
|
|
174
|
+
"could not be installed for this platform. Install Rust from https://rustup.rs.",
|
|
161
175
|
);
|
|
162
176
|
process.exit(127);
|
|
163
177
|
}
|
|
164
|
-
console.error(
|
|
178
|
+
console.error(
|
|
179
|
+
`dart-decimate: cargo build failed to start: ${build.error.message}`,
|
|
180
|
+
);
|
|
165
181
|
process.exit(1);
|
|
166
182
|
}
|
|
167
183
|
|
|
@@ -170,7 +186,12 @@ function buildFromSource(prebuiltError) {
|
|
|
170
186
|
}
|
|
171
187
|
|
|
172
188
|
for (const binary of ["dart-decimate", "dart-decimate-mcp"]) {
|
|
173
|
-
const builtBinary = path.join(
|
|
189
|
+
const builtBinary = path.join(
|
|
190
|
+
root,
|
|
191
|
+
"target",
|
|
192
|
+
"release",
|
|
193
|
+
`${binary}${exeExt}`,
|
|
194
|
+
);
|
|
174
195
|
const cachedBinary = path.join(cacheDir, `${binary}${exeExt}`);
|
|
175
196
|
fs.copyFileSync(builtBinary, cachedBinary);
|
|
176
197
|
if (process.platform !== "win32") {
|
|
@@ -29,7 +29,10 @@ try {
|
|
|
29
29
|
const result = spawnSync(
|
|
30
30
|
"npx",
|
|
31
31
|
["--yes", "--package", tarball, "--", "dart-decimate", "--help"],
|
|
32
|
-
{
|
|
32
|
+
{
|
|
33
|
+
encoding: "utf8",
|
|
34
|
+
env: { ...process.env, DART_DECIMATE_SKIP_DOWNLOAD: "1" },
|
|
35
|
+
},
|
|
33
36
|
);
|
|
34
37
|
if (result.stdout) {
|
|
35
38
|
process.stdout.write(result.stdout);
|
|
@@ -45,7 +48,9 @@ try {
|
|
|
45
48
|
process.exit(result.status || 1);
|
|
46
49
|
}
|
|
47
50
|
if (!result.stdout.includes("Usage: dart-decimate")) {
|
|
48
|
-
process.stderr.write(
|
|
51
|
+
process.stderr.write(
|
|
52
|
+
"dart-decimate --help did not print the expected usage\n",
|
|
53
|
+
);
|
|
49
54
|
process.exit(1);
|
|
50
55
|
}
|
|
51
56
|
} finally {
|
|
@@ -52,7 +52,9 @@ try {
|
|
|
52
52
|
}
|
|
53
53
|
const response = JSON.parse(result.stdout.trim());
|
|
54
54
|
if (response.result?.protocolVersion !== "2025-11-25") {
|
|
55
|
-
process.stderr.write(
|
|
55
|
+
process.stderr.write(
|
|
56
|
+
"dart-decimate-mcp did not negotiate MCP 2025-11-25\n",
|
|
57
|
+
);
|
|
56
58
|
process.exit(1);
|
|
57
59
|
}
|
|
58
60
|
} finally {
|
|
@@ -12,7 +12,9 @@ if (process.platform === "win32") {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const root = path.resolve(__dirname, "../..");
|
|
15
|
-
const tempRoot = fs.mkdtempSync(
|
|
15
|
+
const tempRoot = fs.mkdtempSync(
|
|
16
|
+
path.join(tmpdir(), "dart-decimate-npx-prebuilt-"),
|
|
17
|
+
);
|
|
16
18
|
|
|
17
19
|
main().catch((error) => {
|
|
18
20
|
console.error(error.message);
|
|
@@ -20,7 +22,9 @@ main().catch((error) => {
|
|
|
20
22
|
});
|
|
21
23
|
|
|
22
24
|
async function main() {
|
|
23
|
-
const packageJson = JSON.parse(
|
|
25
|
+
const packageJson = JSON.parse(
|
|
26
|
+
fs.readFileSync(path.join(root, "package.json"), "utf8"),
|
|
27
|
+
);
|
|
24
28
|
const platform = process.platform === "win32" ? "windows" : process.platform;
|
|
25
29
|
const arch = process.arch === "x64" ? "x64" : process.arch;
|
|
26
30
|
const assetName = `dart-decimate-${platform}-${arch}.tar.gz`;
|
|
@@ -46,15 +50,25 @@ async function main() {
|
|
|
46
50
|
encoding: "utf8",
|
|
47
51
|
});
|
|
48
52
|
if (archive.status !== 0 || archive.error) {
|
|
49
|
-
throw new Error(
|
|
53
|
+
throw new Error(
|
|
54
|
+
archive.stderr ||
|
|
55
|
+
archive.error?.message ||
|
|
56
|
+
"failed to create test archive",
|
|
57
|
+
);
|
|
50
58
|
}
|
|
51
59
|
|
|
52
|
-
const pack = spawnSync(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
const pack = spawnSync(
|
|
61
|
+
"npm",
|
|
62
|
+
["pack", "--json", "--pack-destination", tempRoot],
|
|
63
|
+
{
|
|
64
|
+
cwd: root,
|
|
65
|
+
encoding: "utf8",
|
|
66
|
+
},
|
|
67
|
+
);
|
|
56
68
|
if (pack.status !== 0 || pack.error) {
|
|
57
|
-
throw new Error(
|
|
69
|
+
throw new Error(
|
|
70
|
+
pack.stderr || pack.error?.message || "failed to pack npm package",
|
|
71
|
+
);
|
|
58
72
|
}
|
|
59
73
|
const [metadata] = JSON.parse(pack.stdout);
|
|
60
74
|
const tarball = path.join(tempRoot, metadata.filename);
|
|
@@ -93,7 +107,9 @@ async function main() {
|
|
|
93
107
|
throw new Error("npx did not execute the downloaded prebuilt binary");
|
|
94
108
|
}
|
|
95
109
|
if (result.stderr.includes("Rust/Cargo")) {
|
|
96
|
-
throw new Error(
|
|
110
|
+
throw new Error(
|
|
111
|
+
"npx attempted the Cargo fallback even though a prebuilt binary was available",
|
|
112
|
+
);
|
|
97
113
|
}
|
|
98
114
|
} finally {
|
|
99
115
|
await new Promise((resolve) => server.close(resolve));
|
|
@@ -103,10 +119,14 @@ async function main() {
|
|
|
103
119
|
|
|
104
120
|
function runNpx(tarball, cwd, env) {
|
|
105
121
|
return new Promise((resolve) => {
|
|
106
|
-
const child = spawn(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
122
|
+
const child = spawn(
|
|
123
|
+
"npx",
|
|
124
|
+
["--yes", "--package", tarball, "--", "dart-decimate", "--help"],
|
|
125
|
+
{
|
|
126
|
+
cwd,
|
|
127
|
+
env,
|
|
128
|
+
},
|
|
129
|
+
);
|
|
110
130
|
let stdout = "";
|
|
111
131
|
let stderr = "";
|
|
112
132
|
|
|
@@ -7,7 +7,9 @@ const { tmpdir } = require("node:os");
|
|
|
7
7
|
const path = require("node:path");
|
|
8
8
|
|
|
9
9
|
const root = path.resolve(__dirname, "../..");
|
|
10
|
-
const tempRoot = fs.mkdtempSync(
|
|
10
|
+
const tempRoot = fs.mkdtempSync(
|
|
11
|
+
path.join(tmpdir(), "dart-decimate-postinstall-"),
|
|
12
|
+
);
|
|
11
13
|
|
|
12
14
|
main().catch((error) => {
|
|
13
15
|
console.error(error.message);
|
|
@@ -15,7 +17,9 @@ main().catch((error) => {
|
|
|
15
17
|
});
|
|
16
18
|
|
|
17
19
|
async function main() {
|
|
18
|
-
const packageJson = JSON.parse(
|
|
20
|
+
const packageJson = JSON.parse(
|
|
21
|
+
fs.readFileSync(path.join(root, "package.json"), "utf8"),
|
|
22
|
+
);
|
|
19
23
|
const platform = process.platform === "win32" ? "windows" : process.platform;
|
|
20
24
|
const arch = process.arch === "x64" ? "x64" : process.arch;
|
|
21
25
|
const assetName = `dart-decimate-${platform}-${arch}.tar.gz`;
|
|
@@ -33,11 +37,18 @@ async function main() {
|
|
|
33
37
|
);
|
|
34
38
|
fs.writeFileSync(
|
|
35
39
|
path.join(tempRoot, "package.json"),
|
|
36
|
-
JSON.stringify(
|
|
40
|
+
JSON.stringify(
|
|
41
|
+
{ name: "dart-decimate", version: packageJson.version },
|
|
42
|
+
null,
|
|
43
|
+
2,
|
|
44
|
+
),
|
|
37
45
|
);
|
|
38
46
|
|
|
39
47
|
for (const binary of ["dart-decimate", "dart-decimate-mcp"]) {
|
|
40
|
-
const binaryPath = path.join(
|
|
48
|
+
const binaryPath = path.join(
|
|
49
|
+
payloadDir,
|
|
50
|
+
process.platform === "win32" ? `${binary}.exe` : binary,
|
|
51
|
+
);
|
|
41
52
|
fs.writeFileSync(binaryPath, "#!/usr/bin/env sh\nexit 0\n");
|
|
42
53
|
fs.chmodSync(binaryPath, 0o755);
|
|
43
54
|
}
|
|
@@ -47,7 +58,11 @@ async function main() {
|
|
|
47
58
|
encoding: "utf8",
|
|
48
59
|
});
|
|
49
60
|
if (archive.status !== 0 || archive.error) {
|
|
50
|
-
throw new Error(
|
|
61
|
+
throw new Error(
|
|
62
|
+
archive.stderr ||
|
|
63
|
+
archive.error?.message ||
|
|
64
|
+
"failed to create test archive",
|
|
65
|
+
);
|
|
51
66
|
}
|
|
52
67
|
|
|
53
68
|
const server = http.createServer((request, response) => {
|
|
@@ -64,14 +79,17 @@ async function main() {
|
|
|
64
79
|
const { port } = server.address();
|
|
65
80
|
|
|
66
81
|
try {
|
|
67
|
-
const result = await runPostinstall(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
82
|
+
const result = await runPostinstall(
|
|
83
|
+
path.join(scriptDir, "postinstall.js"),
|
|
84
|
+
{
|
|
85
|
+
cwd: tempRoot,
|
|
86
|
+
env: {
|
|
87
|
+
...process.env,
|
|
88
|
+
CARGO: path.join(tempRoot, "missing-cargo"),
|
|
89
|
+
DART_DECIMATE_RELEASE_BASE_URL: `http://127.0.0.1:${port}/v${packageJson.version}`,
|
|
90
|
+
},
|
|
73
91
|
},
|
|
74
|
-
|
|
92
|
+
);
|
|
75
93
|
|
|
76
94
|
if (result.stdout) {
|
|
77
95
|
process.stdout.write(result.stdout);
|
|
@@ -80,7 +98,9 @@ async function main() {
|
|
|
80
98
|
process.stderr.write(result.stderr);
|
|
81
99
|
}
|
|
82
100
|
if (result.status !== 0 || result.error) {
|
|
83
|
-
throw new Error(
|
|
101
|
+
throw new Error(
|
|
102
|
+
result.error?.message || `postinstall exited ${result.status}`,
|
|
103
|
+
);
|
|
84
104
|
}
|
|
85
105
|
|
|
86
106
|
for (const binary of ["dart-decimate", "dart-decimate-mcp"]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dart-decimate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "Rust-native codebase intelligence for Dart and Flutter module graphs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -27,8 +27,12 @@
|
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
29
|
"postinstall": "node npm/scripts/postinstall.js",
|
|
30
|
+
"test": "node --test tests/js/npm-wrapper.test.mjs",
|
|
30
31
|
"version:check": "node scripts/check-version-sync.mjs",
|
|
31
|
-
"lint": "npm run version:check && npm run migration:check",
|
|
32
|
+
"lint": "npm run version:check && npm run migration:check && npm run lint:js && npm run format:check",
|
|
33
|
+
"lint:js": "oxlint .",
|
|
34
|
+
"format": "prettier --write . && cargo fmt",
|
|
35
|
+
"format:check": "prettier --check . && cargo fmt --check",
|
|
32
36
|
"version:bump:check": "node scripts/check-pr-version-bump.mjs",
|
|
33
37
|
"release:check": "node scripts/check-release-version.mjs",
|
|
34
38
|
"migration:check": "node scripts/check-dart-decimate-migration.mjs",
|
|
@@ -47,6 +51,8 @@
|
|
|
47
51
|
"access": "public"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
50
|
-
"fallow": "3.2.0"
|
|
54
|
+
"fallow": "3.2.0",
|
|
55
|
+
"oxlint": "1.15.0",
|
|
56
|
+
"prettier": "3.9.5"
|
|
51
57
|
}
|
|
52
58
|
}
|
package/src/changed_scope.rs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
use std::collections::BTreeSet;
|
|
2
2
|
use std::fmt;
|
|
3
3
|
use std::path::{Path, PathBuf};
|
|
4
|
-
use std::process::Command;
|
|
5
4
|
|
|
6
5
|
use thiserror::Error;
|
|
7
6
|
|
|
7
|
+
use crate::git_command;
|
|
8
8
|
use crate::graph::normalize_against;
|
|
9
9
|
use crate::scan::ScannedProject;
|
|
10
10
|
|
|
@@ -56,9 +56,8 @@ impl RefSuggestions {
|
|
|
56
56
|
/// Returns [`ChangedScopeError`] if `git diff` cannot be executed or the base
|
|
57
57
|
/// revision is invalid for this repository.
|
|
58
58
|
pub fn changed_files(root: &Path, base: &str) -> Result<Vec<PathBuf>, ChangedScopeError> {
|
|
59
|
-
let output =
|
|
59
|
+
let output = git_command::for_repository(root)
|
|
60
60
|
.args(["diff", "--name-only", "--diff-filter=ACMRTUXB", base, "--"])
|
|
61
|
-
.current_dir(root)
|
|
62
61
|
.output()
|
|
63
62
|
.map_err(|source| ChangedScopeError::Git { source })?;
|
|
64
63
|
|
|
@@ -66,9 +65,8 @@ pub fn changed_files(root: &Path, base: &str) -> Result<Vec<PathBuf>, ChangedSco
|
|
|
66
65
|
return Err(git_diff_error(root, base, &output.stderr));
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
let untracked =
|
|
68
|
+
let untracked = git_command::for_repository(root)
|
|
70
69
|
.args(["ls-files", "--others", "--exclude-standard"])
|
|
71
|
-
.current_dir(root)
|
|
72
70
|
.output()
|
|
73
71
|
.map_err(|source| ChangedScopeError::Git { source })?;
|
|
74
72
|
|
|
@@ -146,14 +144,13 @@ fn git_diff_error(root: &Path, base: &str, stderr: &[u8]) -> ChangedScopeError {
|
|
|
146
144
|
}
|
|
147
145
|
|
|
148
146
|
fn similar_refs(root: &Path, base: &str) -> Vec<String> {
|
|
149
|
-
let Ok(output) =
|
|
147
|
+
let Ok(output) = git_command::for_repository(root)
|
|
150
148
|
.args([
|
|
151
149
|
"for-each-ref",
|
|
152
150
|
"--format=%(refname:short)",
|
|
153
151
|
"refs/heads",
|
|
154
152
|
"refs/remotes",
|
|
155
153
|
])
|
|
156
|
-
.current_dir(root)
|
|
157
154
|
.output()
|
|
158
155
|
else {
|
|
159
156
|
return Vec::new();
|
package/src/cli/audit_run.rs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
use std::collections::BTreeSet;
|
|
2
2
|
use std::fs;
|
|
3
3
|
use std::path::{Component, Path, PathBuf};
|
|
4
|
-
use std::process::Command;
|
|
5
4
|
use std::time::{SystemTime, UNIX_EPOCH};
|
|
6
5
|
|
|
7
6
|
use clap::{Arg, ArgMatches};
|
|
@@ -273,9 +272,8 @@ fn git_output<'a, I>(project_root: &Path, base: &str, args: I) -> Result<Vec<u8>
|
|
|
273
272
|
where
|
|
274
273
|
I: IntoIterator<Item = &'a str>,
|
|
275
274
|
{
|
|
276
|
-
let output =
|
|
275
|
+
let output = crate::git_command::for_repository(project_root)
|
|
277
276
|
.args(args)
|
|
278
|
-
.current_dir(project_root)
|
|
279
277
|
.output()
|
|
280
278
|
.map_err(|source| crate::changed_scope::ChangedScopeError::Git { source })?;
|
|
281
279
|
if output.status.success() {
|