codeprobe-scanner 1.0.2 → 1.0.3
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/bin/codeprobe.js +43 -9
- package/package.json +1 -1
package/bin/codeprobe.js
CHANGED
|
@@ -1,18 +1,52 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const os = require('os');
|
|
5
7
|
|
|
6
8
|
// Get the package root directory
|
|
7
9
|
const packageRoot = path.resolve(__dirname, '..');
|
|
8
10
|
|
|
9
|
-
//
|
|
11
|
+
// Try to find bun
|
|
12
|
+
function findBun() {
|
|
13
|
+
try {
|
|
14
|
+
// Try system bun
|
|
15
|
+
execSync('bun --version', { stdio: 'pipe' });
|
|
16
|
+
return 'bun';
|
|
17
|
+
} catch (e) {
|
|
18
|
+
// Try home directory
|
|
19
|
+
const bunPath = path.join(os.homedir(), '.bun', 'bin', 'bun');
|
|
20
|
+
if (fs.existsSync(bunPath)) {
|
|
21
|
+
return bunPath;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Find or install bun
|
|
28
|
+
let bunCmd = findBun();
|
|
29
|
+
if (!bunCmd) {
|
|
30
|
+
console.error('❌ Bun is not installed.');
|
|
31
|
+
console.error('Installing Bun...');
|
|
32
|
+
try {
|
|
33
|
+
execSync('curl -fsSL https://bun.sh/install | bash', { stdio: 'inherit' });
|
|
34
|
+
bunCmd = path.join(os.homedir(), '.bun', 'bin', 'bun');
|
|
35
|
+
} catch (err) {
|
|
36
|
+
console.error('Failed to install Bun. Please install manually: https://bun.sh');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Run the CLI
|
|
10
42
|
const args = process.argv.slice(2);
|
|
11
|
-
const
|
|
12
|
-
stdio: 'inherit',
|
|
13
|
-
shell: true,
|
|
14
|
-
});
|
|
43
|
+
const cmd = `${bunCmd} run ${path.join(packageRoot, 'src/cli-server.ts')} ${args.join(' ')}`;
|
|
15
44
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
45
|
+
try {
|
|
46
|
+
execSync(cmd, {
|
|
47
|
+
stdio: 'inherit',
|
|
48
|
+
cwd: packageRoot
|
|
49
|
+
});
|
|
50
|
+
} catch (err) {
|
|
51
|
+
process.exit(err.status || 1);
|
|
52
|
+
}
|