@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.
Files changed (55) hide show
  1. package/README.md +26 -28
  2. package/dist/cli.js +18 -30
  3. package/dist/client/index.js +1 -1
  4. package/dist/commands/run.js +34 -9
  5. package/dist/commands/tdd.js +6 -1
  6. package/dist/commands/upload.js +52 -3
  7. package/dist/server/handlers/api-handler.js +83 -0
  8. package/dist/server/handlers/tdd-handler.js +138 -0
  9. package/dist/server/http-server.js +132 -0
  10. package/dist/services/api-service.js +40 -11
  11. package/dist/services/server-manager.js +45 -29
  12. package/dist/services/test-runner.js +64 -69
  13. package/dist/services/uploader.js +47 -82
  14. package/dist/types/commands/run.d.ts +4 -1
  15. package/dist/types/commands/tdd.d.ts +4 -1
  16. package/dist/types/sdk/index.d.ts +6 -6
  17. package/dist/types/server/handlers/api-handler.d.ts +49 -0
  18. package/dist/types/server/handlers/tdd-handler.d.ts +85 -0
  19. package/dist/types/server/http-server.d.ts +5 -0
  20. package/dist/types/services/api-service.d.ts +4 -2
  21. package/dist/types/services/server-manager.d.ts +148 -3
  22. package/dist/types/services/test-runner.d.ts +1 -0
  23. package/dist/types/utils/config-helpers.d.ts +1 -1
  24. package/dist/types/utils/console-ui.d.ts +1 -1
  25. package/dist/utils/console-ui.js +4 -14
  26. package/docs/api-reference.md +2 -5
  27. package/docs/getting-started.md +1 -1
  28. package/docs/tdd-mode.md +9 -9
  29. package/docs/test-integration.md +3 -17
  30. package/docs/upload-command.md +7 -0
  31. package/package.json +1 -1
  32. package/dist/screenshot-wrapper.js +0 -68
  33. package/dist/server/index.js +0 -522
  34. package/dist/services/service-utils.js +0 -171
  35. package/dist/types/index.js +0 -153
  36. package/dist/types/screenshot-wrapper.d.ts +0 -27
  37. package/dist/types/server/index.d.ts +0 -38
  38. package/dist/types/services/service-utils.d.ts +0 -45
  39. package/dist/types/types/index.d.ts +0 -373
  40. package/dist/types/utils/diagnostics.d.ts +0 -69
  41. package/dist/types/utils/error-messages.d.ts +0 -42
  42. package/dist/types/utils/framework-detector.d.ts +0 -5
  43. package/dist/types/utils/help.d.ts +0 -11
  44. package/dist/types/utils/image-comparison.d.ts +0 -42
  45. package/dist/types/utils/package.d.ts +0 -1
  46. package/dist/types/utils/project-detection.d.ts +0 -19
  47. package/dist/types/utils/ui-helpers.d.ts +0 -23
  48. package/dist/utils/diagnostics.js +0 -184
  49. package/dist/utils/error-messages.js +0 -34
  50. package/dist/utils/framework-detector.js +0 -40
  51. package/dist/utils/help.js +0 -66
  52. package/dist/utils/image-comparison.js +0 -172
  53. package/dist/utils/package.js +0 -9
  54. package/dist/utils/project-detection.js +0 -145
  55. package/dist/utils/ui-helpers.js +0 -86
@@ -1,153 +0,0 @@
1
- /**
2
- * @fileoverview Vizzly CLI type definitions
3
- * Comprehensive JSDoc type definitions for IDE support
4
- */
5
-
6
- /**
7
- * @typedef {Object} VizzlyConfig
8
- * @property {string} [apiKey] - API key for authentication
9
- * @property {string} [apiUrl='https://vizzly.dev'] - API base URL
10
- * @property {ServerConfig} [server] - Server configuration
11
- * @property {BuildConfig} [build] - Build configuration
12
- * @property {UploadConfig} [upload] - Upload configuration
13
- * @property {ComparisonConfig} [comparison] - Comparison configuration
14
- */
15
-
16
- /**
17
- * @typedef {Object} ServerConfig
18
- * @property {number} [port=3001] - Server port
19
- * @property {string} [host='localhost'] - Server host
20
- * @property {boolean} [https=false] - Use HTTPS
21
- * @property {string} [certPath] - Path to SSL certificate
22
- * @property {string} [keyPath] - Path to SSL key
23
- * @property {string} [screenshotPath='/screenshot'] - Screenshot POST endpoint path
24
- */
25
-
26
- /**
27
- * @typedef {Object} BuildConfig
28
- * @property {string} [name] - Build name
29
- * @property {string} [branch] - Git branch
30
- * @property {string} [commit] - Git commit SHA
31
- * @property {string} [message] - Commit message
32
- * @property {string} [environment='production'] - Environment name
33
- * @property {Object.<string, any>} [metadata] - Additional metadata
34
- */
35
-
36
- /**
37
- * @typedef {Object} UploadConfig
38
- * @property {string} [screenshotsDir='screenshots'] - Directory containing screenshots
39
- * @property {number} [batchSize=50] - Upload batch size
40
- * @property {number} [timeout=300000] - Upload timeout in ms
41
- * @property {number} [retries=3] - Number of retries
42
- * @property {boolean} [deduplication=true] - Enable deduplication
43
- */
44
-
45
- /**
46
- * @typedef {Object} ComparisonConfig
47
- * @property {number} [threshold=0.1] - Default comparison threshold (0-1)
48
- * @property {boolean} [ignoreAntialiasing=true] - Ignore antialiasing differences
49
- * @property {boolean} [ignoreColors=false] - Ignore color differences
50
- * @property {string} [diffColor='#ff0000'] - Color for diff highlighting
51
- */
52
-
53
- /**
54
- * @typedef {Object} Screenshot
55
- * @property {string} name - Screenshot name
56
- * @property {Buffer} image - Image buffer data
57
- * @property {Object.<string, any>} [properties] - Additional properties
58
- * @property {number} [threshold] - Comparison threshold override
59
- * @property {string} [group] - Screenshot group/category
60
- * @property {string[]} [tags] - Screenshot tags
61
- */
62
-
63
- /**
64
- * @typedef {Object} UploadOptions
65
- * @property {string} screenshotsDir - Directory containing screenshots
66
- * @property {string} [buildName] - Name for this build
67
- * @property {string} [branch] - Git branch name
68
- * @property {string} [commit] - Git commit SHA
69
- * @property {string} [message] - Commit message
70
- * @property {string} [environment='production'] - Environment name
71
- * @property {number} [threshold] - Default comparison threshold
72
- * @property {ProgressCallback} [onProgress] - Progress callback
73
- */
74
-
75
- /**
76
- * @typedef {Object} UploadResult
77
- * @property {boolean} success - Whether upload succeeded
78
- * @property {string} [buildId] - Build ID if successful
79
- * @property {string} [url] - Build URL if available
80
- * @property {UploadStats} stats - Upload statistics
81
- * @property {string} [error] - Error message if failed
82
- */
83
-
84
- /**
85
- * @typedef {Object} UploadStats
86
- * @property {number} total - Total files found
87
- * @property {number} uploaded - Files uploaded
88
- * @property {number} skipped - Files skipped (duplicates)
89
- * @property {number} failed - Files failed to upload
90
- */
91
-
92
- /**
93
- * @typedef {Object} ProgressEvent
94
- * @property {'scanning'|'processing'|'deduplication'|'uploading'|'completed'|'error'} phase - Current phase
95
- * @property {number} [current] - Current item being processed
96
- * @property {number} [total] - Total items to process
97
- * @property {string} [message] - Progress message
98
- * @property {number} [toUpload] - Files to upload (deduplication phase)
99
- * @property {number} [existing] - Existing files (deduplication phase)
100
- * @property {string} [buildId] - Build ID (completed phase)
101
- * @property {string} [url] - Build URL (completed phase)
102
- */
103
-
104
- /**
105
- * @callback ProgressCallback
106
- * @param {ProgressEvent} event - Progress event
107
- * @returns {void}
108
- */
109
-
110
- /**
111
- * @typedef {Object} TDDOptions
112
- * @property {string} [baselineDir='baseline'] - Baseline screenshots directory
113
- * @property {string} [currentDir='screenshots'] - Current screenshots directory
114
- * @property {string} [diffDir='diffs'] - Diff output directory
115
- * @property {number} [threshold=0.1] - Comparison threshold
116
- * @property {boolean} [failOnDifference=true] - Fail on any difference
117
- * @property {boolean} [updateBaseline=false] - Update baseline on difference
118
- */
119
-
120
- /**
121
- * @typedef {Object} ComparisonResult
122
- * @property {string} name - Screenshot name
123
- * @property {boolean} passed - Whether comparison passed
124
- * @property {number} [difference] - Difference percentage (0-1)
125
- * @property {string} [diffPath] - Path to diff image
126
- * @property {string} [error] - Error message if comparison failed
127
- */
128
-
129
- /**
130
- * @typedef {Object} BuildInfo
131
- * @property {string} id - Build ID
132
- * @property {string} name - Build name
133
- * @property {'pending'|'processing'|'completed'|'failed'} status - Build status
134
- * @property {string} branch - Git branch
135
- * @property {string} [commit] - Git commit SHA
136
- * @property {string} environment - Environment name
137
- * @property {Date} createdAt - Creation timestamp
138
- * @property {Date} [completedAt] - Completion timestamp
139
- * @property {number} screenshotCount - Number of screenshots
140
- * @property {Object.<string, any>} [metadata] - Additional metadata
141
- */
142
-
143
- /**
144
- * @typedef {Object} CLIOptions
145
- * @property {boolean} [verbose=false] - Enable verbose logging
146
- * @property {string} [logLevel='info'] - Log level
147
- * @property {boolean} [quiet=false] - Suppress all output
148
- * @property {boolean} [json=false] - Output JSON instead of text
149
- * @property {string} [config] - Path to config file
150
- */
151
-
152
- // Export types for use in other files
153
- export default {};
@@ -1,27 +0,0 @@
1
- /**
2
- * Create a factory that pre-configures Vizzly instances
3
- *
4
- * @param {Object} config - Shared configuration
5
- * @param {Object} [config.defaultProperties] - Default metadata for all screenshots
6
- * @param {number} [config.defaultThreshold] - Default comparison threshold
7
- *
8
- * @example
9
- * // test-setup.js - Configure once
10
- * export const createVizzly = vizzlyFactory({
11
- * defaultProperties: {
12
- * framework: 'playwright',
13
- * project: 'web-app'
14
- * }
15
- * });
16
- *
17
- * // my-test.spec.js - Use everywhere
18
- * const vizzly = createVizzly();
19
- *
20
- * const screenshot = await page.screenshot({ fullPage: true }); // Your method
21
- * await vizzly.screenshot({
22
- * name: 'homepage',
23
- * image: screenshot, // Your buffer
24
- * properties: { browser: 'chrome' } // Merges with defaults
25
- * });
26
- */
27
- export function vizzlyFactory(globalConfig: any): (overrideConfig?: {}) => any;
@@ -1,38 +0,0 @@
1
- export class VizzlyServer {
2
- constructor({ port, config, tddMode, baselineBuild, baselineComparison, workingDir, buildId, vizzlyApi, buildInfo, emitter, }: {
3
- port: any;
4
- config: any;
5
- tddMode?: boolean;
6
- baselineBuild: any;
7
- baselineComparison: any;
8
- workingDir: any;
9
- buildId?: any;
10
- vizzlyApi?: any;
11
- buildInfo?: any;
12
- emitter?: any;
13
- });
14
- port: any;
15
- config: any;
16
- builds: Map<any, any>;
17
- server: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
18
- tddMode: boolean;
19
- baselineBuild: any;
20
- baselineComparison: any;
21
- tddService: TddService;
22
- buildId: any;
23
- vizzlyApi: any;
24
- buildInfo: any;
25
- emitter: any;
26
- vizzlyDisabled: boolean;
27
- start(): Promise<any>;
28
- handleRequest(req: any, res: any): Promise<void>;
29
- handleScreenshot(req: any, res: any): Promise<void>;
30
- parseRequestBody(req: any): Promise<any>;
31
- stop(): Promise<any>;
32
- createBuild(options: any): Promise<`${string}-${string}-${string}-${string}-${string}`>;
33
- getScreenshotCount(buildId: any): any;
34
- getTotalScreenshotCount(): number;
35
- finishBuild(buildId: any): Promise<any>;
36
- cleanupBuild(buildId: any): Promise<void>;
37
- }
38
- import { TddService } from '../services/tdd-service.js';
@@ -1,45 +0,0 @@
1
- /**
2
- * Create an event emitter with enhanced functionality
3
- * @returns {EventEmitter} Enhanced event emitter
4
- */
5
- export function createEventEmitter(): EventEmitter;
6
- /**
7
- * Create a cleanup manager
8
- * @returns {Object} Cleanup manager with add/execute methods
9
- */
10
- export function createCleanupManager(): any;
11
- /**
12
- * Create signal handlers for graceful shutdown
13
- * @param {Function} onSignal - Function to call on signal
14
- * @returns {Function} Cleanup function to remove handlers
15
- */
16
- export function createSignalHandlers(onSignal: Function): Function;
17
- /**
18
- * Higher-order function to add error handling to any function
19
- * @param {Function} fn - Function to wrap
20
- * @param {Object} options - Error handling options
21
- * @returns {Function} Wrapped function with error handling
22
- */
23
- export function withErrorHandling(fn: Function, options?: any): Function;
24
- /**
25
- * Higher-order function to add logging to any function
26
- * @param {Function} fn - Function to wrap
27
- * @param {Object} logger - Logger instance
28
- * @param {string} operation - Operation name for logging
29
- * @returns {Function} Wrapped function with logging
30
- */
31
- export function withLogging(fn: Function, logger: any, operation: string): Function;
32
- /**
33
- * Compose multiple functions together
34
- * @param {...Function} fns - Functions to compose
35
- * @returns {Function} Composed function
36
- */
37
- export function compose(...fns: Function[]): Function;
38
- /**
39
- * Create a service context with shared functionality
40
- * @param {Object} config - Service configuration
41
- * @param {Object} options - Service options
42
- * @returns {Object} Service context
43
- */
44
- export function createServiceContext(config: any, options?: any): any;
45
- import { EventEmitter } from 'events';
@@ -1,373 +0,0 @@
1
- declare const _default: {};
2
- export default _default;
3
- export type VizzlyConfig = {
4
- /**
5
- * - API key for authentication
6
- */
7
- apiKey?: string;
8
- /**
9
- * - API base URL
10
- */
11
- apiUrl?: string;
12
- /**
13
- * - Server configuration
14
- */
15
- server?: ServerConfig;
16
- /**
17
- * - Build configuration
18
- */
19
- build?: BuildConfig;
20
- /**
21
- * - Upload configuration
22
- */
23
- upload?: UploadConfig;
24
- /**
25
- * - Comparison configuration
26
- */
27
- comparison?: ComparisonConfig;
28
- };
29
- export type ServerConfig = {
30
- /**
31
- * - Server port
32
- */
33
- port?: number;
34
- /**
35
- * - Server host
36
- */
37
- host?: string;
38
- /**
39
- * - Use HTTPS
40
- */
41
- https?: boolean;
42
- /**
43
- * - Path to SSL certificate
44
- */
45
- certPath?: string;
46
- /**
47
- * - Path to SSL key
48
- */
49
- keyPath?: string;
50
- /**
51
- * - Screenshot POST endpoint path
52
- */
53
- screenshotPath?: string;
54
- };
55
- export type BuildConfig = {
56
- /**
57
- * - Build name
58
- */
59
- name?: string;
60
- /**
61
- * - Git branch
62
- */
63
- branch?: string;
64
- /**
65
- * - Git commit SHA
66
- */
67
- commit?: string;
68
- /**
69
- * - Commit message
70
- */
71
- message?: string;
72
- /**
73
- * - Environment name
74
- */
75
- environment?: string;
76
- /**
77
- * - Additional metadata
78
- */
79
- metadata?: {
80
- [x: string]: any;
81
- };
82
- };
83
- export type UploadConfig = {
84
- /**
85
- * - Directory containing screenshots
86
- */
87
- screenshotsDir?: string;
88
- /**
89
- * - Upload batch size
90
- */
91
- batchSize?: number;
92
- /**
93
- * - Upload timeout in ms
94
- */
95
- timeout?: number;
96
- /**
97
- * - Number of retries
98
- */
99
- retries?: number;
100
- /**
101
- * - Enable deduplication
102
- */
103
- deduplication?: boolean;
104
- };
105
- export type ComparisonConfig = {
106
- /**
107
- * - Default comparison threshold (0-1)
108
- */
109
- threshold?: number;
110
- /**
111
- * - Ignore antialiasing differences
112
- */
113
- ignoreAntialiasing?: boolean;
114
- /**
115
- * - Ignore color differences
116
- */
117
- ignoreColors?: boolean;
118
- /**
119
- * - Color for diff highlighting
120
- */
121
- diffColor?: string;
122
- };
123
- export type Screenshot = {
124
- /**
125
- * - Screenshot name
126
- */
127
- name: string;
128
- /**
129
- * - Image buffer data
130
- */
131
- image: Buffer;
132
- /**
133
- * - Additional properties
134
- */
135
- properties?: {
136
- [x: string]: any;
137
- };
138
- /**
139
- * - Comparison threshold override
140
- */
141
- threshold?: number;
142
- /**
143
- * - Screenshot group/category
144
- */
145
- group?: string;
146
- /**
147
- * - Screenshot tags
148
- */
149
- tags?: string[];
150
- };
151
- export type UploadOptions = {
152
- /**
153
- * - Directory containing screenshots
154
- */
155
- screenshotsDir: string;
156
- /**
157
- * - Name for this build
158
- */
159
- buildName?: string;
160
- /**
161
- * - Git branch name
162
- */
163
- branch?: string;
164
- /**
165
- * - Git commit SHA
166
- */
167
- commit?: string;
168
- /**
169
- * - Commit message
170
- */
171
- message?: string;
172
- /**
173
- * - Environment name
174
- */
175
- environment?: string;
176
- /**
177
- * - Default comparison threshold
178
- */
179
- threshold?: number;
180
- /**
181
- * - Progress callback
182
- */
183
- onProgress?: ProgressCallback;
184
- };
185
- export type UploadResult = {
186
- /**
187
- * - Whether upload succeeded
188
- */
189
- success: boolean;
190
- /**
191
- * - Build ID if successful
192
- */
193
- buildId?: string;
194
- /**
195
- * - Build URL if available
196
- */
197
- url?: string;
198
- /**
199
- * - Upload statistics
200
- */
201
- stats: UploadStats;
202
- /**
203
- * - Error message if failed
204
- */
205
- error?: string;
206
- };
207
- export type UploadStats = {
208
- /**
209
- * - Total files found
210
- */
211
- total: number;
212
- /**
213
- * - Files uploaded
214
- */
215
- uploaded: number;
216
- /**
217
- * - Files skipped (duplicates)
218
- */
219
- skipped: number;
220
- /**
221
- * - Files failed to upload
222
- */
223
- failed: number;
224
- };
225
- export type ProgressEvent = {
226
- /**
227
- * - Current phase
228
- */
229
- phase: "scanning" | "processing" | "deduplication" | "uploading" | "completed" | "error";
230
- /**
231
- * - Current item being processed
232
- */
233
- current?: number;
234
- /**
235
- * - Total items to process
236
- */
237
- total?: number;
238
- /**
239
- * - Progress message
240
- */
241
- message?: string;
242
- /**
243
- * - Files to upload (deduplication phase)
244
- */
245
- toUpload?: number;
246
- /**
247
- * - Existing files (deduplication phase)
248
- */
249
- existing?: number;
250
- /**
251
- * - Build ID (completed phase)
252
- */
253
- buildId?: string;
254
- /**
255
- * - Build URL (completed phase)
256
- */
257
- url?: string;
258
- };
259
- export type ProgressCallback = (event: ProgressEvent) => void;
260
- export type TDDOptions = {
261
- /**
262
- * - Baseline screenshots directory
263
- */
264
- baselineDir?: string;
265
- /**
266
- * - Current screenshots directory
267
- */
268
- currentDir?: string;
269
- /**
270
- * - Diff output directory
271
- */
272
- diffDir?: string;
273
- /**
274
- * - Comparison threshold
275
- */
276
- threshold?: number;
277
- /**
278
- * - Fail on any difference
279
- */
280
- failOnDifference?: boolean;
281
- /**
282
- * - Update baseline on difference
283
- */
284
- updateBaseline?: boolean;
285
- };
286
- export type ComparisonResult = {
287
- /**
288
- * - Screenshot name
289
- */
290
- name: string;
291
- /**
292
- * - Whether comparison passed
293
- */
294
- passed: boolean;
295
- /**
296
- * - Difference percentage (0-1)
297
- */
298
- difference?: number;
299
- /**
300
- * - Path to diff image
301
- */
302
- diffPath?: string;
303
- /**
304
- * - Error message if comparison failed
305
- */
306
- error?: string;
307
- };
308
- export type BuildInfo = {
309
- /**
310
- * - Build ID
311
- */
312
- id: string;
313
- /**
314
- * - Build name
315
- */
316
- name: string;
317
- /**
318
- * - Build status
319
- */
320
- status: "pending" | "processing" | "completed" | "failed";
321
- /**
322
- * - Git branch
323
- */
324
- branch: string;
325
- /**
326
- * - Git commit SHA
327
- */
328
- commit?: string;
329
- /**
330
- * - Environment name
331
- */
332
- environment: string;
333
- /**
334
- * - Creation timestamp
335
- */
336
- createdAt: Date;
337
- /**
338
- * - Completion timestamp
339
- */
340
- completedAt?: Date;
341
- /**
342
- * - Number of screenshots
343
- */
344
- screenshotCount: number;
345
- /**
346
- * - Additional metadata
347
- */
348
- metadata?: {
349
- [x: string]: any;
350
- };
351
- };
352
- export type CLIOptions = {
353
- /**
354
- * - Enable verbose logging
355
- */
356
- verbose?: boolean;
357
- /**
358
- * - Log level
359
- */
360
- logLevel?: string;
361
- /**
362
- * - Suppress all output
363
- */
364
- quiet?: boolean;
365
- /**
366
- * - Output JSON instead of text
367
- */
368
- json?: boolean;
369
- /**
370
- * - Path to config file
371
- */
372
- config?: string;
373
- };
@@ -1,69 +0,0 @@
1
- /**
2
- * Check if required dependencies are available
3
- */
4
- export function checkDependencies(): Promise<{
5
- all_ok: boolean;
6
- details: {
7
- node: {
8
- available: boolean;
9
- version: string;
10
- supported: boolean;
11
- message: string;
12
- error?: undefined;
13
- } | {
14
- available: boolean;
15
- error: any;
16
- version?: undefined;
17
- supported?: undefined;
18
- message?: undefined;
19
- };
20
- npm: any;
21
- git: any;
22
- odiff: {
23
- available: boolean;
24
- path: any;
25
- message: string;
26
- error?: undefined;
27
- } | {
28
- available: boolean;
29
- error: any;
30
- message: string;
31
- path?: undefined;
32
- };
33
- };
34
- }>;
35
- /**
36
- * Check API connectivity
37
- */
38
- export function checkApiConnectivity(config: any): Promise<{
39
- url: any;
40
- has_token: boolean;
41
- reachable: boolean;
42
- authenticated: boolean;
43
- } | {
44
- error: any;
45
- reachable: boolean;
46
- authenticated: boolean;
47
- }>;
48
- /**
49
- * Check terminal capabilities
50
- */
51
- export function checkTerminalCapabilities(): {
52
- stdout_is_tty: boolean;
53
- stdin_is_tty: boolean;
54
- supports_color: boolean;
55
- terminal_type: string;
56
- columns: number;
57
- rows: number;
58
- };
59
- /**
60
- * Get system information
61
- */
62
- export function getSystemInfo(): {
63
- platform: NodeJS.Platform;
64
- arch: NodeJS.Architecture;
65
- node_version: string;
66
- memory_usage: NodeJS.MemoryUsage;
67
- uptime: number;
68
- working_directory: string;
69
- };