project-compass 4.3.3 → 4.3.6
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 +1 -1
- package/src/detectors/python.js +22 -8
package/package.json
CHANGED
package/src/detectors/python.js
CHANGED
|
@@ -24,7 +24,7 @@ function getPythonPackageManager(projectPath) {
|
|
|
24
24
|
function gatherPythonDependencies(projectPath) {
|
|
25
25
|
const deps = new Set();
|
|
26
26
|
|
|
27
|
-
// Only read requirements.txt
|
|
27
|
+
// Only read requirements.txt
|
|
28
28
|
const reqPath = path.join(projectPath, 'requirements.txt');
|
|
29
29
|
if (fs.existsSync(reqPath)) {
|
|
30
30
|
const raw = fs.readFileSync(reqPath, 'utf-8');
|
|
@@ -36,6 +36,7 @@ function gatherPythonDependencies(projectPath) {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// Only read requirements-dev.txt
|
|
39
40
|
const reqDevPath = path.join(projectPath, 'requirements-dev.txt');
|
|
40
41
|
if (fs.existsSync(reqDevPath)) {
|
|
41
42
|
const raw = fs.readFileSync(reqDevPath, 'utf-8');
|
|
@@ -47,7 +48,7 @@ function gatherPythonDependencies(projectPath) {
|
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
// Only read pyproject.toml dependencies section
|
|
51
|
+
// Only read pyproject.toml dependencies section
|
|
51
52
|
const pyproject = path.join(projectPath, 'pyproject.toml');
|
|
52
53
|
if (fs.existsSync(pyproject)) {
|
|
53
54
|
const content = fs.readFileSync(pyproject, 'utf-8');
|
|
@@ -65,15 +66,27 @@ function gatherPythonDependencies(projectPath) {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
// Only read Pipfile
|
|
70
|
+
const pipfile = path.join(projectPath, 'Pipfile');
|
|
71
|
+
if (fs.existsSync(pipfile)) {
|
|
72
|
+
const content = fs.readFileSync(pipfile, 'utf-8');
|
|
73
|
+
const matches = content.match(/["']([^"']+)/g);
|
|
74
|
+
if (matches) {
|
|
75
|
+
matches.forEach((m) => {
|
|
76
|
+
const dep = m.replace(/["']/g, '').split(/[>=<=~!]/)[0].trim();
|
|
77
|
+
if (dep) deps.add(dep.toLowerCase());
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
68
82
|
return Array.from(deps);
|
|
69
83
|
}
|
|
70
84
|
|
|
71
|
-
// Uses EXACT matching - NOT substring!
|
|
72
85
|
function detectPythonFramework(deps) {
|
|
73
86
|
const frameworks = [];
|
|
74
87
|
|
|
75
|
-
const hasDep = (pattern) =>
|
|
76
|
-
deps.some((dep) => {
|
|
88
|
+
const hasDep = (pattern) => {
|
|
89
|
+
return deps.some((dep) => {
|
|
77
90
|
const depLower = dep.toLowerCase();
|
|
78
91
|
return depLower === pattern.toLowerCase() ||
|
|
79
92
|
depLower.startsWith(pattern.toLowerCase() + '==') ||
|
|
@@ -81,6 +94,7 @@ function detectPythonFramework(deps) {
|
|
|
81
94
|
depLower.startsWith(pattern.toLowerCase() + '<=') ||
|
|
82
95
|
depLower.startsWith(pattern.toLowerCase() + '~=');
|
|
83
96
|
});
|
|
97
|
+
};
|
|
84
98
|
|
|
85
99
|
if (hasDep('fastapi')) frameworks.push({ name: 'FastAPI', icon: '⚡' });
|
|
86
100
|
if (hasDep('flask')) frameworks.push({ name: 'Flask', icon: '🌶️' });
|
|
@@ -136,8 +150,8 @@ export default {
|
|
|
136
150
|
commands.install = { label: 'Pip Install', command: ['pip', 'install', '-r', 'requirements.txt'], source: 'builtin' };
|
|
137
151
|
}
|
|
138
152
|
|
|
139
|
-
if (
|
|
140
|
-
commands.test = { label: 'Pytest', command: [isUV ? 'uv' :
|
|
153
|
+
if (hasProjectFile(projectPath, 'pyproject.toml') || hasProjectFile(projectPath, 'setup.py')) {
|
|
154
|
+
commands.test = { label: 'Pytest', command: [isUV ? 'uv' : 'python', ...(isUV ? ['run'] : []), 'pytest'], source: 'builtin' };
|
|
141
155
|
} else {
|
|
142
156
|
commands.test = { label: 'Unittest', command: ['python', '-m', 'unittest', 'discover'], source: 'builtin' };
|
|
143
157
|
}
|
|
@@ -153,7 +167,7 @@ export default {
|
|
|
153
167
|
|
|
154
168
|
if (hasProjectFile(projectPath, 'manage.py')) {
|
|
155
169
|
const djangoCmd = isUV ? ['uv', 'run', 'python', 'manage.py'] :
|
|
156
|
-
|
|
170
|
+
['python', 'manage.py'];
|
|
157
171
|
commands['runserver'] = { label: 'Django Runserver', command: [...djangoCmd, 'runserver'], source: 'builtin' };
|
|
158
172
|
commands['migrate'] = { label: 'Django Migrate', command: [...djangoCmd, 'migrate'], source: 'builtin' };
|
|
159
173
|
commands['test'] = { label: 'Django Test', command: [...djangoCmd, 'test'], source: 'builtin' };
|