projax 1.0.2 → 1.3.1
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/dist/api/database.d.ts +34 -0
- package/dist/api/database.d.ts.map +1 -0
- package/dist/api/database.js +318 -0
- package/dist/api/database.js.map +1 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +130 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/migrate.d.ts +2 -0
- package/dist/api/migrate.d.ts.map +1 -0
- package/dist/api/migrate.js +158 -0
- package/dist/api/migrate.js.map +1 -0
- package/dist/api/package.json +27 -0
- package/dist/api/routes/index.d.ts +3 -0
- package/dist/api/routes/index.d.ts.map +1 -0
- package/dist/api/routes/index.js +17 -0
- package/dist/api/routes/index.js.map +1 -0
- package/dist/api/routes/projects.d.ts +3 -0
- package/dist/api/routes/projects.d.ts.map +1 -0
- package/dist/api/routes/projects.js +198 -0
- package/dist/api/routes/projects.js.map +1 -0
- package/dist/api/routes/settings.d.ts +3 -0
- package/dist/api/routes/settings.d.ts.map +1 -0
- package/dist/api/routes/settings.js +33 -0
- package/dist/api/routes/settings.js.map +1 -0
- package/dist/api/services/scanner.d.ts +9 -0
- package/dist/api/services/scanner.d.ts.map +1 -0
- package/dist/api/services/scanner.js +172 -0
- package/dist/api/services/scanner.js.map +1 -0
- package/dist/api/types.d.ts +48 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +3 -0
- package/dist/api/types.js.map +1 -0
- package/dist/core/database.d.ts +15 -5
- package/dist/core/database.js +136 -208
- package/dist/core/detector.d.ts +5 -0
- package/dist/core/detector.js +135 -0
- package/dist/core/index.d.ts +1 -2
- package/dist/core/index.js +2 -4
- package/dist/core/scanner.js +2 -105
- package/dist/core/settings.d.ts +50 -0
- package/dist/core/settings.js +102 -0
- package/dist/core-bridge.d.ts +2 -0
- package/dist/core-bridge.js +73 -0
- package/dist/core.d.ts +2 -0
- package/dist/core.js +76 -0
- package/dist/electron/core/database.d.ts +76 -0
- package/dist/electron/core/database.js +240 -0
- package/dist/electron/core/detector.d.ts +14 -0
- package/dist/electron/core/detector.js +284 -0
- package/dist/electron/core/index.d.ts +10 -0
- package/dist/electron/core/index.js +41 -0
- package/dist/electron/core/scanner.d.ts +8 -0
- package/dist/electron/core/scanner.js +11 -0
- package/dist/electron/core/settings.d.ts +50 -0
- package/dist/electron/core/settings.js +102 -0
- package/dist/electron/core.d.ts +2 -0
- package/dist/electron/core.js +76 -0
- package/dist/electron/main.js +93 -51
- package/dist/electron/port-scanner.js +4 -4
- package/dist/electron/preload.d.ts +1 -1
- package/dist/electron/renderer/assets/index-7KIJIiIM.js +42 -0
- package/dist/electron/renderer/assets/{index-DohAcUCg.css → index-ezVMxZrM.css} +1 -1
- package/dist/electron/renderer/index.html +2 -2
- package/dist/electron/script-runner.js +4 -4
- package/dist/index.js +240 -75
- package/dist/port-scanner.js +4 -4
- package/dist/script-runner.js +4 -4
- package/package.json +12 -11
- package/dist/electron/renderer/assets/index-BZ6USRnW.js +0 -42
- package/dist/electron/renderer/assets/index-CdMlFqhB.js +0 -42
- package/dist/electron/renderer/assets/index-DNtxfrZe.js +0 -42
- package/dist/electron/renderer/assets/index-khk3K-qG.css +0 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getDatabaseManager = getDatabaseManager;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const os = __importStar(require("os"));
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const child_process_1 = require("child_process");
|
|
41
|
+
class DatabaseManager {
|
|
42
|
+
apiBaseUrl;
|
|
43
|
+
defaultPort = 3001;
|
|
44
|
+
constructor() {
|
|
45
|
+
// Read API port from file, or use default
|
|
46
|
+
const dataDir = path.join(os.homedir(), '.projax');
|
|
47
|
+
const portFile = path.join(dataDir, 'api-port.txt');
|
|
48
|
+
let port = this.defaultPort;
|
|
49
|
+
if (fs.existsSync(portFile)) {
|
|
50
|
+
try {
|
|
51
|
+
const portStr = fs.readFileSync(portFile, 'utf-8').trim();
|
|
52
|
+
port = parseInt(portStr, 10) || this.defaultPort;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Use default if file read fails
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
this.apiBaseUrl = `http://localhost:${port}/api`;
|
|
59
|
+
}
|
|
60
|
+
request(endpoint, options = {}) {
|
|
61
|
+
const url = `${this.apiBaseUrl}${endpoint}`;
|
|
62
|
+
const method = options.method || 'GET';
|
|
63
|
+
const body = options.body;
|
|
64
|
+
try {
|
|
65
|
+
let curlCmd;
|
|
66
|
+
if (method === 'GET') {
|
|
67
|
+
curlCmd = `curl -s -f "${url}"`;
|
|
68
|
+
}
|
|
69
|
+
else if (method === 'DELETE') {
|
|
70
|
+
curlCmd = `curl -s -f -X DELETE "${url}"`;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// POST, PUT, PATCH
|
|
74
|
+
const tempFile = path.join(os.tmpdir(), `prx-${Date.now()}.json`);
|
|
75
|
+
if (body) {
|
|
76
|
+
fs.writeFileSync(tempFile, body);
|
|
77
|
+
}
|
|
78
|
+
curlCmd = `curl -s -f -X ${method} -H "Content-Type: application/json" ${body ? `-d @${tempFile}` : ''} "${url}"`;
|
|
79
|
+
}
|
|
80
|
+
const result = (0, child_process_1.execSync)(curlCmd, { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
81
|
+
// Clean up temp file if created
|
|
82
|
+
if (method !== 'GET' && method !== 'DELETE' && body) {
|
|
83
|
+
const tempFile = path.join(os.tmpdir(), `prx-${Date.now()}.json`);
|
|
84
|
+
try {
|
|
85
|
+
fs.unlinkSync(tempFile);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// Ignore cleanup errors
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!result || result.trim() === '') {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
return JSON.parse(result);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
// Check if it's a 404 or other HTTP error
|
|
98
|
+
if (error instanceof Error && error.message.includes('404')) {
|
|
99
|
+
throw new Error('Resource not found');
|
|
100
|
+
}
|
|
101
|
+
throw new Error(`API request failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Project operations
|
|
105
|
+
addProject(name, projectPath) {
|
|
106
|
+
return this.request('/projects', {
|
|
107
|
+
method: 'POST',
|
|
108
|
+
body: JSON.stringify({ name, path: projectPath }),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
getProject(id) {
|
|
112
|
+
try {
|
|
113
|
+
return this.request(`/projects/${id}`);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
if (error instanceof Error && error.message.includes('404')) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
getProjectByPath(projectPath) {
|
|
123
|
+
const projects = this.getAllProjects();
|
|
124
|
+
return projects.find(p => p.path === projectPath) || null;
|
|
125
|
+
}
|
|
126
|
+
getAllProjects() {
|
|
127
|
+
return this.request('/projects');
|
|
128
|
+
}
|
|
129
|
+
updateProjectLastScanned(id) {
|
|
130
|
+
// Fire and forget - this is handled by the scan endpoint
|
|
131
|
+
// No need to explicitly update last_scanned
|
|
132
|
+
}
|
|
133
|
+
updateProjectFramework(id, framework) {
|
|
134
|
+
// This will be called during scan to update the detected framework
|
|
135
|
+
this.request(`/projects/${id}`, {
|
|
136
|
+
method: 'PUT',
|
|
137
|
+
body: JSON.stringify({ framework }),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
updateProjectName(id, newName) {
|
|
141
|
+
return this.request(`/projects/${id}`, {
|
|
142
|
+
method: 'PUT',
|
|
143
|
+
body: JSON.stringify({ name: newName }),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
removeProject(id) {
|
|
147
|
+
this.request(`/projects/${id}`, {
|
|
148
|
+
method: 'DELETE',
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
scanProject(id) {
|
|
152
|
+
return this.request(`/projects/${id}/scan`, {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
scanAllProjects() {
|
|
157
|
+
return this.request('/projects/scan/all', {
|
|
158
|
+
method: 'POST',
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
// Test operations
|
|
162
|
+
addTest(projectId, filePath, framework = null) {
|
|
163
|
+
// Tests are added via scan endpoint, not directly
|
|
164
|
+
throw new Error('addTest should not be called directly. Use scan endpoint instead.');
|
|
165
|
+
}
|
|
166
|
+
getTest(id) {
|
|
167
|
+
// This endpoint doesn't exist yet
|
|
168
|
+
throw new Error('getTest endpoint not yet implemented in API');
|
|
169
|
+
}
|
|
170
|
+
getTestsByProject(projectId) {
|
|
171
|
+
return this.request(`/projects/${projectId}/tests`);
|
|
172
|
+
}
|
|
173
|
+
removeTestsByProject(projectId) {
|
|
174
|
+
// This is handled by the scan endpoint
|
|
175
|
+
// For now, we'll just call scan which removes and re-adds
|
|
176
|
+
throw new Error('removeTestsByProject should not be called directly. Use scan endpoint instead.');
|
|
177
|
+
}
|
|
178
|
+
// Jenkins operations
|
|
179
|
+
addJenkinsJob(projectId, jobName, jobUrl) {
|
|
180
|
+
// This endpoint doesn't exist yet
|
|
181
|
+
throw new Error('addJenkinsJob endpoint not yet implemented in API');
|
|
182
|
+
}
|
|
183
|
+
getJenkinsJob(id) {
|
|
184
|
+
// This endpoint doesn't exist yet
|
|
185
|
+
throw new Error('getJenkinsJob endpoint not yet implemented in API');
|
|
186
|
+
}
|
|
187
|
+
getJenkinsJobsByProject(projectId) {
|
|
188
|
+
// This endpoint doesn't exist yet
|
|
189
|
+
throw new Error('getJenkinsJobsByProject endpoint not yet implemented in API');
|
|
190
|
+
}
|
|
191
|
+
// Project port operations
|
|
192
|
+
addProjectPort(projectId, port, configSource, scriptName = null) {
|
|
193
|
+
// This endpoint doesn't exist yet
|
|
194
|
+
throw new Error('addProjectPort endpoint not yet implemented in API');
|
|
195
|
+
}
|
|
196
|
+
getProjectPort(id) {
|
|
197
|
+
// This endpoint doesn't exist yet
|
|
198
|
+
throw new Error('getProjectPort endpoint not yet implemented in API');
|
|
199
|
+
}
|
|
200
|
+
getProjectPorts(projectId) {
|
|
201
|
+
return this.request(`/projects/${projectId}/ports`);
|
|
202
|
+
}
|
|
203
|
+
getProjectPortsByScript(projectId, scriptName) {
|
|
204
|
+
const ports = this.getProjectPorts(projectId);
|
|
205
|
+
return ports.filter(p => p.script_name === scriptName);
|
|
206
|
+
}
|
|
207
|
+
removeProjectPorts(projectId) {
|
|
208
|
+
// This endpoint doesn't exist yet
|
|
209
|
+
throw new Error('removeProjectPorts endpoint not yet implemented in API');
|
|
210
|
+
}
|
|
211
|
+
updateProjectPortLastDetected(projectId, port, scriptName) {
|
|
212
|
+
// This endpoint doesn't exist yet - no-op for now
|
|
213
|
+
// Ports are updated via the scan endpoint
|
|
214
|
+
}
|
|
215
|
+
// Settings operations
|
|
216
|
+
getSetting(key) {
|
|
217
|
+
const settings = this.getAllSettings();
|
|
218
|
+
return settings[key] || null;
|
|
219
|
+
}
|
|
220
|
+
setSetting(key, value) {
|
|
221
|
+
this.request(`/settings/${encodeURIComponent(key)}`, {
|
|
222
|
+
method: 'PUT',
|
|
223
|
+
body: JSON.stringify({ value }),
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
getAllSettings() {
|
|
227
|
+
return this.request('/settings');
|
|
228
|
+
}
|
|
229
|
+
close() {
|
|
230
|
+
// No-op for API client
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Singleton instance
|
|
234
|
+
let dbManager = null;
|
|
235
|
+
function getDatabaseManager() {
|
|
236
|
+
if (!dbManager) {
|
|
237
|
+
dbManager = new DatabaseManager();
|
|
238
|
+
}
|
|
239
|
+
return dbManager;
|
|
240
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface TestFramework {
|
|
2
|
+
name: string;
|
|
3
|
+
configFiles: string[];
|
|
4
|
+
testPatterns: RegExp[];
|
|
5
|
+
testDirs: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare const FRAMEWORKS: TestFramework[];
|
|
8
|
+
export declare function detectTestFramework(projectPath: string): string | null;
|
|
9
|
+
export declare function isTestFile(filePath: string, detectedFramework?: string | null): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Detect the main framework/library used in a project
|
|
12
|
+
* Returns null if no framework is detected
|
|
13
|
+
*/
|
|
14
|
+
export declare function detectProjectFramework(projectPath: string): string | null;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.FRAMEWORKS = void 0;
|
|
37
|
+
exports.detectTestFramework = detectTestFramework;
|
|
38
|
+
exports.isTestFile = isTestFile;
|
|
39
|
+
exports.detectProjectFramework = detectProjectFramework;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
exports.FRAMEWORKS = [
|
|
43
|
+
{
|
|
44
|
+
name: 'jest',
|
|
45
|
+
configFiles: ['jest.config.js', 'jest.config.ts', 'jest.config.json', 'jest.config.mjs', 'jest.config.cjs'],
|
|
46
|
+
testPatterns: [
|
|
47
|
+
/\.test\.(js|ts|jsx|tsx)$/i,
|
|
48
|
+
/\.spec\.(js|ts|jsx|tsx)$/i,
|
|
49
|
+
],
|
|
50
|
+
testDirs: ['__tests__', '__test__'],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'vitest',
|
|
54
|
+
configFiles: ['vitest.config.ts', 'vitest.config.js', 'vitest.config.mjs'],
|
|
55
|
+
testPatterns: [
|
|
56
|
+
/\.test\.(js|ts|jsx|tsx)$/i,
|
|
57
|
+
/\.spec\.(js|ts|jsx|tsx)$/i,
|
|
58
|
+
],
|
|
59
|
+
testDirs: ['__tests__'],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'mocha',
|
|
63
|
+
configFiles: ['.mocharc.js', '.mocharc.json', '.mocharc.yaml', '.mocharc.yml', 'mocha.opts'],
|
|
64
|
+
testPatterns: [
|
|
65
|
+
/\.test\.(js|ts|jsx|tsx)$/i,
|
|
66
|
+
/\.spec\.(js|ts|jsx|tsx)$/i,
|
|
67
|
+
],
|
|
68
|
+
testDirs: ['test', 'tests'],
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
function detectTestFramework(projectPath) {
|
|
72
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
73
|
+
// Check package.json for test scripts and dependencies
|
|
74
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
75
|
+
try {
|
|
76
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
77
|
+
// Check dependencies and devDependencies
|
|
78
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
79
|
+
if (deps.jest)
|
|
80
|
+
return 'jest';
|
|
81
|
+
if (deps.vitest)
|
|
82
|
+
return 'vitest';
|
|
83
|
+
if (deps.mocha)
|
|
84
|
+
return 'mocha';
|
|
85
|
+
// Check for jest config in package.json
|
|
86
|
+
if (packageJson.jest)
|
|
87
|
+
return 'jest';
|
|
88
|
+
// Check test scripts
|
|
89
|
+
if (packageJson.scripts) {
|
|
90
|
+
const testScript = packageJson.scripts.test || '';
|
|
91
|
+
if (testScript.includes('jest'))
|
|
92
|
+
return 'jest';
|
|
93
|
+
if (testScript.includes('vitest'))
|
|
94
|
+
return 'vitest';
|
|
95
|
+
if (testScript.includes('mocha'))
|
|
96
|
+
return 'mocha';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
// Invalid JSON, continue with file-based detection
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Check for config files
|
|
104
|
+
for (const framework of exports.FRAMEWORKS) {
|
|
105
|
+
for (const configFile of framework.configFiles) {
|
|
106
|
+
const configPath = path.join(projectPath, configFile);
|
|
107
|
+
if (fs.existsSync(configPath)) {
|
|
108
|
+
return framework.name;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
function isTestFile(filePath, detectedFramework = null) {
|
|
115
|
+
const fileName = path.basename(filePath);
|
|
116
|
+
const dirName = path.dirname(filePath);
|
|
117
|
+
const parentDirName = path.basename(dirName);
|
|
118
|
+
// If framework is detected, use its specific patterns
|
|
119
|
+
if (detectedFramework) {
|
|
120
|
+
const framework = exports.FRAMEWORKS.find(f => f.name === detectedFramework);
|
|
121
|
+
if (framework) {
|
|
122
|
+
// Check test patterns
|
|
123
|
+
for (const pattern of framework.testPatterns) {
|
|
124
|
+
if (pattern.test(fileName)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Check test directories
|
|
129
|
+
for (const testDir of framework.testDirs) {
|
|
130
|
+
if (parentDirName === testDir) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Fallback: check all common patterns
|
|
137
|
+
for (const framework of exports.FRAMEWORKS) {
|
|
138
|
+
for (const pattern of framework.testPatterns) {
|
|
139
|
+
if (pattern.test(fileName)) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
for (const testDir of framework.testDirs) {
|
|
144
|
+
if (parentDirName === testDir) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Detect the main framework/library used in a project
|
|
153
|
+
* Returns null if no framework is detected
|
|
154
|
+
*/
|
|
155
|
+
function detectProjectFramework(projectPath) {
|
|
156
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
157
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
158
|
+
// Check for non-JS projects
|
|
159
|
+
if (fs.existsSync(path.join(projectPath, 'Cargo.toml')))
|
|
160
|
+
return 'rust';
|
|
161
|
+
if (fs.existsSync(path.join(projectPath, 'go.mod')))
|
|
162
|
+
return 'go';
|
|
163
|
+
if (fs.existsSync(path.join(projectPath, 'requirements.txt')) ||
|
|
164
|
+
fs.existsSync(path.join(projectPath, 'setup.py')) ||
|
|
165
|
+
fs.existsSync(path.join(projectPath, 'pyproject.toml'))) {
|
|
166
|
+
return 'python';
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
172
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
173
|
+
// Meta-frameworks (check these first as they often include the base frameworks)
|
|
174
|
+
if (deps['next'] || deps['next.js'])
|
|
175
|
+
return 'next.js';
|
|
176
|
+
if (deps['@nuxt/kit'] || deps['nuxt'] || deps['nuxt3'])
|
|
177
|
+
return 'nuxt.js';
|
|
178
|
+
if (deps['gatsby'])
|
|
179
|
+
return 'gatsby';
|
|
180
|
+
if (deps['@remix-run/react'] || deps['remix'])
|
|
181
|
+
return 'remix';
|
|
182
|
+
if (deps['@astro'] || deps['astro'])
|
|
183
|
+
return 'astro';
|
|
184
|
+
if (deps['@angular/core'])
|
|
185
|
+
return 'angular';
|
|
186
|
+
if (deps['expo'] || deps['expo-cli'])
|
|
187
|
+
return 'expo';
|
|
188
|
+
// React Native (check before React)
|
|
189
|
+
if (deps['react-native'])
|
|
190
|
+
return 'react-native';
|
|
191
|
+
// Frontend frameworks
|
|
192
|
+
if (deps['react'] || deps['react-dom'])
|
|
193
|
+
return 'react';
|
|
194
|
+
if (deps['vue']) {
|
|
195
|
+
// Check Vue version
|
|
196
|
+
const vueVersion = deps['vue']?.match(/\d+/)?.[0];
|
|
197
|
+
return vueVersion === '3' ? 'vue 3' : 'vue';
|
|
198
|
+
}
|
|
199
|
+
if (deps['svelte'])
|
|
200
|
+
return 'svelte';
|
|
201
|
+
if (deps['solid-js'])
|
|
202
|
+
return 'solid';
|
|
203
|
+
if (deps['preact'])
|
|
204
|
+
return 'preact';
|
|
205
|
+
if (deps['alpine'] || deps['alpinejs'])
|
|
206
|
+
return 'alpine.js';
|
|
207
|
+
if (deps['lit'] || deps['lit-element'])
|
|
208
|
+
return 'lit';
|
|
209
|
+
if (deps['hyperapp'])
|
|
210
|
+
return 'hyperapp';
|
|
211
|
+
if (deps['mithril'])
|
|
212
|
+
return 'mithril';
|
|
213
|
+
if (deps['inferno'])
|
|
214
|
+
return 'inferno';
|
|
215
|
+
if (deps['marko'])
|
|
216
|
+
return 'marko';
|
|
217
|
+
// Backend frameworks
|
|
218
|
+
if (deps['express'])
|
|
219
|
+
return 'express';
|
|
220
|
+
if (deps['@nestjs/core'])
|
|
221
|
+
return 'nest.js';
|
|
222
|
+
if (deps['fastify'])
|
|
223
|
+
return 'fastify';
|
|
224
|
+
if (deps['koa'])
|
|
225
|
+
return 'koa';
|
|
226
|
+
if (deps['hapi'] || deps['@hapi/hapi'])
|
|
227
|
+
return 'hapi';
|
|
228
|
+
if (deps['@apollo/server'] || deps['apollo-server'])
|
|
229
|
+
return 'apollo';
|
|
230
|
+
if (deps['graphql'] && (deps['@graphql-yoga/node'] || deps['graphql-yoga']))
|
|
231
|
+
return 'graphql-yoga';
|
|
232
|
+
if (deps['@trpc/server'])
|
|
233
|
+
return 'trpc';
|
|
234
|
+
if (deps['@redwoodjs/core'])
|
|
235
|
+
return 'redwood.js';
|
|
236
|
+
if (deps['@blitzjs/core'])
|
|
237
|
+
return 'blitz.js';
|
|
238
|
+
// Electron
|
|
239
|
+
if (deps['electron'])
|
|
240
|
+
return 'electron';
|
|
241
|
+
// Static site generators
|
|
242
|
+
if (deps['@11ty/eleventy'])
|
|
243
|
+
return '11ty';
|
|
244
|
+
if (deps['hexo'])
|
|
245
|
+
return 'hexo';
|
|
246
|
+
if (deps['jekyll'])
|
|
247
|
+
return 'jekyll';
|
|
248
|
+
if (deps['hugo'])
|
|
249
|
+
return 'hugo';
|
|
250
|
+
// Mobile development
|
|
251
|
+
if (deps['@ionic/core'] || deps['@ionic/angular'] || deps['@ionic/react'])
|
|
252
|
+
return 'ionic';
|
|
253
|
+
if (deps['@nativescript/core'])
|
|
254
|
+
return 'nativescript';
|
|
255
|
+
if (deps['@capacitor/core'])
|
|
256
|
+
return 'capacitor';
|
|
257
|
+
if (deps['cordova'])
|
|
258
|
+
return 'cordova';
|
|
259
|
+
// Desktop development
|
|
260
|
+
if (deps['tauri'])
|
|
261
|
+
return 'tauri';
|
|
262
|
+
if (deps['nw.js'] || deps['nw'])
|
|
263
|
+
return 'nw.js';
|
|
264
|
+
// Build tools / bundlers (as last resort)
|
|
265
|
+
if (deps['vite'])
|
|
266
|
+
return 'vite';
|
|
267
|
+
if (deps['webpack'])
|
|
268
|
+
return 'webpack';
|
|
269
|
+
if (deps['parcel'])
|
|
270
|
+
return 'parcel';
|
|
271
|
+
if (deps['rollup'])
|
|
272
|
+
return 'rollup';
|
|
273
|
+
if (deps['esbuild'])
|
|
274
|
+
return 'esbuild';
|
|
275
|
+
if (deps['turbopack'])
|
|
276
|
+
return 'turbopack';
|
|
277
|
+
// Generic Node.js if no specific framework found but package.json exists
|
|
278
|
+
return 'node.js';
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
// Invalid JSON or read error
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './database';
|
|
2
|
+
export * from './detector';
|
|
3
|
+
export * from './scanner';
|
|
4
|
+
export * from './settings';
|
|
5
|
+
export { getDatabaseManager } from './database';
|
|
6
|
+
import { Project, Test } from './database';
|
|
7
|
+
export declare function getAllProjects(): Project[];
|
|
8
|
+
export declare function addProject(name: string, projectPath: string): Project;
|
|
9
|
+
export declare function removeProject(id: number): void;
|
|
10
|
+
export declare function getTestsByProject(projectId: number): Test[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.getDatabaseManager = void 0;
|
|
18
|
+
exports.getAllProjects = getAllProjects;
|
|
19
|
+
exports.addProject = addProject;
|
|
20
|
+
exports.removeProject = removeProject;
|
|
21
|
+
exports.getTestsByProject = getTestsByProject;
|
|
22
|
+
__exportStar(require("./database"), exports);
|
|
23
|
+
__exportStar(require("./detector"), exports);
|
|
24
|
+
__exportStar(require("./scanner"), exports);
|
|
25
|
+
__exportStar(require("./settings"), exports);
|
|
26
|
+
var database_1 = require("./database");
|
|
27
|
+
Object.defineProperty(exports, "getDatabaseManager", { enumerable: true, get: function () { return database_1.getDatabaseManager; } });
|
|
28
|
+
// Convenience functions for common operations
|
|
29
|
+
const database_2 = require("./database");
|
|
30
|
+
function getAllProjects() {
|
|
31
|
+
return (0, database_2.getDatabaseManager)().getAllProjects();
|
|
32
|
+
}
|
|
33
|
+
function addProject(name, projectPath) {
|
|
34
|
+
return (0, database_2.getDatabaseManager)().addProject(name, projectPath);
|
|
35
|
+
}
|
|
36
|
+
function removeProject(id) {
|
|
37
|
+
(0, database_2.getDatabaseManager)().removeProject(id);
|
|
38
|
+
}
|
|
39
|
+
function getTestsByProject(projectId) {
|
|
40
|
+
return (0, database_2.getDatabaseManager)().getTestsByProject(projectId);
|
|
41
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Project, Test } from './database';
|
|
2
|
+
export interface ScanResult {
|
|
3
|
+
project: Project;
|
|
4
|
+
testsFound: number;
|
|
5
|
+
tests: Test[];
|
|
6
|
+
}
|
|
7
|
+
export declare function scanProject(projectId: number): ScanResult;
|
|
8
|
+
export declare function scanAllProjects(): ScanResult[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scanProject = scanProject;
|
|
4
|
+
exports.scanAllProjects = scanAllProjects;
|
|
5
|
+
const database_1 = require("./database");
|
|
6
|
+
function scanProject(projectId) {
|
|
7
|
+
return (0, database_1.getDatabaseManager)().scanProject(projectId);
|
|
8
|
+
}
|
|
9
|
+
function scanAllProjects() {
|
|
10
|
+
return (0, database_1.getDatabaseManager)().scanAllProjects();
|
|
11
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type EditorType = 'vscode' | 'cursor' | 'windsurf' | 'zed' | 'custom';
|
|
2
|
+
export type BrowserType = 'chrome' | 'firefox' | 'safari' | 'edge' | 'custom';
|
|
3
|
+
export interface EditorSettings {
|
|
4
|
+
type: EditorType;
|
|
5
|
+
customPath?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface BrowserSettings {
|
|
8
|
+
type: BrowserType;
|
|
9
|
+
customPath?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AppSettings {
|
|
12
|
+
editor: EditorSettings;
|
|
13
|
+
browser: BrowserSettings;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get a setting value by key
|
|
17
|
+
*/
|
|
18
|
+
export declare function getSetting(key: string): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Set a setting value by key
|
|
21
|
+
*/
|
|
22
|
+
export declare function setSetting(key: string, value: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Get all settings as a key-value object
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAllSettings(): Record<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Get editor settings
|
|
29
|
+
*/
|
|
30
|
+
export declare function getEditorSettings(): EditorSettings;
|
|
31
|
+
/**
|
|
32
|
+
* Set editor settings
|
|
33
|
+
*/
|
|
34
|
+
export declare function setEditorSettings(settings: EditorSettings): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get browser settings
|
|
37
|
+
*/
|
|
38
|
+
export declare function getBrowserSettings(): BrowserSettings;
|
|
39
|
+
/**
|
|
40
|
+
* Set browser settings
|
|
41
|
+
*/
|
|
42
|
+
export declare function setBrowserSettings(settings: BrowserSettings): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get all app settings
|
|
45
|
+
*/
|
|
46
|
+
export declare function getAppSettings(): AppSettings;
|
|
47
|
+
/**
|
|
48
|
+
* Set all app settings
|
|
49
|
+
*/
|
|
50
|
+
export declare function setAppSettings(settings: AppSettings): void;
|