@mailmodo/cli 0.0.56-beta.pr58.103 → 0.0.56-beta.pr58.104
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.
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
+
const TIME_W = 18;
|
|
3
|
+
const EMAIL_W = 24;
|
|
4
|
+
const SEQ_W = 12;
|
|
5
|
+
const STATUS_W = 14;
|
|
6
|
+
const CONTACT_COL = TIME_W + EMAIL_W + SEQ_W + STATUS_W;
|
|
2
7
|
function statusColor(status) {
|
|
3
8
|
switch (status) {
|
|
4
9
|
case 'bounced':
|
|
@@ -19,25 +24,31 @@ function statusColor(status) {
|
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
}
|
|
27
|
+
function truncate(s, width) {
|
|
28
|
+
return s.length > width ? s.slice(0, width - 1) + '…' : s;
|
|
29
|
+
}
|
|
30
|
+
function shortSeq(id) {
|
|
31
|
+
return id.length > 8 ? id.slice(0, 8) + '…' : id;
|
|
32
|
+
}
|
|
22
33
|
export function renderEntries(ctx, data) {
|
|
23
34
|
const { entries, limit, page, total } = data;
|
|
24
|
-
ctx.log(`\n ${'Time'.padEnd(
|
|
25
|
-
|
|
35
|
+
ctx.log(`\n ${'Time'.padEnd(TIME_W)}${'Email'.padEnd(EMAIL_W)}` +
|
|
36
|
+
`${'Sequence'.padEnd(SEQ_W)}${'Status'.padEnd(STATUS_W)}Contact`);
|
|
37
|
+
ctx.log(` ${'─'.repeat(CONTACT_COL + 28)}`);
|
|
26
38
|
if (!entries?.length) {
|
|
27
39
|
ctx.log(` ${chalk.dim('No entries found.')}`);
|
|
28
40
|
ctx.log('');
|
|
29
41
|
return;
|
|
30
42
|
}
|
|
31
43
|
for (const entry of entries) {
|
|
32
|
-
const time = (entry.timestamp || '').padEnd(
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
ctx.log(` ${time}${emailId}${seqId}${status}${entry.contact || ''}`);
|
|
44
|
+
const time = (entry.timestamp || '').padEnd(TIME_W);
|
|
45
|
+
const email = truncate(entry.emailId || '', EMAIL_W - 2).padEnd(EMAIL_W);
|
|
46
|
+
const seq = chalk.dim(shortSeq(entry.sequenceId || '').padEnd(SEQ_W));
|
|
47
|
+
const status = statusColor(entry.status)((entry.status || '').padEnd(STATUS_W));
|
|
48
|
+
ctx.log(` ${time}${email}${seq}${status}${entry.contact || ''}`);
|
|
38
49
|
if (entry.reason) {
|
|
39
50
|
const label = entry.status === 'skipped' ? 'condition not met' : 'reason';
|
|
40
|
-
ctx.log(` ${' '.repeat(
|
|
51
|
+
ctx.log(` ${' '.repeat(CONTACT_COL)}${chalk.dim(`└ ${label}: ${entry.reason}`)}`);
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
54
|
const totalPages = Math.ceil(total / limit);
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED