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