dart-decimate 0.0.54 → 0.0.57
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 +1 -1
- package/Cargo.toml +1 -1
- package/README.md +22 -20
- package/npm/scripts/postinstall.js +25 -13
- package/package.json +14 -15
- package/src/ci_template.rs +50 -18
- package/src/hooks/templates.rs +14 -8
- package/src/output/route_cycle/classification.rs +142 -3
- package/src/output/route_cycle/navigation.rs +29 -6
- package/src/output/route_cycle/registry_api.rs +14 -10
- package/src/output/route_cycle/state_context.rs +15 -0
- package/src/output/route_cycle.rs +1 -1
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ It answers practical questions:
|
|
|
40
40
|
Inside any Dart or Flutter project, run this:
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
|
|
43
|
+
pnpm dlx dart-decimate@latest
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
That checks the current project and prints a readable report covering dead
|
|
@@ -52,13 +52,13 @@ duplicate group fails the check.
|
|
|
52
52
|
To open the same report in your browser:
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
|
|
55
|
+
pnpm dlx dart-decimate@latest html
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
To review only files changed from another branch or ref:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
|
|
61
|
+
pnpm dlx dart-decimate@latest html --compare origin/main
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
`--compare REF` aliases `--changed-since REF`. If the ref is not found,
|
|
@@ -67,7 +67,7 @@ Dart Decimate suggests similar local or remote branches.
|
|
|
67
67
|
For JSON output that agents and CI can parse:
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
|
-
|
|
70
|
+
pnpm dlx dart-decimate@latest json
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
If the human report says `FAIL`, or JSON says `"verdict": "fail"`, Dart Decimate
|
|
@@ -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
|
-
|
|
93
|
+
pnpm dlx dart-decimate@0.0.57
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
Add this to `package.json` if you want a short project command:
|
|
@@ -101,21 +101,23 @@ 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.
|
|
104
|
+
"dart-decimate": "0.0.57"
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
+
Install with `pnpm install`, approve the package's required postinstall with `pnpm approve-builds`, and commit the resulting lockfile and build policy. The postinstall downloads the native release binaries or uses Cargo when a prebuilt binary is unavailable.
|
|
110
|
+
|
|
109
111
|
Then run:
|
|
110
112
|
|
|
111
113
|
```bash
|
|
112
|
-
|
|
114
|
+
pnpm run dart-decimate
|
|
113
115
|
```
|
|
114
116
|
|
|
115
117
|
If you prefer Cargo, install the matching tagged source:
|
|
116
118
|
|
|
117
119
|
```bash
|
|
118
|
-
cargo install --git https://github.com/sgaabdu4/dart-decimate.git --tag v0.0.
|
|
120
|
+
cargo install --git https://github.com/sgaabdu4/dart-decimate.git --tag v0.0.57 --locked
|
|
119
121
|
```
|
|
120
122
|
|
|
121
123
|
The npm release `X.Y.Z` and Cargo tag `vX.Y.Z` are verified against each other
|
|
@@ -126,10 +128,10 @@ Confirm a Cargo build's version with:
|
|
|
126
128
|
|
|
127
129
|
```bash
|
|
128
130
|
dart-decimate --version
|
|
129
|
-
# dart-decimate 0.0.
|
|
131
|
+
# dart-decimate 0.0.57
|
|
130
132
|
```
|
|
131
133
|
|
|
132
|
-
##
|
|
134
|
+
## pnpm dlx
|
|
133
135
|
|
|
134
136
|
The npm package name is `dart-decimate`. These commands do not require a global
|
|
135
137
|
install.
|
|
@@ -137,19 +139,19 @@ install.
|
|
|
137
139
|
Check everything:
|
|
138
140
|
|
|
139
141
|
```bash
|
|
140
|
-
|
|
142
|
+
pnpm dlx dart-decimate@latest
|
|
141
143
|
```
|
|
142
144
|
|
|
143
145
|
Machine-readable JSON:
|
|
144
146
|
|
|
145
147
|
```bash
|
|
146
|
-
|
|
148
|
+
pnpm dlx dart-decimate@latest json
|
|
147
149
|
```
|
|
148
150
|
|
|
149
151
|
Open the HTML report in your browser:
|
|
150
152
|
|
|
151
153
|
```bash
|
|
152
|
-
|
|
154
|
+
pnpm dlx dart-decimate@latest html
|
|
153
155
|
```
|
|
154
156
|
|
|
155
157
|
The `html` shortcut opens the report by default. On report commands, use
|
|
@@ -166,10 +168,10 @@ messages; HTML reports escape user-derived content.
|
|
|
166
168
|
Print the HTML report instead:
|
|
167
169
|
|
|
168
170
|
```bash
|
|
169
|
-
|
|
171
|
+
pnpm dlx dart-decimate@latest html --stdout > dart-decimate-report.html
|
|
170
172
|
```
|
|
171
173
|
|
|
172
|
-
Changed files only: `
|
|
174
|
+
Changed files only: `pnpm dlx dart-decimate@latest html --compare origin/main`.
|
|
173
175
|
`--compare REF` aliases `--changed-since REF` and suggests similar branches when
|
|
174
176
|
the ref is not found.
|
|
175
177
|
|
|
@@ -536,7 +538,7 @@ Example shape:
|
|
|
536
538
|
{
|
|
537
539
|
"schema_version": "dart-decimate.report.v1",
|
|
538
540
|
"kind": "combined",
|
|
539
|
-
"tool": "dart-decimate 0.0.
|
|
541
|
+
"tool": "dart-decimate 0.0.57",
|
|
540
542
|
"command": "check",
|
|
541
543
|
"verdict": "fail",
|
|
542
544
|
"summary": {
|
|
@@ -552,7 +554,7 @@ Example shape:
|
|
|
552
554
|
|
|
553
555
|
The `dart-decimate.report.v1` field layout is unchanged. Its existing `tool`
|
|
554
556
|
string includes the producing version so saved reports identify the exact
|
|
555
|
-
build, for example `dart-decimate 0.0.
|
|
557
|
+
build, for example `dart-decimate 0.0.57`.
|
|
556
558
|
|
|
557
559
|
When grouped security findings hide additional occurrences, `next_steps` can
|
|
558
560
|
include `review-security-surface`, which reruns
|
|
@@ -640,7 +642,7 @@ you need the installed binary's exact list.
|
|
|
640
642
|
For a complete repository check, including discovered local packages:
|
|
641
643
|
|
|
642
644
|
```bash
|
|
643
|
-
|
|
645
|
+
pnpm dlx dart-decimate@0.0.57 --strict
|
|
644
646
|
```
|
|
645
647
|
|
|
646
648
|
This runs every enabled check from the repository root. The default duplication
|
|
@@ -683,7 +685,7 @@ This repository forbids `unsafe_code`.
|
|
|
683
685
|
|
|
684
686
|
## Release Flow
|
|
685
687
|
|
|
686
|
-
Current source version: `0.0.
|
|
688
|
+
Current source version: `0.0.57`.
|
|
687
689
|
|
|
688
690
|
After the first public release, changes should go through pull requests. Every
|
|
689
691
|
PR to `main` must bump both `Cargo.toml` and `package.json` above the base
|
|
@@ -708,7 +710,7 @@ or npm version from another commit fails.
|
|
|
708
710
|
|
|
709
711
|
Local hooks block direct pushes to `main`, fetch the configured base ref when
|
|
710
712
|
needed, and run the same version, release, lint, Fallow, package, and test gates
|
|
711
|
-
|
|
713
|
+
defined in `hard-eng.gates.json`.
|
|
712
714
|
|
|
713
715
|
## License
|
|
714
716
|
|
|
@@ -57,14 +57,19 @@ async function installPrebuilt() {
|
|
|
57
57
|
const archivePath = path.join(os.tmpdir(), assetName);
|
|
58
58
|
const url = `${releaseBaseUrl.replace(/\/$/, "")}/${assetName}`;
|
|
59
59
|
await download(url, archivePath, 0);
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const staging = fs.mkdtempSync(path.join(cacheDir, ".staging-"));
|
|
61
|
+
try {
|
|
62
|
+
extractArchive(assetName, archivePath, staging);
|
|
63
|
+
activateCachedBinaries(assetName, staging);
|
|
64
|
+
} finally {
|
|
65
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
66
|
+
}
|
|
62
67
|
return true;
|
|
63
68
|
}
|
|
64
69
|
|
|
65
|
-
/** @param {string} assetName @param {string} archivePath */
|
|
66
|
-
function extractArchive(assetName, archivePath) {
|
|
67
|
-
const extract = spawnSync("tar", ["-xzf", archivePath, "-C",
|
|
70
|
+
/** @param {string} assetName @param {string} archivePath @param {string} destination */
|
|
71
|
+
function extractArchive(assetName, archivePath, destination) {
|
|
72
|
+
const extract = spawnSync("tar", ["-xzf", archivePath, "-C", destination], {
|
|
68
73
|
stdio: "pipe",
|
|
69
74
|
windowsHide: false,
|
|
70
75
|
});
|
|
@@ -81,16 +86,23 @@ function extractArchive(assetName, archivePath) {
|
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
88
|
|
|
84
|
-
/** @param {string} assetName */
|
|
85
|
-
function activateCachedBinaries(assetName) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
/** @param {string} assetName @param {string} staging */
|
|
90
|
+
function activateCachedBinaries(assetName, staging) {
|
|
91
|
+
const binaries = ["dart-decimate", "dart-decimate-mcp"].map(
|
|
92
|
+
(binary) => `${binary}${exeExt}`,
|
|
93
|
+
);
|
|
94
|
+
const missing = binaries.find(
|
|
95
|
+
(binary) => !fs.existsSync(path.join(staging, binary)),
|
|
96
|
+
);
|
|
97
|
+
if (missing) {
|
|
98
|
+
throw new Error(`${assetName} did not contain ${missing}`);
|
|
99
|
+
}
|
|
100
|
+
for (const binary of binaries) {
|
|
101
|
+
const stagedBinary = path.join(staging, binary);
|
|
91
102
|
if (process.platform !== "win32") {
|
|
92
|
-
fs.chmodSync(
|
|
103
|
+
fs.chmodSync(stagedBinary, 0o755);
|
|
93
104
|
}
|
|
105
|
+
fs.renameSync(stagedBinary, path.join(cacheDir, binary));
|
|
94
106
|
}
|
|
95
107
|
}
|
|
96
108
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dart-decimate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57",
|
|
4
4
|
"description": "Rust-native codebase intelligence for Dart and Flutter module graphs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -25,6 +25,16 @@
|
|
|
25
25
|
"npm",
|
|
26
26
|
"!npm/bin-cache"
|
|
27
27
|
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22.12.0"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@biomejs/biome": "2.5.14",
|
|
36
|
+
"@types/node": "22.20.4"
|
|
37
|
+
},
|
|
28
38
|
"scripts": {
|
|
29
39
|
"postinstall": "node npm/scripts/postinstall.js",
|
|
30
40
|
"test": "node --test tests/js/*.test.mjs",
|
|
@@ -32,14 +42,14 @@
|
|
|
32
42
|
"test:performance": "cargo build --release --locked --bin dart-decimate && node --test --test-reporter=spec --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=coverage/performance.xml tests/performance/*.test.mjs",
|
|
33
43
|
"typecheck": "node scripts/typecheck-js.mjs",
|
|
34
44
|
"version:check": "node scripts/check-version-sync.mjs",
|
|
35
|
-
"lint": "
|
|
45
|
+
"lint": "pnpm run version:check && pnpm run migration:check && pnpm run lint:js && pnpm run format:check",
|
|
36
46
|
"lint:js": "biome lint .",
|
|
37
47
|
"format": "biome format --write . && cargo fmt",
|
|
38
48
|
"format:check": "biome format . && cargo fmt --check",
|
|
39
49
|
"version:bump:check": "node scripts/check-pr-version-bump.mjs",
|
|
40
50
|
"release:check": "node scripts/check-release-version.mjs",
|
|
41
51
|
"migration:check": "node scripts/check-dart-decimate-migration.mjs",
|
|
42
|
-
"pack:check": "
|
|
52
|
+
"pack:check": "pnpm pack --dry-run",
|
|
43
53
|
"test:npm": "node npm/bin/dart-decimate.js --help",
|
|
44
54
|
"test:npm:mcp": "printf '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2025-11-25\"}}\\n' | node npm/bin/dart-decimate-mcp.js",
|
|
45
55
|
"test:postinstall:prebuilt": "node tests/npm/test-postinstall-prebuilt.js",
|
|
@@ -47,16 +57,5 @@
|
|
|
47
57
|
"test:release:parity": "node tests/npm/test-release-install-parity.js",
|
|
48
58
|
"test:npx:local": "node tests/npm/test-npx-local.js",
|
|
49
59
|
"test:npx:mcp:local": "node tests/npm/test-npx-mcp-local.js"
|
|
50
|
-
},
|
|
51
|
-
"engines": {
|
|
52
|
-
"node": ">=22.12.0"
|
|
53
|
-
},
|
|
54
|
-
"packageManager": "pnpm@12.6.0",
|
|
55
|
-
"publishConfig": {
|
|
56
|
-
"access": "public"
|
|
57
|
-
},
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"@biomejs/biome": "2.5.14",
|
|
60
|
-
"@types/node": "22.20.4"
|
|
61
60
|
}
|
|
62
|
-
}
|
|
61
|
+
}
|
package/src/ci_template.rs
CHANGED
|
@@ -140,13 +140,9 @@ pub fn ci_template_report(platform: CiTemplatePlatform, vendor: bool) -> CiTempl
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
/// Write the selected CI template files under `root`.
|
|
144
|
-
///
|
|
145
143
|
/// # Errors
|
|
146
144
|
///
|
|
147
|
-
///
|
|
148
|
-
/// `force`, or when directories, files, or executable permissions cannot be
|
|
149
|
-
/// written.
|
|
145
|
+
/// Fails if a target exists without `force` or the filesystem cannot write it.
|
|
150
146
|
pub fn vendor_ci_template(
|
|
151
147
|
root: impl AsRef<Path>,
|
|
152
148
|
platform: CiTemplatePlatform,
|
|
@@ -161,12 +157,9 @@ pub fn vendor_ci_template(
|
|
|
161
157
|
Ok(report)
|
|
162
158
|
}
|
|
163
159
|
|
|
164
|
-
/// Build a dry-run CI review reconciliation report.
|
|
165
|
-
///
|
|
166
160
|
/// # Errors
|
|
167
161
|
///
|
|
168
|
-
///
|
|
169
|
-
/// when provider mutation is requested.
|
|
162
|
+
/// Fails if the envelope cannot be read or parsed, or provider mutation is requested.
|
|
170
163
|
pub fn ci_reconcile_review_report(
|
|
171
164
|
options: CiReconcileReviewOptions,
|
|
172
165
|
) -> Result<CiReconcileReviewReport, CiTemplateError> {
|
|
@@ -331,7 +324,7 @@ fn collect_fingerprints(value: &Value, fingerprints: &mut BTreeSet<String>) {
|
|
|
331
324
|
}
|
|
332
325
|
}
|
|
333
326
|
|
|
334
|
-
const GITHUB_WORKFLOW: &str = r"name: Dart Decimate
|
|
327
|
+
const GITHUB_WORKFLOW: &str = r#"name: Dart Decimate
|
|
335
328
|
|
|
336
329
|
on:
|
|
337
330
|
pull_request:
|
|
@@ -344,11 +337,22 @@ jobs:
|
|
|
344
337
|
permissions:
|
|
345
338
|
contents: read
|
|
346
339
|
steps:
|
|
340
|
+
- uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
|
|
341
|
+
with:
|
|
342
|
+
version: latest
|
|
343
|
+
runtime: node@latest
|
|
344
|
+
install: false
|
|
347
345
|
- uses: actions/checkout@v4
|
|
348
346
|
with:
|
|
349
347
|
fetch-depth: 0
|
|
350
|
-
-
|
|
351
|
-
|
|
348
|
+
- env:
|
|
349
|
+
BASE: ${{ github.event.pull_request.base.sha || github.event.before }}
|
|
350
|
+
run: |
|
|
351
|
+
if ! git cat-file -e "$BASE^{commit}" 2>/dev/null; then
|
|
352
|
+
BASE="$(git hash-object -t tree -w /dev/null)"
|
|
353
|
+
fi
|
|
354
|
+
pnpm dlx dart-decimate@__DART_DECIMATE_VERSION__ audit --format json --base "$BASE" --strict
|
|
355
|
+
"#;
|
|
352
356
|
|
|
353
357
|
const GITLAB_CI: &str = r#"stages:
|
|
354
358
|
- quality
|
|
@@ -356,32 +360,60 @@ const GITLAB_CI: &str = r#"stages:
|
|
|
356
360
|
dart-decimate:
|
|
357
361
|
stage: quality
|
|
358
362
|
image: node:24
|
|
363
|
+
variables:
|
|
364
|
+
GIT_DEPTH: "0"
|
|
365
|
+
PNPM_HOME: "$CI_PROJECT_DIR/.pnpm"
|
|
366
|
+
before_script:
|
|
367
|
+
- mkdir -p "$PNPM_HOME"
|
|
368
|
+
- curl -fsSL https://get.pnpm.io/install.sh -o "$PNPM_HOME/install.sh"
|
|
369
|
+
- env PNPM_VERSION=12.6.0 SHELL=/bin/sh ENV="$HOME/.shrc" sh "$PNPM_HOME/install.sh"
|
|
370
|
+
- export PATH="$PNPM_HOME/bin:$PATH"
|
|
359
371
|
script:
|
|
360
|
-
-
|
|
372
|
+
- |
|
|
373
|
+
BASE="${CI_MERGE_REQUEST_DIFF_BASE_SHA:-${CI_COMMIT_BEFORE_SHA:-}}"
|
|
374
|
+
if ! git cat-file -e "$BASE^{commit}" 2>/dev/null; then
|
|
375
|
+
BASE="$(git hash-object -t tree -w /dev/null)"
|
|
376
|
+
fi
|
|
377
|
+
pnpm dlx dart-decimate@__DART_DECIMATE_VERSION__ audit --format json --base "$BASE" --strict
|
|
361
378
|
rules:
|
|
362
379
|
- if: $CI_MERGE_REQUEST_IID
|
|
363
380
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
364
381
|
"#;
|
|
365
382
|
|
|
366
|
-
const GITLAB_VENDORED_CI: &str = r".dart-decimate:
|
|
383
|
+
const GITLAB_VENDORED_CI: &str = r#".dart-decimate:
|
|
367
384
|
stage: quality
|
|
368
385
|
image: node:24
|
|
386
|
+
variables:
|
|
387
|
+
GIT_DEPTH: "0"
|
|
388
|
+
PNPM_HOME: "$CI_PROJECT_DIR/.pnpm"
|
|
389
|
+
before_script:
|
|
390
|
+
- mkdir -p "$PNPM_HOME"
|
|
391
|
+
- curl -fsSL https://get.pnpm.io/install.sh -o "$PNPM_HOME/install.sh"
|
|
392
|
+
- env PNPM_VERSION=12.6.0 SHELL=/bin/sh ENV="$HOME/.shrc" sh "$PNPM_HOME/install.sh"
|
|
393
|
+
- export PATH="$PNPM_HOME/bin:$PATH"
|
|
369
394
|
script:
|
|
370
395
|
- ci/scripts/review.sh
|
|
371
396
|
rules:
|
|
372
397
|
- if: $CI_MERGE_REQUEST_IID
|
|
373
398
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
374
|
-
"
|
|
399
|
+
"#;
|
|
375
400
|
|
|
376
401
|
const GITLAB_REVIEW_SCRIPT: &str = r#"#!/usr/bin/env sh
|
|
377
402
|
set -eu
|
|
378
403
|
|
|
379
|
-
BASE="
|
|
380
|
-
|
|
404
|
+
BASE="${CI_MERGE_REQUEST_DIFF_BASE_SHA:-${CI_COMMIT_BEFORE_SHA:-}}"
|
|
405
|
+
if ! git cat-file -e "$BASE^{commit}" 2>/dev/null; then
|
|
406
|
+
BASE="$(git hash-object -t tree -w /dev/null)"
|
|
407
|
+
fi
|
|
408
|
+
pnpm dlx dart-decimate@__DART_DECIMATE_VERSION__ audit --format json --base "$BASE" --strict
|
|
381
409
|
"#;
|
|
382
410
|
|
|
383
411
|
const GITLAB_COMMENT_SCRIPT: &str = r#"#!/usr/bin/env sh
|
|
384
412
|
set -eu
|
|
385
413
|
|
|
386
|
-
|
|
414
|
+
BASE="${CI_MERGE_REQUEST_DIFF_BASE_SHA:-${CI_COMMIT_BEFORE_SHA:-}}"
|
|
415
|
+
if ! git cat-file -e "$BASE^{commit}" 2>/dev/null; then
|
|
416
|
+
BASE="$(git hash-object -t tree -w /dev/null)"
|
|
417
|
+
fi
|
|
418
|
+
pnpm dlx dart-decimate@__DART_DECIMATE_VERSION__ review --format json --base "$BASE"
|
|
387
419
|
"#;
|
package/src/hooks/templates.rs
CHANGED
|
@@ -13,18 +13,18 @@ case "$INPUT" in
|
|
|
13
13
|
esac
|
|
14
14
|
if command -v dart-decimate >/dev/null 2>&1; then
|
|
15
15
|
DART_DECIMATE_BIN="dart-decimate"
|
|
16
|
-
elif command -v
|
|
17
|
-
|
|
16
|
+
elif command -v pnpm >/dev/null 2>&1; then
|
|
17
|
+
export PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN=false
|
|
18
|
+
export PNPM_CONFIG_PM_ON_FAIL=ignore
|
|
19
|
+
export PNPM_CONFIG_RUNTIME_ON_FAIL=ignore
|
|
20
|
+
DART_DECIMATE_BIN="pnpm exec dart-decimate"
|
|
18
21
|
else
|
|
19
22
|
echo "dart-decimate-gate: dart-decimate binary not found; allowing command" >&2
|
|
20
23
|
exit 0
|
|
21
24
|
fi
|
|
22
25
|
BASE="${{DART_DECIMATE_BASE:-{branch}}}"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
printf '%s\n' "$OUTPUT" >&2
|
|
26
|
-
exit 0
|
|
27
|
-
}}
|
|
26
|
+
AUDIT_EXIT=0
|
|
27
|
+
OUTPUT="$($DART_DECIMATE_BIN audit . --base "$BASE" --format json --summary 2>&1)" || AUDIT_EXIT=$?
|
|
28
28
|
case "$OUTPUT" in
|
|
29
29
|
*'"error":true'*|*'"error": true'*)
|
|
30
30
|
echo "dart-decimate-gate: dart-decimate returned an error envelope; allowing command" >&2
|
|
@@ -35,7 +35,13 @@ case "$OUTPUT" in
|
|
|
35
35
|
printf '%s\n' "$OUTPUT" >&2
|
|
36
36
|
exit 2
|
|
37
37
|
;;
|
|
38
|
-
*)
|
|
38
|
+
*)
|
|
39
|
+
if [ "$AUDIT_EXIT" -ne 0 ]; then
|
|
40
|
+
echo "dart-decimate-gate: dart-decimate audit failed open" >&2
|
|
41
|
+
printf '%s\n' "$OUTPUT" >&2
|
|
42
|
+
fi
|
|
43
|
+
exit 0
|
|
44
|
+
;;
|
|
39
45
|
esac
|
|
40
46
|
"#
|
|
41
47
|
)
|
|
@@ -8,11 +8,11 @@ use petgraph::visit::EdgeRef;
|
|
|
8
8
|
use tree_sitter::Node;
|
|
9
9
|
|
|
10
10
|
use super::{
|
|
11
|
-
argument_list, helper_has_typed_route_navigation_call,
|
|
12
|
-
navigation::term_identifier_shadowed_at,
|
|
11
|
+
argument_list, helper_has_typed_route_navigation_call, is_identifier_text,
|
|
12
|
+
navigation::{expression_declared_type, term_identifier_shadowed_at},
|
|
13
13
|
registry_api::{VisibleNonRouteRegistryApi, visible_non_route_registry_api},
|
|
14
14
|
route_extension_navigation_call, route_location_argument, route_location_expression_member,
|
|
15
|
-
typed_route_navigation_call, visit_named,
|
|
15
|
+
simple_type_name, typed_route_navigation_call, visit_named,
|
|
16
16
|
wrappers::helper_has_typed_route_wrapper_call,
|
|
17
17
|
};
|
|
18
18
|
use crate::{
|
|
@@ -221,6 +221,15 @@ fn helper_references_imported_api(
|
|
|
221
221
|
}
|
|
222
222
|
if imported_api.member_names.contains(name)
|
|
223
223
|
&& member_reference_uses_imported_api(dependency, root, node, source)
|
|
224
|
+
&& !own_instance_member_reference(node, name, source, imported_api, route_classes)
|
|
225
|
+
&& !typed_receiver_outside_registry(
|
|
226
|
+
root,
|
|
227
|
+
node,
|
|
228
|
+
name,
|
|
229
|
+
source,
|
|
230
|
+
imported_api,
|
|
231
|
+
route_classes,
|
|
232
|
+
)
|
|
224
233
|
&& !typed_route_navigation_member_reference(root, node, source, route_classes)
|
|
225
234
|
{
|
|
226
235
|
found = true;
|
|
@@ -278,6 +287,130 @@ fn member_reference_uses_imported_api(
|
|
|
278
287
|
identifier_has_prefix(source, node.start_byte())
|
|
279
288
|
}
|
|
280
289
|
|
|
290
|
+
fn own_instance_member_reference(
|
|
291
|
+
node: Node<'_>,
|
|
292
|
+
name: &str,
|
|
293
|
+
source: &str,
|
|
294
|
+
imported_api: &VisibleNonRouteRegistryApi,
|
|
295
|
+
route_classes: &BTreeSet<String>,
|
|
296
|
+
) -> bool {
|
|
297
|
+
let Some(receiver) = node
|
|
298
|
+
.parent()
|
|
299
|
+
.filter(|member| {
|
|
300
|
+
member
|
|
301
|
+
.child_by_field_name("property")
|
|
302
|
+
.is_some_and(|property| same_node(property, node))
|
|
303
|
+
})
|
|
304
|
+
.and_then(|member| member.child(0))
|
|
305
|
+
else {
|
|
306
|
+
return false;
|
|
307
|
+
};
|
|
308
|
+
let own_instance_receiver = match receiver.kind() {
|
|
309
|
+
"this" => !imported_api.extension_members.contains(name),
|
|
310
|
+
"super" => true,
|
|
311
|
+
_ => false,
|
|
312
|
+
};
|
|
313
|
+
own_instance_receiver
|
|
314
|
+
&& enclosing_type_header(receiver, source)
|
|
315
|
+
.is_some_and(|header| !header_names_route_class(header, route_classes))
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
fn typed_receiver_outside_registry(
|
|
319
|
+
root: Node<'_>,
|
|
320
|
+
node: Node<'_>,
|
|
321
|
+
name: &str,
|
|
322
|
+
source: &str,
|
|
323
|
+
imported_api: &VisibleNonRouteRegistryApi,
|
|
324
|
+
route_classes: &BTreeSet<String>,
|
|
325
|
+
) -> bool {
|
|
326
|
+
let Some(receiver) = node
|
|
327
|
+
.parent()
|
|
328
|
+
.filter(|member| {
|
|
329
|
+
member
|
|
330
|
+
.child_by_field_name("property")
|
|
331
|
+
.is_some_and(|property| same_node(property, node))
|
|
332
|
+
})
|
|
333
|
+
.and_then(|member| member.child_by_field_name("object"))
|
|
334
|
+
else {
|
|
335
|
+
return false;
|
|
336
|
+
};
|
|
337
|
+
let Some(owner) = receiver
|
|
338
|
+
.utf8_text(source.as_bytes())
|
|
339
|
+
.ok()
|
|
340
|
+
.and_then(|text| expression_declared_type(root, receiver, text, source))
|
|
341
|
+
.map(|type_name| simple_type_name(&type_name))
|
|
342
|
+
else {
|
|
343
|
+
return false;
|
|
344
|
+
};
|
|
345
|
+
is_identifier_text(&owner)
|
|
346
|
+
&& owner != "dynamic"
|
|
347
|
+
&& !route_classes.contains(&owner)
|
|
348
|
+
&& !imported_api.extension_members.contains(name)
|
|
349
|
+
&& !type_parameter_declared(root, &owner, source)
|
|
350
|
+
&& local_type_header(root, &owner, source)
|
|
351
|
+
.is_none_or(|header| !header_names_route_class(header, route_classes))
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
fn type_parameter_declared(root: Node<'_>, name: &str, source: &str) -> bool {
|
|
355
|
+
let mut found = false;
|
|
356
|
+
visit_named(root, &mut |node| {
|
|
357
|
+
found = found
|
|
358
|
+
|| (node.kind() == "type_parameter"
|
|
359
|
+
&& node
|
|
360
|
+
.child_by_field_name("name")
|
|
361
|
+
.and_then(|type_name| type_name.utf8_text(source.as_bytes()).ok())
|
|
362
|
+
== Some(name));
|
|
363
|
+
});
|
|
364
|
+
found
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
fn header_names_route_class(header: &str, route_classes: &BTreeSet<String>) -> bool {
|
|
368
|
+
header
|
|
369
|
+
.split(|character: char| !is_identifier_character(character))
|
|
370
|
+
.any(|word| route_classes.contains(word))
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
fn local_type_header<'source>(
|
|
374
|
+
root: Node<'_>,
|
|
375
|
+
name: &str,
|
|
376
|
+
source: &'source str,
|
|
377
|
+
) -> Option<&'source str> {
|
|
378
|
+
let mut cursor = root.walk();
|
|
379
|
+
root.named_children(&mut cursor)
|
|
380
|
+
.find(|declaration| {
|
|
381
|
+
TYPE_DECLARATION_KINDS.contains(&declaration.kind())
|
|
382
|
+
&& declaration
|
|
383
|
+
.child_by_field_name("name")
|
|
384
|
+
.and_then(|type_name| type_name.utf8_text(source.as_bytes()).ok())
|
|
385
|
+
== Some(name)
|
|
386
|
+
})
|
|
387
|
+
.and_then(|declaration| type_header(declaration, source))
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
fn enclosing_type_header<'source>(node: Node<'_>, source: &'source str) -> Option<&'source str> {
|
|
391
|
+
let mut current = node.parent();
|
|
392
|
+
while let Some(parent) = current {
|
|
393
|
+
if TYPE_DECLARATION_KINDS.contains(&parent.kind()) {
|
|
394
|
+
return type_header(parent, source);
|
|
395
|
+
}
|
|
396
|
+
current = parent.parent();
|
|
397
|
+
}
|
|
398
|
+
None
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
fn type_header<'source>(declaration: Node<'_>, source: &'source str) -> Option<&'source str> {
|
|
402
|
+
let body = declaration.child_by_field_name("body")?;
|
|
403
|
+
source.get(declaration.start_byte()..body.start_byte())
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const TYPE_DECLARATION_KINDS: &[&str] = &[
|
|
407
|
+
"class_declaration",
|
|
408
|
+
"enum_declaration",
|
|
409
|
+
"extension_declaration",
|
|
410
|
+
"extension_type_declaration",
|
|
411
|
+
"mixin_declaration",
|
|
412
|
+
];
|
|
413
|
+
|
|
281
414
|
fn typed_route_navigation_member_reference(
|
|
282
415
|
root: Node<'_>,
|
|
283
416
|
node: Node<'_>,
|
|
@@ -468,6 +601,12 @@ fn identifier_is_declaration_name(node: Node<'_>) -> bool {
|
|
|
468
601
|
if parent.kind() == "identifier_list" {
|
|
469
602
|
return true;
|
|
470
603
|
}
|
|
604
|
+
if matches!(
|
|
605
|
+
parent.kind(),
|
|
606
|
+
"constructor_param" | "super_formal_parameter"
|
|
607
|
+
) {
|
|
608
|
+
return node.kind() == "identifier";
|
|
609
|
+
}
|
|
471
610
|
DECLARATION_NAME_OWNER_KINDS.contains(&parent.kind()) && is_child_field(parent, node, "name")
|
|
472
611
|
}
|
|
473
612
|
|
|
@@ -3,7 +3,8 @@ use tree_sitter::Node;
|
|
|
3
3
|
use super::{
|
|
4
4
|
argument_list, balanced_enclosed_text, class_extends_state, direct_constructor_call_text,
|
|
5
5
|
direct_named_child, direct_static_member_call_text, is_identifier_character, simple_type_name,
|
|
6
|
-
strip_constructor_keyword_prefix, strip_whitespace,
|
|
6
|
+
state_widget_type, strip_constructor_keyword_prefix, strip_whitespace,
|
|
7
|
+
unwrap_parenthesized_text,
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
const BUILD_CONTEXT: &str = "BuildContext";
|
|
@@ -603,8 +604,8 @@ fn visible_name_resolution_at(
|
|
|
603
604
|
if let Some(resolution) = class_member_resolution(root, scope, name, source) {
|
|
604
605
|
return Some(resolution);
|
|
605
606
|
}
|
|
606
|
-
if
|
|
607
|
-
return Some(
|
|
607
|
+
if let Some(resolution) = state_member_resolution(scope, name, source) {
|
|
608
|
+
return Some(resolution);
|
|
608
609
|
}
|
|
609
610
|
}
|
|
610
611
|
if same_node(scope, root) {
|
|
@@ -616,6 +617,19 @@ fn visible_name_resolution_at(
|
|
|
616
617
|
top_level_name_resolution(root, name, source)
|
|
617
618
|
}
|
|
618
619
|
|
|
620
|
+
fn state_member_resolution(
|
|
621
|
+
class_body: Node<'_>,
|
|
622
|
+
name: &str,
|
|
623
|
+
source: &str,
|
|
624
|
+
) -> Option<NameResolution> {
|
|
625
|
+
match name {
|
|
626
|
+
"context" => class_extends_state(class_body, source)
|
|
627
|
+
.then(|| NameResolution::Type(BUILD_CONTEXT.to_owned())),
|
|
628
|
+
"widget" => state_widget_type(class_body, source).map(NameResolution::Type),
|
|
629
|
+
_ => None,
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
619
633
|
fn top_level_name_resolution(root: Node<'_>, name: &str, source: &str) -> Option<NameResolution> {
|
|
620
634
|
let mut cursor = root.walk();
|
|
621
635
|
for declaration in root.named_children(&mut cursor) {
|
|
@@ -655,8 +669,8 @@ fn class_member_resolution_at(
|
|
|
655
669
|
if let Some(resolution) = class_member_resolution(root, scope, name, source) {
|
|
656
670
|
return Some(resolution);
|
|
657
671
|
}
|
|
658
|
-
if
|
|
659
|
-
return Some(
|
|
672
|
+
if let Some(resolution) = state_member_resolution(scope, name, source) {
|
|
673
|
+
return Some(resolution);
|
|
660
674
|
}
|
|
661
675
|
return None;
|
|
662
676
|
}
|
|
@@ -925,7 +939,16 @@ fn initializer_type(root: Node<'_>, node: Node<'_>, source: &str) -> Option<Stri
|
|
|
925
939
|
return Some(target_type.to_owned());
|
|
926
940
|
}
|
|
927
941
|
}
|
|
928
|
-
|
|
942
|
+
expression_declared_type(root, node, expression, source)
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
pub(super) fn expression_declared_type(
|
|
946
|
+
root: Node<'_>,
|
|
947
|
+
site: Node<'_>,
|
|
948
|
+
expression: &str,
|
|
949
|
+
source: &str,
|
|
950
|
+
) -> Option<String> {
|
|
951
|
+
match navigation_expression_resolution(root, site, expression, source)? {
|
|
929
952
|
NameResolution::Type(type_name) => Some(type_name),
|
|
930
953
|
NameResolution::Shadowed => None,
|
|
931
954
|
}
|
|
@@ -10,6 +10,7 @@ use crate::{
|
|
|
10
10
|
pub(super) struct VisibleNonRouteRegistryApi {
|
|
11
11
|
pub(super) top_level_names: BTreeSet<String>,
|
|
12
12
|
pub(super) member_names: BTreeSet<String>,
|
|
13
|
+
pub(super) extension_members: BTreeSet<String>,
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
impl VisibleNonRouteRegistryApi {
|
|
@@ -100,16 +101,19 @@ impl ExportApiCollector<'_> {
|
|
|
100
101
|
})
|
|
101
102
|
.map(|declaration| declaration.name.clone()),
|
|
102
103
|
);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
for member in file.members.iter().filter(|member| {
|
|
105
|
+
is_non_route_registry_api_member(member, self.navigation_member_owners)
|
|
106
|
+
&& dependency_imports_name(self.dependency, &member.owner)
|
|
107
|
+
&& is_visible_through_export_chain(&member.owner, chain)
|
|
108
|
+
}) {
|
|
109
|
+
api.member_names.insert(member.name.clone());
|
|
110
|
+
if file.declarations.iter().any(|declaration| {
|
|
111
|
+
declaration.kind == DeclarationKind::Extension
|
|
112
|
+
&& declaration.name == member.owner
|
|
113
|
+
}) {
|
|
114
|
+
api.extension_members.insert(member.name.clone());
|
|
115
|
+
}
|
|
116
|
+
}
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
119
|
}
|
|
@@ -16,6 +16,21 @@ pub(super) fn class_extends_state(class_body: Node<'_>, source: &str) -> bool {
|
|
|
16
16
|
class_or_local_superclass_extends_state(root, class, source, &mut visited)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
pub(super) fn state_widget_type(class_body: Node<'_>, source: &str) -> Option<String> {
|
|
20
|
+
if !class_extends_state(class_body, source) {
|
|
21
|
+
return None;
|
|
22
|
+
}
|
|
23
|
+
let superclass = class_body.parent()?.child_by_field_name("superclass")?;
|
|
24
|
+
let text = superclass.utf8_text(source.as_bytes()).ok()?;
|
|
25
|
+
let widget = text
|
|
26
|
+
.split_once('<')?
|
|
27
|
+
.1
|
|
28
|
+
.split([',', '<', '>'])
|
|
29
|
+
.next()?
|
|
30
|
+
.trim();
|
|
31
|
+
is_identifier_text(widget).then(|| widget.to_owned())
|
|
32
|
+
}
|
|
33
|
+
|
|
19
34
|
fn class_or_local_superclass_extends_state(
|
|
20
35
|
root: Node<'_>,
|
|
21
36
|
class: Node<'_>,
|
|
@@ -22,7 +22,7 @@ use navigation::{
|
|
|
22
22
|
navigation_receiver_accepts_route_location, route_extension_navigation_has_context_argument,
|
|
23
23
|
};
|
|
24
24
|
use receivers::route_extension_receiver_node;
|
|
25
|
-
use state_context::class_extends_state;
|
|
25
|
+
use state_context::{class_extends_state, state_widget_type};
|
|
26
26
|
|
|
27
27
|
fn helper_has_typed_route_navigation_call(
|
|
28
28
|
root: Node<'_>,
|