diffpx 0.0.8 → 0.0.10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diffpx",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "bin": {
5
5
  "diffpx": "bin/diffpx.js"
6
6
  },
package/src/runner.js CHANGED
@@ -51,8 +51,7 @@ async function runJob({diffpxKey, payload}) {
51
51
  hideCursor: true,
52
52
  barCompleteChar: '█',
53
53
  barIncompleteChar: '░',
54
- format: '{name} [{bar}] {percentage}% | {value}/{total}',
55
- stream: process.stdout
54
+ format: '{name} [{bar}] {percentage}% | {value}/{total}'
56
55
  }, cliProgress.Presets.shades_classic);
57
56
 
58
57
  const initialSnapshotsTotal = Array.isArray(payload?.snapshots) ? payload.snapshots.length : 1;
@@ -71,8 +70,6 @@ async function runJob({diffpxKey, payload}) {
71
70
  );
72
71
 
73
72
  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)};
76
73
 
77
74
  try {
78
75
  const diffpxUrl = process.env.DIFFPX_URL || '';
@@ -83,7 +80,7 @@ async function runJob({diffpxKey, payload}) {
83
80
  }
84
81
 
85
82
  const finalStatus = await pollRun(diffpxUrl, diffpxKey, jobId, {
86
- intervalMs: Number(process.env.DIFFPX_POLL_INTERVAL_MS || 1000),
83
+ intervalMs: 1000,
87
84
  onStatus: (status) => {
88
85
  const p = getProgress(status);
89
86
 
@@ -93,20 +90,14 @@ async function runJob({diffpxKey, payload}) {
93
90
  const snapTotal = p.snapshotsTotal > 0 ? p.snapshotsTotal : Math.max(1, initialSnapshotsTotal);
94
91
  const snapDone = p.snapshotsTotal > 0 ? Math.min(p.snapshotsDone, p.snapshotsTotal) : snapshotsBar.value;
95
92
 
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
- }
93
+ snapshotsBar.setTotal(snapTotal);
94
+ snapshotsBar.update(snapDone, {name: snapshotLabel});
101
95
 
102
96
  const wTotal = p.widthsTotal > 0 ? p.widthsTotal : Math.max(1, initialWidthsTotal);
103
97
  const wDone = p.widthsTotal > 0 ? Math.min(p.widthsDone, p.widthsTotal) : widthsBar.value;
104
98
 
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
- }
99
+ widthsBar.setTotal(wTotal);
100
+ widthsBar.update(wDone, {name: widthLabel});
110
101
  }
111
102
  });
112
103
 
package/src/upload.js CHANGED
@@ -8,11 +8,14 @@ function axiosErrorMessage(err) {
8
8
  const statusText = err?.response?.statusText;
9
9
 
10
10
  const data = err?.response?.data;
11
+ const jsonMsg = data && typeof data === 'object'
12
+ ? String(data.error || data.message || '').trim()
13
+ : '';
11
14
  const body = typeof data === 'string'
12
15
  ? ((data.match(/<pre>([\s\S]*?)<\/pre>/i)?.[1] || data).replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim())
13
16
  : '';
14
17
 
15
- return [status ? `HTTP ${status}${statusText ? ` ${statusText}` : ''}` : '', body || '']
18
+ return [status ? `HTTP ${status}${statusText ? ` ${statusText}` : ''}` : '', jsonMsg || body || '']
16
19
  .filter(Boolean)
17
20
  .join(' | ');
18
21
  }
@@ -32,8 +32,11 @@ async function validateConfig() {
32
32
  process.exit(1);
33
33
  }
34
34
 
35
- const config = yaml.load(fs.readFileSync('snapshots.yml', 'utf8'));
36
- const devicesList = yaml.load(fs.readFileSync('devices.yml', 'utf8'));
35
+ const rawConfig = yaml.load(fs.readFileSync('snapshots.yml', 'utf8'));
36
+ const rawDevices = yaml.load(fs.readFileSync('devices.yml', 'utf8'));
37
+
38
+ const config = Array.isArray(rawConfig) ? rawConfig : [];
39
+ const devicesList = Array.isArray(rawDevices) ? rawDevices : [];
37
40
 
38
41
  const devicesConfig = {};
39
42
  for (const d of devicesList) devicesConfig[d.name] = d;
@@ -41,6 +44,10 @@ async function validateConfig() {
41
44
  const seenNames = new Set();
42
45
  const configErrors = [];
43
46
 
47
+ if (!config.length) {
48
+ configErrors.push('🔴 snapshots.yml must contain at least one snapshot');
49
+ }
50
+
44
51
  for (const entry of config) {
45
52
  if (seenNames.has(entry.name)) {
46
53
  configErrors.push(`🔴 Duplicate snapshot name "${ entry.name }" found in snapshots.yml`);