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