@vizzly-testing/cli 0.29.6 → 0.31.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 (87) hide show
  1. package/README.md +34 -6
  2. package/dist/api/client.js +6 -3
  3. package/dist/api/endpoints.js +59 -0
  4. package/dist/api/index.js +1 -1
  5. package/dist/auth/core.js +1 -1
  6. package/dist/auth/index.js +2 -1
  7. package/dist/cli.js +206 -51
  8. package/dist/client/index.js +21 -29
  9. package/dist/commands/api.js +145 -90
  10. package/dist/commands/baselines.js +78 -47
  11. package/dist/commands/builds.js +9 -8
  12. package/dist/commands/comparisons.js +7 -8
  13. package/dist/commands/config-cmd.js +15 -7
  14. package/dist/commands/context.js +870 -0
  15. package/dist/commands/doctor.js +116 -81
  16. package/dist/commands/init.js +202 -201
  17. package/dist/commands/login.js +134 -65
  18. package/dist/commands/logout.js +18 -7
  19. package/dist/commands/preview.js +29 -57
  20. package/dist/commands/project.js +120 -0
  21. package/dist/commands/projects.js +9 -2
  22. package/dist/commands/review.js +236 -202
  23. package/dist/commands/run.js +75 -72
  24. package/dist/commands/status.js +228 -150
  25. package/dist/commands/tdd-daemon-process.js +98 -0
  26. package/dist/commands/tdd-daemon.js +318 -212
  27. package/dist/commands/tdd.js +23 -8
  28. package/dist/commands/upload.js +10 -9
  29. package/dist/commands/whoami.js +64 -26
  30. package/dist/config/core.js +37 -36
  31. package/dist/context/local-workspace-provider.js +532 -0
  32. package/dist/context/provider-resolver.js +36 -0
  33. package/dist/index.js +5 -4
  34. package/dist/plugin-loader.js +55 -49
  35. package/dist/project/core.js +2 -2
  36. package/dist/project/operations.js +6 -3
  37. package/dist/reporter/reporter-bundle.css +2 -1
  38. package/dist/reporter/reporter-bundle.iife.js +119 -119
  39. package/dist/reporter-ssr/ssr-entry.js +605 -509
  40. package/dist/sdk/index.js +162 -107
  41. package/dist/server/handlers/tdd-handler.js +30 -54
  42. package/dist/server/routers/assets.js +4 -0
  43. package/dist/server/routers/baseline.js +195 -178
  44. package/dist/server/routers/events.js +226 -148
  45. package/dist/server/routers/projects.js +14 -5
  46. package/dist/server/routers/screenshot.js +1 -31
  47. package/dist/services/build-manager.js +19 -97
  48. package/dist/services/config-service.js +26 -34
  49. package/dist/services/index.js +2 -4
  50. package/dist/services/static-report-generator.js +11 -12
  51. package/dist/services/test-runner.js +21 -27
  52. package/dist/tdd/core/hotspot-coverage.js +1 -1
  53. package/dist/tdd/index.js +1 -1
  54. package/dist/tdd/metadata/region-metadata.js +0 -37
  55. package/dist/tdd/runtime-context.js +78 -0
  56. package/dist/tdd/server-registry.js +38 -17
  57. package/dist/tdd/services/baseline-manager.js +23 -0
  58. package/dist/tdd/services/hotspot-service.js +1 -14
  59. package/dist/tdd/tdd-service.js +82 -113
  60. package/dist/types/client.d.ts +36 -1
  61. package/dist/types/index.d.ts +114 -22
  62. package/dist/types/sdk.d.ts +47 -7
  63. package/dist/uploader/core.js +5 -4
  64. package/dist/uploader/index.js +79 -2
  65. package/dist/uploader/operations.js +40 -5
  66. package/dist/utils/api-url.js +14 -0
  67. package/dist/utils/async-utils.js +26 -0
  68. package/dist/utils/ci-env.js +19 -12
  69. package/dist/utils/colors.js +46 -44
  70. package/dist/utils/config-loader.js +39 -65
  71. package/dist/utils/config-schema.js +19 -55
  72. package/dist/utils/fetch-utils.js +12 -5
  73. package/dist/utils/git.js +35 -72
  74. package/dist/utils/global-config.js +22 -3
  75. package/dist/utils/output.js +19 -7
  76. package/dist/utils/patterns.js +14 -0
  77. package/dist/utils/project-link-store.js +105 -0
  78. package/dist/utils/report-data.js +31 -0
  79. package/dist/utils/screenshot-options.js +28 -0
  80. package/dist/utils/secret-store.js +65 -0
  81. package/dist/utils/security.js +3 -2
  82. package/package.json +14 -11
  83. package/dist/services/screenshot-server.js +0 -65
  84. package/dist/services/server-manager.js +0 -81
  85. package/dist/services/uploader.js +0 -100
  86. package/dist/tdd/services/region-service.js +0 -75
  87. package/dist/utils/build-history.js +0 -103
@@ -0,0 +1,98 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ let defaultTimers = {
5
+ setTimeout,
6
+ clearTimeout
7
+ };
8
+ function wait(ms, timers = defaultTimers) {
9
+ return new Promise(resolve => {
10
+ timers.setTimeout(resolve, ms);
11
+ });
12
+ }
13
+ function isProcessRunning(pid) {
14
+ try {
15
+ process.kill(pid, 0);
16
+ return true;
17
+ } catch {
18
+ return false;
19
+ }
20
+ }
21
+ function parsePositiveInteger(value) {
22
+ let text = String(value).trim();
23
+ if (!/^\d+$/.test(text)) {
24
+ return null;
25
+ }
26
+ let number = Number(text);
27
+ return Number.isSafeInteger(number) && number > 0 ? number : null;
28
+ }
29
+ export function readDaemonPidFile(pidFile, deps = {}) {
30
+ let fileExists = deps.existsSync || existsSync;
31
+ let readFile = deps.readFileSync || readFileSync;
32
+ if (!fileExists(pidFile)) {
33
+ return null;
34
+ }
35
+ try {
36
+ return parsePositiveInteger(readFile(pidFile, 'utf8'));
37
+ } catch {
38
+ return null;
39
+ }
40
+ }
41
+ export async function findDaemonPidByPort(port, {
42
+ spawnProcess = spawn
43
+ } = {}) {
44
+ try {
45
+ let lsofProcess = spawnProcess('lsof', ['-ti', `:${port}`], {
46
+ stdio: 'pipe'
47
+ });
48
+ let lsofOutput = '';
49
+ lsofProcess.stdout.on('data', data => {
50
+ lsofOutput += data.toString();
51
+ });
52
+ return await new Promise(resolve => {
53
+ lsofProcess.on('close', code => {
54
+ if (code === 0 && lsofOutput.trim()) {
55
+ let foundPid = parsePositiveInteger(lsofOutput.trim().split('\n')[0]);
56
+ resolve(foundPid);
57
+ return;
58
+ }
59
+ resolve(null);
60
+ });
61
+ lsofProcess.on('error', () => {
62
+ resolve(null);
63
+ });
64
+ });
65
+ } catch {
66
+ return null;
67
+ }
68
+ }
69
+ export async function resolveDaemonPid({
70
+ port,
71
+ pidFile = join(process.cwd(), '.vizzly', 'server.pid'),
72
+ readPid = readDaemonPidFile,
73
+ findByPort = findDaemonPidByPort,
74
+ fileDeps = {}
75
+ } = {}) {
76
+ let pid = readPid(pidFile, fileDeps);
77
+ if (pid) {
78
+ return pid;
79
+ }
80
+ return await findByPort(port);
81
+ }
82
+ export async function waitForProcessExit(pid, {
83
+ timeoutMs = 2000,
84
+ intervalMs = 100,
85
+ processRunning = isProcessRunning,
86
+ timers = defaultTimers
87
+ } = {}) {
88
+ let elapsedMs = 0;
89
+ while (elapsedMs < timeoutMs) {
90
+ if (!processRunning(pid)) {
91
+ return true;
92
+ }
93
+ let nextDelay = Math.min(intervalMs, timeoutMs - elapsedMs);
94
+ await wait(nextDelay, timers);
95
+ elapsedMs += nextDelay;
96
+ }
97
+ return !processRunning(pid);
98
+ }