@vizzly-testing/cli 0.19.2 → 0.20.1-beta.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 (76) hide show
  1. package/dist/api/client.js +134 -0
  2. package/dist/api/core.js +341 -0
  3. package/dist/api/endpoints.js +314 -0
  4. package/dist/api/index.js +19 -0
  5. package/dist/auth/client.js +91 -0
  6. package/dist/auth/core.js +176 -0
  7. package/dist/auth/index.js +30 -0
  8. package/dist/auth/operations.js +148 -0
  9. package/dist/cli.js +1 -1
  10. package/dist/client/index.js +0 -1
  11. package/dist/commands/doctor.js +3 -3
  12. package/dist/commands/finalize.js +41 -15
  13. package/dist/commands/login.js +7 -6
  14. package/dist/commands/logout.js +4 -4
  15. package/dist/commands/project.js +5 -4
  16. package/dist/commands/run.js +158 -90
  17. package/dist/commands/status.js +22 -18
  18. package/dist/commands/tdd.js +105 -78
  19. package/dist/commands/upload.js +61 -26
  20. package/dist/commands/whoami.js +4 -4
  21. package/dist/config/core.js +438 -0
  22. package/dist/config/index.js +13 -0
  23. package/dist/config/operations.js +327 -0
  24. package/dist/index.js +1 -1
  25. package/dist/project/core.js +295 -0
  26. package/dist/project/index.js +13 -0
  27. package/dist/project/operations.js +393 -0
  28. package/dist/report-generator/core.js +315 -0
  29. package/dist/report-generator/index.js +8 -0
  30. package/dist/report-generator/operations.js +196 -0
  31. package/dist/reporter/reporter-bundle.iife.js +16 -16
  32. package/dist/screenshot-server/core.js +157 -0
  33. package/dist/screenshot-server/index.js +11 -0
  34. package/dist/screenshot-server/operations.js +183 -0
  35. package/dist/sdk/index.js +3 -2
  36. package/dist/server/handlers/api-handler.js +14 -5
  37. package/dist/server/handlers/tdd-handler.js +80 -48
  38. package/dist/server-manager/core.js +183 -0
  39. package/dist/server-manager/index.js +81 -0
  40. package/dist/server-manager/operations.js +208 -0
  41. package/dist/services/build-manager.js +2 -69
  42. package/dist/services/index.js +21 -48
  43. package/dist/services/screenshot-server.js +40 -74
  44. package/dist/services/server-manager.js +45 -80
  45. package/dist/services/static-report-generator.js +21 -163
  46. package/dist/services/test-runner.js +90 -249
  47. package/dist/services/uploader.js +56 -358
  48. package/dist/tdd/core/hotspot-coverage.js +112 -0
  49. package/dist/tdd/core/signature.js +101 -0
  50. package/dist/tdd/index.js +19 -0
  51. package/dist/tdd/metadata/baseline-metadata.js +103 -0
  52. package/dist/tdd/metadata/hotspot-metadata.js +93 -0
  53. package/dist/tdd/services/baseline-downloader.js +151 -0
  54. package/dist/tdd/services/baseline-manager.js +166 -0
  55. package/dist/tdd/services/comparison-service.js +230 -0
  56. package/dist/tdd/services/hotspot-service.js +71 -0
  57. package/dist/tdd/services/result-service.js +123 -0
  58. package/dist/tdd/tdd-service.js +1081 -0
  59. package/dist/test-runner/core.js +255 -0
  60. package/dist/test-runner/index.js +13 -0
  61. package/dist/test-runner/operations.js +483 -0
  62. package/dist/types/client.d.ts +4 -2
  63. package/dist/types/index.d.ts +5 -0
  64. package/dist/uploader/core.js +396 -0
  65. package/dist/uploader/index.js +11 -0
  66. package/dist/uploader/operations.js +412 -0
  67. package/dist/utils/config-schema.js +8 -3
  68. package/package.json +7 -12
  69. package/dist/services/api-service.js +0 -412
  70. package/dist/services/auth-service.js +0 -226
  71. package/dist/services/config-service.js +0 -369
  72. package/dist/services/html-report-generator.js +0 -455
  73. package/dist/services/project-service.js +0 -326
  74. package/dist/services/report-generator/report.css +0 -411
  75. package/dist/services/report-generator/viewer.js +0 -102
  76. package/dist/services/tdd-service.js +0 -1429
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Report Generator module
3
+ *
4
+ * Pure functions in core.js, I/O operations in operations.js.
5
+ */
6
+
7
+ export * from './core.js';
8
+ export * from './operations.js';
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Report Generator Operations - I/O operations with dependency injection
3
+ *
4
+ * Each operation takes its dependencies as parameters for testability.
5
+ */
6
+
7
+ import { buildBundleDestPaths, buildBundleSourcePaths, buildHtmlContent, buildReportDir, buildReportPath, validateBundlesExist, validateReportData } from './core.js';
8
+
9
+ // ============================================================================
10
+ // File Operations
11
+ // ============================================================================
12
+
13
+ /**
14
+ * Ensure a directory exists
15
+ * @param {Object} options - Options
16
+ * @param {string} options.path - Directory path
17
+ * @param {Object} options.deps - Dependencies
18
+ * @param {Function} options.deps.mkdir - mkdir function
19
+ * @returns {Promise<void>}
20
+ */
21
+ export async function ensureDirectory({
22
+ path,
23
+ deps
24
+ }) {
25
+ let {
26
+ mkdir
27
+ } = deps;
28
+ await mkdir(path, {
29
+ recursive: true
30
+ });
31
+ }
32
+
33
+ /**
34
+ * Check if bundles exist
35
+ * @param {Object} options - Options
36
+ * @param {string} options.projectRoot - Project root directory
37
+ * @param {Object} options.deps - Dependencies
38
+ * @param {Function} options.deps.existsSync - existsSync function
39
+ * @returns {{ bundleExists: boolean, cssExists: boolean, bundlePath: string, cssPath: string }}
40
+ */
41
+ export function checkBundlesExist({
42
+ projectRoot,
43
+ deps
44
+ }) {
45
+ let {
46
+ existsSync
47
+ } = deps;
48
+ let {
49
+ bundlePath,
50
+ cssPath
51
+ } = buildBundleSourcePaths(projectRoot);
52
+ return {
53
+ bundleExists: existsSync(bundlePath),
54
+ cssExists: existsSync(cssPath),
55
+ bundlePath,
56
+ cssPath
57
+ };
58
+ }
59
+
60
+ /**
61
+ * Copy bundle files to report directory
62
+ * @param {Object} options - Options
63
+ * @param {string} options.bundlePath - Source bundle path
64
+ * @param {string} options.cssPath - Source CSS path
65
+ * @param {string} options.reportDir - Report directory
66
+ * @param {Object} options.deps - Dependencies
67
+ * @param {Function} options.deps.copyFile - copyFile function
68
+ * @returns {Promise<void>}
69
+ */
70
+ export async function copyBundles({
71
+ bundlePath,
72
+ cssPath,
73
+ reportDir,
74
+ deps
75
+ }) {
76
+ let {
77
+ copyFile
78
+ } = deps;
79
+ let {
80
+ bundleDest,
81
+ cssDest
82
+ } = buildBundleDestPaths(reportDir);
83
+ await copyFile(bundlePath, bundleDest);
84
+ await copyFile(cssPath, cssDest);
85
+ }
86
+
87
+ /**
88
+ * Write HTML content to file
89
+ * @param {Object} options - Options
90
+ * @param {string} options.path - File path
91
+ * @param {string} options.content - HTML content
92
+ * @param {Object} options.deps - Dependencies
93
+ * @param {Function} options.deps.writeFile - writeFile function
94
+ * @returns {Promise<void>}
95
+ */
96
+ export async function writeHtmlFile({
97
+ path,
98
+ content,
99
+ deps
100
+ }) {
101
+ let {
102
+ writeFile
103
+ } = deps;
104
+ await writeFile(path, content, 'utf8');
105
+ }
106
+
107
+ // ============================================================================
108
+ // Main Report Generation
109
+ // ============================================================================
110
+
111
+ /**
112
+ * Generate a static HTML report with React reporter
113
+ * @param {Object} options - Options
114
+ * @param {Object} options.reportData - Report data
115
+ * @param {string} options.workingDir - Working directory
116
+ * @param {string} options.projectRoot - Project root directory
117
+ * @param {Object} options.deps - Dependencies
118
+ * @param {Function} options.deps.mkdir - mkdir function
119
+ * @param {Function} options.deps.existsSync - existsSync function
120
+ * @param {Function} options.deps.copyFile - copyFile function
121
+ * @param {Function} options.deps.writeFile - writeFile function
122
+ * @param {Object} options.deps.output - Output utilities
123
+ * @param {Function} options.deps.getDate - Function that returns current Date
124
+ * @returns {Promise<string>} Path to generated report
125
+ */
126
+ export async function generateReport({
127
+ reportData,
128
+ workingDir,
129
+ projectRoot,
130
+ deps
131
+ }) {
132
+ let {
133
+ mkdir,
134
+ existsSync,
135
+ copyFile,
136
+ writeFile,
137
+ output,
138
+ getDate
139
+ } = deps;
140
+
141
+ // Validate report data
142
+ let validation = validateReportData(reportData);
143
+ if (!validation.valid) {
144
+ throw new Error(validation.error);
145
+ }
146
+ let reportDir = buildReportDir(workingDir);
147
+ let reportPath = buildReportPath(reportDir);
148
+ try {
149
+ // Ensure report directory exists
150
+ await ensureDirectory({
151
+ path: reportDir,
152
+ deps: {
153
+ mkdir
154
+ }
155
+ });
156
+
157
+ // Check if bundles exist
158
+ let bundleCheck = checkBundlesExist({
159
+ projectRoot,
160
+ deps: {
161
+ existsSync
162
+ }
163
+ });
164
+ let bundleValidation = validateBundlesExist(bundleCheck.bundleExists, bundleCheck.cssExists);
165
+ if (!bundleValidation.valid) {
166
+ throw new Error(bundleValidation.error);
167
+ }
168
+
169
+ // Copy bundles to report directory
170
+ await copyBundles({
171
+ bundlePath: bundleCheck.bundlePath,
172
+ cssPath: bundleCheck.cssPath,
173
+ reportDir,
174
+ deps: {
175
+ copyFile
176
+ }
177
+ });
178
+
179
+ // Generate HTML content
180
+ let htmlContent = buildHtmlContent(reportData, getDate());
181
+
182
+ // Write HTML file
183
+ await writeHtmlFile({
184
+ path: reportPath,
185
+ content: htmlContent,
186
+ deps: {
187
+ writeFile
188
+ }
189
+ });
190
+ output.debug('report', 'generated static report');
191
+ return reportPath;
192
+ } catch (error) {
193
+ output.error(`Failed to generate static report: ${error.message}`);
194
+ throw new Error(`Report generation failed: ${error.message}`);
195
+ }
196
+ }