dart-decimate 0.0.49 → 0.0.51
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 +8 -8
- package/npm/bin/runner.js +11 -2
- package/npm/scripts/postinstall.js +16 -9
- package/package.json +11 -7
- package/npm/scripts/test-npx-local.js +0 -62
- package/npm/scripts/test-npx-mcp-local.js +0 -66
- package/npm/scripts/test-npx-prebuilt.js +0 -146
- package/npm/scripts/test-postinstall-prebuilt.js +0 -142
- package/npm/scripts/test-release-install-parity.js +0 -237
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
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
|
-
npx --yes dart-decimate@0.0.
|
|
93
|
+
npx --yes dart-decimate@0.0.51
|
|
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.
|
|
104
|
+
"dart-decimate": "0.0.51"
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
```
|
|
@@ -115,7 +115,7 @@ npm run dart-decimate
|
|
|
115
115
|
If you prefer Cargo, install the matching tagged source:
|
|
116
116
|
|
|
117
117
|
```bash
|
|
118
|
-
cargo install --git https://github.com/sgaabdu4/dart-decimate.git --tag v0.0.
|
|
118
|
+
cargo install --git https://github.com/sgaabdu4/dart-decimate.git --tag v0.0.51 --locked
|
|
119
119
|
```
|
|
120
120
|
|
|
121
121
|
The npm release `X.Y.Z` and Cargo tag `vX.Y.Z` are verified against each other
|
|
@@ -126,7 +126,7 @@ Confirm a Cargo build's version with:
|
|
|
126
126
|
|
|
127
127
|
```bash
|
|
128
128
|
dart-decimate --version
|
|
129
|
-
# dart-decimate 0.0.
|
|
129
|
+
# dart-decimate 0.0.51
|
|
130
130
|
```
|
|
131
131
|
|
|
132
132
|
## npx
|
|
@@ -536,7 +536,7 @@ Example shape:
|
|
|
536
536
|
{
|
|
537
537
|
"schema_version": "dart-decimate.report.v1",
|
|
538
538
|
"kind": "combined",
|
|
539
|
-
"tool": "dart-decimate 0.0.
|
|
539
|
+
"tool": "dart-decimate 0.0.51",
|
|
540
540
|
"command": "check",
|
|
541
541
|
"verdict": "fail",
|
|
542
542
|
"summary": {
|
|
@@ -552,7 +552,7 @@ Example shape:
|
|
|
552
552
|
|
|
553
553
|
The `dart-decimate.report.v1` field layout is unchanged. Its existing `tool`
|
|
554
554
|
string includes the producing version so saved reports identify the exact
|
|
555
|
-
build, for example `dart-decimate 0.0.
|
|
555
|
+
build, for example `dart-decimate 0.0.51`.
|
|
556
556
|
|
|
557
557
|
When grouped security findings hide additional occurrences, `next_steps` can
|
|
558
558
|
include `review-security-surface`, which reruns
|
|
@@ -640,7 +640,7 @@ you need the installed binary's exact list.
|
|
|
640
640
|
For a complete repository check, including discovered local packages:
|
|
641
641
|
|
|
642
642
|
```bash
|
|
643
|
-
npx --yes dart-decimate@0.0.
|
|
643
|
+
npx --yes dart-decimate@0.0.51 --strict
|
|
644
644
|
```
|
|
645
645
|
|
|
646
646
|
This runs every enabled check from the repository root. The default duplication
|
|
@@ -683,7 +683,7 @@ This repository forbids `unsafe_code`.
|
|
|
683
683
|
|
|
684
684
|
## Release Flow
|
|
685
685
|
|
|
686
|
-
Current source version: `0.0.
|
|
686
|
+
Current source version: `0.0.51`.
|
|
687
687
|
|
|
688
688
|
After the first public release, changes should go through pull requests. Every
|
|
689
689
|
PR to `main` must bump both `Cargo.toml` and `package.json` above the base
|
package/npm/bin/runner.js
CHANGED
|
@@ -2,6 +2,7 @@ const { spawnSync } = require("node:child_process");
|
|
|
2
2
|
const fs = require("node:fs");
|
|
3
3
|
const path = require("node:path");
|
|
4
4
|
|
|
5
|
+
/** @param {string} binaryName @param {string[]} args */
|
|
5
6
|
function runBinary(binaryName, args) {
|
|
6
7
|
const root = path.resolve(__dirname, "../..");
|
|
7
8
|
const exeName =
|
|
@@ -23,6 +24,7 @@ function runBinary(binaryName, args) {
|
|
|
23
24
|
);
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
/** @param {string[]} candidates @param {string[]} args */
|
|
26
28
|
function runFirstExisting(candidates, args) {
|
|
27
29
|
for (const candidate of candidates) {
|
|
28
30
|
if (fs.existsSync(candidate)) {
|
|
@@ -31,6 +33,7 @@ function runFirstExisting(candidates, args) {
|
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
/** @param {string} root */
|
|
34
37
|
function installCachedBinary(root) {
|
|
35
38
|
if (process.env.DART_DECIMATE_SKIP_BUILD === "1") {
|
|
36
39
|
return;
|
|
@@ -49,15 +52,19 @@ function installCachedBinary(root) {
|
|
|
49
52
|
handleInstallerResult(result);
|
|
50
53
|
}
|
|
51
54
|
|
|
55
|
+
/** @param {import("node:child_process").SpawnSyncReturns<Buffer>} result */
|
|
52
56
|
function handleInstallerResult(result) {
|
|
53
|
-
|
|
57
|
+
/** @type {NodeJS.ErrnoException | undefined} */
|
|
58
|
+
const error = result.error;
|
|
59
|
+
if (error && error.code !== "ENOENT") {
|
|
54
60
|
console.error(
|
|
55
|
-
`dart-decimate: install step failed to start: ${
|
|
61
|
+
`dart-decimate: install step failed to start: ${error.message}`,
|
|
56
62
|
);
|
|
57
63
|
}
|
|
58
64
|
forwardSignal(result.signal);
|
|
59
65
|
}
|
|
60
66
|
|
|
67
|
+
/** @param {string} command @param {string[]} commandArgs @param {string | undefined} [cwd] @param {string} [label] */
|
|
61
68
|
function run(command, commandArgs, cwd = undefined, label = command) {
|
|
62
69
|
const result = spawnSync(command, commandArgs, {
|
|
63
70
|
cwd,
|
|
@@ -76,6 +83,7 @@ function run(command, commandArgs, cwd = undefined, label = command) {
|
|
|
76
83
|
process.exit(result.status ?? 1);
|
|
77
84
|
}
|
|
78
85
|
|
|
86
|
+
/** @param {NodeJS.ErrnoException} error @param {string} command @param {string} label */
|
|
79
87
|
function handleRunError(error, command, label) {
|
|
80
88
|
if (error.code === "ENOENT") {
|
|
81
89
|
console.error(
|
|
@@ -88,6 +96,7 @@ function handleRunError(error, command, label) {
|
|
|
88
96
|
process.exit(1);
|
|
89
97
|
}
|
|
90
98
|
|
|
99
|
+
/** @param {NodeJS.Signals | null} signal */
|
|
91
100
|
function forwardSignal(signal) {
|
|
92
101
|
if (!signal) {
|
|
93
102
|
return false;
|
|
@@ -33,6 +33,7 @@ install()
|
|
|
33
33
|
async function install() {
|
|
34
34
|
fs.mkdirSync(cacheDir, { recursive: true });
|
|
35
35
|
|
|
36
|
+
/** @type {unknown} */
|
|
36
37
|
let prebuiltError = null;
|
|
37
38
|
if (process.env.DART_DECIMATE_SKIP_DOWNLOAD !== "1") {
|
|
38
39
|
try {
|
|
@@ -61,6 +62,7 @@ async function installPrebuilt() {
|
|
|
61
62
|
return true;
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
/** @param {string} assetName @param {string} archivePath */
|
|
64
66
|
function extractArchive(assetName, archivePath) {
|
|
65
67
|
const extract = spawnSync("tar", ["-xzf", archivePath, "-C", cacheDir], {
|
|
66
68
|
stdio: "pipe",
|
|
@@ -79,6 +81,7 @@ function extractArchive(assetName, archivePath) {
|
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
|
|
84
|
+
/** @param {string} assetName */
|
|
82
85
|
function activateCachedBinaries(assetName) {
|
|
83
86
|
for (const binary of ["dart-decimate", "dart-decimate-mcp"]) {
|
|
84
87
|
const cachedBinary = path.join(cacheDir, `${binary}${exeExt}`);
|
|
@@ -117,10 +120,12 @@ function prebuiltArchitecture() {
|
|
|
117
120
|
return new Set(["x64", "arm64"]).has(process.arch) ? process.arch : null;
|
|
118
121
|
}
|
|
119
122
|
|
|
123
|
+
/** @param {string} platform @param {string} arch */
|
|
120
124
|
function supportsPrebuiltTarget(platform, arch) {
|
|
121
125
|
return !new Set(["linux:arm64", "windows:arm64"]).has(`${platform}:${arch}`);
|
|
122
126
|
}
|
|
123
127
|
|
|
128
|
+
/** @param {string} url @param {string} destination @param {number} redirectCount @returns {Promise<unknown>} */
|
|
124
129
|
function download(url, destination, redirectCount) {
|
|
125
130
|
if (redirectCount > 5) {
|
|
126
131
|
return Promise.reject(
|
|
@@ -144,6 +149,7 @@ function download(url, destination, redirectCount) {
|
|
|
144
149
|
});
|
|
145
150
|
}
|
|
146
151
|
|
|
152
|
+
/** @param {import("node:http").IncomingMessage} response @param {string} url @param {string} destination @param {number} redirectCount @param {(value: unknown) => void} resolve @param {(reason: unknown) => void} reject */
|
|
147
153
|
function handleDownloadResponse(
|
|
148
154
|
response,
|
|
149
155
|
url,
|
|
@@ -152,9 +158,10 @@ function handleDownloadResponse(
|
|
|
152
158
|
resolve,
|
|
153
159
|
reject,
|
|
154
160
|
) {
|
|
155
|
-
|
|
161
|
+
const location = redirectLocation(response);
|
|
162
|
+
if (location) {
|
|
156
163
|
response.resume();
|
|
157
|
-
const nextUrl = new URL(
|
|
164
|
+
const nextUrl = new URL(location, url).toString();
|
|
158
165
|
download(nextUrl, destination, redirectCount + 1).then(resolve, reject);
|
|
159
166
|
return;
|
|
160
167
|
}
|
|
@@ -169,14 +176,13 @@ function handleDownloadResponse(
|
|
|
169
176
|
);
|
|
170
177
|
}
|
|
171
178
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
Boolean(response.headers.location)
|
|
177
|
-
);
|
|
179
|
+
/** @param {import("node:http").IncomingMessage} response */
|
|
180
|
+
function redirectLocation(response) {
|
|
181
|
+
const status = response.statusCode ?? 0;
|
|
182
|
+
return status >= 300 && status < 400 ? response.headers.location : undefined;
|
|
178
183
|
}
|
|
179
184
|
|
|
185
|
+
/** @param {unknown} prebuiltError */
|
|
180
186
|
function buildFromSource(prebuiltError) {
|
|
181
187
|
const build = spawnSync(cargo, ["build", "--release", "--locked"], {
|
|
182
188
|
cwd: root,
|
|
@@ -190,12 +196,13 @@ function buildFromSource(prebuiltError) {
|
|
|
190
196
|
cacheBuiltBinaries();
|
|
191
197
|
}
|
|
192
198
|
|
|
199
|
+
/** @param {NodeJS.ErrnoException | undefined} error @param {unknown} prebuiltError */
|
|
193
200
|
function handleBuildStartError(error, prebuiltError) {
|
|
194
201
|
if (!error) {
|
|
195
202
|
return;
|
|
196
203
|
}
|
|
197
204
|
if (error.code === "ENOENT") {
|
|
198
|
-
if (prebuiltError) {
|
|
205
|
+
if (prebuiltError instanceof Error) {
|
|
199
206
|
console.error(
|
|
200
207
|
`dart-decimate: prebuilt install failed: ${prebuiltError.message}`,
|
|
201
208
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dart-decimate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.51",
|
|
4
4
|
"description": "Rust-native codebase intelligence for Dart and Flutter module graphs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"postinstall": "node npm/scripts/postinstall.js",
|
|
30
30
|
"test": "node --test tests/js/*.test.mjs",
|
|
31
|
+
"test:coverage": "node --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=coverage/junit.xml --test-reporter=lcov --test-reporter-destination=coverage/lcov.info tests/js/*.test.mjs",
|
|
32
|
+
"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",
|
|
31
33
|
"typecheck": "node scripts/typecheck-js.mjs",
|
|
32
34
|
"version:check": "node scripts/check-version-sync.mjs",
|
|
33
35
|
"lint": "npm run version:check && npm run migration:check && npm run lint:js && npm run format:check",
|
|
@@ -40,19 +42,21 @@
|
|
|
40
42
|
"pack:check": "npm pack --dry-run",
|
|
41
43
|
"test:npm": "node npm/bin/dart-decimate.js --help",
|
|
42
44
|
"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
|
-
"test:postinstall:prebuilt": "node npm/
|
|
44
|
-
"test:npx:prebuilt": "node npm/
|
|
45
|
-
"test:release:parity": "node npm/
|
|
46
|
-
"test:npx:local": "node npm/
|
|
47
|
-
"test:npx:mcp:local": "node npm/
|
|
45
|
+
"test:postinstall:prebuilt": "node tests/npm/test-postinstall-prebuilt.js",
|
|
46
|
+
"test:npx:prebuilt": "node tests/npm/test-npx-prebuilt.js",
|
|
47
|
+
"test:release:parity": "node tests/npm/test-release-install-parity.js",
|
|
48
|
+
"test:npx:local": "node tests/npm/test-npx-local.js",
|
|
49
|
+
"test:npx:mcp:local": "node tests/npm/test-npx-mcp-local.js"
|
|
48
50
|
},
|
|
49
51
|
"engines": {
|
|
50
52
|
"node": ">=22.12.0"
|
|
51
53
|
},
|
|
54
|
+
"packageManager": "pnpm@12.6.0",
|
|
52
55
|
"publishConfig": {
|
|
53
56
|
"access": "public"
|
|
54
57
|
},
|
|
55
58
|
"devDependencies": {
|
|
56
|
-
"@biomejs/biome": "2.5.14"
|
|
59
|
+
"@biomejs/biome": "2.5.14",
|
|
60
|
+
"@types/node": "22.20.4"
|
|
57
61
|
}
|
|
58
62
|
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { mkdtempSync, readFileSync, rmSync } = require("node:fs");
|
|
4
|
-
const { tmpdir } = require("node:os");
|
|
5
|
-
const { join } = require("node:path");
|
|
6
|
-
const { spawnSync } = require("node:child_process");
|
|
7
|
-
|
|
8
|
-
const root = join(__dirname, "..", "..");
|
|
9
|
-
const tempDir = mkdtempSync(join(tmpdir(), "dart-decimate-npx-"));
|
|
10
|
-
const npmEnv = {
|
|
11
|
-
...process.env,
|
|
12
|
-
npm_config_cache: join(tempDir, "npm-cache"),
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
const pack = spawnSync(
|
|
17
|
-
"npm",
|
|
18
|
-
["pack", "--json", "--pack-destination", tempDir],
|
|
19
|
-
{ cwd: root, encoding: "utf8", env: npmEnv },
|
|
20
|
-
);
|
|
21
|
-
if (pack.error) {
|
|
22
|
-
process.stderr.write(`failed to execute npm: ${pack.error.message}\n`);
|
|
23
|
-
process.exit(pack.error.code === "ENOENT" ? 127 : 1);
|
|
24
|
-
}
|
|
25
|
-
if (pack.status !== 0) {
|
|
26
|
-
process.stderr.write(pack.stderr || "");
|
|
27
|
-
process.exit(pack.status || 1);
|
|
28
|
-
}
|
|
29
|
-
const [metadata] = JSON.parse(pack.stdout);
|
|
30
|
-
const tarball = join(tempDir, metadata.filename);
|
|
31
|
-
readFileSync(tarball);
|
|
32
|
-
|
|
33
|
-
const result = spawnSync(
|
|
34
|
-
"npx",
|
|
35
|
-
["--yes", "--package", tarball, "--", "dart-decimate", "--help"],
|
|
36
|
-
{
|
|
37
|
-
encoding: "utf8",
|
|
38
|
-
env: { ...npmEnv, DART_DECIMATE_SKIP_DOWNLOAD: "1" },
|
|
39
|
-
},
|
|
40
|
-
);
|
|
41
|
-
if (result.stdout) {
|
|
42
|
-
process.stdout.write(result.stdout);
|
|
43
|
-
}
|
|
44
|
-
if (result.stderr) {
|
|
45
|
-
process.stderr.write(result.stderr);
|
|
46
|
-
}
|
|
47
|
-
if (result.error) {
|
|
48
|
-
process.stderr.write(`failed to execute npx: ${result.error.message}\n`);
|
|
49
|
-
process.exit(result.error.code === "ENOENT" ? 127 : 1);
|
|
50
|
-
}
|
|
51
|
-
if (result.status !== 0) {
|
|
52
|
-
process.exit(result.status || 1);
|
|
53
|
-
}
|
|
54
|
-
if (!result.stdout.includes("Usage: dart-decimate")) {
|
|
55
|
-
process.stderr.write(
|
|
56
|
-
"dart-decimate --help did not print the expected usage\n",
|
|
57
|
-
);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
} finally {
|
|
61
|
-
rmSync(tempDir, { recursive: true, force: true });
|
|
62
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { mkdtempSync, readFileSync, rmSync } = require("node:fs");
|
|
4
|
-
const { tmpdir } = require("node:os");
|
|
5
|
-
const { join } = require("node:path");
|
|
6
|
-
const { spawnSync } = require("node:child_process");
|
|
7
|
-
|
|
8
|
-
const root = join(__dirname, "..", "..");
|
|
9
|
-
const tempDir = mkdtempSync(join(tmpdir(), "dart-decimate-npx-mcp-"));
|
|
10
|
-
const npmEnv = {
|
|
11
|
-
...process.env,
|
|
12
|
-
npm_config_cache: join(tempDir, "npm-cache"),
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
const pack = spawnSync(
|
|
17
|
-
"npm",
|
|
18
|
-
["pack", "--json", "--pack-destination", tempDir],
|
|
19
|
-
{ cwd: root, encoding: "utf8", env: npmEnv },
|
|
20
|
-
);
|
|
21
|
-
if (pack.error) {
|
|
22
|
-
process.stderr.write(`failed to execute npm: ${pack.error.message}\n`);
|
|
23
|
-
process.exit(pack.error.code === "ENOENT" ? 127 : 1);
|
|
24
|
-
}
|
|
25
|
-
if (pack.status !== 0) {
|
|
26
|
-
process.stderr.write(pack.stderr || "");
|
|
27
|
-
process.exit(pack.status || 1);
|
|
28
|
-
}
|
|
29
|
-
const [metadata] = JSON.parse(pack.stdout);
|
|
30
|
-
const tarball = join(tempDir, metadata.filename);
|
|
31
|
-
readFileSync(tarball);
|
|
32
|
-
|
|
33
|
-
const initialize =
|
|
34
|
-
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25"}}\n';
|
|
35
|
-
const result = spawnSync(
|
|
36
|
-
"npx",
|
|
37
|
-
["--yes", "--package", tarball, "--", "dart-decimate-mcp"],
|
|
38
|
-
{
|
|
39
|
-
input: initialize,
|
|
40
|
-
encoding: "utf8",
|
|
41
|
-
env: { ...npmEnv, DART_DECIMATE_SKIP_DOWNLOAD: "1" },
|
|
42
|
-
},
|
|
43
|
-
);
|
|
44
|
-
if (result.stdout) {
|
|
45
|
-
process.stdout.write(result.stdout);
|
|
46
|
-
}
|
|
47
|
-
if (result.stderr) {
|
|
48
|
-
process.stderr.write(result.stderr);
|
|
49
|
-
}
|
|
50
|
-
if (result.error) {
|
|
51
|
-
process.stderr.write(`failed to execute npx: ${result.error.message}\n`);
|
|
52
|
-
process.exit(result.error.code === "ENOENT" ? 127 : 1);
|
|
53
|
-
}
|
|
54
|
-
if (result.status !== 0) {
|
|
55
|
-
process.exit(result.status || 1);
|
|
56
|
-
}
|
|
57
|
-
const response = JSON.parse(result.stdout.trim());
|
|
58
|
-
if (response.result?.protocolVersion !== "2025-11-25") {
|
|
59
|
-
process.stderr.write(
|
|
60
|
-
"dart-decimate-mcp did not negotiate MCP 2025-11-25\n",
|
|
61
|
-
);
|
|
62
|
-
process.exit(1);
|
|
63
|
-
}
|
|
64
|
-
} finally {
|
|
65
|
-
rmSync(tempDir, { recursive: true, force: true });
|
|
66
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
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
|
-
if (process.platform === "win32") {
|
|
10
|
-
console.log("skipping npx prebuilt fixture on Windows");
|
|
11
|
-
process.exit(0);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const root = path.resolve(__dirname, "../..");
|
|
15
|
-
const tempRoot = fs.mkdtempSync(
|
|
16
|
-
path.join(tmpdir(), "dart-decimate-npx-prebuilt-"),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
main().catch((error) => {
|
|
20
|
-
console.error(error.message);
|
|
21
|
-
process.exit(1);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
async function main() {
|
|
25
|
-
const packageJson = JSON.parse(
|
|
26
|
-
fs.readFileSync(path.join(root, "package.json"), "utf8"),
|
|
27
|
-
);
|
|
28
|
-
const platform = process.platform === "win32" ? "windows" : process.platform;
|
|
29
|
-
const arch = process.arch === "x64" ? "x64" : process.arch;
|
|
30
|
-
const assetName = `dart-decimate-${platform}-${arch}.tar.gz`;
|
|
31
|
-
|
|
32
|
-
const projectDir = path.join(tempRoot, "project");
|
|
33
|
-
const payloadDir = path.join(tempRoot, "payload");
|
|
34
|
-
const assetDir = path.join(tempRoot, "assets");
|
|
35
|
-
fs.mkdirSync(projectDir, { recursive: true });
|
|
36
|
-
fs.mkdirSync(payloadDir, { recursive: true });
|
|
37
|
-
fs.mkdirSync(assetDir, { recursive: true });
|
|
38
|
-
|
|
39
|
-
for (const binary of ["dart-decimate", "dart-decimate-mcp"]) {
|
|
40
|
-
const binaryPath = path.join(payloadDir, binary);
|
|
41
|
-
fs.writeFileSync(
|
|
42
|
-
binaryPath,
|
|
43
|
-
`#!/usr/bin/env sh\nprintf '${binary} prebuilt'\nfor arg in "$@"; do printf ' %s' "$arg"; done\nprintf '\\n'\n`,
|
|
44
|
-
);
|
|
45
|
-
fs.chmodSync(binaryPath, 0o755);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const assetPath = path.join(assetDir, assetName);
|
|
49
|
-
const archive = spawnSync("tar", ["-czf", assetPath, "-C", payloadDir, "."], {
|
|
50
|
-
encoding: "utf8",
|
|
51
|
-
});
|
|
52
|
-
if (archive.status !== 0 || archive.error) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
archive.stderr ||
|
|
55
|
-
archive.error?.message ||
|
|
56
|
-
"failed to create test archive",
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const pack = spawnSync(
|
|
61
|
-
"npm",
|
|
62
|
-
["pack", "--json", "--pack-destination", tempRoot],
|
|
63
|
-
{
|
|
64
|
-
cwd: root,
|
|
65
|
-
encoding: "utf8",
|
|
66
|
-
},
|
|
67
|
-
);
|
|
68
|
-
if (pack.status !== 0 || pack.error) {
|
|
69
|
-
throw new Error(
|
|
70
|
-
pack.stderr || pack.error?.message || "failed to pack npm package",
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
const [metadata] = JSON.parse(pack.stdout);
|
|
74
|
-
const tarball = path.join(tempRoot, metadata.filename);
|
|
75
|
-
|
|
76
|
-
const server = http.createServer((request, response) => {
|
|
77
|
-
if (request.url !== `/v${packageJson.version}/${assetName}`) {
|
|
78
|
-
response.writeHead(404);
|
|
79
|
-
response.end("not found");
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
response.writeHead(200, { "content-type": "application/gzip" });
|
|
83
|
-
fs.createReadStream(assetPath).pipe(response);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
87
|
-
const { port } = server.address();
|
|
88
|
-
|
|
89
|
-
try {
|
|
90
|
-
const result = await runNpx(tarball, projectDir, {
|
|
91
|
-
...process.env,
|
|
92
|
-
CARGO: path.join(tempRoot, "missing-cargo"),
|
|
93
|
-
DART_DECIMATE_RELEASE_BASE_URL: `http://127.0.0.1:${port}/v${packageJson.version}`,
|
|
94
|
-
npm_config_cache: path.join(tempRoot, "npm-cache"),
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
if (result.stdout) {
|
|
98
|
-
process.stdout.write(result.stdout);
|
|
99
|
-
}
|
|
100
|
-
if (result.stderr) {
|
|
101
|
-
process.stderr.write(result.stderr);
|
|
102
|
-
}
|
|
103
|
-
if (result.status !== 0 || result.error) {
|
|
104
|
-
throw new Error(result.error?.message || `npx exited ${result.status}`);
|
|
105
|
-
}
|
|
106
|
-
if (!result.stdout.includes("dart-decimate prebuilt --help")) {
|
|
107
|
-
throw new Error("npx did not execute the downloaded prebuilt binary");
|
|
108
|
-
}
|
|
109
|
-
if (result.stderr.includes("Rust/Cargo")) {
|
|
110
|
-
throw new Error(
|
|
111
|
-
"npx attempted the Cargo fallback even though a prebuilt binary was available",
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
} finally {
|
|
115
|
-
await new Promise((resolve) => server.close(resolve));
|
|
116
|
-
fs.rmSync(tempRoot, { recursive: true, force: true });
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function runNpx(tarball, cwd, env) {
|
|
121
|
-
return new Promise((resolve) => {
|
|
122
|
-
const child = spawn(
|
|
123
|
-
"npx",
|
|
124
|
-
["--yes", "--package", tarball, "--", "dart-decimate", "--help"],
|
|
125
|
-
{
|
|
126
|
-
cwd,
|
|
127
|
-
env,
|
|
128
|
-
},
|
|
129
|
-
);
|
|
130
|
-
let stdout = "";
|
|
131
|
-
let stderr = "";
|
|
132
|
-
|
|
133
|
-
child.stdout.on("data", (chunk) => {
|
|
134
|
-
stdout += chunk;
|
|
135
|
-
});
|
|
136
|
-
child.stderr.on("data", (chunk) => {
|
|
137
|
-
stderr += chunk;
|
|
138
|
-
});
|
|
139
|
-
child.on("error", (error) => {
|
|
140
|
-
resolve({ error, stdout, stderr, status: null });
|
|
141
|
-
});
|
|
142
|
-
child.on("close", (status) => {
|
|
143
|
-
resolve({ stdout, stderr, status });
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
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 tempRoot = fs.mkdtempSync(
|
|
11
|
-
path.join(tmpdir(), "dart-decimate-postinstall-"),
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
main().catch((error) => {
|
|
15
|
-
console.error(error.message);
|
|
16
|
-
process.exit(1);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
async function main() {
|
|
20
|
-
const packageJson = JSON.parse(
|
|
21
|
-
fs.readFileSync(path.join(root, "package.json"), "utf8"),
|
|
22
|
-
);
|
|
23
|
-
const platform = process.platform === "win32" ? "windows" : process.platform;
|
|
24
|
-
const arch = process.arch === "x64" ? "x64" : process.arch;
|
|
25
|
-
const assetName = `dart-decimate-${platform}-${arch}.tar.gz`;
|
|
26
|
-
|
|
27
|
-
const scriptDir = path.join(tempRoot, "npm", "scripts");
|
|
28
|
-
const payloadDir = path.join(tempRoot, "payload");
|
|
29
|
-
const assetDir = path.join(tempRoot, "assets");
|
|
30
|
-
fs.mkdirSync(scriptDir, { recursive: true });
|
|
31
|
-
fs.mkdirSync(payloadDir, { recursive: true });
|
|
32
|
-
fs.mkdirSync(assetDir, { recursive: true });
|
|
33
|
-
|
|
34
|
-
fs.copyFileSync(
|
|
35
|
-
path.join(root, "npm", "scripts", "postinstall.js"),
|
|
36
|
-
path.join(scriptDir, "postinstall.js"),
|
|
37
|
-
);
|
|
38
|
-
fs.writeFileSync(
|
|
39
|
-
path.join(tempRoot, "package.json"),
|
|
40
|
-
JSON.stringify(
|
|
41
|
-
{ name: "dart-decimate", version: packageJson.version },
|
|
42
|
-
null,
|
|
43
|
-
2,
|
|
44
|
-
),
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
for (const binary of ["dart-decimate", "dart-decimate-mcp"]) {
|
|
48
|
-
const binaryPath = path.join(
|
|
49
|
-
payloadDir,
|
|
50
|
-
process.platform === "win32" ? `${binary}.exe` : binary,
|
|
51
|
-
);
|
|
52
|
-
fs.writeFileSync(binaryPath, "#!/usr/bin/env sh\nexit 0\n");
|
|
53
|
-
fs.chmodSync(binaryPath, 0o755);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const assetPath = path.join(assetDir, assetName);
|
|
57
|
-
const archive = spawnSync("tar", ["-czf", assetPath, "-C", payloadDir, "."], {
|
|
58
|
-
encoding: "utf8",
|
|
59
|
-
});
|
|
60
|
-
if (archive.status !== 0 || archive.error) {
|
|
61
|
-
throw new Error(
|
|
62
|
-
archive.stderr ||
|
|
63
|
-
archive.error?.message ||
|
|
64
|
-
"failed to create test archive",
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const server = http.createServer((request, response) => {
|
|
69
|
-
if (request.url !== `/v${packageJson.version}/${assetName}`) {
|
|
70
|
-
response.writeHead(404);
|
|
71
|
-
response.end("not found");
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
response.writeHead(200, { "content-type": "application/gzip" });
|
|
75
|
-
fs.createReadStream(assetPath).pipe(response);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
79
|
-
const { port } = server.address();
|
|
80
|
-
|
|
81
|
-
try {
|
|
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
|
-
},
|
|
91
|
-
},
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
if (result.stdout) {
|
|
95
|
-
process.stdout.write(result.stdout);
|
|
96
|
-
}
|
|
97
|
-
if (result.stderr) {
|
|
98
|
-
process.stderr.write(result.stderr);
|
|
99
|
-
}
|
|
100
|
-
if (result.status !== 0 || result.error) {
|
|
101
|
-
throw new Error(
|
|
102
|
-
result.error?.message || `postinstall exited ${result.status}`,
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
for (const binary of ["dart-decimate", "dart-decimate-mcp"]) {
|
|
107
|
-
const installed = path.join(
|
|
108
|
-
tempRoot,
|
|
109
|
-
"npm",
|
|
110
|
-
"bin-cache",
|
|
111
|
-
process.platform === "win32" ? `${binary}.exe` : binary,
|
|
112
|
-
);
|
|
113
|
-
if (!fs.existsSync(installed)) {
|
|
114
|
-
throw new Error(`missing installed prebuilt binary ${binary}`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
} finally {
|
|
118
|
-
await new Promise((resolve) => server.close(resolve));
|
|
119
|
-
fs.rmSync(tempRoot, { recursive: true, force: true });
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function runPostinstall(script, options) {
|
|
124
|
-
return new Promise((resolve) => {
|
|
125
|
-
const child = spawn("node", [script], options);
|
|
126
|
-
let stdout = "";
|
|
127
|
-
let stderr = "";
|
|
128
|
-
|
|
129
|
-
child.stdout.on("data", (chunk) => {
|
|
130
|
-
stdout += chunk;
|
|
131
|
-
});
|
|
132
|
-
child.stderr.on("data", (chunk) => {
|
|
133
|
-
stderr += chunk;
|
|
134
|
-
});
|
|
135
|
-
child.on("error", (error) => {
|
|
136
|
-
resolve({ error, stdout, stderr, status: null });
|
|
137
|
-
});
|
|
138
|
-
child.on("close", (status) => {
|
|
139
|
-
resolve({ stdout, stderr, status });
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
}
|
|
@@ -1,237 +0,0 @@
|
|
|
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
|
-
}
|