@vizzly-testing/cli 0.30.0 → 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 (77) hide show
  1. package/README.md +9 -9
  2. package/dist/api/client.js +6 -3
  3. package/dist/cli.js +58 -29
  4. package/dist/client/index.js +21 -29
  5. package/dist/commands/api.js +145 -90
  6. package/dist/commands/baselines.js +78 -47
  7. package/dist/commands/builds.js +9 -8
  8. package/dist/commands/comparisons.js +7 -8
  9. package/dist/commands/config-cmd.js +15 -7
  10. package/dist/commands/context.js +329 -18
  11. package/dist/commands/doctor.js +116 -81
  12. package/dist/commands/init.js +202 -201
  13. package/dist/commands/login.js +134 -65
  14. package/dist/commands/logout.js +17 -6
  15. package/dist/commands/preview.js +29 -57
  16. package/dist/commands/project.js +120 -0
  17. package/dist/commands/projects.js +9 -2
  18. package/dist/commands/review.js +236 -202
  19. package/dist/commands/run.js +75 -72
  20. package/dist/commands/status.js +228 -150
  21. package/dist/commands/tdd-daemon-process.js +98 -0
  22. package/dist/commands/tdd-daemon.js +318 -212
  23. package/dist/commands/tdd.js +23 -8
  24. package/dist/commands/upload.js +10 -9
  25. package/dist/commands/whoami.js +63 -25
  26. package/dist/config/core.js +36 -35
  27. package/dist/context/local-workspace-provider.js +132 -12
  28. package/dist/context/provider-resolver.js +5 -1
  29. package/dist/index.js +5 -4
  30. package/dist/plugin-loader.js +55 -49
  31. package/dist/project/core.js +2 -2
  32. package/dist/project/operations.js +6 -3
  33. package/dist/reporter/reporter-bundle.css +1 -1
  34. package/dist/reporter/reporter-bundle.iife.js +7 -7
  35. package/dist/sdk/index.js +162 -107
  36. package/dist/server/handlers/tdd-handler.js +30 -54
  37. package/dist/server/routers/baseline.js +195 -178
  38. package/dist/server/routers/events.js +212 -174
  39. package/dist/server/routers/projects.js +14 -5
  40. package/dist/server/routers/screenshot.js +1 -31
  41. package/dist/services/build-manager.js +19 -97
  42. package/dist/services/config-service.js +26 -34
  43. package/dist/services/index.js +2 -4
  44. package/dist/services/static-report-generator.js +11 -12
  45. package/dist/services/test-runner.js +21 -27
  46. package/dist/tdd/index.js +1 -1
  47. package/dist/tdd/metadata/region-metadata.js +0 -37
  48. package/dist/tdd/runtime-context.js +78 -0
  49. package/dist/tdd/server-registry.js +38 -17
  50. package/dist/tdd/services/baseline-manager.js +23 -0
  51. package/dist/tdd/services/hotspot-service.js +0 -13
  52. package/dist/tdd/tdd-service.js +82 -113
  53. package/dist/types/client.d.ts +36 -1
  54. package/dist/types/index.d.ts +114 -22
  55. package/dist/types/sdk.d.ts +40 -0
  56. package/dist/uploader/core.js +5 -4
  57. package/dist/uploader/index.js +79 -2
  58. package/dist/uploader/operations.js +40 -5
  59. package/dist/utils/api-url.js +14 -0
  60. package/dist/utils/async-utils.js +26 -0
  61. package/dist/utils/ci-env.js +19 -12
  62. package/dist/utils/config-loader.js +39 -65
  63. package/dist/utils/config-schema.js +19 -55
  64. package/dist/utils/fetch-utils.js +12 -5
  65. package/dist/utils/git.js +35 -72
  66. package/dist/utils/global-config.js +20 -1
  67. package/dist/utils/output.js +19 -7
  68. package/dist/utils/patterns.js +14 -0
  69. package/dist/utils/project-link-store.js +105 -0
  70. package/dist/utils/screenshot-options.js +28 -0
  71. package/dist/utils/secret-store.js +65 -0
  72. package/package.json +11 -8
  73. package/dist/services/screenshot-server.js +0 -65
  74. package/dist/services/server-manager.js +0 -81
  75. package/dist/services/uploader.js +0 -100
  76. package/dist/tdd/services/region-service.js +0 -75
  77. 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
+ }