dart-decimate 0.0.43 → 0.0.44
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 +67 -56
- package/npm/scripts/test-release-install-parity.js +237 -0
- package/package.json +2 -1
- package/src/baseline.rs +5 -1
- package/src/ci_template.rs +7 -19
- package/src/cli/common_args.rs +8 -0
- package/src/cli/dupes_args.rs +1 -0
- package/src/cli/fix_run.rs +1 -0
- package/src/cli/list_run.rs +1 -0
- package/src/cli/security_summary_run.rs +15 -7
- package/src/cli.rs +56 -2
- package/src/config/rules.rs +9 -7
- package/src/dupes/tests.rs +6 -0
- package/src/dupes.rs +20 -7
- package/src/lib.rs +5 -0
- package/src/manifest/mcp.rs +7 -0
- package/src/manifest.rs +8 -8
- package/src/mcp/cli_args.rs +22 -6
- package/src/mcp/cli_args_tests.rs +2 -0
- package/src/mcp/tools.rs +7 -0
- package/src/output/scope.rs +24 -0
- package/src/output.rs +39 -3
- package/src/report_schema.rs +4 -1
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
package/README.md
CHANGED
|
@@ -40,24 +40,25 @@ It answers practical questions:
|
|
|
40
40
|
Inside any Dart or Flutter project, run this:
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
npx
|
|
43
|
+
npx dart-decimate@latest
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
That
|
|
47
|
-
dependencies, duplicated code, complex functions, dependency
|
|
48
|
-
architecture drift, Flutter graph issues, security candidates, and
|
|
49
|
-
signals.
|
|
46
|
+
That checks the current project and prints a readable report covering dead
|
|
47
|
+
code, circular dependencies, duplicated code, complex functions, dependency
|
|
48
|
+
hygiene, architecture drift, Flutter graph issues, security candidates, and
|
|
49
|
+
PR-risk signals. The duplication threshold defaults to zero, so any detected
|
|
50
|
+
duplicate group fails the check.
|
|
50
51
|
|
|
51
52
|
To open the same report in your browser:
|
|
52
53
|
|
|
53
54
|
```bash
|
|
54
|
-
npx
|
|
55
|
+
npx dart-decimate@latest html
|
|
55
56
|
```
|
|
56
57
|
|
|
57
58
|
To review only files changed from another branch or ref:
|
|
58
59
|
|
|
59
60
|
```bash
|
|
60
|
-
npx
|
|
61
|
+
npx dart-decimate@latest html --compare origin/main
|
|
61
62
|
```
|
|
62
63
|
|
|
63
64
|
`--compare REF` aliases `--changed-since REF`. If the ref is not found,
|
|
@@ -66,25 +67,30 @@ Dart Decimate suggests similar local or remote branches.
|
|
|
66
67
|
For JSON output that agents and CI can parse:
|
|
67
68
|
|
|
68
69
|
```bash
|
|
69
|
-
npx
|
|
70
|
+
npx dart-decimate@latest json
|
|
70
71
|
```
|
|
71
72
|
|
|
72
73
|
If the human report says `FAIL`, or JSON says `"verdict": "fail"`, Dart Decimate
|
|
73
|
-
worked. It means
|
|
74
|
+
worked. It means a configured quality gate failed: an error-level issue, the
|
|
75
|
+
duplication threshold, or (with `--strict`) any visible finding. It does not
|
|
76
|
+
mean the tool crashed.
|
|
74
77
|
|
|
75
78
|
Exit codes:
|
|
76
79
|
|
|
77
|
-
- `0`:
|
|
78
|
-
- `1`:
|
|
80
|
+
- `0`: the configured gates passed
|
|
81
|
+
- `1`: an error, any duplicated code at the default zero threshold, or any
|
|
82
|
+
finding when `--strict` is enabled
|
|
79
83
|
- `2`: command, config, or runtime error
|
|
80
84
|
- `8`: security gate found new review-required candidates
|
|
81
85
|
|
|
82
86
|
## Install
|
|
83
87
|
|
|
84
|
-
You do not need to install anything permanently. Use
|
|
88
|
+
You do not need to install anything permanently. Use the command above.
|
|
89
|
+
|
|
90
|
+
For repeatable automation, pin the version:
|
|
85
91
|
|
|
86
92
|
```bash
|
|
87
|
-
npx --yes dart-decimate
|
|
93
|
+
npx --yes dart-decimate@0.0.44
|
|
88
94
|
```
|
|
89
95
|
|
|
90
96
|
Add this to `package.json` if you want a short project command:
|
|
@@ -95,7 +101,7 @@ Add this to `package.json` if you want a short project command:
|
|
|
95
101
|
"dart-decimate": "dart-decimate json ."
|
|
96
102
|
},
|
|
97
103
|
"devDependencies": {
|
|
98
|
-
"dart-decimate": "
|
|
104
|
+
"dart-decimate": "0.0.44"
|
|
99
105
|
}
|
|
100
106
|
}
|
|
101
107
|
```
|
|
@@ -106,39 +112,21 @@ Then run:
|
|
|
106
112
|
npm run dart-decimate
|
|
107
113
|
```
|
|
108
114
|
|
|
109
|
-
If you prefer Cargo:
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
cargo install --git https://github.com/sgaabdu4/dart-decimate
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Cargo installs `dart-decimate` and `dart-decimate-mcp` into `~/.cargo/bin`.
|
|
116
|
-
|
|
117
|
-
Fish:
|
|
118
|
-
|
|
119
|
-
```bash
|
|
120
|
-
fish_add_path ~/.cargo/bin
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Bash or Zsh:
|
|
115
|
+
If you prefer Cargo, install the matching tagged source:
|
|
124
116
|
|
|
125
117
|
```bash
|
|
126
|
-
|
|
118
|
+
cargo install --git https://github.com/sgaabdu4/dart-decimate.git --tag v0.0.44 --locked
|
|
127
119
|
```
|
|
128
120
|
|
|
129
|
-
|
|
121
|
+
The npm release `X.Y.Z` and Cargo tag `vX.Y.Z` are verified against each other
|
|
122
|
+
before publication. Do not use an untagged `cargo install --git` command for a
|
|
123
|
+
reproducible gate because it follows the repository's moving default branch.
|
|
130
124
|
|
|
131
|
-
|
|
132
|
-
git clone https://github.com/sgaabdu4/dart-decimate.git
|
|
133
|
-
cd dart-decimate
|
|
134
|
-
cargo install --path . --force
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
Then run it in your app:
|
|
125
|
+
Confirm a Cargo build's version with:
|
|
138
126
|
|
|
139
127
|
```bash
|
|
140
|
-
|
|
141
|
-
dart-decimate
|
|
128
|
+
dart-decimate --version
|
|
129
|
+
# dart-decimate 0.0.44
|
|
142
130
|
```
|
|
143
131
|
|
|
144
132
|
## npx
|
|
@@ -149,19 +137,19 @@ install.
|
|
|
149
137
|
Check everything:
|
|
150
138
|
|
|
151
139
|
```bash
|
|
152
|
-
npx
|
|
140
|
+
npx dart-decimate@latest
|
|
153
141
|
```
|
|
154
142
|
|
|
155
143
|
Machine-readable JSON:
|
|
156
144
|
|
|
157
145
|
```bash
|
|
158
|
-
npx
|
|
146
|
+
npx dart-decimate@latest json
|
|
159
147
|
```
|
|
160
148
|
|
|
161
149
|
Open the HTML report in your browser:
|
|
162
150
|
|
|
163
151
|
```bash
|
|
164
|
-
npx
|
|
152
|
+
npx dart-decimate@latest html
|
|
165
153
|
```
|
|
166
154
|
|
|
167
155
|
The `html` shortcut opens the report by default. On report commands, use
|
|
@@ -178,19 +166,13 @@ messages; HTML reports escape user-derived content.
|
|
|
178
166
|
Print the HTML report instead:
|
|
179
167
|
|
|
180
168
|
```bash
|
|
181
|
-
npx
|
|
169
|
+
npx dart-decimate@latest html --stdout > dart-decimate-report.html
|
|
182
170
|
```
|
|
183
171
|
|
|
184
|
-
Changed files only: `npx
|
|
172
|
+
Changed files only: `npx dart-decimate@latest html --compare origin/main`.
|
|
185
173
|
`--compare REF` aliases `--changed-since REF` and suggests similar branches when
|
|
186
174
|
the ref is not found.
|
|
187
175
|
|
|
188
|
-
To run the GitHub version directly:
|
|
189
|
-
|
|
190
|
-
```bash
|
|
191
|
-
npx --yes --package github:sgaabdu4/dart-decimate dart-decimate check . --format json
|
|
192
|
-
```
|
|
193
|
-
|
|
194
176
|
## What Dart Decimate Looks For
|
|
195
177
|
|
|
196
178
|
### 1. Dead Code
|
|
@@ -549,7 +531,7 @@ Example shape:
|
|
|
549
531
|
{
|
|
550
532
|
"schema_version": "dart-decimate.report.v1",
|
|
551
533
|
"kind": "combined",
|
|
552
|
-
"tool": "dart-decimate",
|
|
534
|
+
"tool": "dart-decimate 0.0.44",
|
|
553
535
|
"command": "check",
|
|
554
536
|
"verdict": "fail",
|
|
555
537
|
"summary": {
|
|
@@ -563,6 +545,10 @@ Example shape:
|
|
|
563
545
|
}
|
|
564
546
|
```
|
|
565
547
|
|
|
548
|
+
The `dart-decimate.report.v1` field layout is unchanged. Its existing `tool`
|
|
549
|
+
string includes the producing version so saved reports identify the exact
|
|
550
|
+
build, for example `dart-decimate 0.0.44`.
|
|
551
|
+
|
|
566
552
|
When grouped security findings hide additional occurrences, `next_steps` can
|
|
567
553
|
include `review-security-surface`, which reruns
|
|
568
554
|
`dart-decimate security . --format json --surface`.
|
|
@@ -646,6 +632,27 @@ you need the installed binary's exact list.
|
|
|
646
632
|
|
|
647
633
|
## CI
|
|
648
634
|
|
|
635
|
+
For a complete repository check, including discovered local packages:
|
|
636
|
+
|
|
637
|
+
```bash
|
|
638
|
+
npx --yes dart-decimate@0.0.44 --strict
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
This runs every enabled check from the repository root. The default duplication
|
|
642
|
+
threshold is zero, and `--strict` makes warnings fail too. Remove `--strict` if
|
|
643
|
+
CI should fail only for error-level findings or duplicated code.
|
|
644
|
+
|
|
645
|
+
Use `json --strict` instead when CI needs the `dart-decimate.report.v1` JSON
|
|
646
|
+
report rather than the readable terminal report.
|
|
647
|
+
|
|
648
|
+
CI can use both the JSON `verdict` and the process exit code:
|
|
649
|
+
|
|
650
|
+
- `0`: pass
|
|
651
|
+
- `1`: error-level findings, the duplication threshold failed, or `--strict`
|
|
652
|
+
found any warning
|
|
653
|
+
- `2`: invalid command, configuration, or runtime error
|
|
654
|
+
- `8`: new security candidates failed a security gate
|
|
655
|
+
|
|
649
656
|
See [docs/ci.md](docs/ci.md) for CI checks, PR gates, hook setup, CI
|
|
650
657
|
templates, and review-thread reconciliation.
|
|
651
658
|
|
|
@@ -671,7 +678,7 @@ This repository forbids `unsafe_code`.
|
|
|
671
678
|
|
|
672
679
|
## Release Flow
|
|
673
680
|
|
|
674
|
-
Current version: `0.0.
|
|
681
|
+
Current source version: `0.0.44`.
|
|
675
682
|
|
|
676
683
|
After the first public release, changes should go through pull requests. Every
|
|
677
684
|
PR to `main` must bump both `Cargo.toml` and `package.json` above the base
|
|
@@ -679,12 +686,16 @@ branch and to an unpublished npm version.
|
|
|
679
686
|
|
|
680
687
|
To release a new version:
|
|
681
688
|
|
|
682
|
-
1. Update
|
|
689
|
+
1. Update `Cargo.toml`, `package.json`, and the pinned commands in `README.md`
|
|
690
|
+
and `docs/ci.md` to the same unpublished version.
|
|
683
691
|
2. Open a PR.
|
|
684
692
|
3. Let CI pass.
|
|
685
693
|
4. Merge to `main`.
|
|
686
|
-
5. GitHub Actions
|
|
687
|
-
|
|
694
|
+
5. GitHub Actions validates the merged commit, builds every release asset, and
|
|
695
|
+
compares a Cargo install from that exact commit with the npm tarball.
|
|
696
|
+
6. Only after that parity check passes, GitHub Actions tags the verified commit
|
|
697
|
+
as `vX.Y.Z`, creates or updates the GitHub release, and publishes
|
|
698
|
+
`dart-decimate@X.Y.Z`.
|
|
688
699
|
|
|
689
700
|
Release reruns for the same commit may update GitHub release assets. If the npm
|
|
690
701
|
package already exists for that commit, the publish step is skipped; a reused tag
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn, spawnSync } = require("node:child_process");
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const http = require("node:http");
|
|
6
|
+
const { tmpdir } = require("node:os");
|
|
7
|
+
const path = require("node:path");
|
|
8
|
+
|
|
9
|
+
const root = path.resolve(__dirname, "../..");
|
|
10
|
+
const fixture = path.join(root, "tests", "fixtures", "install-parity");
|
|
11
|
+
const packageJson = JSON.parse(
|
|
12
|
+
fs.readFileSync(path.join(root, "package.json"), "utf8"),
|
|
13
|
+
);
|
|
14
|
+
const tempRoot = fs.mkdtempSync(
|
|
15
|
+
path.join(tmpdir(), "dart-decimate-release-parity-"),
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
main().catch((error) => {
|
|
19
|
+
console.error(error.message);
|
|
20
|
+
process.exitCode = 1;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
async function main() {
|
|
24
|
+
try {
|
|
25
|
+
const assetDir = path.resolve(
|
|
26
|
+
process.env.DART_DECIMATE_RELEASE_ASSET_DIR ||
|
|
27
|
+
path.join(root, "dist-assets"),
|
|
28
|
+
);
|
|
29
|
+
const assetName = releaseAssetName();
|
|
30
|
+
const assetPath = path.join(assetDir, assetName);
|
|
31
|
+
if (!isFile(assetPath)) {
|
|
32
|
+
throw new Error(`missing release asset ${assetPath}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const cargoBinary = installWithCargo();
|
|
36
|
+
const tarball = packNpmPackage();
|
|
37
|
+
const projectDir = path.join(tempRoot, "npm-project");
|
|
38
|
+
fs.mkdirSync(projectDir, { recursive: true });
|
|
39
|
+
fs.writeFileSync(
|
|
40
|
+
path.join(projectDir, "package.json"),
|
|
41
|
+
JSON.stringify({ name: "release-parity-probe", private: true }, null, 2),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const server = http.createServer((request, response) => {
|
|
45
|
+
if (request.url !== `/v${packageJson.version}/${assetName}`) {
|
|
46
|
+
response.writeHead(404);
|
|
47
|
+
response.end("not found");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
response.writeHead(200, { "content-type": "application/gzip" });
|
|
51
|
+
fs.createReadStream(assetPath).pipe(response);
|
|
52
|
+
});
|
|
53
|
+
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
const { port } = server.address();
|
|
57
|
+
await installNpmTarball(tarball, projectDir, port);
|
|
58
|
+
} finally {
|
|
59
|
+
await new Promise((resolve) => server.close(resolve));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const npmBinary = path.join(
|
|
63
|
+
projectDir,
|
|
64
|
+
"node_modules",
|
|
65
|
+
".bin",
|
|
66
|
+
process.platform === "win32" ? "dart-decimate.cmd" : "dart-decimate",
|
|
67
|
+
);
|
|
68
|
+
assertInstalledPackageVersion(projectDir);
|
|
69
|
+
assertVersion(cargoBinary, "Cargo");
|
|
70
|
+
assertVersion(npmBinary, "npm");
|
|
71
|
+
|
|
72
|
+
const cargoReport = runReport(cargoBinary, "Cargo");
|
|
73
|
+
const npmReport = runReport(npmBinary, "npm");
|
|
74
|
+
if (cargoReport !== npmReport) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
"Cargo and npm installations emitted different JSON reports",
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const report = JSON.parse(cargoReport);
|
|
81
|
+
if (
|
|
82
|
+
report.schema_version !== "dart-decimate.report.v1" ||
|
|
83
|
+
report.tool !== `dart-decimate ${packageJson.version}` ||
|
|
84
|
+
report.verdict !== "pass" ||
|
|
85
|
+
report.summary?.code_duplications !== 0 ||
|
|
86
|
+
report.summary?.unrendered_widgets !== 0 ||
|
|
87
|
+
report.summary?.findings !== 0 ||
|
|
88
|
+
report.findings?.length !== 0
|
|
89
|
+
) {
|
|
90
|
+
throw new Error(`unexpected parity report: ${cargoReport}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
console.log(
|
|
94
|
+
`release install parity ok: Cargo source and npm ${packageJson.version} emitted identical reports`,
|
|
95
|
+
);
|
|
96
|
+
} finally {
|
|
97
|
+
fs.rmSync(tempRoot, { recursive: true, force: true });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function isFile(filePath) {
|
|
102
|
+
try {
|
|
103
|
+
return fs.statSync(filePath).isFile();
|
|
104
|
+
} catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function installWithCargo() {
|
|
110
|
+
const cargoRoot = path.join(tempRoot, "cargo-root");
|
|
111
|
+
const gitUrl = process.env.DART_DECIMATE_CARGO_GIT_URL;
|
|
112
|
+
const tag = process.env.DART_DECIMATE_CARGO_TAG;
|
|
113
|
+
const revision = process.env.DART_DECIMATE_CARGO_REV;
|
|
114
|
+
const args = ["install", "--locked", "--force", "--root", cargoRoot];
|
|
115
|
+
if (gitUrl || tag || revision) {
|
|
116
|
+
if (!gitUrl || Boolean(tag) === Boolean(revision)) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
"DART_DECIMATE_CARGO_GIT_URL and exactly one of DART_DECIMATE_CARGO_TAG or DART_DECIMATE_CARGO_REV must be set together",
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
args.push("--git", gitUrl, tag ? "--tag" : "--rev", tag || revision);
|
|
122
|
+
args.push("dart-decimate");
|
|
123
|
+
} else {
|
|
124
|
+
args.push("--path", root);
|
|
125
|
+
}
|
|
126
|
+
run("cargo", args, root, "Cargo install");
|
|
127
|
+
return path.join(
|
|
128
|
+
cargoRoot,
|
|
129
|
+
"bin",
|
|
130
|
+
process.platform === "win32" ? "dart-decimate.exe" : "dart-decimate",
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function packNpmPackage() {
|
|
135
|
+
const result = run(
|
|
136
|
+
"npm",
|
|
137
|
+
["pack", "--json", "--pack-destination", tempRoot],
|
|
138
|
+
root,
|
|
139
|
+
"npm pack",
|
|
140
|
+
);
|
|
141
|
+
const [metadata] = JSON.parse(result.stdout);
|
|
142
|
+
return path.join(tempRoot, metadata.filename);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function installNpmTarball(tarball, projectDir, port) {
|
|
146
|
+
const result = await spawnResult(
|
|
147
|
+
"npm",
|
|
148
|
+
["install", "--no-audit", "--no-fund", tarball],
|
|
149
|
+
{
|
|
150
|
+
cwd: projectDir,
|
|
151
|
+
env: {
|
|
152
|
+
...process.env,
|
|
153
|
+
CARGO: path.join(tempRoot, "missing-cargo"),
|
|
154
|
+
DART_DECIMATE_RELEASE_BASE_URL: `http://127.0.0.1:${port}/v${packageJson.version}`,
|
|
155
|
+
npm_config_cache: path.join(tempRoot, "npm-cache"),
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
);
|
|
159
|
+
if (result.status !== 0 || result.error) {
|
|
160
|
+
throw new Error(
|
|
161
|
+
result.error?.message ||
|
|
162
|
+
result.stderr ||
|
|
163
|
+
`npm install exited ${result.status}`,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function assertInstalledPackageVersion(projectDir) {
|
|
169
|
+
const installed = JSON.parse(
|
|
170
|
+
fs.readFileSync(
|
|
171
|
+
path.join(projectDir, "node_modules", "dart-decimate", "package.json"),
|
|
172
|
+
"utf8",
|
|
173
|
+
),
|
|
174
|
+
);
|
|
175
|
+
if (installed.version !== packageJson.version) {
|
|
176
|
+
throw new Error(
|
|
177
|
+
`npm installed dart-decimate ${installed.version}; expected ${packageJson.version}`,
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function assertVersion(binary, label) {
|
|
183
|
+
const result = run(binary, ["--version"], fixture, `${label} --version`);
|
|
184
|
+
const expected = `dart-decimate ${packageJson.version}`;
|
|
185
|
+
if (result.stdout.trim() !== expected) {
|
|
186
|
+
throw new Error(
|
|
187
|
+
`${label} reported ${result.stdout.trim()}; expected ${expected}`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function runReport(binary, label) {
|
|
193
|
+
return run(
|
|
194
|
+
binary,
|
|
195
|
+
["check", "lib", "--threshold", "0", "--format", "json"],
|
|
196
|
+
fixture,
|
|
197
|
+
`${label} report`,
|
|
198
|
+
).stdout;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function releaseAssetName() {
|
|
202
|
+
const platform = process.platform === "win32" ? "windows" : process.platform;
|
|
203
|
+
const arch = process.arch === "x64" ? "x64" : process.arch;
|
|
204
|
+
return `dart-decimate-${platform}-${arch}.tar.gz`;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function run(command, args, cwd, label) {
|
|
208
|
+
const result = spawnSync(command, args, { cwd, encoding: "utf8" });
|
|
209
|
+
if (result.status !== 0 || result.error) {
|
|
210
|
+
throw new Error(
|
|
211
|
+
result.error?.message ||
|
|
212
|
+
result.stderr ||
|
|
213
|
+
`${label} exited ${result.status}`,
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function spawnResult(command, args, options) {
|
|
220
|
+
return new Promise((resolve) => {
|
|
221
|
+
const child = spawn(command, args, options);
|
|
222
|
+
let stdout = "";
|
|
223
|
+
let stderr = "";
|
|
224
|
+
child.stdout.on("data", (chunk) => {
|
|
225
|
+
stdout += chunk;
|
|
226
|
+
});
|
|
227
|
+
child.stderr.on("data", (chunk) => {
|
|
228
|
+
stderr += chunk;
|
|
229
|
+
});
|
|
230
|
+
child.on("error", (error) => {
|
|
231
|
+
resolve({ error, status: null, stderr, stdout });
|
|
232
|
+
});
|
|
233
|
+
child.on("close", (status) => {
|
|
234
|
+
resolve({ status, stderr, stdout });
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dart-decimate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
4
4
|
"description": "Rust-native codebase intelligence for Dart and Flutter module graphs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"test:npm:mcp": "printf '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2025-11-25\"}}\\n' | node npm/bin/dart-decimate-mcp.js",
|
|
43
43
|
"test:postinstall:prebuilt": "node npm/scripts/test-postinstall-prebuilt.js",
|
|
44
44
|
"test:npx:prebuilt": "node npm/scripts/test-npx-prebuilt.js",
|
|
45
|
+
"test:release:parity": "node npm/scripts/test-release-install-parity.js",
|
|
45
46
|
"test:npx:local": "node npm/scripts/test-npx-local.js",
|
|
46
47
|
"test:npx:mcp:local": "node npm/scripts/test-npx-mcp-local.js"
|
|
47
48
|
},
|
package/src/baseline.rs
CHANGED
|
@@ -6,7 +6,10 @@ use serde::{Deserialize, Serialize};
|
|
|
6
6
|
use thiserror::Error;
|
|
7
7
|
|
|
8
8
|
use crate::finding_identity::finding_identity;
|
|
9
|
-
use crate::output::{
|
|
9
|
+
use crate::output::{
|
|
10
|
+
Finding, FindingKind, JsonAttackSurfaceEntry, JsonReport, Severity, Verdict,
|
|
11
|
+
recompute_visible_duplication_summary,
|
|
12
|
+
};
|
|
10
13
|
use crate::{JsonCloneGroup, JsonComplexityFinding, JsonFeatureFlag, JsonSecurityCandidate};
|
|
11
14
|
|
|
12
15
|
pub const BASELINE_SCHEMA_VERSION: &str = "dart-decimate.baseline.v1";
|
|
@@ -554,6 +557,7 @@ fn kind_suffix(kind: FindingKind) -> &'static str {
|
|
|
554
557
|
}
|
|
555
558
|
}
|
|
556
559
|
fn recompute_summary(report: &mut JsonReport) {
|
|
560
|
+
recompute_visible_duplication_summary(report);
|
|
557
561
|
report.summary.unresolved_dependencies =
|
|
558
562
|
kind_count(&report.findings, FindingKind::UnresolvedDependency);
|
|
559
563
|
report.summary.part_of_violations = kind_count(&report.findings, FindingKind::PartOfViolation);
|
package/src/ci_template.rs
CHANGED
|
@@ -302,7 +302,7 @@ fn template_file(path: &str, executable: bool, content: &str) -> CiTemplateFile
|
|
|
302
302
|
CiTemplateFile {
|
|
303
303
|
path: path.to_owned(),
|
|
304
304
|
executable,
|
|
305
|
-
content: content.
|
|
305
|
+
content: content.replace("__DART_DECIMATE_VERSION__", crate::VERSION),
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
|
|
@@ -347,11 +347,7 @@ jobs:
|
|
|
347
347
|
- uses: actions/checkout@v4
|
|
348
348
|
with:
|
|
349
349
|
fetch-depth: 0
|
|
350
|
-
- run:
|
|
351
|
-
rustup toolchain install 1.90.0 --profile minimal
|
|
352
|
-
rustup default 1.90.0
|
|
353
|
-
- run: cargo install --git https://github.com/sgaabdu4/dart-decimate --locked dart-decimate
|
|
354
|
-
- run: dart-decimate audit --format json --base origin/${{ github.base_ref || 'main' }}
|
|
350
|
+
- run: npx --yes dart-decimate@__DART_DECIMATE_VERSION__ audit --format json --base origin/${{ github.base_ref || 'main' }} --strict
|
|
355
351
|
";
|
|
356
352
|
|
|
357
353
|
const GITLAB_CI: &str = r#"stages:
|
|
@@ -359,13 +355,9 @@ const GITLAB_CI: &str = r#"stages:
|
|
|
359
355
|
|
|
360
356
|
dart-decimate:
|
|
361
357
|
stage: quality
|
|
362
|
-
image:
|
|
363
|
-
before_script:
|
|
364
|
-
- rustup toolchain install 1.90.0 --profile minimal
|
|
365
|
-
- rustup default 1.90.0
|
|
366
|
-
- cargo install --git https://github.com/sgaabdu4/dart-decimate --locked dart-decimate
|
|
358
|
+
image: node:24
|
|
367
359
|
script:
|
|
368
|
-
- dart-decimate audit --format json --base "origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-main}"
|
|
360
|
+
- npx --yes dart-decimate@__DART_DECIMATE_VERSION__ audit --format json --base "origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-main}" --strict
|
|
369
361
|
rules:
|
|
370
362
|
- if: $CI_MERGE_REQUEST_IID
|
|
371
363
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
@@ -373,11 +365,7 @@ dart-decimate:
|
|
|
373
365
|
|
|
374
366
|
const GITLAB_VENDORED_CI: &str = r".dart-decimate:
|
|
375
367
|
stage: quality
|
|
376
|
-
image:
|
|
377
|
-
before_script:
|
|
378
|
-
- rustup toolchain install 1.90.0 --profile minimal
|
|
379
|
-
- rustup default 1.90.0
|
|
380
|
-
- cargo install --git https://github.com/sgaabdu4/dart-decimate --locked dart-decimate
|
|
368
|
+
image: node:24
|
|
381
369
|
script:
|
|
382
370
|
- ci/scripts/review.sh
|
|
383
371
|
rules:
|
|
@@ -389,11 +377,11 @@ const GITLAB_REVIEW_SCRIPT: &str = r#"#!/usr/bin/env sh
|
|
|
389
377
|
set -eu
|
|
390
378
|
|
|
391
379
|
BASE="origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-main}"
|
|
392
|
-
dart-decimate audit --format json --base "$BASE"
|
|
380
|
+
npx --yes dart-decimate@__DART_DECIMATE_VERSION__ audit --format json --base "$BASE" --strict
|
|
393
381
|
"#;
|
|
394
382
|
|
|
395
383
|
const GITLAB_COMMENT_SCRIPT: &str = r#"#!/usr/bin/env sh
|
|
396
384
|
set -eu
|
|
397
385
|
|
|
398
|
-
dart-decimate review --format json --base "origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-main}"
|
|
386
|
+
npx --yes dart-decimate@__DART_DECIMATE_VERSION__ review --format json --base "origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-main}"
|
|
399
387
|
"#;
|
package/src/cli/common_args.rs
CHANGED
|
@@ -17,6 +17,7 @@ pub(super) fn report_command(command: Command) -> Command {
|
|
|
17
17
|
scan_command_with_format(command, report_format_arg()),
|
|
18
18
|
))
|
|
19
19
|
.arg(open_arg())
|
|
20
|
+
.arg(strict_arg())
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
fn scan_command_with_format(command: Command, format: Arg) -> Command {
|
|
@@ -88,6 +89,13 @@ fn open_arg() -> Arg {
|
|
|
88
89
|
.action(ArgAction::SetTrue)
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
fn strict_arg() -> Arg {
|
|
93
|
+
Arg::new("strict")
|
|
94
|
+
.long("strict")
|
|
95
|
+
.help("Fail when any finding is reported, including warnings")
|
|
96
|
+
.action(ArgAction::SetTrue)
|
|
97
|
+
}
|
|
98
|
+
|
|
91
99
|
pub(super) fn config_arg() -> Arg {
|
|
92
100
|
Arg::new("config")
|
|
93
101
|
.long("config")
|
package/src/cli/dupes_args.rs
CHANGED
package/src/cli/fix_run.rs
CHANGED
|
@@ -111,6 +111,7 @@ pub(super) fn run_fix<W: Write>(subcommand: &ArgMatches, mut writer: W) -> Resul
|
|
|
111
111
|
save_regression_baseline: None,
|
|
112
112
|
regression_tolerance: RegressionTolerance::default(),
|
|
113
113
|
fail_on_regression: false,
|
|
114
|
+
finding_gate: super::FindingGate::ErrorsOnly,
|
|
114
115
|
trace_file: None,
|
|
115
116
|
trace_symbol: None,
|
|
116
117
|
trace_dependency: None,
|
package/src/cli/list_run.rs
CHANGED
|
@@ -169,6 +169,7 @@ fn scoped_project(
|
|
|
169
169
|
save_regression_baseline: None,
|
|
170
170
|
regression_tolerance: crate::RegressionTolerance::default(),
|
|
171
171
|
fail_on_regression: false,
|
|
172
|
+
finding_gate: crate::cli::FindingGate::ErrorsOnly,
|
|
172
173
|
trace_file: None,
|
|
173
174
|
trace_symbol: None,
|
|
174
175
|
trace_dependency: None,
|
|
@@ -23,15 +23,23 @@ pub(super) fn apply_security_summary(request: &CommandRequest, report: &mut Json
|
|
|
23
23
|
report.attack_surface.clear();
|
|
24
24
|
report.runtime_coverage = None;
|
|
25
25
|
report.next_steps.clear();
|
|
26
|
+
crate::output::recompute_visible_duplication_summary(report);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
pub(super) fn exit_code(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
pub(super) fn exit_code(
|
|
30
|
+
request: &CommandRequest,
|
|
31
|
+
report: &JsonReport,
|
|
32
|
+
regressed: bool,
|
|
33
|
+
duplication_failed: bool,
|
|
34
|
+
strict_failed: bool,
|
|
35
|
+
verdict_before_duplication: Verdict,
|
|
36
|
+
) -> i32 {
|
|
37
|
+
if request.security_gate.is_some() && verdict_before_duplication == Verdict::Fail {
|
|
38
|
+
8
|
|
39
|
+
} else if strict_failed || duplication_failed {
|
|
40
|
+
1
|
|
41
|
+
} else if request.security_gate.is_some() {
|
|
42
|
+
0
|
|
35
43
|
} else if request.security_issue_mode.fails_on_issues() {
|
|
36
44
|
i32::from(report.summary.findings > 0)
|
|
37
45
|
} else if request.command == ReportCommand::Audit && request.audit_gate == AuditGate::NewOnly {
|