blast-radius-cli 0.2.0
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/README.md +42 -0
- package/bin/blast-radius.js +135 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# blast-radius-cli
|
|
2
|
+
|
|
3
|
+
Prebuilt binary distribution of [blast-radius](https://github.com/ehermanson/blast-radius) —
|
|
4
|
+
a CLI that analyzes the transitive blast radius of code changes.
|
|
5
|
+
|
|
6
|
+
No Rust toolchain required: installing this package pulls in a small
|
|
7
|
+
platform-specific package (esbuild-style) containing a native binary for your
|
|
8
|
+
OS/architecture. Nothing is downloaded at runtime and there is no postinstall
|
|
9
|
+
step.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install --save-dev blast-radius-cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or run it without installing:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npx blast-radius-cli --help
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Either way, the command is `blast-radius`:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npx blast-radius src/some/file.ts
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Notes
|
|
30
|
+
|
|
31
|
+
- The prebuilt binaries ship with **all language features compiled in**
|
|
32
|
+
(Python, Rust, Vue, Svelte, Ruby, Java) — unlike a default
|
|
33
|
+
`cargo install blast-radius`, which only includes the default feature set.
|
|
34
|
+
- Supported platforms: Linux x64/arm64 (glibc), Linux x64 (musl), macOS
|
|
35
|
+
x64/arm64, Windows x64. On other platforms, build from source with
|
|
36
|
+
`cargo install blast-radius`.
|
|
37
|
+
|
|
38
|
+
Full documentation: https://github.com/ehermanson/blast-radius
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// Shim that locates the platform-specific blast-radius binary (shipped as an
|
|
5
|
+
// optionalDependency, esbuild-style) and execs it, propagating the exact exit
|
|
6
|
+
// code. Exit codes 0/1/2/64 are a documented CI contract — do not remap them.
|
|
7
|
+
//
|
|
8
|
+
// This shim never downloads anything; if the platform package is missing the
|
|
9
|
+
// install was incomplete or the platform is unsupported.
|
|
10
|
+
|
|
11
|
+
const { spawnSync } = require('child_process');
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
|
|
14
|
+
const SUPPORTED = [
|
|
15
|
+
'blast-radius-cli-linux-x64 (Linux x64, glibc)',
|
|
16
|
+
'blast-radius-cli-linux-arm64 (Linux arm64, glibc)',
|
|
17
|
+
'blast-radius-cli-linux-x64-musl (Linux x64, musl e.g. Alpine)',
|
|
18
|
+
'blast-radius-cli-darwin-x64 (macOS x64)',
|
|
19
|
+
'blast-radius-cli-darwin-arm64 (macOS arm64)',
|
|
20
|
+
'blast-radius-cli-win32-x64 (Windows x64)',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
function isMusl() {
|
|
24
|
+
// glibc exposes its version in the process report; musl does not.
|
|
25
|
+
try {
|
|
26
|
+
const report = process.report && process.report.getReport();
|
|
27
|
+
if (report && report.header) {
|
|
28
|
+
return !report.header.glibcVersionRuntime;
|
|
29
|
+
}
|
|
30
|
+
} catch (err) {
|
|
31
|
+
// fall through to the filesystem probe
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
return (
|
|
35
|
+
fs.existsSync('/lib/ld-musl-x86_64.so.1') ||
|
|
36
|
+
fs.existsSync('/lib/ld-musl-aarch64.so.1')
|
|
37
|
+
);
|
|
38
|
+
} catch (err) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Returns the candidate platform package names, most preferred first.
|
|
44
|
+
function candidatePackages(platform, arch) {
|
|
45
|
+
if (platform === 'linux' && arch === 'x64') {
|
|
46
|
+
// On musl systems prefer the musl build but fall back to glibc, and vice
|
|
47
|
+
// versa (the musl build is statically linked and runs on glibc too).
|
|
48
|
+
return isMusl()
|
|
49
|
+
? ['blast-radius-cli-linux-x64-musl', 'blast-radius-cli-linux-x64']
|
|
50
|
+
: ['blast-radius-cli-linux-x64', 'blast-radius-cli-linux-x64-musl'];
|
|
51
|
+
}
|
|
52
|
+
if (platform === 'linux' && arch === 'arm64') {
|
|
53
|
+
return ['blast-radius-cli-linux-arm64'];
|
|
54
|
+
}
|
|
55
|
+
if (platform === 'darwin' && arch === 'x64') {
|
|
56
|
+
return ['blast-radius-cli-darwin-x64'];
|
|
57
|
+
}
|
|
58
|
+
if (platform === 'darwin' && arch === 'arm64') {
|
|
59
|
+
return ['blast-radius-cli-darwin-arm64'];
|
|
60
|
+
}
|
|
61
|
+
if (platform === 'win32' && arch === 'x64') {
|
|
62
|
+
return ['blast-radius-cli-win32-x64'];
|
|
63
|
+
}
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function resolveBinary() {
|
|
68
|
+
const platform = process.platform;
|
|
69
|
+
const arch = process.arch;
|
|
70
|
+
const binName = platform === 'win32' ? 'blast-radius.exe' : 'blast-radius';
|
|
71
|
+
const candidates = candidatePackages(platform, arch);
|
|
72
|
+
|
|
73
|
+
for (const pkg of candidates) {
|
|
74
|
+
try {
|
|
75
|
+
return require.resolve(`${pkg}/bin/${binName}`);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
// try the next candidate
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const expected =
|
|
82
|
+
candidates.length > 0
|
|
83
|
+
? `Expected the npm package "${candidates[0]}" to be installed, but it was not found.`
|
|
84
|
+
: `Your platform (${platform}-${arch}) has no prebuilt blast-radius binary.`;
|
|
85
|
+
|
|
86
|
+
console.error(
|
|
87
|
+
[
|
|
88
|
+
`blast-radius: could not find a prebuilt binary for ${platform}-${arch}.`,
|
|
89
|
+
'',
|
|
90
|
+
expected,
|
|
91
|
+
'',
|
|
92
|
+
candidates.length > 0
|
|
93
|
+
? 'It is normally installed automatically as an optionalDependency of'
|
|
94
|
+
: 'Prebuilt binaries exist for these platforms (installed automatically as',
|
|
95
|
+
candidates.length > 0
|
|
96
|
+
? '"blast-radius-cli". If it is missing, your package manager may have'
|
|
97
|
+
: 'optionalDependencies of "blast-radius-cli"):'
|
|
98
|
+
,
|
|
99
|
+
...(candidates.length > 0
|
|
100
|
+
? [
|
|
101
|
+
'skipped optional dependencies (e.g. --no-optional / --omit=optional),',
|
|
102
|
+
'or the lockfile was created on a different platform. Try reinstalling',
|
|
103
|
+
'with optional dependencies enabled.',
|
|
104
|
+
'',
|
|
105
|
+
'Prebuilt binaries exist for these platforms:',
|
|
106
|
+
]
|
|
107
|
+
: []),
|
|
108
|
+
...SUPPORTED.map((line) => ` - ${line}`),
|
|
109
|
+
'',
|
|
110
|
+
'Alternatively, build from source with the Rust toolchain:',
|
|
111
|
+
' cargo install blast-radius',
|
|
112
|
+
'',
|
|
113
|
+
'More info: https://github.com/ehermanson/blast-radius',
|
|
114
|
+
].join('\n')
|
|
115
|
+
);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const binary = resolveBinary();
|
|
120
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: 'inherit' });
|
|
121
|
+
|
|
122
|
+
if (result.error) {
|
|
123
|
+
console.error(`blast-radius: failed to run ${binary}: ${result.error.message}`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (result.signal) {
|
|
128
|
+
// Re-raise the signal so callers observe the same termination the child did
|
|
129
|
+
// (shells report this as exit code 128 + signal number).
|
|
130
|
+
process.kill(process.pid, result.signal);
|
|
131
|
+
// If the signal was non-fatal for this process, fall back to a non-zero exit.
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "blast-radius-cli",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Prebuilt blast-radius binary — analyze the transitive blast radius of code changes",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"blast-radius",
|
|
7
|
+
"impact-analysis",
|
|
8
|
+
"dependency-graph",
|
|
9
|
+
"static-analysis",
|
|
10
|
+
"refactoring",
|
|
11
|
+
"cli"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/ehermanson/blast-radius.git"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/ehermanson/blast-radius#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/ehermanson/blast-radius/issues"
|
|
21
|
+
},
|
|
22
|
+
"bin": {
|
|
23
|
+
"blast-radius": "bin/blast-radius.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"bin/",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"optionalDependencies": {
|
|
33
|
+
"blast-radius-cli-linux-x64": "0.2.0",
|
|
34
|
+
"blast-radius-cli-linux-arm64": "0.2.0",
|
|
35
|
+
"blast-radius-cli-linux-x64-musl": "0.2.0",
|
|
36
|
+
"blast-radius-cli-darwin-x64": "0.2.0",
|
|
37
|
+
"blast-radius-cli-darwin-arm64": "0.2.0",
|
|
38
|
+
"blast-radius-cli-win32-x64": "0.2.0"
|
|
39
|
+
}
|
|
40
|
+
}
|