mailpop 1.0.3 → 1.0.4
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/dist/index.js +10 -0
- package/dist/logger.js +29 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,8 +5,13 @@ import { Crawler } from './crawler.js';
|
|
|
5
5
|
import { Logger } from './logger.js';
|
|
6
6
|
import pLimit from 'p-limit';
|
|
7
7
|
import fs from 'fs/promises';
|
|
8
|
+
import { readFileSync } from 'fs';
|
|
8
9
|
import path from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
9
11
|
import { normalizeDomain, findWebsiteInRow } from './utils/normalize.js';
|
|
12
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const pkg = JSON.parse(readFileSync(path.resolve(__dirname, '../package.json'), 'utf-8'));
|
|
14
|
+
const version = pkg.version || 'unknown';
|
|
10
15
|
let highestContiguousIndex = -1;
|
|
11
16
|
const completedIndices = new Set();
|
|
12
17
|
let completedUrls = [];
|
|
@@ -90,6 +95,10 @@ async function main() {
|
|
|
90
95
|
config.excludePrefixes = Array.from(new Set([...config.excludePrefixes, ...list]));
|
|
91
96
|
i++;
|
|
92
97
|
}
|
|
98
|
+
else if (args[i] === '-v' || args[i] === '--version') {
|
|
99
|
+
process.stdout.write(`mailpop v${version}\n`);
|
|
100
|
+
process.exit(0);
|
|
101
|
+
}
|
|
93
102
|
else if (args[i] === '-h' || args[i] === '--help') {
|
|
94
103
|
process.stdout.write(`
|
|
95
104
|
mailpop - CLI Guide
|
|
@@ -99,6 +108,7 @@ Options:
|
|
|
99
108
|
-i, --input <path> Path to the input CSV file
|
|
100
109
|
-o, --output <path> Path to the output CSV file
|
|
101
110
|
-e, --exclude <list> Comma-separated list of email local-parts to exclude
|
|
111
|
+
-v, --version Display the version number
|
|
102
112
|
-h, --help Display this help message
|
|
103
113
|
\n`);
|
|
104
114
|
process.exit(0);
|
package/dist/logger.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
const LOGS_DIR = path.resolve('logs');
|
|
4
|
+
// ANSI escape codes for styling
|
|
5
|
+
const RESET = '\x1b[0m';
|
|
6
|
+
const BOLD = '\x1b[1m';
|
|
7
|
+
const FG_CYAN = '\x1b[36m';
|
|
8
|
+
const FG_GREEN = '\x1b[32m';
|
|
9
|
+
const FG_RED = '\x1b[31m';
|
|
10
|
+
const FG_YELLOW = '\x1b[33m';
|
|
11
|
+
const FG_GRAY = '\x1b[90m';
|
|
12
|
+
const FG_WHITE = '\x1b[37m';
|
|
13
|
+
const TEXT_BLACK = '\x1b[30m';
|
|
14
|
+
const BG_CYAN = '\x1b[46m';
|
|
15
|
+
const BG_GREEN = '\x1b[42m';
|
|
16
|
+
const BG_RED = '\x1b[41m';
|
|
4
17
|
/**
|
|
5
18
|
* Ensures that the logs directory exists on disk.
|
|
6
19
|
*/
|
|
@@ -41,7 +54,12 @@ export class Logger {
|
|
|
41
54
|
result,
|
|
42
55
|
message,
|
|
43
56
|
};
|
|
44
|
-
const
|
|
57
|
+
const levelTag = `${BOLD}${BG_CYAN}${TEXT_BLACK} INFO ${RESET}`;
|
|
58
|
+
const domainStr = domain ? ` ${FG_GRAY}[${FG_CYAN}${domain}${FG_GRAY}]${RESET}` : '';
|
|
59
|
+
const actionStr = ` ${BOLD}${action}${RESET}`;
|
|
60
|
+
const resultStr = result ? ` -> ${FG_GREEN}${result}${RESET}` : '';
|
|
61
|
+
const msgStr = message ? ` | ${FG_GRAY}${message}${RESET}` : '';
|
|
62
|
+
const consoleMsg = `${levelTag}${domainStr}${actionStr}${resultStr}${msgStr}`;
|
|
45
63
|
process.stdout.write(consoleMsg + '\n');
|
|
46
64
|
await writeLog('app.log', entry);
|
|
47
65
|
}
|
|
@@ -58,7 +76,11 @@ export class Logger {
|
|
|
58
76
|
error: errorMsg,
|
|
59
77
|
stack,
|
|
60
78
|
};
|
|
61
|
-
const
|
|
79
|
+
const levelTag = `${BOLD}${BG_RED}${FG_WHITE} ERROR ${RESET}`;
|
|
80
|
+
const domainStr = domain ? ` ${FG_GRAY}[${FG_RED}${domain}${FG_GRAY}]${RESET}` : '';
|
|
81
|
+
const actionStr = ` ${BOLD}${action}${RESET}`;
|
|
82
|
+
const errorStr = errorMsg ? `: ${FG_RED}${errorMsg}${RESET}` : '';
|
|
83
|
+
const consoleMsg = `${levelTag}${domainStr}${actionStr}${errorStr}`;
|
|
62
84
|
process.stderr.write(consoleMsg + '\n');
|
|
63
85
|
await writeLog('app.log', entry);
|
|
64
86
|
await writeLog('errors.log', entry);
|
|
@@ -75,7 +97,11 @@ export class Logger {
|
|
|
75
97
|
confidenceScore: confidence,
|
|
76
98
|
discoveryMethod: method,
|
|
77
99
|
};
|
|
78
|
-
const
|
|
100
|
+
const levelTag = `${BOLD}${BG_GREEN}${TEXT_BLACK} EMAIL ${RESET}`;
|
|
101
|
+
const domainStr = ` ${FG_GRAY}[${FG_CYAN}${domain}${FG_GRAY}]${RESET}`;
|
|
102
|
+
const emailStr = ` Found ${BOLD}${FG_GREEN}${email}${RESET}`;
|
|
103
|
+
const detailsStr = ` (${FG_YELLOW}${method}${RESET}, confidence: ${BOLD}${confidence}${RESET}) at ${FG_GRAY}${source}${RESET}`;
|
|
104
|
+
const consoleMsg = `${levelTag}${domainStr}${emailStr}${detailsStr}`;
|
|
79
105
|
process.stdout.write(consoleMsg + '\n');
|
|
80
106
|
await writeLog('discovered-emails.log', entry);
|
|
81
107
|
}
|