projax 3.3.58 → 3.3.63

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.
Files changed (84) hide show
  1. package/README.md +10 -1
  2. package/dist/electron/preload.d.ts +1 -0
  3. package/dist/electron/renderer/assets/index-CmtZriN5.js +66 -0
  4. package/dist/electron/renderer/index.html +1 -1
  5. package/dist/electron/script-runner.js +52 -20
  6. package/dist/index.js +14 -10
  7. package/dist/prxi.js +877 -109
  8. package/dist/prxi.tsx +1249 -177
  9. package/dist/script-runner.js +52 -20
  10. package/package.json +1 -1
  11. package/coverage/base.css +0 -224
  12. package/coverage/block-navigation.js +0 -87
  13. package/coverage/core-bridge.ts.html +0 -292
  14. package/coverage/favicon.png +0 -0
  15. package/coverage/index.html +0 -191
  16. package/coverage/lcov-report/base.css +0 -224
  17. package/coverage/lcov-report/block-navigation.js +0 -87
  18. package/coverage/lcov-report/core-bridge.ts.html +0 -292
  19. package/coverage/lcov-report/favicon.png +0 -0
  20. package/coverage/lcov-report/index.html +0 -191
  21. package/coverage/lcov-report/port-extractor.ts.html +0 -1174
  22. package/coverage/lcov-report/port-scanner.ts.html +0 -301
  23. package/coverage/lcov-report/port-utils.ts.html +0 -670
  24. package/coverage/lcov-report/prettify.css +0 -1
  25. package/coverage/lcov-report/prettify.js +0 -2
  26. package/coverage/lcov-report/script-runner.ts.html +0 -3346
  27. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  28. package/coverage/lcov-report/sorter.js +0 -210
  29. package/coverage/lcov-report/test-parser.ts.html +0 -799
  30. package/coverage/lcov.info +0 -1338
  31. package/coverage/port-extractor.ts.html +0 -1174
  32. package/coverage/port-scanner.ts.html +0 -301
  33. package/coverage/port-utils.ts.html +0 -670
  34. package/coverage/prettify.css +0 -1
  35. package/coverage/prettify.js +0 -2
  36. package/coverage/script-runner.ts.html +0 -3346
  37. package/coverage/sort-arrow-sprite.png +0 -0
  38. package/coverage/sorter.js +0 -210
  39. package/coverage/test-parser.ts.html +0 -799
  40. package/dist/__tests__/core-bridge.test.d.ts +0 -1
  41. package/dist/__tests__/core-bridge.test.js +0 -135
  42. package/dist/__tests__/port-extractor.test.d.ts +0 -1
  43. package/dist/__tests__/port-extractor.test.js +0 -407
  44. package/dist/__tests__/port-scanner.test.d.ts +0 -1
  45. package/dist/__tests__/port-scanner.test.js +0 -170
  46. package/dist/__tests__/port-utils.test.d.ts +0 -1
  47. package/dist/__tests__/port-utils.test.js +0 -127
  48. package/dist/__tests__/script-runner.test.d.ts +0 -1
  49. package/dist/__tests__/script-runner.test.js +0 -491
  50. package/dist/__tests__/test-parser.test.d.ts +0 -1
  51. package/dist/__tests__/test-parser.test.js +0 -276
  52. package/dist/api/__tests__/database.test.d.ts +0 -2
  53. package/dist/api/__tests__/database.test.d.ts.map +0 -1
  54. package/dist/api/__tests__/database.test.js +0 -485
  55. package/dist/api/__tests__/database.test.js.map +0 -1
  56. package/dist/api/__tests__/routes.test.d.ts +0 -2
  57. package/dist/api/__tests__/routes.test.d.ts.map +0 -1
  58. package/dist/api/__tests__/routes.test.js +0 -484
  59. package/dist/api/__tests__/routes.test.js.map +0 -1
  60. package/dist/api/__tests__/scanner.test.d.ts +0 -2
  61. package/dist/api/__tests__/scanner.test.d.ts.map +0 -1
  62. package/dist/api/__tests__/scanner.test.js +0 -403
  63. package/dist/api/__tests__/scanner.test.js.map +0 -1
  64. package/dist/core/__tests__/database.test.d.ts +0 -1
  65. package/dist/core/__tests__/database.test.js +0 -557
  66. package/dist/core/__tests__/detector.test.d.ts +0 -1
  67. package/dist/core/__tests__/detector.test.js +0 -375
  68. package/dist/core/__tests__/index.test.d.ts +0 -1
  69. package/dist/core/__tests__/index.test.js +0 -469
  70. package/dist/core/__tests__/scanner.test.d.ts +0 -1
  71. package/dist/core/__tests__/scanner.test.js +0 -406
  72. package/dist/core/__tests__/settings.test.d.ts +0 -1
  73. package/dist/core/__tests__/settings.test.js +0 -280
  74. package/dist/electron/core/__tests__/database.test.d.ts +0 -1
  75. package/dist/electron/core/__tests__/database.test.js +0 -557
  76. package/dist/electron/core/__tests__/detector.test.d.ts +0 -1
  77. package/dist/electron/core/__tests__/detector.test.js +0 -375
  78. package/dist/electron/core/__tests__/index.test.d.ts +0 -1
  79. package/dist/electron/core/__tests__/index.test.js +0 -469
  80. package/dist/electron/core/__tests__/scanner.test.d.ts +0 -1
  81. package/dist/electron/core/__tests__/scanner.test.js +0 -406
  82. package/dist/electron/core/__tests__/settings.test.d.ts +0 -1
  83. package/dist/electron/core/__tests__/settings.test.js +0 -280
  84. package/jest.config.js +0 -26
@@ -1,469 +0,0 @@
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
- /* eslint-disable @typescript-eslint/no-var-requires */
37
- const fs = __importStar(require("fs"));
38
- const child_process_1 = require("child_process");
39
- const index_1 = require("../index");
40
- // Mock modules
41
- jest.mock('fs');
42
- jest.mock('child_process');
43
- const mockedFs = fs;
44
- const mockedExecSync = child_process_1.execSync;
45
- describe('index - convenience functions', () => {
46
- beforeEach(() => {
47
- jest.clearAllMocks();
48
- mockedFs.existsSync.mockReturnValue(false);
49
- // Reset the singleton
50
- require('../database').dbManager = null;
51
- });
52
- describe('getAllProjects', () => {
53
- it('should return all projects', () => {
54
- const mockProjects = [
55
- {
56
- id: 1,
57
- name: 'Project 1',
58
- path: '/path/1',
59
- description: 'First project',
60
- framework: 'react',
61
- last_scanned: Date.now(),
62
- created_at: Date.now() - 10000,
63
- tags: ['frontend', 'react'],
64
- },
65
- {
66
- id: 2,
67
- name: 'Project 2',
68
- path: '/path/2',
69
- description: 'Second project',
70
- framework: 'express',
71
- last_scanned: Date.now(),
72
- created_at: Date.now() - 20000,
73
- tags: ['backend', 'api'],
74
- },
75
- ];
76
- mockedExecSync.mockReturnValue(JSON.stringify(mockProjects));
77
- const result = (0, index_1.getAllProjects)();
78
- expect(result).toEqual(mockProjects);
79
- expect(result.length).toBe(2);
80
- expect(result[0].name).toBe('Project 1');
81
- expect(result[1].name).toBe('Project 2');
82
- });
83
- it('should return empty array when no projects exist', () => {
84
- mockedExecSync.mockReturnValue(JSON.stringify([]));
85
- const result = (0, index_1.getAllProjects)();
86
- expect(result).toEqual([]);
87
- expect(Array.isArray(result)).toBe(true);
88
- });
89
- it('should handle projects with different properties', () => {
90
- const mockProjects = [
91
- {
92
- id: 1,
93
- name: 'Basic Project',
94
- path: '/basic',
95
- description: null,
96
- framework: null,
97
- last_scanned: null,
98
- created_at: Date.now(),
99
- },
100
- {
101
- id: 2,
102
- name: 'Full Project',
103
- path: '/full',
104
- description: 'Complete details',
105
- framework: 'next.js',
106
- last_scanned: Date.now(),
107
- created_at: Date.now(),
108
- tags: ['fullstack', 'nextjs'],
109
- },
110
- ];
111
- mockedExecSync.mockReturnValue(JSON.stringify(mockProjects));
112
- const result = (0, index_1.getAllProjects)();
113
- expect(result[0].description).toBeNull();
114
- expect(result[0].framework).toBeNull();
115
- expect(result[1].description).toBe('Complete details');
116
- expect(result[1].framework).toBe('next.js');
117
- });
118
- });
119
- describe('addProject', () => {
120
- it('should add a new project', () => {
121
- const mockProject = {
122
- id: 1,
123
- name: 'New Project',
124
- path: '/new/path',
125
- description: null,
126
- framework: null,
127
- last_scanned: null,
128
- created_at: Date.now(),
129
- };
130
- mockedExecSync.mockReturnValue(JSON.stringify(mockProject));
131
- const result = (0, index_1.addProject)('New Project', '/new/path');
132
- expect(result).toEqual(mockProject);
133
- expect(result.name).toBe('New Project');
134
- expect(result.path).toBe('/new/path');
135
- });
136
- it('should add project with special characters in name', () => {
137
- const mockProject = {
138
- id: 1,
139
- name: 'My Project (v2.0) [Test]',
140
- path: '/special/path',
141
- description: null,
142
- framework: null,
143
- last_scanned: null,
144
- created_at: Date.now(),
145
- };
146
- mockedExecSync.mockReturnValue(JSON.stringify(mockProject));
147
- const result = (0, index_1.addProject)('My Project (v2.0) [Test]', '/special/path');
148
- expect(result.name).toBe('My Project (v2.0) [Test]');
149
- });
150
- it('should add project with absolute path', () => {
151
- const mockProject = {
152
- id: 1,
153
- name: 'Test Project',
154
- path: '/Users/username/projects/test',
155
- description: null,
156
- framework: null,
157
- last_scanned: null,
158
- created_at: Date.now(),
159
- };
160
- mockedExecSync.mockReturnValue(JSON.stringify(mockProject));
161
- const result = (0, index_1.addProject)('Test Project', '/Users/username/projects/test');
162
- expect(result.path).toBe('/Users/username/projects/test');
163
- });
164
- it('should handle API errors when adding project', () => {
165
- mockedExecSync.mockImplementation(() => {
166
- throw new Error('API request failed: Project already exists');
167
- });
168
- expect(() => (0, index_1.addProject)('Duplicate', '/path')).toThrow('API request failed');
169
- });
170
- it('should return project with correct created_at timestamp', () => {
171
- const now = Date.now();
172
- const mockProject = {
173
- id: 1,
174
- name: 'Test',
175
- path: '/test',
176
- description: null,
177
- framework: null,
178
- last_scanned: null,
179
- created_at: now,
180
- };
181
- mockedExecSync.mockReturnValue(JSON.stringify(mockProject));
182
- const result = (0, index_1.addProject)('Test', '/test');
183
- expect(result.created_at).toBe(now);
184
- });
185
- });
186
- describe('removeProject', () => {
187
- it('should remove a project by id', () => {
188
- mockedExecSync.mockReturnValue('');
189
- expect(() => (0, index_1.removeProject)(1)).not.toThrow();
190
- expect(mockedExecSync).toHaveBeenCalledWith(expect.stringContaining('DELETE'), expect.any(Object));
191
- });
192
- it('should handle removing multiple projects', () => {
193
- mockedExecSync.mockReturnValue('');
194
- expect(() => {
195
- (0, index_1.removeProject)(1);
196
- (0, index_1.removeProject)(2);
197
- (0, index_1.removeProject)(3);
198
- }).not.toThrow();
199
- expect(mockedExecSync).toHaveBeenCalledTimes(3);
200
- });
201
- it('should handle errors when removing non-existent project', () => {
202
- mockedExecSync.mockImplementation(() => {
203
- const error = new Error('Command failed: curl');
204
- error.message = 'Command failed: curl ... 404';
205
- throw error;
206
- });
207
- expect(() => (0, index_1.removeProject)(999)).toThrow();
208
- });
209
- it('should not return a value', () => {
210
- mockedExecSync.mockReturnValue('');
211
- const result = (0, index_1.removeProject)(1);
212
- expect(result).toBeUndefined();
213
- });
214
- });
215
- describe('getTestsByProject', () => {
216
- it('should get all tests for a project', () => {
217
- const mockTests = [
218
- {
219
- id: 1,
220
- project_id: 1,
221
- file_path: '/test/file1.test.ts',
222
- framework: 'jest',
223
- status: 'passed',
224
- last_run: Date.now(),
225
- created_at: Date.now() - 10000,
226
- },
227
- {
228
- id: 2,
229
- project_id: 1,
230
- file_path: '/test/file2.spec.ts',
231
- framework: 'jest',
232
- status: 'failed',
233
- last_run: Date.now(),
234
- created_at: Date.now() - 10000,
235
- },
236
- ];
237
- mockedExecSync.mockReturnValue(JSON.stringify(mockTests));
238
- const result = (0, index_1.getTestsByProject)(1);
239
- expect(result).toEqual(mockTests);
240
- expect(result.length).toBe(2);
241
- });
242
- it('should return empty array for project with no tests', () => {
243
- mockedExecSync.mockReturnValue(JSON.stringify([]));
244
- const result = (0, index_1.getTestsByProject)(1);
245
- expect(result).toEqual([]);
246
- expect(Array.isArray(result)).toBe(true);
247
- });
248
- it('should handle tests with different frameworks', () => {
249
- const mockTests = [
250
- {
251
- id: 1,
252
- project_id: 1,
253
- file_path: '/test/jest.test.ts',
254
- framework: 'jest',
255
- status: null,
256
- last_run: null,
257
- created_at: Date.now(),
258
- },
259
- {
260
- id: 2,
261
- project_id: 1,
262
- file_path: '/test/vitest.spec.ts',
263
- framework: 'vitest',
264
- status: null,
265
- last_run: null,
266
- created_at: Date.now(),
267
- },
268
- ];
269
- mockedExecSync.mockReturnValue(JSON.stringify(mockTests));
270
- const result = (0, index_1.getTestsByProject)(1);
271
- expect(result[0].framework).toBe('jest');
272
- expect(result[1].framework).toBe('vitest');
273
- });
274
- it('should handle tests without status or last_run', () => {
275
- const mockTests = [
276
- {
277
- id: 1,
278
- project_id: 1,
279
- file_path: '/test/new.test.ts',
280
- framework: 'jest',
281
- status: null,
282
- last_run: null,
283
- created_at: Date.now(),
284
- },
285
- ];
286
- mockedExecSync.mockReturnValue(JSON.stringify(mockTests));
287
- const result = (0, index_1.getTestsByProject)(1);
288
- expect(result[0].status).toBeNull();
289
- expect(result[0].last_run).toBeNull();
290
- });
291
- it('should handle API errors', () => {
292
- mockedExecSync.mockImplementation(() => {
293
- throw new Error('API request failed');
294
- });
295
- expect(() => (0, index_1.getTestsByProject)(1)).toThrow('API request failed');
296
- });
297
- it('should filter tests by project_id', () => {
298
- const mockTests = [
299
- {
300
- id: 1,
301
- project_id: 5,
302
- file_path: '/test/file.test.ts',
303
- framework: 'jest',
304
- status: null,
305
- last_run: null,
306
- created_at: Date.now(),
307
- },
308
- ];
309
- mockedExecSync.mockReturnValue(JSON.stringify(mockTests));
310
- const result = (0, index_1.getTestsByProject)(5);
311
- expect(result[0].project_id).toBe(5);
312
- });
313
- });
314
- describe('getDatabaseManager', () => {
315
- it('should return database manager instance', () => {
316
- const db = (0, index_1.getDatabaseManager)();
317
- expect(db).toBeDefined();
318
- expect(typeof db.getAllProjects).toBe('function');
319
- expect(typeof db.addProject).toBe('function');
320
- expect(typeof db.removeProject).toBe('function');
321
- });
322
- it('should return singleton instance', () => {
323
- const db1 = (0, index_1.getDatabaseManager)();
324
- const db2 = (0, index_1.getDatabaseManager)();
325
- expect(db1).toBe(db2);
326
- });
327
- it('should have all expected methods', () => {
328
- const db = (0, index_1.getDatabaseManager)();
329
- // Project methods
330
- expect(db).toHaveProperty('addProject');
331
- expect(db).toHaveProperty('getProject');
332
- expect(db).toHaveProperty('getAllProjects');
333
- expect(db).toHaveProperty('updateProject');
334
- expect(db).toHaveProperty('removeProject');
335
- expect(db).toHaveProperty('scanProject');
336
- expect(db).toHaveProperty('scanAllProjects');
337
- // Test methods
338
- expect(db).toHaveProperty('getTestsByProject');
339
- // Settings methods
340
- expect(db).toHaveProperty('getSetting');
341
- expect(db).toHaveProperty('setSetting');
342
- expect(db).toHaveProperty('getAllSettings');
343
- // Test result methods
344
- expect(db).toHaveProperty('addTestResult');
345
- expect(db).toHaveProperty('getLatestTestResult');
346
- expect(db).toHaveProperty('getTestResultsByProject');
347
- // Port methods
348
- expect(db).toHaveProperty('getProjectPorts');
349
- expect(db).toHaveProperty('getProjectPortsByScript');
350
- // Utility methods
351
- expect(db).toHaveProperty('close');
352
- });
353
- });
354
- describe('module exports', () => {
355
- it('should export all necessary functions', () => {
356
- const index = require('../index');
357
- expect(index.getAllProjects).toBeDefined();
358
- expect(index.addProject).toBeDefined();
359
- expect(index.removeProject).toBeDefined();
360
- expect(index.getTestsByProject).toBeDefined();
361
- expect(index.getDatabaseManager).toBeDefined();
362
- });
363
- it('should re-export types from other modules', () => {
364
- const index = require('../index');
365
- // These should be available via re-exports
366
- expect(index.detectTestFramework).toBeDefined();
367
- expect(index.detectProjectFramework).toBeDefined();
368
- expect(index.isTestFile).toBeDefined();
369
- expect(index.scanProject).toBeDefined();
370
- expect(index.scanAllProjects).toBeDefined();
371
- expect(index.getSetting).toBeDefined();
372
- expect(index.setSetting).toBeDefined();
373
- expect(index.getAllSettings).toBeDefined();
374
- });
375
- });
376
- describe('integration scenarios', () => {
377
- it('should support adding and then getting a project', () => {
378
- const mockProject = {
379
- id: 1,
380
- name: 'Integration Test',
381
- path: '/integration',
382
- description: null,
383
- framework: null,
384
- last_scanned: null,
385
- created_at: Date.now(),
386
- };
387
- // First call: addProject
388
- mockedExecSync.mockReturnValueOnce(JSON.stringify(mockProject));
389
- // Second call: getAllProjects
390
- mockedExecSync.mockReturnValueOnce(JSON.stringify([mockProject]));
391
- const addedProject = (0, index_1.addProject)('Integration Test', '/integration');
392
- const allProjects = (0, index_1.getAllProjects)();
393
- expect(addedProject.id).toBe(1);
394
- expect(allProjects.length).toBe(1);
395
- expect(allProjects[0].id).toBe(addedProject.id);
396
- });
397
- it('should support adding project and getting its tests', () => {
398
- const mockProject = {
399
- id: 1,
400
- name: 'Test Project',
401
- path: '/test',
402
- description: null,
403
- framework: 'jest',
404
- last_scanned: null,
405
- created_at: Date.now(),
406
- };
407
- const mockTests = [
408
- {
409
- id: 1,
410
- project_id: 1,
411
- file_path: '/test/file.test.ts',
412
- framework: 'jest',
413
- status: null,
414
- last_run: null,
415
- created_at: Date.now(),
416
- },
417
- ];
418
- // First call: addProject
419
- mockedExecSync.mockReturnValueOnce(JSON.stringify(mockProject));
420
- // Second call: getTestsByProject
421
- mockedExecSync.mockReturnValueOnce(JSON.stringify(mockTests));
422
- const project = (0, index_1.addProject)('Test Project', '/test');
423
- const tests = (0, index_1.getTestsByProject)(project.id);
424
- expect(tests.length).toBe(1);
425
- expect(tests[0].project_id).toBe(project.id);
426
- });
427
- it('should handle multiple operations in sequence', () => {
428
- // Add project
429
- mockedExecSync.mockReturnValueOnce(JSON.stringify({
430
- id: 1,
431
- name: 'Project 1',
432
- path: '/p1',
433
- description: null,
434
- framework: null,
435
- last_scanned: null,
436
- created_at: Date.now(),
437
- }));
438
- // Add another project
439
- mockedExecSync.mockReturnValueOnce(JSON.stringify({
440
- id: 2,
441
- name: 'Project 2',
442
- path: '/p2',
443
- description: null,
444
- framework: null,
445
- last_scanned: null,
446
- created_at: Date.now(),
447
- }));
448
- // Get all projects
449
- mockedExecSync.mockReturnValueOnce(JSON.stringify([
450
- { id: 1, name: 'Project 1', path: '/p1', description: null, framework: null, last_scanned: null, created_at: Date.now() },
451
- { id: 2, name: 'Project 2', path: '/p2', description: null, framework: null, last_scanned: null, created_at: Date.now() },
452
- ]));
453
- // Remove first project
454
- mockedExecSync.mockReturnValueOnce('');
455
- // Get all projects again
456
- mockedExecSync.mockReturnValueOnce(JSON.stringify([
457
- { id: 2, name: 'Project 2', path: '/p2', description: null, framework: null, last_scanned: null, created_at: Date.now() },
458
- ]));
459
- const p1 = (0, index_1.addProject)('Project 1', '/p1');
460
- const p2 = (0, index_1.addProject)('Project 2', '/p2');
461
- let projects = (0, index_1.getAllProjects)();
462
- expect(projects.length).toBe(2);
463
- (0, index_1.removeProject)(p1.id);
464
- projects = (0, index_1.getAllProjects)();
465
- expect(projects.length).toBe(1);
466
- expect(projects[0].id).toBe(p2.id);
467
- });
468
- });
469
- });
@@ -1 +0,0 @@
1
- export {};