@vizzly-testing/cli 0.1.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/LICENSE +21 -0
- package/README.md +363 -0
- package/bin/vizzly.js +3 -0
- package/dist/cli.js +104 -0
- package/dist/client/index.js +237 -0
- package/dist/commands/doctor.js +158 -0
- package/dist/commands/init.js +102 -0
- package/dist/commands/run.js +224 -0
- package/dist/commands/status.js +164 -0
- package/dist/commands/tdd.js +212 -0
- package/dist/commands/upload.js +181 -0
- package/dist/container/index.js +184 -0
- package/dist/errors/vizzly-error.js +149 -0
- package/dist/index.js +31 -0
- package/dist/screenshot-wrapper.js +68 -0
- package/dist/sdk/index.js +364 -0
- package/dist/server/index.js +522 -0
- package/dist/services/api-service.js +215 -0
- package/dist/services/base-service.js +154 -0
- package/dist/services/build-manager.js +214 -0
- package/dist/services/screenshot-server.js +96 -0
- package/dist/services/server-manager.js +61 -0
- package/dist/services/service-utils.js +171 -0
- package/dist/services/tdd-service.js +444 -0
- package/dist/services/test-runner.js +210 -0
- package/dist/services/uploader.js +413 -0
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/client/index.d.ts +76 -0
- package/dist/types/commands/doctor.d.ts +11 -0
- package/dist/types/commands/init.d.ts +14 -0
- package/dist/types/commands/run.d.ts +13 -0
- package/dist/types/commands/status.d.ts +13 -0
- package/dist/types/commands/tdd.d.ts +13 -0
- package/dist/types/commands/upload.d.ts +13 -0
- package/dist/types/container/index.d.ts +61 -0
- package/dist/types/errors/vizzly-error.d.ts +75 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.js +153 -0
- package/dist/types/screenshot-wrapper.d.ts +27 -0
- package/dist/types/sdk/index.d.ts +108 -0
- package/dist/types/server/index.d.ts +38 -0
- package/dist/types/services/api-service.d.ts +77 -0
- package/dist/types/services/base-service.d.ts +72 -0
- package/dist/types/services/build-manager.d.ts +68 -0
- package/dist/types/services/screenshot-server.d.ts +10 -0
- package/dist/types/services/server-manager.d.ts +8 -0
- package/dist/types/services/service-utils.d.ts +45 -0
- package/dist/types/services/tdd-service.d.ts +55 -0
- package/dist/types/services/test-runner.d.ts +25 -0
- package/dist/types/services/uploader.d.ts +34 -0
- package/dist/types/types/index.d.ts +373 -0
- package/dist/types/utils/colors.d.ts +12 -0
- package/dist/types/utils/config-helpers.d.ts +6 -0
- package/dist/types/utils/config-loader.d.ts +22 -0
- package/dist/types/utils/console-ui.d.ts +61 -0
- package/dist/types/utils/diagnostics.d.ts +69 -0
- package/dist/types/utils/environment-config.d.ts +54 -0
- package/dist/types/utils/environment.d.ts +36 -0
- package/dist/types/utils/error-messages.d.ts +42 -0
- package/dist/types/utils/fetch-utils.d.ts +1 -0
- package/dist/types/utils/framework-detector.d.ts +5 -0
- package/dist/types/utils/git.d.ts +44 -0
- package/dist/types/utils/help.d.ts +11 -0
- package/dist/types/utils/image-comparison.d.ts +42 -0
- package/dist/types/utils/logger-factory.d.ts +26 -0
- package/dist/types/utils/logger.d.ts +79 -0
- package/dist/types/utils/package-info.d.ts +15 -0
- package/dist/types/utils/package.d.ts +1 -0
- package/dist/types/utils/project-detection.d.ts +19 -0
- package/dist/types/utils/ui-helpers.d.ts +23 -0
- package/dist/utils/colors.js +66 -0
- package/dist/utils/config-helpers.js +8 -0
- package/dist/utils/config-loader.js +120 -0
- package/dist/utils/console-ui.js +226 -0
- package/dist/utils/diagnostics.js +184 -0
- package/dist/utils/environment-config.js +93 -0
- package/dist/utils/environment.js +109 -0
- package/dist/utils/error-messages.js +34 -0
- package/dist/utils/fetch-utils.js +9 -0
- package/dist/utils/framework-detector.js +40 -0
- package/dist/utils/git.js +226 -0
- package/dist/utils/help.js +66 -0
- package/dist/utils/image-comparison.js +172 -0
- package/dist/utils/logger-factory.js +76 -0
- package/dist/utils/logger.js +231 -0
- package/dist/utils/package-info.js +38 -0
- package/dist/utils/package.js +9 -0
- package/dist/utils/project-detection.js +145 -0
- package/dist/utils/ui-helpers.js +86 -0
- package/package.json +103 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export function createInitCommand(options: any): () => Promise<void>;
|
|
3
|
+
export function init(options?: {}): Promise<void>;
|
|
4
|
+
/**
|
|
5
|
+
* Simple configuration setup for Vizzly CLI
|
|
6
|
+
*/
|
|
7
|
+
export class InitCommand {
|
|
8
|
+
constructor(logger: any);
|
|
9
|
+
logger: any;
|
|
10
|
+
run(options?: {}): Promise<void>;
|
|
11
|
+
generateConfigFile(configPath: any): Promise<void>;
|
|
12
|
+
showNextSteps(): void;
|
|
13
|
+
fileExists(filePath: any): Promise<boolean>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run command implementation
|
|
3
|
+
* @param {string} testCommand - Test command to execute
|
|
4
|
+
* @param {Object} options - Command options
|
|
5
|
+
* @param {Object} globalOptions - Global CLI options
|
|
6
|
+
*/
|
|
7
|
+
export function runCommand(testCommand: string, options?: any, globalOptions?: any): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Validate run options
|
|
10
|
+
* @param {string} testCommand - Test command to execute
|
|
11
|
+
* @param {Object} options - Command options
|
|
12
|
+
*/
|
|
13
|
+
export function validateRunOptions(testCommand: string, options: any): string[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status command implementation
|
|
3
|
+
* @param {string} buildId - Build ID to check status for
|
|
4
|
+
* @param {Object} options - Command options
|
|
5
|
+
* @param {Object} globalOptions - Global CLI options
|
|
6
|
+
*/
|
|
7
|
+
export function statusCommand(buildId: string, options?: any, globalOptions?: any): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Validate status options
|
|
10
|
+
* @param {string} buildId - Build ID to check
|
|
11
|
+
* @param {Object} options - Command options
|
|
12
|
+
*/
|
|
13
|
+
export function validateStatusOptions(buildId: string): string[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TDD command implementation
|
|
3
|
+
* @param {string} testCommand - Test command to execute
|
|
4
|
+
* @param {Object} options - Command options
|
|
5
|
+
* @param {Object} globalOptions - Global CLI options
|
|
6
|
+
*/
|
|
7
|
+
export function tddCommand(testCommand: string, options?: any, globalOptions?: any): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Validate TDD options
|
|
10
|
+
* @param {string} testCommand - Test command to execute
|
|
11
|
+
* @param {Object} options - Command options
|
|
12
|
+
*/
|
|
13
|
+
export function validateTddOptions(testCommand: string, options: any): string[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload command implementation
|
|
3
|
+
* @param {string} screenshotsPath - Path to screenshots
|
|
4
|
+
* @param {Object} options - Command options
|
|
5
|
+
* @param {Object} globalOptions - Global CLI options
|
|
6
|
+
*/
|
|
7
|
+
export function uploadCommand(screenshotsPath: string, options?: any, globalOptions?: any): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Validate upload options
|
|
10
|
+
* @param {string} screenshotsPath - Path to screenshots
|
|
11
|
+
* @param {Object} options - Command options
|
|
12
|
+
*/
|
|
13
|
+
export function validateUploadOptions(screenshotsPath: string, options: any): string[];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a configured service container
|
|
3
|
+
* @param {Object} config - Configuration object
|
|
4
|
+
* @returns {ServiceContainer}
|
|
5
|
+
*/
|
|
6
|
+
export function createServiceContainer(config: any, command?: string): ServiceContainer;
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} ServiceDefinition
|
|
9
|
+
* @property {Function} factory - Factory function to create service instance
|
|
10
|
+
* @property {boolean} [singleton=true] - Whether to cache the instance
|
|
11
|
+
* @property {string[]} [dependencies=[]] - Array of dependency names
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Service container for dependency injection and lifecycle management
|
|
15
|
+
*/
|
|
16
|
+
export class ServiceContainer extends EventEmitter<[never]> {
|
|
17
|
+
constructor();
|
|
18
|
+
services: Map<any, any>;
|
|
19
|
+
instances: Map<any, any>;
|
|
20
|
+
starting: Map<any, any>;
|
|
21
|
+
/**
|
|
22
|
+
* Register a service
|
|
23
|
+
* @param {string} name - Service name
|
|
24
|
+
* @param {Function|ServiceDefinition} factoryOrDefinition - Factory function or service definition
|
|
25
|
+
*/
|
|
26
|
+
register(name: string, factoryOrDefinition: Function | ServiceDefinition): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get a service instance
|
|
29
|
+
* @param {string} name - Service name
|
|
30
|
+
* @returns {Promise<any>} Service instance
|
|
31
|
+
*/
|
|
32
|
+
get(name: string): Promise<any>;
|
|
33
|
+
/**
|
|
34
|
+
* Start all registered services
|
|
35
|
+
*/
|
|
36
|
+
startAll(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Stop all services in reverse order
|
|
39
|
+
*/
|
|
40
|
+
stopAll(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Clear all services and instances
|
|
43
|
+
*/
|
|
44
|
+
clear(): void;
|
|
45
|
+
}
|
|
46
|
+
export const container: ServiceContainer;
|
|
47
|
+
export type ServiceDefinition = {
|
|
48
|
+
/**
|
|
49
|
+
* - Factory function to create service instance
|
|
50
|
+
*/
|
|
51
|
+
factory: Function;
|
|
52
|
+
/**
|
|
53
|
+
* - Whether to cache the instance
|
|
54
|
+
*/
|
|
55
|
+
singleton?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* - Array of dependency names
|
|
58
|
+
*/
|
|
59
|
+
dependencies?: string[];
|
|
60
|
+
};
|
|
61
|
+
import { EventEmitter } from 'events';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all Vizzly errors
|
|
3
|
+
* Provides consistent error structure and helpful debugging information
|
|
4
|
+
*/
|
|
5
|
+
export class VizzlyError extends Error {
|
|
6
|
+
constructor(message: any, code?: string, context?: {});
|
|
7
|
+
code: string;
|
|
8
|
+
context: {};
|
|
9
|
+
timestamp: string;
|
|
10
|
+
/**
|
|
11
|
+
* Get a user-friendly error message
|
|
12
|
+
*/
|
|
13
|
+
getUserMessage(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Get error details for logging
|
|
16
|
+
*/
|
|
17
|
+
toJSON(): {
|
|
18
|
+
name: string;
|
|
19
|
+
code: string;
|
|
20
|
+
message: string;
|
|
21
|
+
context: {};
|
|
22
|
+
timestamp: string;
|
|
23
|
+
stack: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Configuration-related errors
|
|
28
|
+
*/
|
|
29
|
+
export class ConfigError extends VizzlyError {
|
|
30
|
+
constructor(message: any, context?: {});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Authentication/authorization errors
|
|
34
|
+
*/
|
|
35
|
+
export class AuthError extends VizzlyError {
|
|
36
|
+
constructor(message: any, context?: {});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Network/connection errors
|
|
40
|
+
*/
|
|
41
|
+
export class NetworkError extends VizzlyError {
|
|
42
|
+
constructor(message: any, context?: {});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Upload-related errors
|
|
46
|
+
*/
|
|
47
|
+
export class UploadError extends VizzlyError {
|
|
48
|
+
constructor(message: any, context?: {});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Screenshot-related errors
|
|
52
|
+
*/
|
|
53
|
+
export class ScreenshotError extends VizzlyError {
|
|
54
|
+
constructor(message: any, context?: {});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Build-related errors
|
|
58
|
+
*/
|
|
59
|
+
export class BuildError extends VizzlyError {
|
|
60
|
+
constructor(message: any, context?: {});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Timeout errors
|
|
64
|
+
*/
|
|
65
|
+
export class TimeoutError extends VizzlyError {
|
|
66
|
+
constructor(message: any, duration: any, context?: {});
|
|
67
|
+
duration: any;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Validation errors
|
|
71
|
+
*/
|
|
72
|
+
export class ValidationError extends VizzlyError {
|
|
73
|
+
constructor(message: any, errors?: any[], context?: {});
|
|
74
|
+
errors: any[];
|
|
75
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { createVizzly } from "./sdk/index.js";
|
|
2
|
+
export { createUploader } from "./services/uploader.js";
|
|
3
|
+
export { createTDDService } from "./services/tdd-service.js";
|
|
4
|
+
export { BaseService } from "./services/base-service.js";
|
|
5
|
+
export { loadConfig } from "./utils/config-loader.js";
|
|
6
|
+
export { createLogger } from "./utils/logger.js";
|
|
7
|
+
export { defineConfig } from "./utils/config-helpers.js";
|
|
8
|
+
export { UploadError } from "./errors/vizzly-error.js";
|
|
9
|
+
export { vizzlyScreenshot, configure, setEnabled } from "./client/index.js";
|
|
10
|
+
export { ServiceContainer, container } from "./container/index.js";
|
|
@@ -0,0 +1,153 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,27 @@
|
|
|
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;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new Vizzly instance with custom configuration
|
|
3
|
+
*
|
|
4
|
+
* @param {import('../types').VizzlyConfig} [config] - Configuration options
|
|
5
|
+
* @returns {Promise<VizzlySDK>} Configured Vizzly SDK instance
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Create with custom config
|
|
9
|
+
* import { createVizzly } from '@vizzly-testing/cli/sdk';
|
|
10
|
+
*
|
|
11
|
+
* const vizzly = await createVizzly({
|
|
12
|
+
* apiKey: process.env.VIZZLY_TOKEN,
|
|
13
|
+
* apiUrl: 'https://vizzly.dev',
|
|
14
|
+
* server: {
|
|
15
|
+
* port: 3003,
|
|
16
|
+
* enabled: true
|
|
17
|
+
* }
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Start the server
|
|
21
|
+
* await vizzly.start();
|
|
22
|
+
*
|
|
23
|
+
* // Take screenshots
|
|
24
|
+
* const screenshot = await getScreenshotSomehow();
|
|
25
|
+
* await vizzly.screenshot('my-test', screenshot);
|
|
26
|
+
*
|
|
27
|
+
* // Upload results
|
|
28
|
+
* const result = await vizzly.upload();
|
|
29
|
+
* console.log(`Build URL: ${result.url}`);
|
|
30
|
+
*
|
|
31
|
+
* // Cleanup
|
|
32
|
+
* await vizzly.stop();
|
|
33
|
+
*/
|
|
34
|
+
export function createVizzly(config?: import("../types").VizzlyConfig, options?: {}): Promise<VizzlySDK>;
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {Object} VizzlySDK
|
|
37
|
+
* @property {Function} start - Start the Vizzly server
|
|
38
|
+
* @property {Function} stop - Stop the Vizzly server
|
|
39
|
+
* @property {Function} screenshot - Capture a screenshot
|
|
40
|
+
* @property {Function} upload - Upload screenshots to Vizzly
|
|
41
|
+
* @property {Function} compare - Run local comparison (TDD mode)
|
|
42
|
+
* @property {Function} getConfig - Get current configuration
|
|
43
|
+
* @property {Function} on - Subscribe to events
|
|
44
|
+
* @property {Function} off - Unsubscribe from events
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* VizzlySDK class implementation
|
|
48
|
+
* @class
|
|
49
|
+
* @extends {EventEmitter}
|
|
50
|
+
*/
|
|
51
|
+
export class VizzlySDK extends EventEmitter<[never]> {
|
|
52
|
+
/**
|
|
53
|
+
* @param {import('../types').VizzlyConfig} config - Configuration
|
|
54
|
+
* @param {import('../utils/logger').Logger} logger - Logger instance
|
|
55
|
+
* @param {Object} services - Service instances
|
|
56
|
+
*/
|
|
57
|
+
constructor(config: import("../types").VizzlyConfig, logger: import("../utils/logger").Logger, services: any);
|
|
58
|
+
config: import("../types").VizzlyConfig;
|
|
59
|
+
logger: import("../utils/logger.js").Logger;
|
|
60
|
+
services: any;
|
|
61
|
+
server: ScreenshotServer;
|
|
62
|
+
currentBuildId: any;
|
|
63
|
+
/**
|
|
64
|
+
* Stop the Vizzly server
|
|
65
|
+
* @returns {Promise<void>}
|
|
66
|
+
*/
|
|
67
|
+
stop(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Get current configuration
|
|
70
|
+
* @returns {Object} Current config
|
|
71
|
+
*/
|
|
72
|
+
getConfig(): any;
|
|
73
|
+
/**
|
|
74
|
+
* Start the Vizzly server
|
|
75
|
+
* @returns {Promise<{port: number, url: string}>} Server information
|
|
76
|
+
*/
|
|
77
|
+
start(): Promise<{
|
|
78
|
+
port: number;
|
|
79
|
+
url: string;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Capture a screenshot
|
|
83
|
+
* @param {string} name - Screenshot name
|
|
84
|
+
* @param {Buffer} imageBuffer - Image data
|
|
85
|
+
* @param {import('../types').ScreenshotOptions} [options] - Options
|
|
86
|
+
* @returns {Promise<void>}
|
|
87
|
+
*/
|
|
88
|
+
screenshot(name: string, imageBuffer: Buffer, options?: import("../types").ScreenshotOptions): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Upload all captured screenshots
|
|
91
|
+
* @param {import('../types').UploadOptions} [options] - Upload options
|
|
92
|
+
* @returns {Promise<import('../types').UploadResult>} Upload result
|
|
93
|
+
*/
|
|
94
|
+
upload(options?: import("../types").UploadOptions): Promise<import("../types").UploadResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Run local comparison in TDD mode
|
|
97
|
+
* @param {string} name - Screenshot name
|
|
98
|
+
* @param {Buffer} imageBuffer - Current image
|
|
99
|
+
* @returns {Promise<import('../types').ComparisonResult>} Comparison result
|
|
100
|
+
*/
|
|
101
|
+
compare(name: string, imageBuffer: Buffer): Promise<import("../types").ComparisonResult>;
|
|
102
|
+
}
|
|
103
|
+
export { loadConfig } from "../utils/config-loader.js";
|
|
104
|
+
export { createLogger } from "../utils/logger.js";
|
|
105
|
+
export { createUploader } from "../services/uploader.js";
|
|
106
|
+
export { createTDDService } from "../services/tdd-service.js";
|
|
107
|
+
import { EventEmitter } from 'events';
|
|
108
|
+
import { ScreenshotServer } from '../services/screenshot-server.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
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';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ApiService class for direct API communication
|
|
3
|
+
*/
|
|
4
|
+
export class ApiService {
|
|
5
|
+
constructor(options?: {});
|
|
6
|
+
baseUrl: any;
|
|
7
|
+
token: any;
|
|
8
|
+
userAgent: string;
|
|
9
|
+
/**
|
|
10
|
+
* Make an API request
|
|
11
|
+
* @param {string} endpoint - API endpoint
|
|
12
|
+
* @param {Object} options - Fetch options
|
|
13
|
+
* @returns {Promise<Object>} Response data
|
|
14
|
+
*/
|
|
15
|
+
request(endpoint: string, options?: any): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Get build information
|
|
18
|
+
* @param {string} buildId - Build ID
|
|
19
|
+
* @param {string} include - Optional include parameter (e.g., 'screenshots')
|
|
20
|
+
* @returns {Promise<Object>} Build data
|
|
21
|
+
*/
|
|
22
|
+
getBuild(buildId: string, include?: string): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Get comparison information
|
|
25
|
+
* @param {string} comparisonId - Comparison ID
|
|
26
|
+
* @returns {Promise<Object>} Comparison data
|
|
27
|
+
*/
|
|
28
|
+
getComparison(comparisonId: string): Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* Get builds for a project
|
|
31
|
+
* @param {Object} filters - Filter options
|
|
32
|
+
* @returns {Promise<Array>} List of builds
|
|
33
|
+
*/
|
|
34
|
+
getBuilds(filters?: any): Promise<any[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new build
|
|
37
|
+
* @param {Object} metadata - Build metadata
|
|
38
|
+
* @returns {Promise<Object>} Created build data
|
|
39
|
+
*/
|
|
40
|
+
createBuild(metadata: any): Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* Check if SHAs already exist on the server
|
|
43
|
+
* @param {string[]} shas - Array of SHA256 hashes to check
|
|
44
|
+
* @returns {Promise<string[]>} Array of existing SHAs
|
|
45
|
+
*/
|
|
46
|
+
checkShas(shas: string[]): Promise<string[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Upload a screenshot with SHA checking
|
|
49
|
+
* @param {string} buildId - Build ID
|
|
50
|
+
* @param {string} name - Screenshot name
|
|
51
|
+
* @param {Buffer} buffer - Screenshot data
|
|
52
|
+
* @param {Object} metadata - Additional metadata
|
|
53
|
+
* @returns {Promise<Object>} Upload result
|
|
54
|
+
*/
|
|
55
|
+
uploadScreenshot(buildId: string, name: string, buffer: Buffer, metadata?: any): Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
* Update build status
|
|
58
|
+
* @param {string} buildId - Build ID
|
|
59
|
+
* @param {string} status - Build status (pending|running|completed|failed)
|
|
60
|
+
* @param {number} executionTimeMs - Execution time in milliseconds
|
|
61
|
+
* @returns {Promise<Object>} Updated build data
|
|
62
|
+
*/
|
|
63
|
+
updateBuildStatus(buildId: string, status: string, executionTimeMs?: number): Promise<any>;
|
|
64
|
+
/**
|
|
65
|
+
* Finalize a build (convenience method)
|
|
66
|
+
* @param {string} buildId - Build ID
|
|
67
|
+
* @param {boolean} success - Whether the build succeeded
|
|
68
|
+
* @param {number} executionTimeMs - Execution time in milliseconds
|
|
69
|
+
* @returns {Promise<Object>} Finalized build data
|
|
70
|
+
*/
|
|
71
|
+
finalizeBuild(buildId: string, success?: boolean, executionTimeMs?: number): Promise<any>;
|
|
72
|
+
/**
|
|
73
|
+
* Get token context (organization and project info)
|
|
74
|
+
* @returns {Promise<Object>} Token context data
|
|
75
|
+
*/
|
|
76
|
+
getTokenContext(): Promise<any>;
|
|
77
|
+
}
|