diffpx 0.0.5 → 0.0.6
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/package.json +1 -1
- package/src/runner.js +14 -18
package/package.json
CHANGED
package/src/runner.js
CHANGED
|
@@ -45,20 +45,20 @@ function getProgress(status) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
async function runJob({
|
|
49
|
-
const initialSnapshotsTotal = Array.isArray(payload?.snapshots) ? payload.snapshots.length : 1;
|
|
50
|
-
const initialWidthsTotal = Array.isArray(payload?.settings?.width) ? payload.settings.width.length : 1;
|
|
51
|
-
const isTTY = !!process.stdout.isTTY;
|
|
48
|
+
async function runJob({ppKey, payload}) {
|
|
52
49
|
const multiBar = new cliProgress.MultiBar({
|
|
53
50
|
clearOnComplete: false,
|
|
54
51
|
hideCursor: true,
|
|
55
52
|
barCompleteChar: '█',
|
|
56
53
|
barIncompleteChar: '░',
|
|
57
54
|
format: '{name} [{bar}] {percentage}% | {value}/{total}',
|
|
58
|
-
noTTYOutput:
|
|
59
|
-
notTTYSchedule:
|
|
55
|
+
noTTYOutput: true,
|
|
56
|
+
notTTYSchedule: 500
|
|
60
57
|
}, cliProgress.Presets.shades_classic);
|
|
61
58
|
|
|
59
|
+
const initialSnapshotsTotal = Array.isArray(payload?.snapshots) ? payload.snapshots.length : 1;
|
|
60
|
+
const initialWidthsTotal = Array.isArray(payload?.settings?.width) ? payload.settings.width.length : 1;
|
|
61
|
+
|
|
62
62
|
const snapshotsBar = multiBar.create(
|
|
63
63
|
Math.max(1, initialSnapshotsTotal),
|
|
64
64
|
0,
|
|
@@ -74,15 +74,14 @@ async function runJob({diffpxKey, payload}) {
|
|
|
74
74
|
let jobId = null;
|
|
75
75
|
|
|
76
76
|
try {
|
|
77
|
-
const
|
|
78
|
-
const res = await submitRun(diffpxUrl, diffpxKey, payload);
|
|
77
|
+
const res = await submitRun(ppKey, payload);
|
|
79
78
|
jobId = res?.jobId || res?.id || res?.job_id || res?.data?.jobId || null;
|
|
80
79
|
if (!jobId) {
|
|
81
80
|
throw new Error('Server did not return a job id');
|
|
82
81
|
}
|
|
83
82
|
|
|
84
|
-
const finalStatus = await pollRun(
|
|
85
|
-
intervalMs: Number(process.env.
|
|
83
|
+
const finalStatus = await pollRun(ppKey, jobId, {
|
|
84
|
+
intervalMs: Number(process.env.PP_POLL_INTERVAL_MS || 1000),
|
|
86
85
|
onStatus: (status) => {
|
|
87
86
|
const p = getProgress(status);
|
|
88
87
|
|
|
@@ -90,17 +89,14 @@ async function runJob({diffpxKey, payload}) {
|
|
|
90
89
|
const widthLabel = normalizePxLabel(p.widthLabel) || getInitialWidthName(payload);
|
|
91
90
|
|
|
92
91
|
const snapTotal = p.snapshotsTotal > 0 ? p.snapshotsTotal : Math.max(1, initialSnapshotsTotal);
|
|
93
|
-
const snapDone = p.snapshotsTotal > 0
|
|
94
|
-
? Math.min(p.snapshotsDone, p.snapshotsTotal)
|
|
95
|
-
: (snapshotsBar ? snapshotsBar.value : 0);
|
|
96
|
-
|
|
97
|
-
const wTotal = p.widthsTotal > 0 ? p.widthsTotal : Math.max(1, initialWidthsTotal);
|
|
98
|
-
const wDone = p.widthsTotal > 0
|
|
99
|
-
? Math.min(p.widthsDone, p.widthsTotal)
|
|
100
|
-
: widthsBar.value;
|
|
92
|
+
const snapDone = p.snapshotsTotal > 0 ? Math.min(p.snapshotsDone, p.snapshotsTotal) : snapshotsBar.value;
|
|
101
93
|
|
|
102
94
|
snapshotsBar.setTotal(snapTotal);
|
|
103
95
|
snapshotsBar.update(snapDone, {name: snapshotLabel});
|
|
96
|
+
|
|
97
|
+
const wTotal = p.widthsTotal > 0 ? p.widthsTotal : Math.max(1, initialWidthsTotal);
|
|
98
|
+
const wDone = p.widthsTotal > 0 ? Math.min(p.widthsDone, p.widthsTotal) : widthsBar.value;
|
|
99
|
+
|
|
104
100
|
widthsBar.setTotal(wTotal);
|
|
105
101
|
widthsBar.update(wDone, {name: widthLabel});
|
|
106
102
|
}
|