devbonzai 2.1.8 → 2.1.9
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devbonzai",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
4
4
|
"description": "Quickly set up a local file server in any repository for browser-based file access",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"express": "^4.18.2",
|
|
26
26
|
"cors": "^2.8.5",
|
|
27
27
|
"body-parser": "^1.20.2",
|
|
28
|
-
"raw-body": "^2.5.2"
|
|
28
|
+
"raw-body": "^2.5.2",
|
|
29
|
+
"glob": "^10.0.0"
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const glob = require('glob');
|
|
4
|
+
|
|
5
|
+
module.exports = async function scanCodeQuality(req, res) {
|
|
6
|
+
try {
|
|
7
|
+
const { projectPath, maxFileLines = 500, maxFolderFiles = 20 } = req.body;
|
|
8
|
+
|
|
9
|
+
if (!projectPath) {
|
|
10
|
+
return res.status(400).json({ error: 'projectPath required' });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const issues = [];
|
|
14
|
+
|
|
15
|
+
// 1. Check file sizes
|
|
16
|
+
const files = glob.sync('**/*.{js,ts,jsx,tsx,py,java,go}', {
|
|
17
|
+
cwd: projectPath,
|
|
18
|
+
nodir: true,
|
|
19
|
+
ignore: ['node_modules/**', 'dist/**', 'build/**', '.git/**']
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
files.forEach(file => {
|
|
23
|
+
const fullPath = path.join(projectPath, file);
|
|
24
|
+
const content = fs.readFileSync(fullPath, 'utf8');
|
|
25
|
+
const lines = content.split('\n').length;
|
|
26
|
+
|
|
27
|
+
if (lines > maxFileLines) {
|
|
28
|
+
issues.push({
|
|
29
|
+
type: 'large_file',
|
|
30
|
+
file: file,
|
|
31
|
+
lines: lines,
|
|
32
|
+
limit: maxFileLines
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// 2. Check folder sizes
|
|
38
|
+
const folders = glob.sync('**/', {
|
|
39
|
+
cwd: projectPath,
|
|
40
|
+
ignore: ['node_modules/**', 'dist/**', 'build/**', '.git/**']
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
folders.forEach(folder => {
|
|
44
|
+
const fullPath = path.join(projectPath, folder);
|
|
45
|
+
const contents = fs.readdirSync(fullPath);
|
|
46
|
+
const fileCount = contents.filter(item => {
|
|
47
|
+
const itemPath = path.join(fullPath, item);
|
|
48
|
+
return fs.statSync(itemPath).isFile();
|
|
49
|
+
}).length;
|
|
50
|
+
|
|
51
|
+
if (fileCount > maxFolderFiles) {
|
|
52
|
+
issues.push({
|
|
53
|
+
type: 'crowded_folder',
|
|
54
|
+
folder: folder,
|
|
55
|
+
count: fileCount,
|
|
56
|
+
limit: maxFolderFiles
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
res.json({ issues });
|
|
62
|
+
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('Scan error:', error);
|
|
65
|
+
res.status(500).json({ error: error.message });
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
package/templates/receiver.js
CHANGED
|
@@ -18,6 +18,7 @@ const promptAgentHandler = require('./handlers/prompt_agent');
|
|
|
18
18
|
const promptAgentStreamHandler = require('./handlers/prompt_agent_stream');
|
|
19
19
|
const revertJobHandler = require('./handlers/revert_job');
|
|
20
20
|
const shutdownHandler = require('./handlers/shutdown');
|
|
21
|
+
const scanCodeQualityHandler = require('./handlers/scan_code_quality');
|
|
21
22
|
|
|
22
23
|
const app = express();
|
|
23
24
|
|
|
@@ -39,6 +40,7 @@ app.post('/prompt_agent', promptAgentHandler);
|
|
|
39
40
|
app.post('/prompt_agent_stream', promptAgentStreamHandler);
|
|
40
41
|
app.post('/revert_job', revertJobHandler);
|
|
41
42
|
app.post('/shutdown', shutdownHandler);
|
|
43
|
+
app.post('/scan_code_quality', scanCodeQualityHandler);
|
|
42
44
|
|
|
43
45
|
const port = 3001;
|
|
44
46
|
app.listen(port, () => {
|