mailpop 1.0.2 → 1.0.3
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/config.js +4 -0
- package/dist/index.js +14 -1
- package/dist/utils/validators.js +5 -0
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -20,6 +20,10 @@ export const config = {
|
|
|
20
20
|
outputCsv: path.resolve(process.env.OUTPUT_CSV || 'output/output.csv'),
|
|
21
21
|
checkpointFile: path.resolve(process.env.CHECKPOINT_FILE || 'output/checkpoint.json'),
|
|
22
22
|
cacheDir: path.resolve(process.env.CACHE_DIR || 'output/cache'),
|
|
23
|
+
excludePrefixes: (process.env.EXCLUDE_PREFIXES || '')
|
|
24
|
+
.split(',')
|
|
25
|
+
.map((s) => s.trim().toLowerCase())
|
|
26
|
+
.filter(Boolean),
|
|
23
27
|
concurrency: getEnvNumber('CONCURRENCY', 5),
|
|
24
28
|
maxDepth: getEnvNumber('MAX_DEPTH', 2),
|
|
25
29
|
maxPagesPerSite: getEnvNumber('MAX_PAGES_PER_SITE', 25),
|
package/dist/index.js
CHANGED
|
@@ -71,6 +71,7 @@ async function main() {
|
|
|
71
71
|
const args = process.argv.slice(2);
|
|
72
72
|
let inputPath = config.inputCsv;
|
|
73
73
|
let outputPath = config.outputCsv;
|
|
74
|
+
const positionals = [];
|
|
74
75
|
for (let i = 0; i < args.length; i++) {
|
|
75
76
|
if (args[i] === '-i' || args[i] === '--input') {
|
|
76
77
|
inputPath = path.resolve(args[i + 1]);
|
|
@@ -80,6 +81,15 @@ async function main() {
|
|
|
80
81
|
outputPath = path.resolve(args[i + 1]);
|
|
81
82
|
i++;
|
|
82
83
|
}
|
|
84
|
+
else if (args[i] === '-e' || args[i] === '--exclude') {
|
|
85
|
+
const excludeStr = args[i + 1] || '';
|
|
86
|
+
const list = excludeStr
|
|
87
|
+
.split(',')
|
|
88
|
+
.map((s) => s.trim().toLowerCase())
|
|
89
|
+
.filter(Boolean);
|
|
90
|
+
config.excludePrefixes = Array.from(new Set([...config.excludePrefixes, ...list]));
|
|
91
|
+
i++;
|
|
92
|
+
}
|
|
83
93
|
else if (args[i] === '-h' || args[i] === '--help') {
|
|
84
94
|
process.stdout.write(`
|
|
85
95
|
mailpop - CLI Guide
|
|
@@ -88,13 +98,16 @@ Usage: npx mailpop [options] [input.csv] [output.csv]
|
|
|
88
98
|
Options:
|
|
89
99
|
-i, --input <path> Path to the input CSV file
|
|
90
100
|
-o, --output <path> Path to the output CSV file
|
|
101
|
+
-e, --exclude <list> Comma-separated list of email local-parts to exclude
|
|
91
102
|
-h, --help Display this help message
|
|
92
103
|
\n`);
|
|
93
104
|
process.exit(0);
|
|
94
105
|
}
|
|
106
|
+
else if (!args[i].startsWith('-')) {
|
|
107
|
+
positionals.push(args[i]);
|
|
108
|
+
}
|
|
95
109
|
}
|
|
96
110
|
// Fallback to positional arguments
|
|
97
|
-
const positionals = args.filter((a) => !a.startsWith('-'));
|
|
98
111
|
if (positionals.length >= 1) {
|
|
99
112
|
inputPath = path.resolve(positionals[0]);
|
|
100
113
|
}
|
package/dist/utils/validators.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalizeDomain } from './normalize.js';
|
|
2
|
+
import { config } from '../config.js';
|
|
2
3
|
const EMAIL_REGEX = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
3
4
|
const REJECTED_PREFIXES = [
|
|
4
5
|
'noreply',
|
|
@@ -45,6 +46,10 @@ export function isValidEmail(email) {
|
|
|
45
46
|
if (REJECTED_PREFIXES.includes(localPart)) {
|
|
46
47
|
return false;
|
|
47
48
|
}
|
|
49
|
+
// Reject user-configured excluded prefixes
|
|
50
|
+
if (config.excludePrefixes.includes(localPart)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
48
53
|
// Reject blacklisted domains
|
|
49
54
|
if (REJECTED_DOMAINS.includes(domainPart)) {
|
|
50
55
|
return false;
|