@vizzly-testing/cli 0.3.1 → 0.4.0
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/README.md +26 -28
- package/dist/cli.js +18 -30
- package/dist/client/index.js +1 -1
- package/dist/commands/run.js +34 -9
- package/dist/commands/tdd.js +6 -1
- package/dist/commands/upload.js +52 -3
- package/dist/server/handlers/api-handler.js +83 -0
- package/dist/server/handlers/tdd-handler.js +138 -0
- package/dist/server/http-server.js +132 -0
- package/dist/services/api-service.js +40 -11
- package/dist/services/server-manager.js +45 -29
- package/dist/services/test-runner.js +64 -69
- package/dist/services/uploader.js +47 -82
- package/dist/types/commands/run.d.ts +4 -1
- package/dist/types/commands/tdd.d.ts +4 -1
- package/dist/types/sdk/index.d.ts +6 -6
- package/dist/types/server/handlers/api-handler.d.ts +49 -0
- package/dist/types/server/handlers/tdd-handler.d.ts +85 -0
- package/dist/types/server/http-server.d.ts +5 -0
- package/dist/types/services/api-service.d.ts +4 -2
- package/dist/types/services/server-manager.d.ts +148 -3
- package/dist/types/services/test-runner.d.ts +1 -0
- package/dist/types/utils/config-helpers.d.ts +1 -1
- package/dist/types/utils/console-ui.d.ts +1 -1
- package/dist/utils/console-ui.js +4 -14
- package/docs/api-reference.md +2 -5
- package/docs/getting-started.md +1 -1
- package/docs/tdd-mode.md +9 -9
- package/docs/test-integration.md +3 -17
- package/docs/upload-command.md +7 -0
- package/package.json +1 -1
- package/dist/screenshot-wrapper.js +0 -68
- package/dist/server/index.js +0 -522
- package/dist/services/service-utils.js +0 -171
- package/dist/types/index.js +0 -153
- package/dist/types/screenshot-wrapper.d.ts +0 -27
- package/dist/types/server/index.d.ts +0 -38
- package/dist/types/services/service-utils.d.ts +0 -45
- package/dist/types/types/index.d.ts +0 -373
- package/dist/types/utils/diagnostics.d.ts +0 -69
- package/dist/types/utils/error-messages.d.ts +0 -42
- package/dist/types/utils/framework-detector.d.ts +0 -5
- package/dist/types/utils/help.d.ts +0 -11
- package/dist/types/utils/image-comparison.d.ts +0 -42
- package/dist/types/utils/package.d.ts +0 -1
- package/dist/types/utils/project-detection.d.ts +0 -19
- package/dist/types/utils/ui-helpers.d.ts +0 -23
- package/dist/utils/diagnostics.js +0 -184
- package/dist/utils/error-messages.js +0 -34
- package/dist/utils/framework-detector.js +0 -40
- package/dist/utils/help.js +0 -66
- package/dist/utils/image-comparison.js +0 -172
- package/dist/utils/package.js +0 -9
- package/dist/utils/project-detection.js +0 -145
- package/dist/utils/ui-helpers.js +0 -86
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project Detection Utilities
|
|
3
|
-
* Automatically detect project type and framework
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { readFile, access } from 'fs/promises';
|
|
7
|
-
import { join } from 'path';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Detect project type and framework
|
|
11
|
-
* @param {string} directory - Directory to analyze
|
|
12
|
-
* @returns {Promise<Object>} Project information
|
|
13
|
-
*/
|
|
14
|
-
export async function detectProjectType(directory = process.cwd()) {
|
|
15
|
-
const packageJsonPath = join(directory, 'package.json');
|
|
16
|
-
let packageJsonData = null;
|
|
17
|
-
try {
|
|
18
|
-
const content = await readFile(packageJsonPath, 'utf8');
|
|
19
|
-
packageJsonData = JSON.parse(content);
|
|
20
|
-
} catch {
|
|
21
|
-
// No package.json found
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Detect framework based on dependencies and files
|
|
25
|
-
const framework = await detectFramework(directory, packageJsonData);
|
|
26
|
-
const type = detectProjectTypeFromFramework(framework);
|
|
27
|
-
return {
|
|
28
|
-
type,
|
|
29
|
-
framework,
|
|
30
|
-
hasPackageJson: !!packageJsonData,
|
|
31
|
-
projectName: packageJsonData?.name || 'unknown',
|
|
32
|
-
dependencies: packageJsonData?.dependencies || {},
|
|
33
|
-
devDependencies: packageJsonData?.devDependencies || {}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Detect testing framework
|
|
39
|
-
* @param {string} directory - Directory to analyze
|
|
40
|
-
* @param {Object} packageJson - Package.json content
|
|
41
|
-
* @returns {Promise<string>} Framework name
|
|
42
|
-
*/
|
|
43
|
-
async function detectFramework(directory, packageJson) {
|
|
44
|
-
const dependencies = {
|
|
45
|
-
...packageJson?.dependencies,
|
|
46
|
-
...packageJson?.devDependencies
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// Check for specific framework dependencies
|
|
50
|
-
if (dependencies.cypress) {
|
|
51
|
-
return 'cypress';
|
|
52
|
-
}
|
|
53
|
-
if (dependencies.playwright || dependencies['@playwright/test']) {
|
|
54
|
-
return 'playwright';
|
|
55
|
-
}
|
|
56
|
-
if (dependencies.webdriverio || dependencies['@wdio/cli']) {
|
|
57
|
-
return 'webdriver';
|
|
58
|
-
}
|
|
59
|
-
if (dependencies.jest || dependencies['@jest/core']) {
|
|
60
|
-
return 'jest';
|
|
61
|
-
}
|
|
62
|
-
if (dependencies.vitest) {
|
|
63
|
-
return 'vitest';
|
|
64
|
-
}
|
|
65
|
-
if (dependencies.mocha) {
|
|
66
|
-
return 'mocha';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Check for config files
|
|
70
|
-
const configFiles = ['cypress.config.js', 'playwright.config.js', 'wdio.conf.js', 'jest.config.js', 'vitest.config.js'];
|
|
71
|
-
for (const configFile of configFiles) {
|
|
72
|
-
try {
|
|
73
|
-
await access(join(directory, configFile));
|
|
74
|
-
return configFile.split('.')[0];
|
|
75
|
-
} catch {
|
|
76
|
-
// File doesn't exist
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return 'generic';
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Determine project type from framework
|
|
84
|
-
* @param {string} framework - Framework name
|
|
85
|
-
* @returns {string} Project type
|
|
86
|
-
*/
|
|
87
|
-
function detectProjectTypeFromFramework(framework) {
|
|
88
|
-
const e2eFrameworks = ['cypress', 'playwright', 'webdriver'];
|
|
89
|
-
if (e2eFrameworks.includes(framework)) {
|
|
90
|
-
return 'e2e';
|
|
91
|
-
}
|
|
92
|
-
return 'web';
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Get suggested test command for framework
|
|
97
|
-
* @param {string} framework - Framework name
|
|
98
|
-
* @param {Object} packageJson - Package.json content
|
|
99
|
-
* @returns {string} Suggested test command
|
|
100
|
-
*/
|
|
101
|
-
export function getSuggestedTestCommand(framework, packageJson) {
|
|
102
|
-
const scripts = packageJson?.scripts || {};
|
|
103
|
-
|
|
104
|
-
// Check for common script names
|
|
105
|
-
const testScripts = ['test:e2e', 'test:integration', 'e2e', 'cypress:run', 'playwright:test', 'test'];
|
|
106
|
-
for (const script of testScripts) {
|
|
107
|
-
if (scripts[script]) {
|
|
108
|
-
return `npm run ${script}`;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Framework-specific defaults
|
|
113
|
-
switch (framework) {
|
|
114
|
-
case 'cypress':
|
|
115
|
-
return 'npx cypress run';
|
|
116
|
-
case 'playwright':
|
|
117
|
-
return 'npx playwright test';
|
|
118
|
-
case 'webdriver':
|
|
119
|
-
return 'npx wdio run';
|
|
120
|
-
case 'jest':
|
|
121
|
-
return 'npx jest';
|
|
122
|
-
case 'vitest':
|
|
123
|
-
return 'npx vitest run';
|
|
124
|
-
default:
|
|
125
|
-
return 'npm test';
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Get suggested screenshots directory for framework
|
|
131
|
-
* @param {string} framework - Framework name
|
|
132
|
-
* @returns {string} Screenshots directory
|
|
133
|
-
*/
|
|
134
|
-
export function getSuggestedScreenshotsDir(framework) {
|
|
135
|
-
switch (framework) {
|
|
136
|
-
case 'cypress':
|
|
137
|
-
return './cypress/screenshots';
|
|
138
|
-
case 'playwright':
|
|
139
|
-
return './test-results';
|
|
140
|
-
case 'webdriver':
|
|
141
|
-
return './screenshots';
|
|
142
|
-
default:
|
|
143
|
-
return './screenshots';
|
|
144
|
-
}
|
|
145
|
-
}
|
package/dist/utils/ui-helpers.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Color and styling utilities for Ink components
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Check if colors should be used
|
|
7
|
-
*/
|
|
8
|
-
export function shouldUseColors(flags = {}) {
|
|
9
|
-
return !flags.noColor && !process.env.NO_COLOR && process.stdout.isTTY && process.env.TERM !== 'dumb';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Get color for text based on type and color support
|
|
14
|
-
*/
|
|
15
|
-
export function getColor(type, flags = {}) {
|
|
16
|
-
if (!shouldUseColors(flags)) {
|
|
17
|
-
return undefined; // No color
|
|
18
|
-
}
|
|
19
|
-
const colors = {
|
|
20
|
-
success: 'green',
|
|
21
|
-
error: 'red',
|
|
22
|
-
warning: 'yellow',
|
|
23
|
-
info: 'blue',
|
|
24
|
-
progress: 'cyan',
|
|
25
|
-
dim: 'gray'
|
|
26
|
-
};
|
|
27
|
-
return colors[type];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Get status icon with fallback for no-color mode
|
|
32
|
-
*/
|
|
33
|
-
export function getStatusIcon(status, flags = {}) {
|
|
34
|
-
if (shouldUseColors(flags)) {
|
|
35
|
-
// Colored emoji icons
|
|
36
|
-
const icons = {
|
|
37
|
-
success: '✅',
|
|
38
|
-
error: '❌',
|
|
39
|
-
warning: '⚠️',
|
|
40
|
-
progress: '🔄',
|
|
41
|
-
uploading: '📤',
|
|
42
|
-
waiting: '⏳',
|
|
43
|
-
running: '🧪',
|
|
44
|
-
starting: '🚀'
|
|
45
|
-
};
|
|
46
|
-
return icons[status] || '•';
|
|
47
|
-
} else {
|
|
48
|
-
// Text-only fallback
|
|
49
|
-
const icons = {
|
|
50
|
-
success: '[OK]',
|
|
51
|
-
error: '[ERR]',
|
|
52
|
-
warning: '[WARN]',
|
|
53
|
-
progress: '[...]',
|
|
54
|
-
uploading: '[UP]',
|
|
55
|
-
waiting: '[WAIT]',
|
|
56
|
-
running: '[RUN]',
|
|
57
|
-
starting: '[START]'
|
|
58
|
-
};
|
|
59
|
-
return icons[status] || '[•]';
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Responsive layout helper
|
|
65
|
-
*/
|
|
66
|
-
export function getLayout(columns = process.stdout.columns || 80) {
|
|
67
|
-
if (columns < 60) {
|
|
68
|
-
return {
|
|
69
|
-
type: 'compact',
|
|
70
|
-
showDetails: false,
|
|
71
|
-
maxWidth: columns - 4
|
|
72
|
-
};
|
|
73
|
-
} else if (columns < 100) {
|
|
74
|
-
return {
|
|
75
|
-
type: 'normal',
|
|
76
|
-
showDetails: true,
|
|
77
|
-
maxWidth: columns - 8
|
|
78
|
-
};
|
|
79
|
-
} else {
|
|
80
|
-
return {
|
|
81
|
-
type: 'wide',
|
|
82
|
-
showDetails: true,
|
|
83
|
-
maxWidth: Math.min(columns - 16, 120)
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|